From 6fb49ef2f8a26edb5a04b980fd2accdb4f602424 Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Tue, 29 Oct 2024 14:42:34 +0100 Subject: [PATCH 01/12] Do not modify Sample object when rendering ElementalCompositionCustom Assigning to `el_composition.data` would cause the sample to be considered as `isEdited`. --- .../ElementalCompositionCustom.js | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) 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() { From 3b8f31834963e9b96ecbc0b3f484ee26056f462f Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Mon, 28 Oct 2024 16:33:59 +0100 Subject: [PATCH 02/12] Add missing key prop when rendering UserLabels --- app/packs/src/components/UserLabels.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) => ); } } From bc81f624acfcb76e3b78e5f64ec986306ac95f0a Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Thu, 10 Oct 2024 14:59:09 +0200 Subject: [PATCH 03/12] Do not update state during render in InboxModal Before this change, we would `this.state.sortColumn = ...` during render in order to get the latest value from UserStore. Now we properly listen (and unlisten) for store changes and update the state using `this.setState`. With this change we also set the initial UIStore state when the component mounts and not only when the store state changes. --- app/packs/src/apps/mydb/inbox/InboxModal.js | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) 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)'; From 17527ba60ea9994b7051ff1b467357995c88d7e8 Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Wed, 16 Oct 2024 13:39:33 +0200 Subject: [PATCH 04/12] Remove unused genericEls prop from ManagingActions The ManagingActions component handles syncing genericEls with UserStore itself. No need to pass that information in as prop. --- .../src/components/managingActions/ManagingActions.js | 4 +--- app/packs/src/components/navigation/Navigation.js | 10 +--------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/packs/src/components/managingActions/ManagingActions.js b/app/packs/src/components/managingActions/ManagingActions.js index 909912aa15..23c0dfd136 100644 --- a/app/packs/src/components/managingActions/ManagingActions.js +++ b/app/packs/src/components/managingActions/ManagingActions.js @@ -79,7 +79,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); @@ -252,10 +252,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 { Date: Tue, 29 Oct 2024 10:00:51 +0100 Subject: [PATCH 05/12] Do not copy UIStore state into local component state We used to copy the state to determine whether the selection had changed or not. However, we can simply calculate that information from the UIStore state without the local state. --- .../managingActions/ManagingActions.js | 78 ++----------------- 1 file changed, 6 insertions(+), 72 deletions(-) diff --git a/app/packs/src/components/managingActions/ManagingActions.js b/app/packs/src/components/managingActions/ManagingActions.js index 23c0dfd136..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) { @@ -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 }; From 39b619171273e9e7832daacc0c2256b24a2f7750 Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Fri, 1 Nov 2024 10:13:04 +0100 Subject: [PATCH 06/12] Fix showing/hiding preview images in list of Samples --- .../list/ElementsTableSampleEntries.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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} From 8f160258683eeec8533b0329e2d11e7d861230db Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Fri, 1 Nov 2024 13:20:27 +0100 Subject: [PATCH 07/12] Remove unnecessary UIAction.selectSyncCollection This used to trigger `UIState.handleSelectSyncCollection` which forwarded to `UIStore.handleSelectCollection`. Removing in favour of less indirection. --- app/packs/src/apps/mydb/elements/list/ElementsList.js | 5 ++--- .../src/components/navigation/search/AutoCompleteInput.js | 5 ++--- app/packs/src/components/navigation/search/Search.js | 5 ++--- app/packs/src/stores/alt/actions/UIActions.js | 4 ---- app/packs/src/stores/alt/stores/UIStore.js | 5 ----- app/packs/src/utilities/routesUtils.js | 2 +- 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/app/packs/src/apps/mydb/elements/list/ElementsList.js b/app/packs/src/apps/mydb/elements/list/ElementsList.js index c0c60cf81c..17288a857c 100644 --- a/app/packs/src/apps/mydb/elements/list/ElementsList.js +++ b/app/packs/src/apps/mydb/elements/list/ElementsList.js @@ -163,9 +163,8 @@ export default class ElementsList extends React.Component { 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) { diff --git a/app/packs/src/components/navigation/search/AutoCompleteInput.js b/app/packs/src/components/navigation/search/AutoCompleteInput.js index 6a4233bcd9..fa2ba3baa8 100644 --- a/app/packs/src/components/navigation/search/AutoCompleteInput.js +++ b/app/packs/src/components/navigation/search/AutoCompleteInput.js @@ -234,10 +234,9 @@ export default class AutoCompleteInput extends React.Component { this.setState({ value: '' }); - let { currentCollection, isSync } = UIStore.getState(); + let { currentCollection } = UIStore.getState(); currentCollection['clearSearch'] = true; - isSync ? UIActions.selectSyncCollection(currentCollection) - : UIActions.selectCollection(currentCollection); + UIActions.selectCollection(currentCollection); return 0; } diff --git a/app/packs/src/components/navigation/search/Search.js b/app/packs/src/components/navigation/search/Search.js index a6b1717223..3c87ee0366 100644 --- a/app/packs/src/components/navigation/search/Search.js +++ b/app/packs/src/components/navigation/search/Search.js @@ -47,11 +47,10 @@ export default class Search extends React.Component { } handleClearSearchSelection() { - const { currentCollection, isSync } = UIStore.getState(); + const { currentCollection } = UIStore.getState(); this.setState({ elementType: 'all' }) currentCollection['clearSearch'] = true; - isSync ? UIActions.selectSyncCollection(currentCollection) - : UIActions.selectCollection(currentCollection); + UIActions.selectCollection(currentCollection); } handleElementSelection(event, element = null) { diff --git a/app/packs/src/stores/alt/actions/UIActions.js b/app/packs/src/stores/alt/actions/UIActions.js index 91bc651785..f31bb9fe22 100644 --- a/app/packs/src/stores/alt/actions/UIActions.js +++ b/app/packs/src/stores/alt/actions/UIActions.js @@ -51,10 +51,6 @@ class UIActions { return collection } - selectSyncCollection(syncCollection) { - return syncCollection - } - checkAllElements(params) { return params; } diff --git a/app/packs/src/stores/alt/stores/UIStore.js b/app/packs/src/stores/alt/stores/UIStore.js index 97fe95bffe..ca73545e2b 100644 --- a/app/packs/src/stores/alt/stores/UIStore.js +++ b/app/packs/src/stores/alt/stores/UIStore.js @@ -88,7 +88,6 @@ class UIStore { handleSelectActiveAnalysisTab: UIActions.selectActiveAnalysisTab, handleSelectCollection: UIActions.selectCollection, - handleSelectSyncCollection: UIActions.selectSyncCollection, handleCheckAllElements: UIActions.checkAllElements, handleToggleShowPreviews: UIActions.toggleShowPreviews, handleToggleAdvancedSearch: UIActions.toggleAdvancedSearch, @@ -437,10 +436,6 @@ class UIStore { }); } - handleSelectSyncCollection(collection) { - this.handleSelectCollection(collection) - } - // FIXME this method is also defined in ElementStore handleSetPagination(pagination) { let { type, page } = pagination; diff --git a/app/packs/src/utilities/routesUtils.js b/app/packs/src/utilities/routesUtils.js index cd293c90f3..6824f2f0a7 100644 --- a/app/packs/src/utilities/routesUtils.js +++ b/app/packs/src/utilities/routesUtils.js @@ -85,7 +85,7 @@ const scollectionShow = (e) => { collectionId: collection.id, isSync: !!collection.is_sync_to_me }); } else { - UIActions.selectSyncCollection(collection); + UIActions.selectCollection(collection); if (currentSearchByID) { UIActions.clearSearchById(); } From b53063a1284b16f6422f9a28aeace07a8da67d2e Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Fri, 1 Nov 2024 13:53:54 +0100 Subject: [PATCH 08/12] Use currentTab data stored in UserStore Before this change, we would always reset the currentTab to 0 and not use the data stored in the UserStore. This was fine when we never unmounted/mounted the ElementList component but leads to the undesired effect of not respecting the user's selected tab when we unmount/mount the component. --- .../apps/mydb/elements/list/ElementsList.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/app/packs/src/apps/mydb/elements/list/ElementsList.js b/app/packs/src/apps/mydb/elements/list/ElementsList.js index 17288a857c..12efee2b8d 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 }); @@ -185,7 +182,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; @@ -261,7 +258,7 @@ export default class ElementsList extends React.Component {
this.handleTabSelect(parseInt(eventKey, 10))} > {tabItems} From 7e02ed641f475eb7930f7974a753b05bd3073414 Mon Sep 17 00:00:00 2001 From: Luciano Maiwald Date: Fri, 1 Nov 2024 12:09:39 +0100 Subject: [PATCH 09/12] Remove obsolete `update` prop in ResearchPlanDetails This was used to force a re-render when changing to full screen. It does not seem to be necessary anymore. --- .../researchPlans/ResearchPlanDetails.js | 18 ++++-------------- .../researchPlanTab/ResearchPlanDetailsBody.js | 5 +---- .../ResearchPlanDetailsField.js | 4 +--- .../ResearchPlanDetailsFieldTable.js | 8 -------- 4 files changed, 6 insertions(+), 29 deletions(-) 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}> -