Derive column layout from displayed entities, not filter state
The column set (System, Owner, Type, etc.) now stays consistent with the displayed rows during kind filter transitions, same as the name column's defaultKind. The switch statement uses the entity-derived kind so columns don't jump until new data actually arrives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -295,11 +295,15 @@ describe('CatalogTable component', () => {
|
||||
])(
|
||||
'should render correct columns with kind filter $kind',
|
||||
async ({ kind, expectedColumns }) => {
|
||||
const kindEntities = entities.map(e => ({
|
||||
...e,
|
||||
kind: kind ?? e.kind,
|
||||
}));
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={mockApis}>
|
||||
<MockEntityListContextProvider
|
||||
value={{
|
||||
entities,
|
||||
entities: kindEntities,
|
||||
filters: {
|
||||
kind: kind
|
||||
? new EntityKindFilter(kind.toLocaleLowerCase('en-US'), kind)
|
||||
|
||||
@@ -25,18 +25,17 @@ export const defaultCatalogTableColumnsFunc: CatalogTableColumnsFunc = ({
|
||||
filters,
|
||||
entities,
|
||||
}) => {
|
||||
// Derive the name column's defaultKind from the displayed entities so
|
||||
// that the entity ref prefix stays consistent with the rows during
|
||||
// filter transitions (when stale rows are kept visible while new data
|
||||
// loads). The column layout switch still uses the filter's kind so the
|
||||
// table shape updates immediately.
|
||||
const defaultKind =
|
||||
// Derive the effective kind from the displayed entities so that both
|
||||
// the column layout and the name column's defaultKind stay consistent
|
||||
// with the rows during filter transitions (when stale rows are kept
|
||||
// visible while new data loads).
|
||||
const effectiveKind =
|
||||
entities[0]?.kind?.toLocaleLowerCase('en-US') ?? filters.kind?.value;
|
||||
const showTypeColumn = filters.type === undefined;
|
||||
|
||||
return [
|
||||
columnFactories.createTitleColumn({ hidden: true }),
|
||||
columnFactories.createNameColumn({ defaultKind }),
|
||||
columnFactories.createNameColumn({ defaultKind: effectiveKind }),
|
||||
...createEntitySpecificColumns(),
|
||||
];
|
||||
|
||||
@@ -51,7 +50,7 @@ export const defaultCatalogTableColumnsFunc: CatalogTableColumnsFunc = ({
|
||||
columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
|
||||
columnFactories.createSpecLifecycleColumn(),
|
||||
];
|
||||
switch (filters.kind?.value) {
|
||||
switch (effectiveKind) {
|
||||
case 'user':
|
||||
return [...descriptionTagColumns];
|
||||
case 'domain':
|
||||
|
||||
Reference in New Issue
Block a user