(core) Hide the GristDocTour table by default but reveal it when /p/GristDocTour is in the URL

Summary:
Adds 'GristDocTour' as a possible value of urlState().docPage

GristDoc checks for this and converts it to a normal view record ID

It also then sets a flag showGristDocTour=true which tells Pages.ts to show the page in the sidebar

Otherwise the page is 'hidden' in the sidebar in the same way it would be if blocked by ACL rules

This all feels very hacky, but I don't know this code well enough to know if there's a better way. Hopefully this behaviour is temporary.

Test Plan: Tested manually, not sure if this is worth an automated test at this stage

Reviewers: paulfitz, dsagal

Reviewed By: paulfitz, dsagal

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D2953
This commit is contained in:
Alex Hall
2021-07-30 20:05:16 +02:00
parent 6b3ac07ca7
commit 73c4efa315
4 changed files with 28 additions and 12 deletions

View File

@@ -5,7 +5,6 @@ import { colors } from "app/client/ui2018/cssVars";
import { icon } from "app/client/ui2018/icons";
import { menu, menuItem, menuText } from "app/client/ui2018/menus";
import { dom, domComputed, DomElementArg, makeTestId, observable, Observable, styled } from "grainjs";
import * as ko from "knockout";
const testId = makeTestId('test-docpage-');
@@ -18,15 +17,12 @@ export interface PageActions {
isReadonly: Observable<boolean>;
}
// to work with existing code we need to support both knockout and grainjs observable
type NameType = Observable<string>|ko.Observable<string>;
// build the dom for a document page entry. It shows an icon (for now the first letter of the name,
// but later we'll support user selected icon), the name and a dots menu containing a "Rename" and
// "Remove" entries. Clicking "Rename" turns the page name into an editable input, which then call
// the actions.onRename callback with the new name. Setting actions.onRemove to undefined disables
// the item in the menu.
export function buildPageDom(name: NameType, actions: PageActions, ...args: DomElementArg[]) {
export function buildPageDom(name: Observable<string>, actions: PageActions, ...args: DomElementArg[]) {
const isRenaming = observable(false);
const pageMenu = () => [
@@ -59,7 +55,7 @@ export function buildPageDom(name: NameType, actions: PageActions, ...args: DomE
cssPageInitial(dom.text((use) => use(name)[0])),
cssEditorInput(
{
initialValue: typeof name === 'function' ? name() : name.get() || '',
initialValue: name.get() || '',
save: (val) => actions.onRename(val),
close: () => isRenaming.set(false)
},