mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix non-existent page ID showing all raw data widgets
Summary: Check that view exists first, otherwise fall back to default Test Plan: Manual Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3260
This commit is contained in:
parent
592a43ec36
commit
1c855537d6
@ -53,7 +53,7 @@ import {DisposableWithEvents} from 'app/common/DisposableWithEvents';
|
|||||||
import {isSchemaAction, UserAction} from 'app/common/DocActions';
|
import {isSchemaAction, UserAction} from 'app/common/DocActions';
|
||||||
import {OpenLocalDocResult} from 'app/common/DocListAPI';
|
import {OpenLocalDocResult} from 'app/common/DocListAPI';
|
||||||
import {isList, isRefListType, RecalcWhen} from 'app/common/gristTypes';
|
import {isList, isRefListType, RecalcWhen} from 'app/common/gristTypes';
|
||||||
import {HashLink, IDocPage} from 'app/common/gristUrls';
|
import {HashLink, IDocPage, SpecialDocPage} from 'app/common/gristUrls';
|
||||||
import {undef, waitObs} from 'app/common/gutil';
|
import {undef, waitObs} from 'app/common/gutil';
|
||||||
import {LocalPlugin} from "app/common/plugin";
|
import {LocalPlugin} from "app/common/plugin";
|
||||||
import {StringUnion} from 'app/common/StringUnion';
|
import {StringUnion} from 'app/common/StringUnion';
|
||||||
@ -166,13 +166,20 @@ export class GristDoc extends DisposableWithEvents {
|
|||||||
|
|
||||||
// Grainjs observable for current view id, which may be a string such as 'code'.
|
// Grainjs observable for current view id, which may be a string such as 'code'.
|
||||||
this.activeViewId = Computed.create(this, (use) => {
|
this.activeViewId = Computed.create(this, (use) => {
|
||||||
let result = use(urlState().state).docPage;
|
const {docPage} = use(urlState().state);
|
||||||
if (result === 'GristDocTour') {
|
|
||||||
|
// Return most special pages like 'code' and 'acl' as is
|
||||||
|
if (typeof docPage === 'string' && docPage !== 'GristDocTour' && SpecialDocPage.guard(docPage)) {
|
||||||
|
return docPage;
|
||||||
|
}
|
||||||
|
|
||||||
// GristDocTour is a special table that is usually hidden from users, but putting /p/GristDocTour
|
// GristDocTour is a special table that is usually hidden from users, but putting /p/GristDocTour
|
||||||
// in the URL navigates to it and makes it visible in the list of pages in the sidebar
|
// in the URL navigates to it and makes it visible in the list of pages in the sidebar
|
||||||
result = this.docModel.views.tableData.findRow('name', result);
|
// For GristDocTour, find the view with that name.
|
||||||
}
|
// Otherwise find the view with the given row ID, because letting a non-existent row ID pass through here is bad.
|
||||||
return result || use(defaultViewId);
|
// If no such view exists, return the default view.
|
||||||
|
const viewId = this.docModel.views.tableData.findRow(docPage === 'GristDocTour' ? 'name' : 'id', docPage);
|
||||||
|
return viewId || use(defaultViewId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// This viewModel reflects the currently active view, relying on the fact that
|
// This viewModel reflects the currently active view, relying on the fact that
|
||||||
|
@ -10,7 +10,7 @@ import {Document} from 'app/common/UserAPI';
|
|||||||
import clone = require('lodash/clone');
|
import clone = require('lodash/clone');
|
||||||
import pickBy = require('lodash/pickBy');
|
import pickBy = require('lodash/pickBy');
|
||||||
|
|
||||||
const SpecialDocPage = StringUnion('code', 'acl', 'data', 'GristDocTour');
|
export const SpecialDocPage = StringUnion('code', 'acl', 'data', 'GristDocTour');
|
||||||
type SpecialDocPage = typeof SpecialDocPage.type;
|
type SpecialDocPage = typeof SpecialDocPage.type;
|
||||||
export type IDocPage = number | SpecialDocPage;
|
export type IDocPage = number | SpecialDocPage;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user