(core) Allow creating docs from the templates page

Summary:
Enables the options in the Add New menu when on the templates page
(p/templates).

Test Plan: Browser test.

Reviewers: paulfitz, alexmojaki

Reviewed By: paulfitz, alexmojaki

Subscribers: paulfitz, jarek, alexmojaki

Differential Revision: https://phab.getgrist.com/D2971
This commit is contained in:
George Gevoian 2021-08-10 15:08:24 -07:00
parent ffeab944cc
commit ba1e919d39

View File

@ -126,8 +126,8 @@ export class HomeModelImpl extends Disposable implements HomeModel, ViewSettings
public readonly newDocWorkspace = Computed.create(this, this.currentPage, this.currentWS, (use, page, ws) => { public readonly newDocWorkspace = Computed.create(this, this.currentPage, this.currentWS, (use, page, ws) => {
// Anonymous user can create docs, but in unsaved mode. // Anonymous user can create docs, but in unsaved mode.
if (!this.app.currentValidUser) { return "unsaved"; } if (!this.app.currentValidUser) { return "unsaved"; }
if (['templates', 'trash'].includes(page)) { return null; } if (page === 'trash') { return null; }
const destWS = (page === 'all') ? (use(this.workspaces)[0] || null) : ws; const destWS = (['all', 'templates'].includes(page)) ? (use(this.workspaces)[0] || null) : ws;
return destWS && roles.canEdit(destWS.access) ? destWS : null; return destWS && roles.canEdit(destWS.access) ? destWS : null;
}); });