Skip to content

Commit

Permalink
Merge branch 'main' into e2e-eventhub
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj authored Apr 22, 2024
2 parents 305f166 + ba36324 commit 8cde5ea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
7 changes: 5 additions & 2 deletions ui/app/mirrors/create/cdc/cdc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export default function CDCConfigForm({
(label.includes('initial copy') ||
label.includes('initial load') ||
label.includes('soft delete') ||
label.includes('snapshot')))
label.includes('snapshot'))) ||
((mirrorConfig.source?.type !== DBType.POSTGRES ||
mirrorConfig.destination?.type !== DBType.POSTGRES) &&
label.includes('type system'))
) {
return false;
}
Expand Down Expand Up @@ -97,7 +100,7 @@ export default function CDCConfigForm({
? publications
: undefined
}
publicationsLoading={pubLoading}
optionsLoading={pubLoading}
/>
)
);
Expand Down
7 changes: 3 additions & 4 deletions ui/app/mirrors/create/cdc/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ interface FieldProps {
setting: MirrorSetting;
handleChange: (val: string | boolean, setting: MirrorSetting) => void;
options?: string[];
publicationsLoading?: boolean;
optionsLoading?: boolean;
}

const CDCField = ({
setting,
handleChange,
options,
publicationsLoading,
optionsLoading,
}: FieldProps) => {
return setting.type === 'switch' ? (
<RowWithSwitch
Expand Down Expand Up @@ -70,15 +70,14 @@ const CDCField = ({
>
<div style={{ width: '100%' }}>
<ReactSelect
placeholder={`Select a publication`}
onChange={(val, action) =>
val && handleChange(val.option, setting)
}
options={options?.map((option) => ({ option, label: option }))}
getOptionLabel={(option) => option.label}
getOptionValue={(option) => option.option}
theme={SelectTheme}
isLoading={publicationsLoading}
isLoading={optionsLoading}
/>
</div>
{setting.tips && (
Expand Down
13 changes: 13 additions & 0 deletions ui/app/mirrors/create/helpers/cdc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TypeSystem } from '@/grpc_generated/flow';
import { CDCConfig } from '../../../dto/MirrorsDTO';
import { MirrorSetting } from './common';
export const cdcSettings: MirrorSetting[] = [
Expand Down Expand Up @@ -149,4 +150,16 @@ export const cdcSettings: MirrorSetting[] = [
tips: 'Associate PeerDB script with this mirror.',
advanced: true,
},
{
label: 'Use Postgres type system',
stateHandler: (value, setter) =>
setter((curr: CDCConfig) => ({
...curr,
system: value === true ? TypeSystem.PG : TypeSystem.Q,
})),
type: 'switch',
default: false,
tips: 'Decide if PeerDB should use native Postgres types directly',
advanced: true,
},
];
12 changes: 2 additions & 10 deletions ui/app/mirrors/create/helpers/common.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import {
FlowConnectionConfigs,
QRepWriteType,
TypeSystem,
} from '@/grpc_generated/flow';
import { Peer } from '@/grpc_generated/peers';
import { FlowConnectionConfigs, TypeSystem } from '@/grpc_generated/flow';

export interface MirrorSetting {
label: string;
stateHandler: (
value: string | string[] | Peer | boolean | QRepWriteType,
setter: any
) => void;
stateHandler: (value: any, setter: any) => void;
type?: string;
required?: boolean;
tips?: string;
Expand Down

0 comments on commit 8cde5ea

Please sign in to comment.