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

Commit 9dde27b

Browse files
fix: DIA-736: [FE] disable add to project actions when dataset sync is not complete (#276)
1 parent dc7e27b commit 9dde27b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Diff for: src/components/DataManager/Toolbar/ActionsButton.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
7373
const onClick = useCallback((e) => {
7474
e.preventDefault();
7575
e.stopPropagation();
76+
if (action.disabled) return;
7677
action?.callback ? action?.callback(store.currentView?.selected?.snapshot, action) : invokeAction(action, isDeleteAction);
7778
parentRef?.current?.close?.();
7879
}, [store.currentView?.selected]);
@@ -88,12 +89,13 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
8889
isSeparator: action.isSeparator,
8990
isTitle: action.isTitle,
9091
danger: isDeleteAction,
92+
disabled: action.disabled,
9193
}}
9294
name='actionButton'
9395
>
94-
<Elem name='titleContainer'>
96+
<Elem name='titleContainer' {...(action.disabled ? { title: action.disabledReason } : {})}>
9597
<Elem name='title'>{action.title}</Elem>
96-
{hasChildren ? <Elem name='icon' tag={FaChevronRight} /> : null}
98+
{(hasChildren) ? <Elem name='icon' tag={FaChevronRight} /> : null}
9799
</Elem>
98100
</Block>
99101
);
@@ -125,8 +127,9 @@ export const ActionsButton = injector(observer(({ store, size, hasSelected, ...r
125127
key={action.id}
126128
danger={isDeleteAction}
127129
onClick={onClick}
128-
className={`actionButton${action.isSeparator ? "_isSeparator" : (action.isTitle ? "_isTitle" : "")}`}
130+
className={`actionButton${action.isSeparator ? "_isSeparator" : (action.isTitle ? "_isTitle" : "")} ${(action.disabled) ? "actionButton_disabled" : ""}`}
129131
icon={isDeleteAction && <FaTrash />}
132+
title={action.disabled ? action.disabledReason : null}
130133
>
131134
{action.title}
132135
</Menu.Item>

Diff for: src/components/DataManager/Toolbar/ActionsButton.styl

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050
background-color rgba(0,0,0,0.04)
5151
&_danger
5252
color #d00
53+
&_disabled
54+
background-color rgba(0,0,0,0.04)
55+
color rgba(0,0,0,0.25)
56+
cursor initial
57+
&:hover
58+
background-color rgba(0,0,0,0.04) !important
59+
color rgba(0,0,0,0.25) !important
60+
cursor initial
5361

5462
.actionButtonPrime
5563
gap 8px

Diff for: src/stores/Action.js

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export const Action = types.model("Action", {
5959
isSeparator: types.optional(types.boolean, false),
6060
isTitle: types.optional(types.boolean, false),
6161
newStyle: types.optional(types.boolean, false),
62+
disabled: types.optional(types.boolean, false),
63+
disabledReason: types.optional(types.string, ""),
6264
} : {}),
6365
}).volatile(() => ({
6466
caller: null,

0 commit comments

Comments
 (0)