mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-01 02:58:11 +08:00
* Add undo/redo tests for annotations Fixes https://github.com/chanzuckerberg/cellxgene/issues/969 ... also refactor the tests for DRY. * Add done() * Make e2e annotations tests safer to concurrency * Add data-testclass for save state. * Simplify tests and make them dependent on save state
56 lines
1.0 KiB
JavaScript
56 lines
1.0 KiB
JavaScript
const Autosave = (
|
|
state = {
|
|
saveInProgress: false,
|
|
error: false,
|
|
lastSavedObsAnnotations: null,
|
|
initialDataLoadComplete: false
|
|
},
|
|
action,
|
|
nextSharedState
|
|
) => {
|
|
switch (action.type) {
|
|
case "initial data load complete (universe exists)": {
|
|
/* don't save on init */
|
|
const { universe } = nextSharedState;
|
|
return {
|
|
...state,
|
|
error: false,
|
|
saveInProgress: false,
|
|
lastSavedObsAnnotations: universe.obsAnnotations,
|
|
initialDataLoadComplete: true,
|
|
};
|
|
}
|
|
|
|
case "writable obs annotations - save started": {
|
|
return {
|
|
...state,
|
|
saveInProgress: true
|
|
};
|
|
}
|
|
|
|
case "writable obs annotations - save error": {
|
|
const { message } = action;
|
|
return {
|
|
...state,
|
|
error: message,
|
|
saveInProgress: false
|
|
};
|
|
}
|
|
|
|
case "writable obs annotations - save complete": {
|
|
const lastSavedObsAnnotations = action.obsAnnotations;
|
|
return {
|
|
...state,
|
|
saveInProgress: false,
|
|
error: false,
|
|
lastSavedObsAnnotations
|
|
};
|
|
}
|
|
|
|
default:
|
|
return { ...state };
|
|
}
|
|
};
|
|
|
|
export default Autosave;
|