mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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
This commit is contained in:
@@ -3,6 +3,7 @@ import { duplicatePage } from "app/client/components/duplicatePage";
|
||||
import { GristDoc } from "app/client/components/GristDoc";
|
||||
import { PageRec } from "app/client/models/DocModel";
|
||||
import { urlState } from "app/client/models/gristUrlState";
|
||||
import { isHiddenTable } from 'app/client/models/isHiddenTable';
|
||||
import * as MetaTableModel from "app/client/models/MetaTableModel";
|
||||
import { find as findInTree, fromTableData, TreeItemRecord, TreeRecord,
|
||||
TreeTableData} from "app/client/models/TreeModel";
|
||||
@@ -80,7 +81,11 @@ function buildDomFromTable(pagesTable: MetaTableModel<PageRec>, activeDoc: Grist
|
||||
actions.onRemove = () => confirmModal(
|
||||
`Delete ${pageName()} data, and remove it from all pages?`, 'Delete', doRemove);
|
||||
|
||||
actions.isRemoveDisabled = () => (docModel.allTables.all().length <= 1);
|
||||
// Disable removing the last page. Sometimes hidden pages end up showing in the side panel
|
||||
// (e.g. GristHidden_import* for aborted imports); those aren't listed in allTables, and we
|
||||
// should allow removing them.
|
||||
actions.isRemoveDisabled = () => (docModel.allTables.all().length <= 1) &&
|
||||
!isHiddenTable(docModel.tables.tableData, tableRef);
|
||||
}
|
||||
|
||||
return buildPageDom(fromKo(pageName), actions, urlState().setLinkUrl({docPage: viewId}));
|
||||
|
||||
Reference in New Issue
Block a user