Skip to content

Commit

Permalink
move checked state calc to settings, doesn't belong in layout
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed May 18, 2024
1 parent e9dfc7d commit c9bd38d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ui/app/mirrors/create/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum AdvancedSettingType {
export interface MirrorSetting {
label: string;
stateHandler: (value: any, setter: any) => void;
checked?: (setting: any) => boolean;
type?: string;
required?: boolean;
tips?: string;
Expand Down Expand Up @@ -57,5 +58,4 @@ export const blankQRepSetting = {
stagingPath: '',
numRowsPerPartition: 100000,
setupWatermarkTableOnDestination: false,
dstTableFullResync: false,
};
4 changes: 4 additions & 0 deletions ui/app/mirrors/create/helpers/qrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const qrepSettings: MirrorSetting[] = [
...curr,
setupWatermarkTableOnDestination: value as boolean,
})),
checked: (state) => state.setupWatermarkTableOnDestination,
tips: 'Specify if you want to create the watermark table on the destination as-is, can be used for some queries.',
type: 'switch',
default: false,
Expand All @@ -48,6 +49,7 @@ export const qrepSettings: MirrorSetting[] = [
...curr,
destinationTableIdentifier: value as string,
})),
checked: (state) => state.destinationTableIdentifier,
tips: 'Name of the destination. For any destination peer apart from BigQuery, this must be schema-qualified. Example: public.users',
required: true,
},
Expand Down Expand Up @@ -116,6 +118,7 @@ export const qrepSettings: MirrorSetting[] = [
...curr,
initialCopyOnly: (value as boolean) || false,
})),
checked: (state) => state.initialCopyOnly,
tips: 'Specify if you want query replication to stop at initial load.',
type: 'switch',
},
Expand Down Expand Up @@ -144,6 +147,7 @@ export const qrepSettings: MirrorSetting[] = [
...curr,
system: value === true ? TypeSystem.PG : TypeSystem.Q,
})),
checked: (state) => state.system === TypeSystem.PG,
type: 'switch',
default: false,
tips: 'Decide if PeerDB should use native Postgres types directly',
Expand Down
8 changes: 1 addition & 7 deletions ui/app/mirrors/create/qrep/qrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ export default function QRepConfigForm({
}}
>
<Switch
checked={
setting.label === 'Create Destination Table'
? mirrorConfig.setupWatermarkTableOnDestination
: setting.label === 'Initial Copy Only'
? mirrorConfig.initialCopyOnly
: mirrorConfig.dstTableFullResync
}
checked={setting.checked!(mirrorConfig)}
onCheckedChange={(state: boolean) =>
handleChange(state, setting)
}
Expand Down

0 comments on commit c9bd38d

Please sign in to comment.