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:
Rodrigo Antinarelli 2020-07-03 00:26:06 -03:00 committed by GitHub
parent 454474ddb4
commit cf91b0f942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -91,6 +91,8 @@ const Button = ({
startIcon: startIconProp,
endIcon: endIconProp,
className,
onClick,
/** TODO: All possible props should be explicitly defined -- avoid spreading props */
...rest
}) => {
const startIcon = startIconProp && (
@ -112,8 +114,8 @@ const Button = ({
const handleOnClick = e => {
buttonElement.current.blur();
if (rest.onClick) {
rest.onClick(e);
if (!disabled) {
onClick(e);
}
};
@ -159,6 +161,7 @@ Button.propTypes = {
startIcon: PropTypes.node,
endIcon: PropTypes.node,
className: PropTypes.string,
onClick: PropTypes.func.isRequired,
};
export default Button;

View File

@ -79,8 +79,9 @@ const StudyBrowser = ({
className="border rounded-md border-secondary-light"
>
{tabs.map(tab => {
const { name, label } = tab;
const { name, label, studies } = tab;
const isActive = activeTabName === name;
const isDisabled = !studies.length;
return (
<Button
key={name}
@ -92,6 +93,7 @@ const StudyBrowser = ({
onClick={() => {
onClickTab(name);
}}
disabled={isDisabled}
>
{label}
</Button>