Skip to content

Commit 3ace80c

Browse files
committed
Disable the backfill button when all bindings are disabled
1 parent e7801c1 commit 3ace80c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/components/editor/Bindings/Backfill/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from 'stores/FormState/hooks';
1010
import { FormStatus } from 'stores/FormState/types';
1111
import {
12+
useResourceConfig_allBindingsDisabled,
1213
useResourceConfig_backfillAllBindings,
1314
useResourceConfig_backfilledCollections,
1415
useResourceConfig_collections,
@@ -47,6 +48,7 @@ function Backfill({ description, bindingIndex = -1 }: Props) {
4748
useResourceConfig_setBackfilledCollections();
4849

4950
const backfillAllBindings = useResourceConfig_backfillAllBindings();
51+
const allBindingsDisabled = useResourceConfig_allBindingsDisabled();
5052

5153
const selected = useMemo(() => {
5254
if (bindingIndex === -1) {
@@ -169,7 +171,9 @@ function Backfill({ description, bindingIndex = -1 }: Props) {
169171
<OutlinedToggleButton
170172
value={value}
171173
selected={selected}
172-
disabled={formActive || !hasLength(collections)}
174+
disabled={
175+
formActive || !hasLength(collections) || allBindingsDisabled
176+
}
173177
onClick={(event, checked: string) => {
174178
event.preventDefault();
175179
event.stopPropagation();

src/stores/ResourceConfig/hooks.ts

+11
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ export const useResourceConfig_resourceConfig = () => {
148148
);
149149
};
150150

151+
export const useResourceConfig_allBindingsDisabled = () => {
152+
return useZustandStore<ResourceConfigState, boolean>(
153+
ResourceConfigStoreNames.GENERAL,
154+
(state) =>
155+
Object.values(state.resourceConfig).every(
156+
(config) => config.disable
157+
),
158+
shallow
159+
);
160+
};
161+
151162
export const useResourceConfig_resourceConfigOfCollection = (
152163
collection: keyof ResourceConfigState['resourceConfig']
153164
) => {

0 commit comments

Comments
 (0)