Skip to content

Commit a26a0bc

Browse files
fix(ui): fix schema prefixing (#4562)
Fixes #4561
1 parent fa9c3c0 commit a26a0bc

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

ui/app/mirrors/create/cdc/schemabox.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ import {
2828
} from 'react';
2929
import ReactSelect from 'react-select';
3030
import { useTheme as useStyledTheme } from 'styled-components';
31-
import { fetchColumns, fetchTables } from '../handlers';
31+
import {
32+
fetchColumns,
33+
fetchTables,
34+
getDefaultDestinationTable,
35+
} from '../handlers';
3236
import ColumnBox from './columnbox';
3337
import CustomColumnType from './customColumnType';
3438
import SchemaSettings from './schemasettings';
@@ -75,6 +79,25 @@ export default function SchemaBox({
7579
const [tableQuery, setTableQuery] = useState<string>('');
7680
const [defaultTargetSchema, setDefaultTargetSchema] =
7781
useState<string>(schema);
82+
83+
const applyTargetSchemaOverride = (newSchema: string) => {
84+
setDefaultTargetSchema(newSchema);
85+
if (peerType === undefined) return;
86+
setRows((oldRows) =>
87+
oldRows.map((row) =>
88+
row.schema !== schema || row.editingDisabled
89+
? row
90+
: {
91+
...row,
92+
destination: getDefaultDestinationTable(
93+
peerType,
94+
newSchema,
95+
row.source.slice(schema.length + 1)
96+
),
97+
}
98+
)
99+
);
100+
};
78101
const searchedTables = useMemo(() => {
79102
const tableQueryLower = tableQuery.toLowerCase();
80103
return rows
@@ -310,7 +333,7 @@ export default function SchemaBox({
310333
<div style={{ alignSelf: 'center', cursor: 'pointer' }}>
311334
<SchemaSettings
312335
schema={defaultTargetSchema}
313-
setTargetSchemaOverride={setDefaultTargetSchema}
336+
setTargetSchemaOverride={applyTargetSchemaOverride}
314337
/>
315338
</div>
316339
</div>

ui/app/mirrors/create/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export async function fetchSchemas(peer_name: string) {
375375
return schemasRes.schemas;
376376
}
377377

378-
function getDefaultDestinationTable(
378+
export function getDefaultDestinationTable(
379379
peerType: DBType,
380380
schemaName: string,
381381
tableName: string

0 commit comments

Comments
 (0)