From 07bf2505928dd06431359ee33a0880fd5c8bef29 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 5 Aug 2021 14:22:50 -0700 Subject: [PATCH] (core) Hide workspace in breadcrumbs if doc is unsaved Summary: Hides the workspace in the breadcrumbs menu if the doc is unsaved and is not a fork. In practice, this should usually be when an anonymous user creates a new document. Test Plan: Browser tests. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2967 --- app/client/ui/TopBar.ts | 1 + app/client/ui2018/breadcrumbs.ts | 41 +++++++++++++++++++------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/client/ui/TopBar.ts b/app/client/ui/TopBar.ts index 8bad3a47..a310ce81 100644 --- a/app/client/ui/TopBar.ts +++ b/app/client/ui/TopBar.ts @@ -47,6 +47,7 @@ export function createTopBarDoc(owner: MultiHolder, appModel: AppModel, pageMode isPageNameReadOnly: (use) => use(gristDoc.isReadonly) || typeof use(gristDoc.activeViewId) !== 'number', isDocNameReadOnly: (use) => use(gristDoc.isReadonly) || use(pageModel.isFork), isFork: pageModel.isFork, + isBareFork: pageModel.isBareFork, isRecoveryMode: pageModel.isRecoveryMode, userOverride: pageModel.userOverride, isFiddle: Computed.create(owner, (use) => use(pageModel.isPrefork)), diff --git a/app/client/ui2018/breadcrumbs.ts b/app/client/ui2018/breadcrumbs.ts index 34f61e97..df046a1e 100644 --- a/app/client/ui2018/breadcrumbs.ts +++ b/app/client/ui2018/breadcrumbs.ts @@ -106,6 +106,7 @@ export function docBreadcrumbs( isDocNameReadOnly?: BindableValue, isPageNameReadOnly?: BindableValue, isFork: Observable, + isBareFork: Observable, isFiddle: Observable, isRecoveryMode: Observable, userOverride: Observable, @@ -114,25 +115,31 @@ export function docBreadcrumbs( } ): Element { return cssBreadcrumbs( - cssIcon('Home', + dom.domComputed<[boolean, PartialWorkspace|null]>( + (use) => [use(options.isBareFork), use(workspace)], + ([isBareFork, ws]) => { + if (isBareFork || !ws) { return null; } + return [ + cssIcon('Home', testId('bc-home'), cssHideForNarrowScreen.cls('')), - dom.maybe(workspace, _workspace => [ - cssWorkspaceName( - urlState().setLinkUrl({ws: _workspace.id}), - dom.text(_workspace.name), - testId('bc-workspace'), - cssHideForNarrowScreen.cls('') - ), - cssWorkspaceNarrowScreen( - 'Expand', - urlState().setLinkUrl({ws: _workspace.id}), - testId('bc-workspace-ns') - ), - separator(' / ', - testId('bc-separator'), - cssHideForNarrowScreen.cls('')) - ]), + cssWorkspaceName( + urlState().setLinkUrl({ws: ws.id}), + dom.text(ws.name), + testId('bc-workspace'), + cssHideForNarrowScreen.cls('') + ), + cssWorkspaceNarrowScreen( + 'Expand', + urlState().setLinkUrl({ws: ws.id}), + testId('bc-workspace-ns') + ), + separator(' / ', + testId('bc-separator'), + cssHideForNarrowScreen.cls('')) + ]; + } + ), editableLabel( docName, options.docNameSave, testId('bc-doc'), cssEditableName.cls(''), dom.boolAttr('disabled', options.isDocNameReadOnly || false),