gristlabs_grist-core/app/client/models/isHiddenTable.ts
Dmitry S cf7a3153f9 (core) When hidden pages are present in the page list, allow removing them
Summary:
After an incomplete import, any GristHidden_* tables will show up in the page
list, but may not be removable if there is only one non-hidden table remaining.
Such tables should still be removable in this case.

Test Plan: Added a test case

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3058
2021-10-05 15:39:42 -04:00

13 lines
558 B
TypeScript

import {RowId} from 'app/client/models/rowset';
import {TableData} from 'app/client/models/TableData';
/**
* Return whether a table identified by the rowId of its metadata record, should normally be
* hidden from the user (e.g. as an option in the page-widget picker).
*/
export function isHiddenTable(tablesData: TableData, tableRef: RowId): boolean {
const tableId = tablesData.getValue(tableRef, 'tableId') as string|undefined;
return tablesData.getValue(tableRef, 'summarySourceTable') !== 0 ||
Boolean(tableId?.startsWith('GristHidden'));
}