mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Redesign examples and templates UI
Summary: The old Examples and Templates workspace is now a page that pulls templates from a new public Grist Templates org. The All Documents view will pull featured templates from that org, where featured templates are simply pinned documents in Grist Templates. The Examples and Templates page will also show the featured templates, as well as the rest of the available templates organized by category. The categories are equivalent to workspaces in Grist Templates, and are generated dynamically. Test Plan: Browser tests. Reviewers: paulfitz, dsagal Reviewed By: paulfitz, dsagal Subscribers: dsagal, paulfitz, jarek Differential Revision: https://phab.getgrist.com/D2930
This commit is contained in:
@@ -28,7 +28,6 @@ import {Holder, Observable, subscribe} from 'grainjs';
|
||||
|
||||
export interface DocInfo extends Document {
|
||||
isReadonly: boolean;
|
||||
isSample: boolean;
|
||||
isPreFork: boolean;
|
||||
isFork: boolean;
|
||||
isRecoveryMode: boolean;
|
||||
@@ -59,7 +58,6 @@ export interface DocPageModel {
|
||||
isRecoveryMode: Observable<boolean>;
|
||||
userOverride: Observable<UserOverride|null>;
|
||||
isBareFork: Observable<boolean>;
|
||||
isSample: Observable<boolean>;
|
||||
|
||||
importSources: ImportSource[];
|
||||
|
||||
@@ -98,7 +96,6 @@ 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 isSample = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isSample : false);
|
||||
|
||||
public readonly importSources: ImportSource[] = [];
|
||||
|
||||
@@ -123,7 +120,7 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
|
||||
this.autoDispose(subscribe(urlState().state, (use, state) => {
|
||||
const urlId = state.doc;
|
||||
const urlOpenMode = state.mode || 'default';
|
||||
const urlOpenMode = state.mode;
|
||||
const linkParameters = state.params?.linkParameters;
|
||||
const docKey = this._getDocKey(state);
|
||||
if (docKey !== this._openerDocKey) {
|
||||
@@ -226,7 +223,7 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
);
|
||||
}
|
||||
|
||||
private async _openDoc(flow: AsyncFlow, urlId: string, urlOpenMode: OpenDocMode,
|
||||
private async _openDoc(flow: AsyncFlow, urlId: string, urlOpenMode: OpenDocMode | undefined,
|
||||
comparisonUrlId: string | undefined,
|
||||
linkParameters: Record<string, string> | undefined): Promise<void> {
|
||||
console.log(`DocPageModel _openDoc starting for ${urlId} (mode ${urlOpenMode})` +
|
||||
@@ -326,11 +323,21 @@ function addMenu(importSources: ImportSource[], gristDoc: GristDoc, isReadonly:
|
||||
];
|
||||
}
|
||||
|
||||
function buildDocInfo(doc: Document, mode: OpenDocMode): DocInfo {
|
||||
function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo {
|
||||
const idParts = parseUrlId(doc.urlId || doc.id);
|
||||
const isFork = Boolean(idParts.forkId || idParts.snapshotId);
|
||||
const isSample = !isFork && Boolean(doc.workspace.isSupportWorkspace);
|
||||
const openMode = isSample ? 'fork' : mode;
|
||||
|
||||
let openMode = mode;
|
||||
if (!openMode) {
|
||||
if (isFork) {
|
||||
// Ignore the document 'openMode' setting if the doc is an unsaved fork.
|
||||
openMode = 'default';
|
||||
} else {
|
||||
// Try to use the document's 'openMode' if it's set.
|
||||
openMode = doc.options?.openMode ?? 'default';
|
||||
}
|
||||
}
|
||||
|
||||
const isPreFork = (openMode === 'fork');
|
||||
const isBareFork = isFork && idParts.trunkId === NEW_DOCUMENT_CODE;
|
||||
const isEditable = canEdit(doc.access) || isPreFork;
|
||||
@@ -339,7 +346,6 @@ function buildDocInfo(doc: Document, mode: OpenDocMode): DocInfo {
|
||||
isFork,
|
||||
isRecoveryMode: false, // we don't know yet, will learn when doc is opened.
|
||||
userOverride: null, // ditto.
|
||||
isSample,
|
||||
isPreFork,
|
||||
isBareFork,
|
||||
isReadonly: !isEditable,
|
||||
|
||||
Reference in New Issue
Block a user