From 2399baaca2c40a752b5654ccfef0b9875ff36683 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Mon, 27 Jul 2020 13:26:28 -0400 Subject: [PATCH] (core) When saving copies, allow saving to another org; update menus for making and saving copies. Summary: - Implemented selecting an org in some cases when using Save-Copy dialog. - Unified previous 'Save Copy' menu into an enhanced "Share" menu. - Renamed ExportMenu to ShareMenu, collect related code into it, and design the share button. - Introduced trunkAccess property for forks, to know whether "Replace Original" is available. - Simplified handling of fork() result, now that all code has been upgraded. - Replaced 'Copy as Template' menu items with a checkbox in the Save-Copy dialog - Removed copy links for examples in the DocMenu (to simplify, since not part of updated design) - Updated the UI of the copying dialog. Test Plan: Updated affected tests, added new test cases for copying when other orgs are a choice or not. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2561 --- app/common/ActiveDocAPI.ts | 3 +-- app/common/UserAPI.ts | 1 + app/gen-server/entity/Document.ts | 3 +++ app/gen-server/lib/HomeDBManager.ts | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/common/ActiveDocAPI.ts b/app/common/ActiveDocAPI.ts index 46aa352a..b7c29401 100644 --- a/app/common/ActiveDocAPI.ts +++ b/app/common/ActiveDocAPI.ts @@ -220,7 +220,6 @@ export interface ActiveDocAPI { /** * Prepare a fork of the document, and return the id(s) of the fork. - * TODO: remove string option here, it is present to ease transition. */ - fork(): Promise; + fork(): Promise; } diff --git a/app/common/UserAPI.ts b/app/common/UserAPI.ts index e3bc86ea..8b4218ac 100644 --- a/app/common/UserAPI.ts +++ b/app/common/UserAPI.ts @@ -99,6 +99,7 @@ export interface Document extends DocumentProperties { id: string; workspace: Workspace; access: roles.Role; + trunkAccess?: roles.Role|null; } export interface PermissionDelta { diff --git a/app/gen-server/entity/Document.ts b/app/gen-server/entity/Document.ts index e256efd8..e3328c0b 100644 --- a/app/gen-server/entity/Document.ts +++ b/app/gen-server/entity/Document.ts @@ -37,6 +37,9 @@ export class Document extends Resource { // fetching user has on the doc, i.e. 'owners', 'editors', 'viewers' public access: Role|null; + // Property set for forks, containing access the fetching user has on the trunk. + public trunkAccess?: Role|null; + // a computed column with permissions. // {insert: false} makes sure typeorm doesn't try to put values into such // a column when creating documents. diff --git a/app/gen-server/lib/HomeDBManager.ts b/app/gen-server/lib/HomeDBManager.ts index d2a64a94..74a0ce5b 100644 --- a/app/gen-server/lib/HomeDBManager.ts +++ b/app/gen-server/lib/HomeDBManager.ts @@ -958,6 +958,10 @@ export class HomeDBManager extends EventEmitter { if (doc.urlId) { doc.urlId = buildUrlId({trunkId: doc.urlId, forkId, forkUserId, snapshotId}); } + + // Set trunkAccess field. + doc.trunkAccess = doc.access; + // Forks without a user id are editable by anyone with view access to the trunk. if (forkUserId === undefined && doc.access === 'viewers') { doc.access = 'editors'; } if (forkUserId !== undefined) {