mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-23 10:58:12 +08:00
* remove debug logging * load and save obs/row index in label file * lint * update tests
80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
/*
|
|
Reducers for annotation UI-state.
|
|
*/
|
|
const Annotations = (
|
|
state = {
|
|
isEditingCategoryName: false,
|
|
isEditingLabelName: false,
|
|
categoryEditable: false,
|
|
labelEditable: { category: null, label: null }
|
|
},
|
|
action
|
|
) => {
|
|
switch (action.type) {
|
|
/* CATEGORY */
|
|
case "annotation: activate add new label mode":
|
|
return {
|
|
...state,
|
|
isAddingNewLabel: true,
|
|
categoryAddingNewLabel: action.data
|
|
};
|
|
case "annotation: disable add new label mode":
|
|
return {
|
|
...state,
|
|
isAddingNewLabel: false,
|
|
categoryAddingNewLabel: null
|
|
};
|
|
case "annotation: add new label to category":
|
|
return {
|
|
...state,
|
|
isAddingNewLabel: false,
|
|
categoryAddingNewLabel: null
|
|
};
|
|
case "annotation: activate category edit mode":
|
|
return {
|
|
...state,
|
|
isEditingCategoryName: true,
|
|
categoryEditable: action.data
|
|
};
|
|
case "annotation: disable category edit mode":
|
|
return {
|
|
...state,
|
|
isEditingCategoryName: false,
|
|
categoryEditable: null
|
|
};
|
|
case "annotation: category edited":
|
|
return {
|
|
...state,
|
|
isEditingCategoryName: true,
|
|
categoryEditable: null
|
|
};
|
|
|
|
/* LABEL */
|
|
case "annotation: activate edit label mode":
|
|
return {
|
|
...state,
|
|
isEditingLabelName: true,
|
|
labelEditable: {
|
|
category: action.metadataField,
|
|
label: action.categoryIndex
|
|
}
|
|
};
|
|
case "annotation: cancel edit label mode":
|
|
return {
|
|
...state,
|
|
isEditingLabelName: false,
|
|
labelEditable: { category: null, label: null }
|
|
};
|
|
case "annotation: label edited":
|
|
return {
|
|
...state,
|
|
isEditingLabelName: false,
|
|
labelEditable: { category: null, label: null }
|
|
};
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default Annotations;
|