-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Improve table picker component (#859)
- Fixes SelectAll and SchemaExpand issues - Moves Column view to separate component for readability - Moves table picker below the settings for CDC and has more height - useMemo for table search - overall code improvements
- Loading branch information
1 parent
531e1c2
commit d5baa48
Showing
4 changed files
with
209 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use client'; | ||
import { TableMapRow } from '@/app/dto/MirrorsDTO'; | ||
import { Checkbox } from '@/lib/Checkbox'; | ||
import { Label } from '@/lib/Label'; | ||
import { RowWithCheckbox } from '@/lib/Layout'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
|
||
interface ColumnProps { | ||
columns: string[]; | ||
tableRow: TableMapRow; | ||
rows: TableMapRow[]; | ||
setRows: Dispatch<SetStateAction<TableMapRow[]>>; | ||
} | ||
export default function ColumnBox({ | ||
columns, | ||
tableRow, | ||
rows, | ||
setRows, | ||
}: ColumnProps) { | ||
const handleColumnExclusion = ( | ||
source: string, | ||
column: string, | ||
include: boolean | ||
) => { | ||
const currRows = [...rows]; | ||
const rowOfSource = currRows.find((row) => row.source === source); | ||
if (rowOfSource) { | ||
if (include) { | ||
const updatedExclude = rowOfSource.exclude.filter( | ||
(col) => col !== column | ||
); | ||
rowOfSource.exclude = updatedExclude; | ||
} else { | ||
rowOfSource.exclude.push(column); | ||
} | ||
} | ||
setRows(currRows); | ||
}; | ||
|
||
const columnExclusion = new Set(tableRow.exclude); | ||
return columns.map((column) => { | ||
const [columnName, columnType, isPkeyStr] = column.split(':'); | ||
const isPkey = isPkeyStr === 'true'; | ||
return ( | ||
<RowWithCheckbox | ||
key={column} | ||
label={ | ||
<Label | ||
as='label' | ||
style={{ | ||
fontSize: 13, | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
> | ||
{columnName} | ||
<p | ||
style={{ | ||
marginLeft: '0.5rem', | ||
color: 'gray', | ||
}} | ||
> | ||
{columnType} | ||
</p> | ||
</Label> | ||
} | ||
action={ | ||
<Checkbox | ||
style={{ cursor: 'pointer' }} | ||
disabled={isPkey} | ||
checked={!columnExclusion.has(columnName)} | ||
onCheckedChange={(state: boolean) => | ||
handleColumnExclusion(tableRow.source, columnName, state) | ||
} | ||
/> | ||
} | ||
/> | ||
); | ||
}); | ||
} |
Oops, something went wrong.