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 authored and GitHub committed 2020-07-02 23:26:06 -04:00
1 parent 454474ddb4
commit cf91b0f942
2 files changed
+8 -3

No files matched your search

+5 -2
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;
@@ -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>