chore: sketch out beginnings of isDisabled method for sidePanel menuOptions
This commit is contained in:
parent
f04d459a63
commit
f68aaf973c
@ -25,9 +25,14 @@ class ToolbarRow extends Component {
|
|||||||
isRightSidePanelOpen: PropTypes.bool.isRequired,
|
isRightSidePanelOpen: PropTypes.bool.isRequired,
|
||||||
selectedLeftSidePanel: PropTypes.string.isRequired,
|
selectedLeftSidePanel: PropTypes.string.isRequired,
|
||||||
selectedRightSidePanel: PropTypes.string.isRequired,
|
selectedRightSidePanel: PropTypes.string.isRequired,
|
||||||
handleSidePanelChange: PropTypes.func,
|
handleSidePanelChange: PropTypes.func.isRequired,
|
||||||
activeContexts: PropTypes.arrayOf(PropTypes.string).isRequired,
|
activeContexts: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||||
studies: PropTypes.array,
|
studies: PropTypes.array,
|
||||||
|
t: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
studies: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -50,30 +55,26 @@ class ToolbarRow extends Component {
|
|||||||
this._handleBuiltIn = _handleBuiltIn.bind(this);
|
this._handleBuiltIn = _handleBuiltIn.bind(this);
|
||||||
|
|
||||||
const panelModules = extensionManager.modules[MODULE_TYPES.PANEL];
|
const panelModules = extensionManager.modules[MODULE_TYPES.PANEL];
|
||||||
|
|
||||||
this.buttonGroups = {
|
this.buttonGroups = {
|
||||||
left: [
|
left: [],
|
||||||
// TODO: This should come from extensions, instead of being baked in
|
|
||||||
{
|
|
||||||
value: 'studies',
|
|
||||||
icon: 'th-large',
|
|
||||||
bottomLabel: this.props.t('Series'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
right: [],
|
right: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ~ FIND MENU OPTIONS
|
||||||
panelModules.forEach(panelExtension => {
|
panelModules.forEach(panelExtension => {
|
||||||
const panelModule = panelExtension.module;
|
const panelModule = panelExtension.module;
|
||||||
const defaultContexts = Array.from(panelModule.defaultContext);
|
const defaultContexts = Array.from(panelModule.defaultContext);
|
||||||
|
|
||||||
// MENU OPTIONS
|
|
||||||
panelModule.menuOptions.forEach(menuOption => {
|
panelModule.menuOptions.forEach(menuOption => {
|
||||||
const contexts = Array.from(menuOption.context || defaultContexts);
|
const contexts = Array.from(menuOption.context || defaultContexts);
|
||||||
|
const hasActiveContext = this.props.activeContexts.some(actx =>
|
||||||
const activeContextIncludesAnyPanelContexts = this.props.activeContexts.some(
|
contexts.includes(actx)
|
||||||
actx => contexts.includes(actx)
|
|
||||||
);
|
);
|
||||||
if (activeContextIncludesAnyPanelContexts) {
|
// TODO: what should `isDisabled` receive?
|
||||||
|
const isDisabled = menuOption.isDisabled();
|
||||||
|
|
||||||
|
if (hasActiveContext && !isDisabled) {
|
||||||
const menuOptionEntry = {
|
const menuOptionEntry = {
|
||||||
value: menuOption.target,
|
value: menuOption.target,
|
||||||
icon: menuOption.icon,
|
icon: menuOption.icon,
|
||||||
@ -85,6 +86,16 @@ class ToolbarRow extends Component {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// TODO: This should come from extensions, instead of being baked in
|
||||||
|
this.buttonGroups.right.unshift({
|
||||||
|
value: 'studies',
|
||||||
|
icon: 'th-large',
|
||||||
|
bottomLabel: this.props.t('Series'),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user