From 931827b19505729639145489bcc48e3b33c8126b Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 29 Jul 2021 15:57:05 -0700 Subject: [PATCH] (core) Hide templates org in copy menu Summary: Temporarily adds a client-side check to hide the Grist Templates org in the Save Copy menu. This will be removed later once we update getOrgs to optionally filter orgs that have no workspaces with write access. Test Plan: Browser tests. Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D2951 --- app/client/ui/MakeCopyMenu.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/client/ui/MakeCopyMenu.ts b/app/client/ui/MakeCopyMenu.ts index bd8402a3..9bb30d5a 100644 --- a/app/client/ui/MakeCopyMenu.ts +++ b/app/client/ui/MakeCopyMenu.ts @@ -97,7 +97,13 @@ export async function makeCopy(doc: Document, app: AppModel, modalTitle: string) signupModal('To save your changes, please sign up, then reload this page.'); return; } - const orgs = allowOtherOrgs(doc, app) ? await app.api.getOrgs(true) : null; + let orgs = allowOtherOrgs(doc, app) ? await app.api.getOrgs(true) : null; + if (orgs) { + // TODO: Need a more robust way to detect and exclude the templates org. + // Don't show the templates org since it's selected by default, and + // is not writable to. + orgs = orgs.filter(o => o.domain !== 'templates' && o.domain !== 'templates-s'); + } // Show a dialog with a form to select destination. saveModal((ctl, owner) => { @@ -122,7 +128,7 @@ class SaveCopyModal extends Disposable { (!name.trim() || !ws || !roles.canEdit(ws.access))); // Only show workspaces for team sites, since they are not a feature of personal orgs. - private _showWorkspaces = Computed.create(this, this._destOrg, (use, org) => (org && !org.owner)); + private _showWorkspaces = Computed.create(this, this._destOrg, (use, org) => Boolean(org && !org.owner)); // If orgs is non-null, then we show a selector for orgs. constructor(private _doc: Document, private _app: AppModel, private _orgs: Organization[]|null) { @@ -134,7 +140,7 @@ class SaveCopyModal extends Disposable { // Set _destOrg to an Organization object from _orgs array; there should be one equivalent // to currentOrg, but we need the actual object for select() to recognize it as selected. const orgId = this._app.currentOrg.id; - this._destOrg.set(this._orgs.find((org) => org.id === orgId) || null); + this._destOrg.set(this._orgs.find((org) => org.id === orgId) || this._orgs[0]); } this.autoDispose(subscribe(this._destOrg, (use, org) => this._updateWorkspaces(org).catch(reportError))); }