mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix owner view access to snapshots
Summary: Owners weren't able to access snapshots if access rules that denied access to non-owners existed. The backend was lowering snapshot document access to "viewers" as part of implementing read-only behavior; this is now done in the client, with document access for snapshots now accurately reflecting the user's trunk access. Additionally, sandboxes are no longer created for snapshots, and background intervals aren't started for snapshots. Test Plan: Browser test. Reviewers: jarek, paulfitz Reviewed By: jarek, paulfitz Differential Revision: https://phab.getgrist.com/D3849
This commit is contained in:
@@ -39,6 +39,7 @@ export interface DocInfo extends Document {
|
||||
userOverride: UserOverride|null;
|
||||
isBareFork: boolean; // a document created without logging in, which is treated as a
|
||||
// fork without an original.
|
||||
isSnapshot: boolean;
|
||||
isTutorialTrunk: boolean;
|
||||
isTutorialFork: boolean;
|
||||
idParts: UrlIdParts;
|
||||
@@ -72,6 +73,7 @@ export interface DocPageModel {
|
||||
isRecoveryMode: Observable<boolean>;
|
||||
userOverride: Observable<UserOverride|null>;
|
||||
isBareFork: Observable<boolean>;
|
||||
isSnapshot: Observable<boolean>;
|
||||
isTutorialTrunk: Observable<boolean>;
|
||||
isTutorialFork: Observable<boolean>;
|
||||
|
||||
@@ -124,6 +126,7 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
(use, doc) => doc ? doc.isRecoveryMode : false);
|
||||
public readonly userOverride = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.userOverride : null);
|
||||
public readonly isBareFork = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isBareFork : false);
|
||||
public readonly isSnapshot = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isSnapshot : false);
|
||||
public readonly isTutorialTrunk = Computed.create(this, this.currentDoc,
|
||||
(use, doc) => doc ? doc.isTutorialTrunk : false);
|
||||
public readonly isTutorialFork = Computed.create(this, this.currentDoc,
|
||||
@@ -441,9 +444,10 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo {
|
||||
|
||||
const isPreFork = (openMode === 'fork');
|
||||
const isBareFork = isFork && idParts.trunkId === NEW_DOCUMENT_CODE;
|
||||
const isSnapshot = Boolean(idParts.snapshotId);
|
||||
const isTutorialTrunk = !isFork && doc.type === 'tutorial' && mode !== 'default';
|
||||
const isTutorialFork = isFork && doc.type === 'tutorial';
|
||||
const isEditable = canEdit(doc.access) || isPreFork;
|
||||
const isEditable = !isSnapshot && (canEdit(doc.access) || isPreFork);
|
||||
return {
|
||||
...doc,
|
||||
isFork,
|
||||
@@ -451,6 +455,7 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo {
|
||||
userOverride: null, // ditto.
|
||||
isPreFork,
|
||||
isBareFork,
|
||||
isSnapshot,
|
||||
isTutorialTrunk,
|
||||
isTutorialFork,
|
||||
isReadonly: !isEditable,
|
||||
|
||||
@@ -36,7 +36,7 @@ export function buildShareMenuButton(pageModel: DocPageModel): DomContents {
|
||||
return dom.maybe(pageModel.currentDoc, (doc) => {
|
||||
const appModel = pageModel.appModel;
|
||||
const saveCopy = () => makeCopy(doc, appModel, t("Save Document")).catch(reportError);
|
||||
if (doc.idParts.snapshotId) {
|
||||
if (doc.isSnapshot) {
|
||||
const backToCurrent = () => urlState().pushUrl({doc: buildOriginalUrlId(doc.id, true)});
|
||||
return shareButton(t("Back to Current"), () => [
|
||||
menuManageUsers(doc, pageModel),
|
||||
|
||||
@@ -86,7 +86,7 @@ export function createTopBarDoc(owner: MultiHolder, appModel: AppModel, pageMode
|
||||
isRecoveryMode: pageModel.isRecoveryMode,
|
||||
isTutorialFork: pageModel.isTutorialFork,
|
||||
isFiddle: Computed.create(owner, (use) => use(pageModel.isPrefork)),
|
||||
isSnapshot: Computed.create(owner, doc, (use, _doc) => Boolean(_doc && _doc.idParts.snapshotId)),
|
||||
isSnapshot: pageModel.isSnapshot,
|
||||
isPublic: Computed.create(owner, doc, (use, _doc) => Boolean(_doc && _doc.public)),
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user