(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
This commit is contained in:
George Gevoian 2021-08-05 14:22:50 -07:00
parent 4a23b964ed
commit 07bf250592
2 changed files with 25 additions and 17 deletions

View File

@ -47,6 +47,7 @@ export function createTopBarDoc(owner: MultiHolder, appModel: AppModel, pageMode
isPageNameReadOnly: (use) => use(gristDoc.isReadonly) || typeof use(gristDoc.activeViewId) !== 'number', isPageNameReadOnly: (use) => use(gristDoc.isReadonly) || typeof use(gristDoc.activeViewId) !== 'number',
isDocNameReadOnly: (use) => use(gristDoc.isReadonly) || use(pageModel.isFork), isDocNameReadOnly: (use) => use(gristDoc.isReadonly) || use(pageModel.isFork),
isFork: pageModel.isFork, isFork: pageModel.isFork,
isBareFork: pageModel.isBareFork,
isRecoveryMode: pageModel.isRecoveryMode, isRecoveryMode: pageModel.isRecoveryMode,
userOverride: pageModel.userOverride, userOverride: pageModel.userOverride,
isFiddle: Computed.create(owner, (use) => use(pageModel.isPrefork)), isFiddle: Computed.create(owner, (use) => use(pageModel.isPrefork)),

View File

@ -106,6 +106,7 @@ export function docBreadcrumbs(
isDocNameReadOnly?: BindableValue<boolean>, isDocNameReadOnly?: BindableValue<boolean>,
isPageNameReadOnly?: BindableValue<boolean>, isPageNameReadOnly?: BindableValue<boolean>,
isFork: Observable<boolean>, isFork: Observable<boolean>,
isBareFork: Observable<boolean>,
isFiddle: Observable<boolean>, isFiddle: Observable<boolean>,
isRecoveryMode: Observable<boolean>, isRecoveryMode: Observable<boolean>,
userOverride: Observable<UserOverride|null>, userOverride: Observable<UserOverride|null>,
@ -114,25 +115,31 @@ export function docBreadcrumbs(
} }
): Element { ): Element {
return cssBreadcrumbs( return cssBreadcrumbs(
dom.domComputed<[boolean, PartialWorkspace|null]>(
(use) => [use(options.isBareFork), use(workspace)],
([isBareFork, ws]) => {
if (isBareFork || !ws) { return null; }
return [
cssIcon('Home', cssIcon('Home',
testId('bc-home'), testId('bc-home'),
cssHideForNarrowScreen.cls('')), cssHideForNarrowScreen.cls('')),
dom.maybe(workspace, _workspace => [
cssWorkspaceName( cssWorkspaceName(
urlState().setLinkUrl({ws: _workspace.id}), urlState().setLinkUrl({ws: ws.id}),
dom.text(_workspace.name), dom.text(ws.name),
testId('bc-workspace'), testId('bc-workspace'),
cssHideForNarrowScreen.cls('') cssHideForNarrowScreen.cls('')
), ),
cssWorkspaceNarrowScreen( cssWorkspaceNarrowScreen(
'Expand', 'Expand',
urlState().setLinkUrl({ws: _workspace.id}), urlState().setLinkUrl({ws: ws.id}),
testId('bc-workspace-ns') testId('bc-workspace-ns')
), ),
separator(' / ', separator(' / ',
testId('bc-separator'), testId('bc-separator'),
cssHideForNarrowScreen.cls('')) cssHideForNarrowScreen.cls(''))
]), ];
}
),
editableLabel( editableLabel(
docName, options.docNameSave, testId('bc-doc'), cssEditableName.cls(''), docName, options.docNameSave, testId('bc-doc'), cssEditableName.cls(''),
dom.boolAttr('disabled', options.isDocNameReadOnly || false), dom.boolAttr('disabled', options.isDocNameReadOnly || false),