Skip to content

Commit

Permalink
fix: defaults for table map
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Nov 7, 2023
1 parent 24080c7 commit 54ba602
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions ui/app/mirrors/create/tablemapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,22 @@ const TableMapping = ({
fetchTables(sourcePeerName, schemaName, setLoading).then((tableNames) =>
setRows((curr) => {
const newRows = [...curr];

tableNames.forEach((tableName) => {
const row = newRows.find(
(row) => row.source === `${schemaName}.${tableName}`
);
if (!row) {
const dstName =
peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY'
? tableName
: `${schemaName}.${tableName}`;
newRows.push({
source: `${schemaName}.${tableName}`,
destination: `${schemaName}.${tableName}`,
destination:
peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY'
? tableName
: `${schemaName}.${tableName}`,
partitionKey: '',
selected: false,
});
Expand All @@ -111,7 +119,7 @@ const TableMapping = ({
})
);
},
[sourcePeerName, setRows]
[sourcePeerName, setRows, peerType]
);

const [searchQuery, setSearchQuery] = useState('');
Expand All @@ -124,6 +132,36 @@ const TableMapping = ({
return row.source.toLowerCase().includes(searchQuery.toLowerCase());
});

useEffect(() => {
if (peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY') {
setRows((rows) => {
const newRows = [...rows];
newRows.forEach((_, i) => {
const row = newRows[i];
newRows[i] = {
...row,
destination: row.destination.split('.')[1],
};
});
return newRows;
});
} else {
setRows((rows) => {
const newRows = [...rows];
newRows.forEach((_, i) => {
const row = newRows[i];
newRows[i] = {
...row,
destination: `${schema}.${
row.destination.split('.')[1] || row.destination
}`,
};
});
return newRows;
});
}
}, [peerType, setRows, schema]);

useEffect(() => {
fetchSchemas(sourcePeerName, setLoading).then((res) => setAllSchemas(res));
setSchema('public');
Expand Down

0 comments on commit 54ba602

Please sign in to comment.