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

fix: DIA-736: [FE] disable add to project actions when dataset sync is not complete #276

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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