mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
460f22b701
Summary: As reported in https://grist.slack.com/archives/C069RUP71/p1655316194602829, when a table is hidden by ACL, it was still showing as a blank 'ghost' option to select data when adding a widget: {F55498} The fix is simply to return `true` from `isHiddenTable` for empty table IDs, which indicate a table hidden by ACL. `TableRec.isHidden` is supposed to match this so I updated it too, and I cleaned up a tiny bit of other related code. Test Plan: Extended `nbrowser/AccessRules1.ts` to test the data options when adding widgets. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3530
20 lines
789 B
TypeScript
20 lines
789 B
TypeScript
import {TableData} from 'app/common/TableData';
|
|
import {UIRowId} from 'app/common/UIRowId';
|
|
|
|
/**
|
|
* 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: UIRowId): boolean {
|
|
const tableId = tablesData.getValue(tableRef, 'tableId') as string|undefined;
|
|
return !tableId || isSummaryTable(tablesData, tableRef) || tableId.startsWith('GristHidden_');
|
|
}
|
|
|
|
/**
|
|
* Return whether a table (identified by the rowId of its metadata record) is a
|
|
* summary table.
|
|
*/
|
|
export function isSummaryTable(tablesData: TableData, tableRef: UIRowId): boolean {
|
|
return tablesData.getValue(tableRef, 'summarySourceTable') !== 0;
|
|
}
|