Skip to content

Commit

Permalink
Fix showing reset dialog after refresh source (#19350)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes authored and akashkulk committed Nov 17, 2022
1 parent 92c89ec commit 41ac8d6
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,24 @@ export const ConnectionReplicationTab: React.FC = () => {
connection.operations
);

// Detect whether the catalog has any differences in its enabled streams compared to the original one.
// This could be due to user changes (e.g. in the sync mode) or due to new/removed
// streams due to a "refreshed source schema".
const catalogHasChanged = !equal(
// Check if the user refreshed the catalog and there was any change in a currently enabled stream
const hasDiffInEnabledStream = connection.catalogDiff?.transforms.some(({ streamDescriptor }) => {
// Find the stream for this transform in our form's syncCatalog
const stream = formValues.syncCatalog.streams.find(
({ stream }) => streamDescriptor.name === stream?.name && streamDescriptor.namespace === stream.namespace
);
return stream?.config?.selected;
});

// Check if the user made any modifications to enabled streams compared to the ones in the latest connection
// e.g. changed the sync mode of an enabled stream
const hasUserChangesInEnabledStreams = !equal(
formValues.syncCatalog.streams.filter((s) => s.config?.selected),
connection.syncCatalog.streams.filter((s) => s.config?.selected)
);

const catalogHasChanged = hasDiffInEnabledStream || hasUserChangesInEnabledStreams;

setSubmitError(null);

// Whenever the catalog changed show a warning to the user, that we're about to reset their data.
Expand Down Expand Up @@ -131,6 +141,7 @@ export const ConnectionReplicationTab: React.FC = () => {
},
[
connection.connectionId,
connection.catalogDiff,
connection.operations,
connection.status,
connection.syncCatalog.streams,
Expand Down

0 comments on commit 41ac8d6

Please sign in to comment.