(core) read document as owner in pre-fork mode, if have sufficient access to it

Summary:
This tweaks pre-fork mode to make the user's experience a bit more seamless.
Pre-fork mode is where the user has opened a document with intent to
fork it, but actual forking (with allocation of a new document id)
is postponed until they make their first change.

The tweak makes the user an owner for granular access purposes, if
forking is permitted.  So data visible only to owners because of
access rules will be visible to them.  As always, any edits would
go to a separate new copy.

A remaining tricky corner is what to do about "View As" functionality
on forks.  Fork sharing cannot be controlled, so the "Users -> View As"
functionality isn't available.  Perhaps the "Users" button on a fork
could encourage doing a save-copy and inviting users, or offer some
dummy users?  In any case, this diff doesn't change anything with
that corner.

Test Plan: added test

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2931
This commit is contained in:
Paul Fitzpatrick
2021-07-20 16:20:31 -04:00
parent 291bcd17ff
commit 95cc2eb282
4 changed files with 76 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ export interface OptDocSession {
// special permissions for creating, plugins, system, and share access
mode?: 'nascent'|'plugin'|'system'|'share';
authorizer?: Authorizer;
forkingAsOwner?: boolean; // Set if it is appropriate in a pre-fork state to become an owner.
}
export function makeOptDocSession(client: Client|null, browserSettings?: BrowserSettings): OptDocSession {
@@ -67,6 +68,8 @@ export class DocSession implements OptDocSession {
*/
public linkId?: number;
public forkingAsOwner?: boolean;
constructor(
public readonly activeDoc: ActiveDoc,
public readonly client: Client,