From 8eb7e93917c247772604a7e1a06a52ee0eb93877 Mon Sep 17 00:00:00 2001 From: matej <60509086+matej-vavrek@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:52:37 +0100 Subject: [PATCH] #1540 preferred aliases (#466) * removed SGC column from target list * #1540 added preferred alias functionality * #1540 added edit column to target list and use target settings modal * #1540 updated "Open" label and read only version of display name --------- Co-authored-by: boriskovar-m2ms --- js/components/header/index.js | 36 ++- js/components/landing/Landing.js | 10 +- .../observationCmpView/observationCmpView.js | 63 +++- js/components/preview/tags/api/tagsApi.js | 10 +- .../preview/tags/redux/dispatchActions.js | 9 +- .../snapshot/withSnapshotManagement.js | 5 +- js/components/target/targetList.js | 31 +- js/components/target/targetSettingsModal.js | 273 ++++++++++++++++++ js/reducers/api/actions.js | 25 +- js/reducers/api/apiReducers.js | 26 +- js/reducers/api/constants.js | 5 +- js/reducers/api/selectors.js | 6 + 12 files changed, 461 insertions(+), 38 deletions(-) create mode 100644 js/components/target/targetSettingsModal.js diff --git a/js/components/header/index.js b/js/components/header/index.js index c7a3b316a..3c737fade 100644 --- a/js/components/header/index.js +++ b/js/components/header/index.js @@ -72,7 +72,8 @@ import { AddProjectDetail } from '../projects/addProjectDetail'; import { ServicesStatusWrapper } from '../services'; import { COMPANIES, get_logo } from '../funders/constants'; import { setEditTargetDialogOpen } from '../target/redux/actions'; -import { Upload } from '@mui/icons-material'; +import { Settings, Upload } from '@mui/icons-material'; +import { TargetSettingsModal } from '../target/targetSettingsModal'; import { SnapshotType } from '../projects/redux/constants'; import { NglContext } from '../nglView/nglProvider'; import { VIEWS } from '../../constants/constants'; @@ -134,7 +135,7 @@ export default memo( const [openMenu, setOpenMenu] = useState(false); const [openFunders, setOpenFunders] = useState(false); - const [openTrackingModal, setOpenTrackingModal] = useState(false); + const [openTargetSettings, setOpenTargetSettings] = useState(false); const [versions, setVersions] = useState({}); const layoutEnabled = useSelector(state => state.layoutReducers.layoutEnabled); @@ -310,14 +311,13 @@ export default memo( > Menu - + + + + ); +}); diff --git a/js/reducers/api/actions.js b/js/reducers/api/actions.js index 08ebe6857..6b4c5b89f 100644 --- a/js/reducers/api/actions.js +++ b/js/reducers/api/actions.js @@ -43,6 +43,20 @@ export const setTargetOn = function (target_id, skipTracking = false) { }; }; +export const setTargetOnName = function (target_on_name) { + return { + type: constants.SET_TARGET_ON_NAME, + target_on_name: target_on_name + }; +}; + +export const setTargetOnAliases = function (target_on_aliases) { + return { + type: constants.SET_TARGET_ON_ALIASES, + target_on_aliases: target_on_aliases + }; +}; + export const setPanddaSiteList = function (pandda_site_list) { return { type: constants.SET_PANNDA_SITE_LIST, @@ -314,6 +328,7 @@ export const reloadApiState = function (apiReducers) { return { type: constants.RELOAD_API_STATE, + target_on_aliases: apiReducers.target_on_aliases, target_on_name: apiReducers.target_on_name, target_on: apiReducers.target_on, target_id: apiReducers.target_id, @@ -332,7 +347,8 @@ export const reloadApiState = function (apiReducers) { pandda_event_on: apiReducers.pandda_event_on, pandda_site_on: apiReducers.pandda_site_on, pandda_event_list: apiReducers.pandda_event_list, - pandda_site_list: apiReducers.pandda_site_list + pandda_site_list: apiReducers.pandda_site_list, + compound_identifiers: apiReducers.compound_identifiers }; }; @@ -436,3 +452,10 @@ export const setProteinIsLoaded = proteinIsLoaded => { proteinIsLoaded: proteinIsLoaded }; }; + +export const setCompoundIdentifiers = compoundIdentifiers => { + return { + type: constants.SET_COMPOUND_IDENTIFIERS, + compound_identifiers: compoundIdentifiers + }; +}; diff --git a/js/reducers/api/apiReducers.js b/js/reducers/api/apiReducers.js index 92f2c2481..800295b1f 100644 --- a/js/reducers/api/apiReducers.js +++ b/js/reducers/api/apiReducers.js @@ -24,6 +24,7 @@ export const INITIAL_STATE = { mol_group_on: undefined, target_on: undefined, target_on_name: undefined, + target_on_aliases: [], group_id: undefined, isFetching: false, app_on: 'PREVIEW', @@ -58,7 +59,8 @@ export const INITIAL_STATE = { rhsDataIsLoading: false, rhsDataIsLoaded: false, proteinIsLoading: false, - proteinIsLoaded: false + proteinIsLoaded: false, + compound_identifiers: [] }; export const RESET_TARGET_STATE = { @@ -74,6 +76,7 @@ export const RESET_TARGET_STATE = { mol_group_on: undefined, target_on: undefined, target_on_name: undefined, + target_on_aliases: [], group_id: undefined, isFetching: false, app_on: 'PREVIEW', @@ -100,7 +103,8 @@ export const RESET_TARGET_STATE = { target_data_loading_in_progress: false, all_data_loaded: false, snapshotLoadingInProgress: false, - lhs_compounds_list: [] + lhs_compounds_list: [], + compound_identifiers: [] }; export default function apiReducers(state = INITIAL_STATE, action = {}) { @@ -123,6 +127,9 @@ export default function apiReducers(state = INITIAL_STATE, action = {}) { case constants.SET_PROTEIN_IS_LOADED: return { ...state, proteinIsLoaded: action.proteinIsLoaded }; + case constants.SET_COMPOUND_IDENTIFIERS: + return { ...state, compound_identifiers: action.compound_identifiers }; + case constants.SET_OPEN_DISCOURSE_ERROR_MODAL: return Object.assign({}, state, { open_discourse_error_modal: action.payload }); @@ -142,17 +149,26 @@ export default function apiReducers(state = INITIAL_STATE, action = {}) { case constants.SET_TARGET_ON: { let target_on_name = undefined; + let target_on_aliases = []; for (let ind in state.target_id_list) { if (state.target_id_list[ind].id === action.target_on) { - target_on_name = state.target_id_list[ind].title; + target_on_name = state.target_id_list[ind].display_name; + target_on_aliases = state.target_id_list[ind].alias_order; } } return Object.assign({}, state, { target_on_name: target_on_name, + target_on_aliases: target_on_aliases, target_on: action.target_on }); } + case constants.SET_TARGET_ON_NAME: + return { ...state, target_on_name: action.target_on_name }; + + case constants.SET_TARGET_ON_ALIASES: + return { ...state, target_on_aliases: action.target_on_aliases }; + case constants.SET_MOL_GROUP_LIST: return Object.assign({}, state, { mol_group_list: action.mol_group_list @@ -378,6 +394,7 @@ export default function apiReducers(state = INITIAL_STATE, action = {}) { case constants.RELOAD_API_STATE: return Object.assign({}, state, { project: action.project, + target_on_aliases: action.target_on_aliases, target_on_name: action.target_on_name, target_on: action.target_on, target_id: action.target_id, @@ -396,7 +413,8 @@ export default function apiReducers(state = INITIAL_STATE, action = {}) { pandda_event_list: action.pandda_event_list, pandda_site_list: action.pandda_site_list, latestSession: action.latestSession, - direct_access: action.direct_access + direct_access: action.direct_access, + compound_identifiers: action.compound_identifiers // direct_access_processed: action.direct_access_processed }); diff --git a/js/reducers/api/constants.js b/js/reducers/api/constants.js index c8ae1a86f..22cda23fe 100644 --- a/js/reducers/api/constants.js +++ b/js/reducers/api/constants.js @@ -4,6 +4,8 @@ export const constants = { SET_LEGACY_TARGET_ID_LIST: prefix + 'SET_LEGACY_TARGET_ID_LIST', SET_DUCK_YANK_DATA: prefix + 'SET_DUCK_YANK_DATA', SET_TARGET_ON: prefix + 'REDUCERS_API_SET_TARGET_ON', + SET_TARGET_ON_NAME: prefix + 'SET_TARGET_ON_NAME', + SET_TARGET_ON_ALIASES: prefix + 'SET_TARGET_ON_ALIASES', // Pandda stuff SET_PANNDA_SITE_LIST: prefix + 'SET_PANNDA_SITE_LIST', @@ -62,5 +64,6 @@ export const constants = { SET_RHS_DATA_IS_LOADING: prefix + 'SET_RHS_DATA_IS_LOADING', SET_RHS_DATA_IS_LOADED: prefix + 'SET_RHS_DATA_IS_LOADED', SET_PROTEIN_IS_LOADING: prefix + 'SET_PROTEIN_IS_LOADING', - SET_PROTEIN_IS_LOADED: prefix + 'SET_PROTEIN_IS_LOADED' + SET_PROTEIN_IS_LOADED: prefix + 'SET_PROTEIN_IS_LOADED', + SET_COMPOUND_IDENTIFIERS: prefix + 'SET_COMPOUND_IDENTIFIERS' }; diff --git a/js/reducers/api/selectors.js b/js/reducers/api/selectors.js index e5f0260fe..bd7e7b5b6 100644 --- a/js/reducers/api/selectors.js +++ b/js/reducers/api/selectors.js @@ -16,3 +16,9 @@ export const getCombinedTargetList = state => { return result; }; +export const getCurrentTarget = state => { + const target_on = state.apiReducers.target_on; + const targets = state.apiReducers.target_id_list; + + return targets?.find(target => target.id === target_on); +};