diff --git a/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamFieldCell.tsx b/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamFieldCell.tsx index 51125d80a52..83f10165569 100644 --- a/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamFieldCell.tsx +++ b/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamFieldCell.tsx @@ -22,7 +22,7 @@ import { isCursor as checkIsCursor, isPrimaryKey as checkIsPrimaryKey, } from "../../../syncCatalog/StreamFieldsTable/StreamFieldsTable"; -import { updateFieldSelected } from "../../../syncCatalog/SyncCatalog/streamConfigHelpers"; +import { getSelectedMandatoryFields, updateFieldSelected } from "../../../syncCatalog/SyncCatalog/streamConfigHelpers"; import { getFieldPathDisplayName } from "../../../syncCatalog/utils"; import { SyncStreamFieldWithId } from "../../formConfig"; import { SyncCatalogUIModel } from "../SyncCatalogTable"; @@ -64,13 +64,11 @@ export const StreamFieldNameCell: React.FC = ({ const isHashed = checkIsFieldHashed(field, config); const isDisabled = - !config?.selected || - mode === "readonly" || - (config.syncMode === SyncMode.incremental && (isCursor || isChildFieldCursor)) || - (config.destinationSyncMode === DestinationSyncMode.append_dedup && (isPrimaryKey || isChildFieldPrimaryKey)) || - (config.destinationSyncMode === DestinationSyncMode.overwrite_dedup && (isPrimaryKey || isChildFieldPrimaryKey)) || - isNestedField; - const showTooltip = isDisabled && mode !== "readonly" && config?.selected; + config?.selected && + ((config.syncMode === SyncMode.incremental && (isCursor || isChildFieldCursor)) || + (config.destinationSyncMode === DestinationSyncMode.append_dedup && (isPrimaryKey || isChildFieldPrimaryKey)) || + (config.destinationSyncMode === DestinationSyncMode.overwrite_dedup && (isPrimaryKey || isChildFieldPrimaryKey))); + const showTooltip = isDisabled && mode !== "readonly"; const isFieldSelected = checkIsFieldSelected(field, config); @@ -98,9 +96,15 @@ export const StreamFieldNameCell: React.FC = ({ numberOfFieldsInStream, }); + const mandatorySelectedFields = getSelectedMandatoryFields(config); + updateStreamField(row.original.streamNode, { ...updatedConfig, - selectedFields: !updatedConfig?.fieldSelectionEnabled ? [] : updatedConfig?.selectedFields, + // any field selection immediately enables the disabled stream + ...(isSelected && !config?.selected && { selected: true }), + selectedFields: !updatedConfig?.fieldSelectionEnabled + ? [] + : [...(updatedConfig?.selectedFields ?? []), ...mandatorySelectedFields], // remove this field if it was part of hashedFields hashedFields: config.hashedFields?.filter((f) => !isEqual(f.fieldPath, fieldPath)), }); diff --git a/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamNameCell.tsx b/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamNameCell.tsx index dfeb836b8fb..ab0edbce72f 100644 --- a/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamNameCell.tsx +++ b/airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/StreamNameCell.tsx @@ -50,7 +50,14 @@ export const StreamNameCell: React.FC = ({ updateStreamField(row.original.streamNode!, { selected: checked })} + onChange={({ target: { checked } }) => + updateStreamField(row.original.streamNode!, { + selected: checked, + // enable/disable stream will enable/disable all fields + fieldSelectionEnabled: false, + selectedFields: [], + }) + } data-testid="sync-stream-checkbox" />