OHIF-252: "Recent" and "All" tabs should be disabled if there are no studies on their category (#1859)
* OHIF-252: "Recent" and "All" tabs should be disabled if there are no studies on their category * fix button props and avoid onClick on disabled state
This commit is contained in:
parent
454474ddb4
commit
cf91b0f942
@ -91,6 +91,8 @@ const Button = ({
|
|||||||
startIcon: startIconProp,
|
startIcon: startIconProp,
|
||||||
endIcon: endIconProp,
|
endIcon: endIconProp,
|
||||||
className,
|
className,
|
||||||
|
onClick,
|
||||||
|
/** TODO: All possible props should be explicitly defined -- avoid spreading props */
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const startIcon = startIconProp && (
|
const startIcon = startIconProp && (
|
||||||
@ -112,8 +114,8 @@ const Button = ({
|
|||||||
|
|
||||||
const handleOnClick = e => {
|
const handleOnClick = e => {
|
||||||
buttonElement.current.blur();
|
buttonElement.current.blur();
|
||||||
if (rest.onClick) {
|
if (!disabled) {
|
||||||
rest.onClick(e);
|
onClick(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -159,6 +161,7 @@ Button.propTypes = {
|
|||||||
startIcon: PropTypes.node,
|
startIcon: PropTypes.node,
|
||||||
endIcon: PropTypes.node,
|
endIcon: PropTypes.node,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
|
onClick: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Button;
|
export default Button;
|
||||||
|
|||||||
@ -79,8 +79,9 @@ const StudyBrowser = ({
|
|||||||
className="border rounded-md border-secondary-light"
|
className="border rounded-md border-secondary-light"
|
||||||
>
|
>
|
||||||
{tabs.map(tab => {
|
{tabs.map(tab => {
|
||||||
const { name, label } = tab;
|
const { name, label, studies } = tab;
|
||||||
const isActive = activeTabName === name;
|
const isActive = activeTabName === name;
|
||||||
|
const isDisabled = !studies.length;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
key={name}
|
key={name}
|
||||||
@ -92,6 +93,7 @@ const StudyBrowser = ({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClickTab(name);
|
onClickTab(name);
|
||||||
}}
|
}}
|
||||||
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user