Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions ui/app/mirrors/create/cdc/schemabox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import {
} from 'react';
import ReactSelect from 'react-select';
import { useTheme as useStyledTheme } from 'styled-components';
import { fetchColumns, fetchTables } from '../handlers';
import {
fetchColumns,
fetchTables,
getDefaultDestinationTable,
} from '../handlers';
import ColumnBox from './columnbox';
import CustomColumnType from './customColumnType';
import SchemaSettings from './schemasettings';
Expand Down Expand Up @@ -75,6 +79,25 @@ export default function SchemaBox({
const [tableQuery, setTableQuery] = useState<string>('');
const [defaultTargetSchema, setDefaultTargetSchema] =
useState<string>(schema);

const applyTargetSchemaOverride = (newSchema: string) => {
setDefaultTargetSchema(newSchema);
if (peerType === undefined) return;
setRows((oldRows) =>
oldRows.map((row) =>
row.schema !== schema || row.editingDisabled
? row
: {
...row,
destination: getDefaultDestinationTable(
peerType,
newSchema,
row.source.slice(schema.length + 1)
),
}
)
);
};
const searchedTables = useMemo(() => {
const tableQueryLower = tableQuery.toLowerCase();
return rows
Expand Down Expand Up @@ -310,7 +333,7 @@ export default function SchemaBox({
<div style={{ alignSelf: 'center', cursor: 'pointer' }}>
<SchemaSettings
schema={defaultTargetSchema}
setTargetSchemaOverride={setDefaultTargetSchema}
setTargetSchemaOverride={applyTargetSchemaOverride}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/mirrors/create/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export async function fetchSchemas(peer_name: string) {
return schemasRes.schemas;
}

function getDefaultDestinationTable(
export function getDefaultDestinationTable(
peerType: DBType,
schemaName: string,
tableName: string
Expand Down
Loading