diff --git a/app/packs/src/apps/mydb/elements/details/researchPlans/ResearchPlanDetails.js b/app/packs/src/apps/mydb/elements/details/researchPlans/ResearchPlanDetails.js
index a4ce1ba224..00b8be2243 100644
--- a/app/packs/src/apps/mydb/elements/details/researchPlans/ResearchPlanDetails.js
+++ b/app/packs/src/apps/mydb/elements/details/researchPlans/ResearchPlanDetails.js
@@ -50,13 +50,11 @@ export default class ResearchPlanDetails extends Component {
const { researchPlan } = props;
this.state = {
researchPlan,
- update: false,
visible: Immutable.List(),
currentUser: (UserStore.getState() && UserStore.getState().currentUser) || {},
};
this.handleSwitchMode = this.handleSwitchMode.bind(this);
this.handleResearchPlanChange = this.handleResearchPlanChange.bind(this);
- this.toggleFullScreen = this.toggleFullScreen.bind(this);
this.handleNameChange = this.handleNameChange.bind(this);
this.handleBodyChange = this.handleBodyChange.bind(this);
this.handleBodyAdd = this.handleBodyAdd.bind(this);
@@ -261,13 +259,6 @@ export default class ResearchPlanDetails extends Component {
this.setState({ visible });
}
- toggleFullScreen() {
- this.props.toggleFullScreen();
-
- // toogle update prop to notify react data grid for view change
- this.setState({ update: !this.state.update });
- }
-
dropWellplate(wellplate) {
const { researchPlan } = this.state;
researchPlan.changed = true;
@@ -351,7 +342,7 @@ export default class ResearchPlanDetails extends Component {
);
}
- renderResearchPlanMain(researchPlan, update) { /* eslint-disable react/jsx-no-bind */
+ renderResearchPlanMain(researchPlan) { /* eslint-disable react/jsx-no-bind */
const {
name, body, changed, attachments
} = researchPlan;
@@ -434,7 +425,6 @@ export default class ResearchPlanDetails extends Component {
onDelete={this.handleBodyDelete.bind(this)}
onExport={this.handleExportField.bind(this)}
onCopyToMetadata={this.handleCopyToMetadata.bind(this)}
- update={update}
edit={edit}
copyableFields={[
{ title: 'Subject', fieldName: 'subject' },
@@ -515,7 +505,7 @@ export default class ResearchPlanDetails extends Component {
Full Research Plan}>
-
@@ -529,7 +519,7 @@ export default class ResearchPlanDetails extends Component {
}
render() {
- const { researchPlan, update, visible } = this.state;
+ const { researchPlan, visible } = this.state;
const tabContentsMap = {
research_plan: (
@@ -537,7 +527,7 @@ export default class ResearchPlanDetails extends Component {
{
!researchPlan.isNew &&
}
- {this.renderResearchPlanMain(researchPlan, update)}
+ {this.renderResearchPlanMain(researchPlan)}
),
diff --git a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsBody.js b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsBody.js
index c48f3b71c4..ae7be9fdd7 100644
--- a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsBody.js
+++ b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsBody.js
@@ -9,7 +9,7 @@ import Field from 'src/apps/mydb/elements/details/researchPlans/researchPlanTab/
export default class ResearchPlanDetailsBody extends Component {
render() {
const {
- body, disabled, onChange, onDrop, onAdd, onDelete, onExport, update, edit, isNew,
+ body, disabled, onChange, onDrop, onAdd, onDelete, onExport, edit, isNew,
copyableFields, onCopyToMetadata
} = this.props;
@@ -29,7 +29,6 @@ export default class ResearchPlanDetailsBody extends Component {
onDelete={onDelete.bind(this)}
onExport={onExport.bind(this)}
onCopyToMetadata={onCopyToMetadata.bind(this)}
- update={update}
edit={edit}
tableIndex={tableIndex}
isNew={isNew}
@@ -49,7 +48,6 @@ export default class ResearchPlanDetailsBody extends Component {
onDelete={onDelete.bind(this)}
onExport={onExport.bind(this)}
onCopyToMetadata={onCopyToMetadata.bind(this)}
- update={update}
edit={edit}
tableIndex={tableIndex}
isNew={isNew}
@@ -92,7 +90,6 @@ ResearchPlanDetailsBody.propTypes = {
onDelete: PropTypes.func,
onExport: PropTypes.func,
onCopyToMetadata: PropTypes.func,
- update: PropTypes.bool,
edit: PropTypes.bool,
isNew: PropTypes.bool,
copyableFields: PropTypes.arrayOf(PropTypes.object),
diff --git a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsField.js b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsField.js
index 2d5a091a25..538a8bfed0 100644
--- a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsField.js
+++ b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsField.js
@@ -20,7 +20,7 @@ import ResearchPlanDetailsFieldReaction from 'src/apps/mydb/elements/details/res
export default class ResearchPlanDetailsField extends Component {
render() {
const {
- field, index, disabled, onChange, onDrop, onDelete, onExport, update, edit, tableIndex,
+ field, index, disabled, onChange, onDrop, onDelete, onExport, edit, tableIndex,
onCopyToMetadata, isNew, copyableFields
} = this.props;
let label;
@@ -82,7 +82,6 @@ export default class ResearchPlanDetailsField extends Component {
disabled={disabled}
onChange={onChange.bind(this)}
onExport={onExport}
- update={update}
edit={edit}
tableIndex={tableIndex}
/>
@@ -206,7 +205,6 @@ ResearchPlanDetailsField.propTypes = {
onCopyToMetadata: PropTypes.func,
isNew: PropTypes.bool,
copyableFields: PropTypes.arrayOf(PropTypes.object),
- update: PropTypes.bool,
edit: PropTypes.bool,
attachments: PropTypes.array
};
diff --git a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsFieldTable.js b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsFieldTable.js
index b7c9648917..ef0c9c5878 100644
--- a/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsFieldTable.js
+++ b/app/packs/src/apps/mydb/elements/details/researchPlans/researchPlanTab/ResearchPlanDetailsFieldTable.js
@@ -20,7 +20,6 @@ export default class ResearchPlanDetailsFieldTable extends Component {
constructor(props) {
super(props);
this.state = {
- update: this.props.update,
currentlyCollapsedInEditMode: this.props?.field?.value?.startCollapsed ?? false,
currentlyCollapsedInViewMode: this.props?.field?.value?.startCollapsed ?? false,
columnNameModal: {
@@ -45,12 +44,6 @@ export default class ResearchPlanDetailsFieldTable extends Component {
this.ref = React.createRef();
}
- componentDidUpdate() {
- if (this.state.update !== this.props.update) {
- this.setState({ update: this.props.update });
- }
- }
-
buildColumn(columnName) {
return {
cellEditor: 'agTextCellEditor',
@@ -663,6 +656,5 @@ ResearchPlanDetailsFieldTable.propTypes = {
index: PropTypes.number,
disabled: PropTypes.bool,
onChange: PropTypes.func,
- update: PropTypes.bool,
edit: PropTypes.bool
};
diff --git a/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/ElementalCompositionCustom.js b/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/ElementalCompositionCustom.js
index 62a239f528..c558f05069 100644
--- a/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/ElementalCompositionCustom.js
+++ b/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/ElementalCompositionCustom.js
@@ -32,33 +32,23 @@ export default class ElementalCompositionCustom extends React.Component {
}
elementsList(el_composition, concat_formula) {
- const elements = [];
- const newData = {};
-
// be sure that 3, 2-symbol (Br) elements are all before one-symbol (B)!
// TODO: check performance
const mendeleev = /(Uut|Uup|Uus|Uuo|He|Li|Be|Ne|Na|Mg|Al|Si|Cl|Ar|Ca|Sc|Ti|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|As|Se|Br|Kr|Rb|Sr|Zr|Nb|Mo|Tc|Ru|Rh|Pd|Ag|Cd|In|Sn|Sb|Te|Xe|Cs|Ba|La|Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Lu|Hf|Ta|Re|Os|Ir|Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Ac|Th|Pa|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No|Lr|Rf|Db|Sg|Bh|Hs|Mt|Ds|Rg|Cn|Fl|Lv|H|B|C|N|O|F|P|S|K|V|Y|I|W|U)/g;
const keys = _.uniq(concat_formula.match(mendeleev)).sort();
// add new key to custom composition, so that we have new input
- keys.forEach((key) => {
- newData[key] = (el_composition.data[key] || 0.0);
- elements.push(
-
- {key}
- this.handleElementsListChanged(v, key, el_composition)}
- />
-
- );
- });
-
- el_composition.data = newData;
- return elements;
+ return keys.map((key) => (
+
+ {key}
+ this.handleElementsListChanged(v, key, el_composition)}
+ />
+
+ ));
}
render() {
diff --git a/app/packs/src/apps/mydb/elements/list/ElementsList.js b/app/packs/src/apps/mydb/elements/list/ElementsList.js
index c0c60cf81c..24ad14388a 100644
--- a/app/packs/src/apps/mydb/elements/list/ElementsList.js
+++ b/app/packs/src/apps/mydb/elements/list/ElementsList.js
@@ -99,31 +99,28 @@ export default class ElementsList extends React.Component {
onChangeUser(state) {
let visible = Immutable.List();
let hidden = Immutable.List();
- let currentTabIndex = 0;
-
- const { currentType } = state;
- let type = state.currentType;
+ let { currentType, currentTab } = state;
if (typeof (state.profile) !== 'undefined' && state.profile
&& typeof (state.profile.data) !== 'undefined' && state.profile.data) {
visible = getArrayFromLayout(state.profile.data.layout, true);
hidden = getArrayFromLayout(state.profile.data.layout, false);
- currentTabIndex = visible.findIndex((e) => e === currentType);
- if (type === '') { type = visible.get(0); }
+ currentTab = visible.findIndex((e) => e === currentType);
+ if (currentType === '') { currentType = visible.get(0); }
}
if (hidden.size === 0) {
hidden = ArrayUtils.pushUniq(hidden, 'hidden');
}
- if (currentTabIndex < 0) currentTabIndex = 0;
+ if (currentTab < 0) currentTab = 0;
- if (typeof type !== 'undefined' && type != null) {
- KeyboardActions.contextChange.defer(type);
+ if (typeof currentType !== 'undefined' && currentType != null) {
+ KeyboardActions.contextChange.defer(currentType);
}
this.setState({
- currentTab: currentTabIndex,
genericEls: state.genericEls || [],
+ currentTab,
visible,
hidden
});
@@ -131,7 +128,6 @@ export default class ElementsList extends React.Component {
onChangeUI(state) {
const { totalCheckedElements } = this.state;
- let forceUpdate = false;
// const genericNames = (genericEls && genericEls.map(el => el.name)) || [];
let genericKlasses = [];
const currentUser = (UserStore.getState() && UserStore.getState().currentUser) || {};
@@ -141,31 +137,33 @@ export default class ElementsList extends React.Component {
}
const elNames = ['sample', 'reaction', 'screen', 'wellplate', 'research_plan', 'cell_line'].concat(genericKlasses);
+ const newTotalCheckedElements = {};
+ let needsUpdate = false;
elNames.forEach((type) => {
const elementUI = state[type] || {
- checkedAll: false, checkedIds: [], uncheckedIds: [], currentId: null
+ checkedAll: false,
+ checkedIds: Immutable.List(),
+ uncheckedIds: Immutable.List(),
};
const element = ElementStore.getState().elements[`${type}s`];
const nextCount = elementUI.checkedAll
? (element.totalElements - elementUI.uncheckedIds.size)
: elementUI.checkedIds.size;
- if (!forceUpdate && nextCount !== (totalCheckedElements[type] || 0)) { forceUpdate = true; }
- totalCheckedElements[type] = nextCount;
+ needsUpdate = needsUpdate || nextCount !== totalCheckedElements[type];
+ newTotalCheckedElements[type] = nextCount
});
- this.setState((previousState) => ({ ...previousState, totalCheckedElements }));
- // could not use shouldComponentUpdate because state.totalCheckedElements
- // has already changed independently of setstate
- if (forceUpdate) { this.forceUpdate(); }
+ if (needsUpdate) {
+ this.setState({ totalCheckedElements: newTotalCheckedElements });
+ }
}
handleRemoveSearchResult(searchStore) {
searchStore.changeShowSearchResultListValue(false);
UIActions.clearSearchById();
ElementActions.changeSorting(false);
- const { currentCollection, isSync } = UIStore.getState();
- isSync ? UIActions.selectSyncCollection(currentCollection)
- : UIActions.selectCollection(currentCollection);
+ const { currentCollection } = UIStore.getState();
+ UIActions.selectCollection(currentCollection);
}
handleTabSelect(tab) {
@@ -186,7 +184,7 @@ export default class ElementsList extends React.Component {
render() {
const {
- visible, hidden, totalCheckedElements, totalElements
+ visible, hidden, totalCheckedElements, totalElements, currentTab
} = this.state;
const { overview } = this.props;
@@ -262,7 +260,7 @@ export default class ElementsList extends React.Component {
this.handleTabSelect(parseInt(eventKey, 10))}
>
{tabItems}
diff --git a/app/packs/src/apps/mydb/elements/list/ElementsTable.js b/app/packs/src/apps/mydb/elements/list/ElementsTable.js
index 2a0d636645..62eb0af319 100644
--- a/app/packs/src/apps/mydb/elements/list/ElementsTable.js
+++ b/app/packs/src/apps/mydb/elements/list/ElementsTable.js
@@ -59,10 +59,32 @@ export default class ElementsTable extends React.Component {
}
componentDidMount() {
- UIStore.getState();
ElementStore.listen(this.onChange);
+ this.onChange(ElementStore.getState());
+
UIStore.listen(this.onChangeUI);
- this.initState();
+ this.onChangeUI(UIStore.getState());
+
+ const { type, genericEl } = this.props;
+ if (type === 'reaction' || genericEl) {
+ const userState = UserStore.getState();
+ const filters = userState.profile.data.filters || {};
+
+ const { elementsGroup, elementsSort, sortDirection } = this.state;
+ const newElementsGroup = filters[type]?.group || 'none';
+ const newElementsSort = filters[type]?.sort ?? true;
+ const newSortDirection = filters[type]?.direction || 'DESC';
+
+ if (newElementsGroup !== elementsGroup
+ || newElementsSort !== elementsSort
+ || newSortDirection !== sortDirection) {
+ this.setState({
+ elementsGroup: newElementsGroup,
+ elementsSort: newElementsSort,
+ sortDirection: newSortDirection,
+ });
+ }
+ }
}
componentWillUnmount() {
@@ -169,25 +191,6 @@ export default class ElementsTable extends React.Component {
if (toDate !== date) UIActions.setToDate(date);
}
- initState = () => {
- this.onChange(ElementStore.getState());
-
- const { type, genericEl } = this.props;
-
- if (type === 'reaction' || genericEl) {
- const userState = UserStore.getState();
- const filters = userState.profile.data.filters || {};
-
- // you are not able to use this.setState because this would rerender it again and again ...
- // eslint-disable-next-line react/no-direct-mutation-state
- this.state.elementsGroup = filters[type]?.group || 'none';
- // eslint-disable-next-line react/no-direct-mutation-state
- this.state.elementsSort = filters[type]?.sort ?? true;
- // eslint-disable-next-line react/no-direct-mutation-state
- this.state.sortDirection = filters[type]?.direction || 'DESC';
- }
- };
-
changeCollapse = (collapseAll) => {
this.setState({ collapseAll: !collapseAll });
};
diff --git a/app/packs/src/apps/mydb/elements/list/ElementsTableSampleEntries.js b/app/packs/src/apps/mydb/elements/list/ElementsTableSampleEntries.js
index 00f15dae4f..f2faaf5591 100644
--- a/app/packs/src/apps/mydb/elements/list/ElementsTableSampleEntries.js
+++ b/app/packs/src/apps/mydb/elements/list/ElementsTableSampleEntries.js
@@ -126,10 +126,7 @@ const svgPreview = (sample) => (
/>
);
-function MoleculeHeader({
- sample, show, showDragColumn, onClick, targetType
-}) {
- const { collId, showPreviews } = UIStore.getState();
+function MoleculeHeader({ sample, show, showPreviews, showDragColumn, onClick, targetType }) {
const isNoStructureSample = sample.molecule?.inchikey === 'DUMMY' && sample.molfile == null;
return (
@@ -174,19 +171,31 @@ function MoleculeHeader({
export default class ElementsTableSampleEntries extends Component {
constructor(props) {
super(props);
+
+ const { showPreviews } = UIStore.getState();
this.state = {
displayedMoleculeGroup: [],
moleculeGroupsShown: [],
+ showPreviews,
flattenSamplesId: [],
keyboardIndex: null,
keyboardSeletectedElementId: null,
};
this.sampleOnKeyDown = this.sampleOnKeyDown.bind(this);
+ this.onUIStoreChange = this.onUIStoreChange.bind(this);
}
componentDidMount() {
KeyboardStore.listen(this.sampleOnKeyDown);
+ UIStore.listen(this.onUIStoreChange);
+ }
+
+ onUIStoreChange(state) {
+ const { showPreviews } = state;
+ if (this.state.showPreviews !== showPreviews) {
+ this.setState({ showPreviews });
+ }
}
getMolId(sample) {
@@ -237,10 +246,11 @@ export default class ElementsTableSampleEntries extends Component {
const {
collapseAll, showDragColumn, moleculeSort, currentElement, elements, ui
} = this.props;
- const { keyboardIndex, keyboardSeletectedElementId } = this.state;
+ const { keyboardIndex, keyboardSeletectedElementId, showPreviews } = this.state;
const { checkedAll, checkedIds, uncheckedIds } = ui;
const nextUi = nextProps.ui;
return collapseAll !== nextProps.collapseAll // Bool
+ || showPreviews !== nextState.showPreviews // Bool
|| showDragColumn !== nextProps.showDragColumn // Bool
|| moleculeSort !== nextProps.moleculeSort // Bool
|| currentElement !== nextProps.currentElement // instance of Sample
@@ -254,6 +264,7 @@ export default class ElementsTableSampleEntries extends Component {
componentWillUnmount() {
KeyboardStore.unlisten(this.sampleOnKeyDown);
+ UIStore.unlisten(this.onUIStoreChange);
}
handleMoleculeToggle(moleculeName) {
@@ -396,7 +407,7 @@ export default class ElementsTableSampleEntries extends Component {
renderMoleculeGroup(moleculeGroup, index) {
const { showDragColumn, collapseAll } = this.props;
- const { moleculeGroupsShown, targetType } = this.state;
+ const { showPreviews, moleculeGroupsShown, targetType } = this.state;
const { molecule } = moleculeGroup[0];
const moleculeName = molecule.iupac_name || molecule.inchistring;
const showGroup = !moleculeGroupsShown.includes(moleculeName) && !collapseAll;
@@ -406,6 +417,7 @@ export default class ElementsTableSampleEntries extends Component {
this.handleMoleculeToggle(moleculeName)}
targetType={targetType}
diff --git a/app/packs/src/apps/mydb/inbox/InboxModal.js b/app/packs/src/apps/mydb/inbox/InboxModal.js
index 9427cf5093..e0bda31ca0 100644
--- a/app/packs/src/apps/mydb/inbox/InboxModal.js
+++ b/app/packs/src/apps/mydb/inbox/InboxModal.js
@@ -37,8 +37,10 @@ export default class InboxModal extends React.Component {
colMdValue: 4,
};
- this.onChange = this.onChange.bind(this);
+ this.onInboxStoreChange = this.onInboxStoreChange.bind(this);
this.onUIStoreChange = this.onUIStoreChange.bind(this);
+ this.onUserStoreChange = this.onUserStoreChange.bind(this);
+
this.onClickInbox = this.onClickInbox.bind(this);
this.handleMouseDown = this.handleMouseDown.bind(this);
this.handleMouseMove = this.handleMouseMove.bind(this);
@@ -46,10 +48,13 @@ export default class InboxModal extends React.Component {
}
componentDidMount() {
- InboxStore.listen(this.onChange);
+ InboxStore.listen(this.onInboxStoreChange);
UIStore.listen(this.onUIStoreChange);
+ this.onUIStoreChange(UIStore.getState());
+ UserStore.listen(this.onUserStoreChange);
+ this.onUserStoreChange(UserStore.getState());
+
InboxActions.fetchInboxCount();
- this.initState();
}
componentDidUpdate(prevProps, prevState) {
@@ -61,7 +66,9 @@ export default class InboxModal extends React.Component {
}
componentWillUnmount() {
- InboxStore.unlisten(this.onChange);
+ InboxStore.unlisten(this.onInboxStoreChange);
+ UIStore.unlisten(this.onUIStoreChange);
+ UserStore.unlisten(this.onUserStoreChange);
}
handlePageChange(pageNumber) {
@@ -73,7 +80,7 @@ export default class InboxModal extends React.Component {
}
}
- onChange(state) {
+ onInboxStoreChange(state) {
this.setState(state);
this.setState({ visible: state.inboxModalVisible });
}
@@ -85,6 +92,17 @@ export default class InboxModal extends React.Component {
}
}
+ onUserStoreChange(state) {
+ const type = 'inbox';
+ const filters = state?.profile?.data?.filters || {};
+ const newSortColumn = filters[type]?.sort || 'name';
+
+ const { sortColumn } = this.state;
+ if (sortColumn !== newSortColumn) {
+ this.setState({ sortColumn: newSortColumn });
+ }
+ }
+
onClickInbox() {
const {
inboxVisible, inbox, currentPage, itemsPerPage
@@ -130,17 +148,6 @@ export default class InboxModal extends React.Component {
}
};
- initState = () => {
- const type = 'inbox';
- const userState = UserStore.getState();
- const filters = userState?.profile?.data?.filters || {};
-
- // you are not able to use this.setState because this would rerender it again and again ...
-
- // eslint-disable-next-line react/no-direct-mutation-state
- this.state.sortColumn = filters[type]?.sort || 'name';
- };
-
updateFilterAndUserProfile = (type, sort) => {
InboxActions.changeInboxFilter({
name: type,
@@ -340,8 +347,6 @@ export default class InboxModal extends React.Component {
}
renderSortButton() {
- this.initState();
-
const sortTitle = this.state.sortColumn === 'name'
? 'click to sort datasets and attachments by creation date (descending) - currently sorted alphabetically'
: 'click to sort datasets and attachments alphabetically - currently sorted by creation date (descending)';
diff --git a/app/packs/src/components/UserLabels.js b/app/packs/src/components/UserLabels.js
index b69996ac3e..71061f6d3e 100644
--- a/app/packs/src/components/UserLabels.js
+++ b/app/packs/src/components/UserLabels.js
@@ -422,7 +422,7 @@ class ShowUserLabels extends React.Component {
curLabelIds.includes(o.id) && (o.access_level > 0 || o.user_id === currentUser.id)
));
- return labels.map((l) => );
+ return labels.map((l) => );
}
}
diff --git a/app/packs/src/components/managingActions/ManagingActions.js b/app/packs/src/components/managingActions/ManagingActions.js
index 909912aa15..784c27aa15 100644
--- a/app/packs/src/components/managingActions/ManagingActions.js
+++ b/app/packs/src/components/managingActions/ManagingActions.js
@@ -1,7 +1,6 @@
import React from 'react';
import { ButtonGroup } from 'react-bootstrap';
import PropTypes from 'prop-types';
-import { List } from 'immutable';
import {
ShareButton,
MoveOrAssignButton,
@@ -20,53 +19,6 @@ import ManagingModalTopSecret from 'src/components/managingActions/ManagingModal
import ElementActions from 'src/stores/alt/actions/ElementActions';
import { elementNames } from 'src/apps/generic/Utils';
-const upState = async (state) => {
- const { sample, reaction, screen, wellplate, research_plan, cell_line } = state;
- const stateObj = {
- sample: {
- checkedAll: sample ? sample.checkedAll : false,
- checkedIds: sample ? sample.checkedIds : List(),
- uncheckedIds: sample ? sample.uncheckedIds : List(),
- },
- reaction: {
- checkedAll: reaction ? reaction.checkedAll : false,
- checkedIds: reaction ? reaction.checkedIds : List(),
- uncheckedIds: reaction ? reaction.uncheckedIds : List(),
- },
- wellplate: {
- checkedAll: wellplate ? wellplate.checkedAll : false,
- checkedIds: wellplate ? wellplate.checkedIds : List(),
- uncheckedIds: wellplate ? wellplate.uncheckedIds : List(),
- },
- screen: {
- checkedAll: screen ? screen.checkedAll : false,
- checkedIds: screen ? screen.checkedIds : List(),
- uncheckedIds: screen ? screen.uncheckedIds : List(),
- },
- research_plan: {
- checkedAll: research_plan ? research_plan.checkedAll : false,
- checkedIds: research_plan ? research_plan.checkedIds : List(),
- uncheckedIds: research_plan ? research_plan.uncheckedIds : List(),
- },
- cell_line: {
- checkedAll: cell_line ? cell_line.checkedAll : false,
- checkedIds: cell_line ? cell_line.checkedIds : List(),
- uncheckedIds: cell_line ? cell_line.uncheckedIds : List(),
- }
- };
-
- // eslint-disable-next-line no-unused-expressions
- const klassArray = await elementNames(false);
- klassArray.forEach((klass) => {
- stateObj[`${klass}`] = {
- checkedAll: state[`${klass}`] ? state[`${klass}`].checkedAll : false,
- checkedIds: state[`${klass}`] ? state[`${klass}`].checkedIds : List(),
- uncheckedIds: state[`${klass}`] ? state[`${klass}`].uncheckedIds : List(),
- };
- });
- // }
- return (stateObj);
-};
export default class ManagingActions extends React.Component {
constructor(props) {
@@ -79,7 +31,7 @@ export default class ManagingActions extends React.Component {
deletion_allowed: false,
remove_allowed: false,
is_top_secret: false,
- genericEls: []
+ genericEls: genericEls
};
this.handleButtonClick = this.handleButtonClick.bind(this);
@@ -87,8 +39,6 @@ export default class ManagingActions extends React.Component {
this.onUserChange = this.onUserChange.bind(this);
this.onPermissionChange = this.onPermissionChange.bind(this);
-
- this.initializeAsyncState();
}
componentDidMount() {
@@ -115,14 +65,14 @@ export default class ManagingActions extends React.Component {
hasSel: false,
currentCollection
});
- } else if (this.checkUIState(state)) {
+ } else {
const klassArray = await elementNames(true);
- const hasSel = klassArray.some((el) => (state[el] && (state[el].checkedIds.size > 0 || state[el].checkedAll)));
- PermissionActions.fetchPermissionStatus(state);
- const upStateResult = await upState(state);
- this.setState({
- ...upStateResult, hasSel
+ const newHasSel = klassArray.some((el) => {
+ return (state[el] && (state[el].checkedIds.size > 0 || state[el].checkedAll));
});
+ PermissionActions.fetchPermissionStatus(state);
+ const { hasSel } = this.state;
+ if (newHasSel != hasSel) this.setState({ hasSel: newHasSel });
}
}
@@ -145,11 +95,6 @@ export default class ManagingActions extends React.Component {
this.setState({ ...state });
}
- async initializeAsyncState() {
- const upStateResult = await upState({});
- this.setState({ ...upStateResult });
- }
-
collectionChanged(state) {
const { currentCollection } = state;
if (typeof currentCollection === 'undefined' || currentCollection == null) {
@@ -160,17 +105,6 @@ export default class ManagingActions extends React.Component {
this.state.currentCollection.is_sync_to_me !== is_sync_to_me;
}
- checkUIState(state) {
- const genericNames = (this.state.genericEls && this.state.genericEls.map(el => el.name)) || [];
- const elNames = ['sample', 'reaction', 'screen', 'wellplate', 'research_plan', 'cell_line'].concat(genericNames);
- const result = elNames.find(el => (this.state[el] && state[el] && (
- state[el].checkedIds !== this.state[el].checkedIds ||
- state[el].checkedAll !== this.state[el].checkedAll ||
- state[el].uncheckedIds !== this.state[el].uncheckedIds
- )));
- return result;
- }
-
// eslint-disable-next-line react/sort-comp
handleButtonClick(type) {
const modalProps = { show: true, action: '', listSharedCollections: false };
@@ -252,10 +186,8 @@ export default class ManagingActions extends React.Component {
ManagingActions.propTypes = {
updateModalProps: PropTypes.func.isRequired,
customClass: PropTypes.string,
- genericEls: PropTypes.array
};
ManagingActions.defaultProps = {
customClass: null,
- genericEls: []
};
diff --git a/app/packs/src/components/navigation/Navigation.js b/app/packs/src/components/navigation/Navigation.js
index 5be809f6d0..f583991734 100644
--- a/app/packs/src/components/navigation/Navigation.js
+++ b/app/packs/src/components/navigation/Navigation.js
@@ -24,7 +24,6 @@ export default class Navigation extends React.Component {
super(props);
this.state = {
currentUser: null,
- genericEls: null,
modalProps: {
show: false,
title: '',
@@ -61,11 +60,6 @@ export default class Navigation extends React.Component {
currentUser: state.currentUser
});
}
- if (this.state.genericEls === null) {
- this.setState({
- genericEls: state.genericEls
- });
- }
if (state.omniauthProviders !== this.state.omniauthProviders) {
this.setState({
omniauthProviders: state.omniauthProviders
@@ -141,8 +135,7 @@ export default class Navigation extends React.Component {
render() {
const {
- currentUser,
- modalProps, genericEls, omniauthProviders, extraRules
+ currentUser, modalProps, omniauthProviders, extraRules
} = this.state;
const { isHidden } = this.props;
const { profile } = UserStore.getState();
@@ -160,7 +153,6 @@ export default class Navigation extends React.Component {
{
collectionId: collection.id,
isSync: !!collection.is_sync_to_me });
} else {
- UIActions.selectSyncCollection(collection);
+ UIActions.selectCollection(collection);
if (currentSearchByID) {
UIActions.clearSearchById();
}