From 8453a020d5f46a63cea5d1a7e42b60a9aca223cf Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Mon, 9 Dec 2024 22:39:20 -0500 Subject: [PATCH] (core) Revert "Document type conversion UX/UI (#1181)" Summary: The recently-landed document type conversion feature was broken, failing to change the document's type in both Jenkins CI runs and during manual testing of the SaaS build of Grist. This reverts the feature until a fix is ready. Test Plan: N/A Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D4411 --- app/client/models/DocPageModel.ts | 13 +- app/client/ui/DocumentSettings.ts | 201 ++-------------------------- app/client/ui2018/cssVars.ts | 1 - app/common/UserAPI.ts | 17 +-- app/gen-server/ApiServer.ts | 19 +-- static/locales/en.client.json | 23 +--- test/gen-server/ApiServer.ts | 24 +--- test/nbrowser/DocTypeConversion.ts | 187 -------------------------- test/nbrowser/SavePosition.ntest.js | 1 + test/nbrowser/Timing.ts | 38 +++++- test/nbrowser/elementUtils.ts | 48 ------- 11 files changed, 58 insertions(+), 514 deletions(-) delete mode 100644 test/nbrowser/DocTypeConversion.ts delete mode 100644 test/nbrowser/elementUtils.ts diff --git a/app/client/models/DocPageModel.ts b/app/client/models/DocPageModel.ts index 8c196e2ef5..f0a2683b63 100644 --- a/app/client/models/DocPageModel.ts +++ b/app/client/models/DocPageModel.ts @@ -29,7 +29,6 @@ import {Holder, Observable, subscribe} from 'grainjs'; import {Computed, Disposable, dom, DomArg, DomElementArg} from 'grainjs'; import {makeT} from 'app/client/lib/localization'; import {logTelemetryEvent} from 'app/client/lib/telemetry'; -import {DocumentType} from 'app/common/UserAPI'; // tslint:disable:no-console @@ -88,7 +87,7 @@ export interface DocPageModel { isTutorialTrunk: Observable; isTutorialFork: Observable; isTemplate: Observable; - type: Observable; + importSources: ImportSource[]; undoState: Observable; // See UndoStack for details. @@ -148,8 +147,6 @@ export class DocPageModelImpl extends Disposable implements DocPageModel { (use, doc) => doc ? doc.isTutorialFork : false); public readonly isTemplate = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isTemplate : false); - public readonly type = Computed.create(this, this.currentDoc, - (use, doc) => doc?.type ?? null); public readonly importSources: ImportSource[] = []; @@ -502,8 +499,7 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo { const isFork = Boolean(idParts.forkId || idParts.snapshotId); const isBareFork = isFork && idParts.trunkId === NEW_DOCUMENT_CODE; const isSnapshot = Boolean(idParts.snapshotId); - const type = doc.type; - const isTutorial = type === 'tutorial'; + const isTutorial = doc.type === 'tutorial'; const isTutorialTrunk = isTutorial && !isFork && mode !== 'default'; const isTutorialFork = isTutorial && isFork; @@ -515,7 +511,7 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo { // mode. Since the document's 'openMode' has no effect, don't bother trying // to set it here, as it'll potentially be confusing for other code reading it. openMode = 'default'; - } else if (!isFork && type === 'template') { + } else if (!isFork && doc.type === 'template') { // Templates should always open in fork mode by default. openMode = 'fork'; } else { @@ -525,7 +521,7 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo { } const isPreFork = openMode === 'fork'; - const isTemplate = type === 'template' && (isFork || isPreFork); + const isTemplate = doc.type === 'template' && (isFork || isPreFork); const isEditable = !isSnapshot && (canEdit(doc.access) || isPreFork); return { ...doc, @@ -538,7 +534,6 @@ function buildDocInfo(doc: Document, mode: OpenDocMode | undefined): DocInfo { isSnapshot, isTutorialTrunk, isTutorialFork, - type, isTemplate, isReadonly: !isEditable, idParts, diff --git a/app/client/ui/DocumentSettings.ts b/app/client/ui/DocumentSettings.ts index ff583067eb..b2c9ba287b 100644 --- a/app/client/ui/DocumentSettings.ts +++ b/app/client/ui/DocumentSettings.ts @@ -29,18 +29,7 @@ import {commonUrls, GristLoadConfig} from 'app/common/gristUrls'; import {not, propertyCompare} from 'app/common/gutil'; import {getCurrency, locales} from 'app/common/Locales'; import {isOwner, isOwnerOrEditor} from 'app/common/roles'; -import {DOCTYPE_NORMAL, DOCTYPE_TEMPLATE, DOCTYPE_TUTORIAL, DocumentType, persistType} from 'app/common/UserAPI'; -import { - Computed, - Disposable, - dom, - DomElementMethod, - fromKo, - IDisposableOwner, - makeTestId, - Observable, - styled -} from 'grainjs'; +import {Computed, Disposable, dom, fromKo, IDisposableOwner, makeTestId, Observable, styled} from 'grainjs'; import * as moment from 'moment-timezone'; const t = makeT('DocumentSettings'); @@ -96,22 +85,6 @@ export class DocSettingsPage extends Disposable { {defaultCurrencyLabel: t("Local currency ({{currency}})", {currency: getCurrency(l)})}) ) }), - dom.create(AdminSectionItem, { - id: 'templateMode', - name: t('Template mode'), - description: t('Change document type'), - value: cssDocTypeContainer( - dom.create( - displayCurrentType, - docPageModel.type, - ), - cssSmallButton(t('Edit'), - dom.on('click', this._buildDocumentTypeModal.bind(this, true)), - testId('doctype-edit') - ), - ), - disabled: isDocOwner ? false : t('Only available to document owners'), - }), ]), dom.create(AdminSection, t('Data Engine'), [ @@ -147,6 +120,7 @@ export class DocSettingsPage extends Disposable { )), disabled: isDocOwner ? false : t('Only available to document owners'), }), + dom.create(AdminSectionItem, { id: 'reload', name: t('Reload'), @@ -154,6 +128,7 @@ export class DocSettingsPage extends Disposable { value: cssSmallButton(t('Reload data engine'), dom.on('click', this._reloadEngine.bind(this, true))), disabled: isDocEditor ? false : t('Only available to document editors'), }), + canChangeEngine ? dom.create(AdminSectionItem, { id: 'python', name: t('Python'), @@ -211,6 +186,7 @@ export class DocSettingsPage extends Disposable { href: getApiConsoleLink(docPageModel), }), }), + dom.create(AdminSectionItem, { id: 'webhooks', name: t('Webhooks'), @@ -248,11 +224,11 @@ export class DocSettingsPage extends Disposable { const docPageModel = this._gristDoc.docPageModel; modal((ctl, owner) => { this.onDispose(() => ctl.close()); - const selected = Observable.create(owner, TimingModalOption.Adhoc); + const selected = Observable.create