-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set custom workspaces at the level of the NMRium component (#1956)
feat: set custom workspaces at the level of the NMRium component close #1936 * chore: update demo to take a custom workspaces * feat: set the custom workspaces at the level of the component * chore: update demo to take a custom workspaces * demo: Metabo workspace
- Loading branch information
1 parent
93158dd
commit f3b3c65
Showing
14 changed files
with
178 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/component/reducer/preferences/utilities/filterCustomWorkspaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Workspace } from '../../../workspaces/Workspace'; | ||
|
||
export function filterCustomWorkspaces(workspaces: Record<string, Workspace>) { | ||
const mapObject = {}; | ||
for (const key in workspaces) { | ||
if (!key.startsWith('custom-')) { | ||
mapObject[key] = workspaces[key]; | ||
} | ||
} | ||
return mapObject; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/component/reducer/preferences/utilities/mapWorkspaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import lodashMerge from 'lodash/merge'; | ||
|
||
import { Workspace, WorkSpaceSource } from '../../../workspaces/Workspace'; | ||
import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties'; | ||
|
||
export function mapWorkspaces( | ||
customWorkspaces: Record<string, Workspace>, | ||
source: WorkSpaceSource, | ||
) { | ||
const mapObject = {}; | ||
const prefix = source === 'custom' ? 'custom-' : ''; | ||
for (const key in customWorkspaces) { | ||
mapObject[`${prefix}${key}`] = lodashMerge( | ||
{}, | ||
workspaceDefaultProperties, | ||
customWorkspaces[key], | ||
); | ||
} | ||
return mapObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { CustomWorkspaces } from '../../component/workspaces/Workspace'; | ||
|
||
import View from './View'; | ||
|
||
const customWorkspaces: CustomWorkspaces = { | ||
test: { | ||
label: 'Test Workspace', | ||
display: { | ||
panels: { | ||
spectraPanel: { display: true, open: true }, | ||
multipleSpectraAnalysisPanel: { display: true, open: true }, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default function CustomWorkspace(props) { | ||
return <View {...props} customWorkspaces={customWorkspaces} />; | ||
} |
Oops, something went wrong.