Skip to content

Commit

Permalink
Unset sourceBackfillRecommended when backfill counter decremented
Browse files Browse the repository at this point in the history
  • Loading branch information
kiahna-tucker committed Feb 21, 2025
1 parent 0ed1839 commit 20f3a1f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/editor/Bindings/Backfill/BackfillButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from 'stores/FormState/hooks';
import { FormStatus } from 'stores/FormState/types';
import { BindingMetadata } from 'types';
import { hasLength } from 'utils/misc-utils';
import { useEditorStore_queryResponse_draftSpecs } from '../../Store/hooks';
import BackfillCount from './BackfillCount';
import BackfillDataFlowOption from './BackfillDataFlowOption';
Expand Down Expand Up @@ -59,6 +60,9 @@ function BackfillButton({
const setCollectionMetadata = useBindingStore(
(state) => state.setCollectionMetadata
);
const setSourceBackfillRecommended = useBindingStore(
(state) => state.setSourceBackfillRecommended
);

// Draft Editor Store
const draftSpecs = useEditorStore_queryResponse_draftSpecs();
Expand Down Expand Up @@ -167,6 +171,13 @@ function BackfillButton({
() => {}
);

if (hasLength(changes.counterDecremented)) {
setSourceBackfillRecommended(
changes.counterDecremented,
false
);
}

setFormState({ status: FormStatus.UPDATED });
},
(error) => {
Expand All @@ -191,6 +202,7 @@ function BackfillButton({
setBackfilledBindings,
setCollectionMetadata,
setFormState,
setSourceBackfillRecommended,
updateBackfillCounter,
]
);
Expand Down
14 changes: 14 additions & 0 deletions src/stores/Binding/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,20 @@ const getInitialState = (
);
},

setSourceBackfillRecommended: (collections, value) => {
set(
produce((state: BindingState) => {
collections.forEach((collection) => {
state.collectionMetadata[
collection
].sourceBackfillRecommended = value;
});
}),
false,
'Source Backfill Recommended Set'
);
},

setSpecOnIncompatibleSchemaChange: (value) => {
set(
produce((state: BindingState) => {
Expand Down
4 changes: 4 additions & 0 deletions src/stores/Binding/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export interface BindingState
values: TrialCollectionQuery[],
addedCollections: string[]
) => void;
setSourceBackfillRecommended: (
collections: string[],
value: CollectionMetadata['sourceBackfillRecommended']
) => void;

// Control sourceCapture optional settings
resourceConfigPointers?: ResourceConfigPointers;
Expand Down

0 comments on commit 20f3a1f

Please sign in to comment.