From cd241a633ada7d80bfaefbb0fc266dfd7219d112 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Mon, 20 Sep 2021 11:54:01 -0400 Subject: [PATCH] (core) In make-copy dialog, ensure it's non-saveable while fetching workspaces after a switch of the destination org Summary: While switching the destination site in the Duplicate Document dialog, there were times when it was saveable even though destination workspaces were still being fetched. This sometimes causes a test failure, with the document getting saved to a workspace from the previously-selected org. Test Plan: Tested manually; reproduced by adding a conditional artificial delay in _updateWorkspaces helper. Reviewers: paulfitz, georgegevoian Reviewed By: paulfitz, georgegevoian Differential Revision: https://phab.getgrist.com/D3032 --- app/client/ui/MakeCopyMenu.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/client/ui/MakeCopyMenu.ts b/app/client/ui/MakeCopyMenu.ts index a9ccd328..1e69190a 100644 --- a/app/client/ui/MakeCopyMenu.ts +++ b/app/client/ui/MakeCopyMenu.ts @@ -222,8 +222,14 @@ class SaveCopyModal extends Disposable { */ private async _updateWorkspaces(org: Organization|null) { this._workspaces.set(null); // Show that workspaces are loading. + this._destWS.set(null); // Disable saving while waiting to set a new destination workspace. try { let wss = org ? await this._app.api.getOrgWorkspaces(org.id) : []; + if (this._destOrg.get() !== org) { + // We must have switched the org. Don't update anything; in particularr, keep _workspaces + // and _destWS as null, to show loading/save-disabled status. Let the new fetch update things. + return; + } // Sort the same way that HomeModel sorts workspaces. wss = sortBy(wss, (ws) => [ws.isSupportWorkspace, ownerName(this._app, ws).toLowerCase(), ws.name.toLowerCase()]);