Skip to content

Commit

Permalink
Merge branch 'main' into datatypes/set-srid
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj authored Mar 20, 2024
2 parents 1f8a1e8 + 61a73d9 commit a0ca88e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
26 changes: 10 additions & 16 deletions ui/app/mirrors/create/cdc/cdc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function CDCConfigForm({
setRows,
}: MirrorConfigProps) {
const [publications, setPublications] = useState<string[]>();
const [pubLoading, setPubLoading] = useState(true);
const [show, setShow] = useState(false);
const handleChange = (val: string | boolean, setting: MirrorSetting) => {
let stateVal: string | boolean = val;
Expand Down Expand Up @@ -66,26 +67,15 @@ export default function CDCConfigForm({
return true;
};

const optionsForField = (setting: MirrorSetting) => {
switch (setting.label) {
case 'Publication Name':
return publications;
default:
return [];
}
};

useEffect(() => {
setPubLoading(true);
fetchPublications(mirrorConfig.source?.name || '').then((pubs) => {
setPublications(pubs);
setPubLoading(false);
});
}, [mirrorConfig.source?.name]);

if (
mirrorConfig.source != undefined &&
mirrorConfig.destination != undefined &&
publications != undefined
)
if (mirrorConfig.source != undefined && mirrorConfig.destination != undefined)
return (
<>
{normalSettings.map((setting, id) => {
Expand All @@ -95,7 +85,12 @@ export default function CDCConfigForm({
key={id}
handleChange={handleChange}
setting={setting}
options={optionsForField(setting)}
options={
setting.label === 'Publication Name'
? publications
: undefined
}
publicationsLoading={pubLoading}
/>
)
);
Expand Down Expand Up @@ -126,7 +121,6 @@ export default function CDCConfigForm({
key={setting.label}
handleChange={handleChange}
setting={setting}
options={optionsForField(setting)}
/>
);
})}
Expand Down
9 changes: 8 additions & 1 deletion ui/app/mirrors/create/cdc/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ interface FieldProps {
setting: MirrorSetting;
handleChange: (val: string | boolean, setting: MirrorSetting) => void;
options?: string[];
publicationsLoading?: boolean;
}

const CDCField = ({ setting, handleChange, options }: FieldProps) => {
const CDCField = ({
setting,
handleChange,
options,
publicationsLoading,
}: FieldProps) => {
return setting.type === 'switch' ? (
<RowWithSwitch
label={
Expand Down Expand Up @@ -72,6 +78,7 @@ const CDCField = ({ setting, handleChange, options }: FieldProps) => {
getOptionLabel={(option) => option.label}
getOptionValue={(option) => option.option}
theme={SelectTheme}
isLoading={publicationsLoading}
/>
</div>
{setting.tips && (
Expand Down

0 comments on commit a0ca88e

Please sign in to comment.