Skip to content

Commit

Permalink
Do not filter "hidden" tables in "Create Table Form" FK drop down. Fixes
Browse files Browse the repository at this point in the history
 #4.
  • Loading branch information
ignatz committed Nov 26, 2024
1 parent 420d643 commit 35b8a21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions ui/admin/src/components/logs/LogsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ function WorldMap(props: { country_codes: { [key in string]?: number } }) {
? `<b>${props.name}</b><br />${requests} req`
: "Hover over a country";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any)._container.innerHTML = contents;
},
});
Expand Down
22 changes: 10 additions & 12 deletions ui/admin/src/components/tables/TablesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,14 @@ function pickInitiallySelectedTable(
function TablePickerPane(props: {
horizontal: boolean;
tablesAndViews: (Table | View)[];
allTables: Table[];
selectedTableName: Signal<string | undefined>;
schemaRefetch: () => Promise<void>;
}) {
const tablesAndViews = createMemo(() =>
props.tablesAndViews.toSorted((a, b) => {
const aHidden = a.name.startsWith("_");
const bHidden = b.name.startsWith("_");
const aHidden = hiddenTable(a);
const bHidden = hiddenTable(b);

if (aHidden == bHidden) {
return a.name.localeCompare(b.name);
Expand All @@ -1096,10 +1097,6 @@ function TablePickerPane(props: {
return aHidden ? 1 : -1;
}),
);
const tables = () =>
tablesAndViews().filter(
(either) => (either as Table) !== undefined,
) as Table[];

const showHidden = useStore($showHiddenTables);

Expand Down Expand Up @@ -1169,7 +1166,7 @@ function TablePickerPane(props: {
<SheetContent class={sheetMaxWidth}>
<CreateAlterTableForm
schemaRefetch={props.schemaRefetch}
allTables={tables()}
allTables={props.allTables}
setSelected={setSelectedTableName}
{...sheet}
/>
Expand Down Expand Up @@ -1219,11 +1216,11 @@ function TableSplitView(props: {
): (Table | View)[] {
return schemas.filter((s) => showHidden || !s.name.startsWith("_"));
}
const tablesAndViews = () =>
filterHidden(
[...props.schemas.tables, ...props.schemas.views],
showHidden(),
);
const allTablesAndViews = () => [
...props.schemas.tables,
...props.schemas.views,
];
const tablesAndViews = () => filterHidden(allTablesAndViews(), showHidden());

const [searchParams] = useSearchParams<{ table: string }>();
const selectedTableNameSignal = createSignal<string | undefined>(
Expand All @@ -1245,6 +1242,7 @@ function TableSplitView(props: {
<TablePickerPane
horizontal={p.horizontal}
tablesAndViews={tablesAndViews()}
allTables={props.schemas.tables}
selectedTableName={selectedTableNameSignal}
schemaRefetch={props.schemaRefetch}
/>
Expand Down

0 comments on commit 35b8a21

Please sign in to comment.