Skip to content

Commit

Permalink
🪟 🔧 Update auto-detect schema feature name (#20591)
Browse files Browse the repository at this point in the history
* Update auto-detect schema feature name

* The name should be AllowAutoDetectSchema

* Update feature item for SchemaChangesBackdrop
  • Loading branch information
edmundito committed Dec 16, 2022
1 parent 79bfe56 commit 2c5d799
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const CreateConnectionFormInner: React.FC<CreateConnectionPropsInner> = ({ schem
const navigate = useNavigate();
const canEditDataGeographies = useFeature(FeatureItem.AllowChangeDataGeographies);
const { mutateAsync: createConnection } = useCreateConnection();
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);
const { clearFormChange } = useFormChangeTrackerService();

const workspaceId = useCurrentWorkspaceId();
Expand All @@ -58,7 +58,7 @@ const CreateConnectionFormInner: React.FC<CreateConnectionPropsInner> = ({ schem
workspaceId,
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges
allowAutoDetectSchema
);

try {
Expand Down Expand Up @@ -93,7 +93,7 @@ const CreateConnectionFormInner: React.FC<CreateConnectionPropsInner> = ({ schem
workspaceId,
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
createConnection,
connection.source,
connection.destination,
Expand All @@ -118,7 +118,7 @@ const CreateConnectionFormInner: React.FC<CreateConnectionPropsInner> = ({ schem
validationSchema={createConnectionValidationSchema({
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
})}
onSubmit={onFormSubmit}
>
Expand Down
6 changes: 3 additions & 3 deletions airbyte-webapp/src/components/EntityTable/ConnectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface IProps {
const ConnectionTable: React.FC<IProps> = ({ data, entity, onClickRow, onSync }) => {
const navigate = useNavigate();
const query = useQuery<{ sortBy?: string; order?: SortOrderEnum }>();
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);
const allowSync = useFeature(FeatureItem.AllowSync);

const sortBy = query.sortBy || "entityName";
Expand Down Expand Up @@ -163,7 +163,7 @@ const ConnectionTable: React.FC<IProps> = ({ data, entity, onClickRow, onSync })
isSyncing={row.original.isSyncing}
isManual={row.original.scheduleType === ConnectionScheduleType.manual}
onSync={onSync}
hasBreakingChange={allowAutoDetectSchemaChanges && row.original.schemaChange === SchemaChange.breaking}
hasBreakingChange={allowAutoDetectSchema && row.original.schemaChange === SchemaChange.breaking}
allowSync={allowSync}
/>
),
Expand All @@ -175,7 +175,7 @@ const ConnectionTable: React.FC<IProps> = ({ data, entity, onClickRow, onSync })
Cell: ({ cell }: CellProps<ITableDataItem>) => <ConnectionSettingsCell id={cell.value} />,
},
],
[sortBy, sortOrder, entity, onSortClick, onSync, allowSync, allowAutoDetectSchemaChanges]
[sortBy, sortOrder, entity, onSortClick, onSync, allowSync, allowAutoDetectSchema]
);

return <Table columns={columns} data={sortingData} onClickRow={onClickRow} erroredRows />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const StatusCell: React.FC<StatusCellProps> = ({
schemaChange,
hasBreakingChange,
}) => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);

return (
<div className={styles.container}>
Expand All @@ -41,7 +41,7 @@ export const StatusCell: React.FC<StatusCellProps> = ({
hasBreakingChange={hasBreakingChange}
allowSync={allowSync}
/>
{allowAutoDetectSchemaChanges && <ChangesStatusIcon schemaChange={schemaChange} />}
{allowAutoDetectSchema && <ChangesStatusIcon schemaChange={schemaChange} />}
</div>
);
};
6 changes: 3 additions & 3 deletions airbyte-webapp/src/hooks/connection/useSchemaChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { SchemaChange } from "core/request/AirbyteClient";
import { FeatureItem, useFeature } from "hooks/services/Feature";

export const useSchemaChanges = (schemaChange: SchemaChange) => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);

return useMemo(() => {
const hasSchemaChanges = allowAutoDetectSchemaChanges && schemaChange !== SchemaChange.no_change;
const hasSchemaChanges = allowAutoDetectSchema && schemaChange !== SchemaChange.no_change;
const hasBreakingSchemaChange = hasSchemaChanges && schemaChange === SchemaChange.breaking;
const hasNonBreakingSchemaChange = hasSchemaChanges && schemaChange === SchemaChange.non_breaking;

Expand All @@ -17,5 +17,5 @@ export const useSchemaChanges = (schemaChange: SchemaChange) => {
hasBreakingSchemaChange,
hasNonBreakingSchemaChange,
};
}, [allowAutoDetectSchemaChanges, schemaChange]);
}, [allowAutoDetectSchema, schemaChange]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export const tidyConnectionFormValues = (
workspaceId: string,
mode: ConnectionFormMode,
allowSubOneHourCronExpressions: boolean,
allowAutoDetectSchemaChanges: boolean,
allowAutoDetectSchema: boolean,
operations?: OperationRead[]
): ValuesProps => {
// TODO (https://github.com/airbytehq/airbyte/issues/17279): We should try to fix the types so we don't need the casting.
const formValues: ConnectionFormValues = createConnectionValidationSchema({
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
}).cast(values, {
context: { isRequest: true },
}) as unknown as ConnectionFormValues;
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/hooks/services/Feature/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

export enum FeatureItem {
AllowAutoDetectSchemaChanges = "ALLOW_AUTO_DETECT_SCHEMA_CHANGES",
AllowAutoDetectSchema = "ALLOW_AUTO_DETECT_SCHEMA",
AllowUploadCustomImage = "ALLOW_UPLOAD_CUSTOM_IMAGE",
AllowCustomDBT = "ALLOW_CUSTOM_DBT",
AllowDBTCloudIntegration = "ALLOW_DBT_CLOUD_INTEGRATION",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ValidateFormOnSchemaRefresh: React.FC = () => {
};

export const ConnectionReplicationTab: React.FC = () => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);
const analyticsService = useAnalyticsService();
const connectionService = useConnectionService();
const workspaceId = useCurrentWorkspaceId();
Expand Down Expand Up @@ -99,7 +99,7 @@ export const ConnectionReplicationTab: React.FC = () => {
workspaceId,
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
connection.operations
);

Expand Down Expand Up @@ -158,7 +158,7 @@ export const ConnectionReplicationTab: React.FC = () => {
workspaceId,
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
connection.operations,
connection.catalogDiff?.transforms,
connection.syncCatalog.streams,
Expand Down Expand Up @@ -188,7 +188,7 @@ export const ConnectionReplicationTab: React.FC = () => {
validationSchema={createConnectionValidationSchema({
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
})}
onSubmit={onFormSubmit}
enableReinitialize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jest.doMock("views/Connection/ConnectionForm/components/refreshSourceSchemaWithC
}));

const TestWrapperWithAutoDetectSchema: React.FC<React.PropsWithChildren<Record<string, unknown>>> = ({ children }) => (
<TestWrapper features={[FeatureItem.AllowAutoDetectSchemaChanges]}>{children}</TestWrapper>
<TestWrapper features={[FeatureItem.AllowAutoDetectSchema]}>{children}</TestWrapper>
);

const renderComponent = () => render(<SchemaChangesDetected />, { wrapper: TestWrapperWithAutoDetectSchema });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.doMock("views/Connection/ConnectionForm/components/refreshSourceSchemaWithC
}));

const TestWrapperWithAutoDetectSchema: React.FC<React.PropsWithChildren<Record<string, unknown>>> = ({ children }) => (
<TestWrapper features={[...defaultOssFeatures, FeatureItem.AllowAutoDetectSchemaChanges]}>{children}</TestWrapper>
<TestWrapper features={[...defaultOssFeatures, FeatureItem.AllowAutoDetectSchema]}>{children}</TestWrapper>
);

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ConnectionFormFieldsProps {
}

export const ConnectionFormFields: React.FC<ConnectionFormFieldsProps> = ({ values, isSubmitting, dirty }) => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);

const { mode, formId } = useConnectionFormService();
const { formatMessage } = useIntl();
Expand All @@ -59,7 +59,7 @@ export const ConnectionFormFields: React.FC<ConnectionFormFieldsProps> = ({ valu
<div className={styles.formContainer}>
<Section title={<FormattedMessage id="connection.transfer" />}>
<ScheduleField />
{allowAutoDetectSchemaChanges && (
{allowAutoDetectSchema && (
<Field name="nonBreakingChangesPreference" component={NonBreakingChangesPreferenceField} />
)}
</Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { OctaviaYellowFlag } from "./OctaviaYellowFlag";
import styles from "./SchemaChangeBackdrop.module.scss";

export const SchemaChangeBackdrop: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const allowAutoDetectSchemaChanges = useFeature(FeatureItem.AllowAutoDetectSchemaChanges);
const allowAutoDetectSchema = useFeature(FeatureItem.AllowAutoDetectSchema);

const {
schemaHasBeenRefreshed,
Expand All @@ -25,11 +25,7 @@ export const SchemaChangeBackdrop: React.FC<React.PropsWithChildren<unknown>> =
return hasBreakingSchemaChange ? <OctaviaRedFlag /> : hasNonBreakingSchemaChange ? <OctaviaYellowFlag /> : null;
}, [hasBreakingSchemaChange, hasNonBreakingSchemaChange]);

if (
!allowAutoDetectSchemaChanges ||
(!hasBreakingSchemaChange && !hasNonBreakingSchemaChange) ||
schemaHasBeenRefreshed
) {
if (!allowAutoDetectSchema || (!hasBreakingSchemaChange && !hasNonBreakingSchemaChange) || schemaHasBeenRefreshed) {
return <>{children}</>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.doMock("hooks/services/ConnectionEdit/ConnectionEditService", () => ({
}));

const TestWrapperWithAutoDetectSchema: React.FC<React.PropsWithChildren<Record<string, unknown>>> = ({ children }) => (
<TestWrapper features={[FeatureItem.AllowAutoDetectSchemaChanges]}>{children}</TestWrapper>
<TestWrapper features={[FeatureItem.AllowAutoDetectSchema]}>{children}</TestWrapper>
);

const buttonSpy = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ export function useDefaultTransformation(): OperationCreate {
interface CreateConnectionValidationSchemaArgs {
allowSubOneHourCronExpressions: boolean;
mode: ConnectionFormMode;
allowAutoDetectSchemaChanges: boolean;
allowAutoDetectSchema: boolean;
}

export const createConnectionValidationSchema = ({
mode,
allowSubOneHourCronExpressions,
allowAutoDetectSchemaChanges,
allowAutoDetectSchema,
}: CreateConnectionValidationSchemaArgs) =>
yup
.object({
Expand Down Expand Up @@ -131,7 +131,7 @@ export const createConnectionValidationSchema = ({
.defined("form.empty.error"),
});
}),
nonBreakingChangesPreference: allowAutoDetectSchemaChanges
nonBreakingChangesPreference: allowAutoDetectSchema
? yup.mixed().oneOf(Object.values(NonBreakingChangesPreference)).required("form.empty.error")
: yup.mixed().notRequired(),

Expand Down

0 comments on commit 2c5d799

Please sign in to comment.