Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
fix: DIA-736: [FE] disable add to project actions when dataset sync i…
Browse files Browse the repository at this point in the history
…s not complete (#276)
  • Loading branch information
yyassi-heartex authored Nov 30, 2023
1 parent dc7e27b commit 9dde27b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/DataManager/Toolbar/ActionsButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
const onClick = useCallback((e) => {
e.preventDefault();
e.stopPropagation();
if (action.disabled) return;
action?.callback ? action?.callback(store.currentView?.selected?.snapshot, action) : invokeAction(action, isDeleteAction);
parentRef?.current?.close?.();
}, [store.currentView?.selected]);
Expand All @@ -88,12 +89,13 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
isSeparator: action.isSeparator,
isTitle: action.isTitle,
danger: isDeleteAction,
disabled: action.disabled,
}}
name='actionButton'
>
<Elem name='titleContainer'>
<Elem name='titleContainer' {...(action.disabled ? { title: action.disabledReason } : {})}>
<Elem name='title'>{action.title}</Elem>
{hasChildren ? <Elem name='icon' tag={FaChevronRight} /> : null}
{(hasChildren) ? <Elem name='icon' tag={FaChevronRight} /> : null}
</Elem>
</Block>
);
Expand Down Expand Up @@ -125,8 +127,9 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
key={action.id}
danger={isDeleteAction}
onClick={onClick}
className={`actionButton${action.isSeparator ? "_isSeparator" : (action.isTitle ? "_isTitle" : "")}`}
className={`actionButton${action.isSeparator ? "_isSeparator" : (action.isTitle ? "_isTitle" : "")} ${(action.disabled) ? "actionButton_disabled" : ""}`}
icon={isDeleteAction && <FaTrash />}
title={action.disabled ? action.disabledReason : null}
>
{action.title}
</Menu.Item>
Expand Down
8 changes: 8 additions & 0 deletions src/components/DataManager/Toolbar/ActionsButton.styl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
background-color rgba(0,0,0,0.04)
&_danger
color #d00
&_disabled
background-color rgba(0,0,0,0.04)
color rgba(0,0,0,0.25)
cursor initial
&:hover
background-color rgba(0,0,0,0.04) !important
color rgba(0,0,0,0.25) !important
cursor initial

.actionButtonPrime
gap 8px
Expand Down
2 changes: 2 additions & 0 deletions src/stores/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const Action = types.model("Action", {
isSeparator: types.optional(types.boolean, false),
isTitle: types.optional(types.boolean, false),
newStyle: types.optional(types.boolean, false),
disabled: types.optional(types.boolean, false),
disabledReason: types.optional(types.string, ""),
} : {}),
}).volatile(() => ({
caller: null,
Expand Down

0 comments on commit 9dde27b

Please sign in to comment.