(core) Removing virtual tables when they are not needed

Summary:
Clearing virtual tables after user navigates away from the pages
that show them. Leaving them behind will reveal them on the Raw
Data page, with a buggy experience as user can't view the data
there.

Test Plan: Extended tests.

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: jarek, georgegevoian

Differential Revision: https://phab.getgrist.com/D4258
This commit is contained in:
George Gevoian
2024-05-28 15:13:10 -07:00
parent 06acc47cdb
commit c469a68d6e
7 changed files with 98 additions and 59 deletions

View File

@@ -109,6 +109,7 @@ Please log in as an administrator.`)),
url: dom('pre', `/admin?boot-key=${exampleKey}`)
}),
),
testId('admin-panel-error'),
]);
}

View File

@@ -2,13 +2,13 @@ import {transition} from 'app/client/ui/transitions';
import {toggle} from 'app/client/ui2018/checkbox';
import {mediaSmall, testId, theme, vars} from 'app/client/ui2018/cssVars';
import {icon} from 'app/client/ui2018/icons';
import {dom, DomContents, IDisposableOwner, Observable, styled} from 'grainjs';
import {dom, DomContents, DomElementArg, IDisposableOwner, Observable, styled} from 'grainjs';
export function HidableToggle(owner: IDisposableOwner, value: Observable<boolean|null>) {
return toggle(value, dom.hide((use) => use(value) === null));
}
export function AdminSection(owner: IDisposableOwner, title: DomContents, items: DomContents[]) {
export function AdminSection(owner: IDisposableOwner, title: DomContents, items: DomElementArg[]) {
return cssSection(
cssSectionTitle(title),
...items,

View File

@@ -2,7 +2,7 @@ import BaseView = require('app/client/components/BaseView');
import {GristDoc} from 'app/client/components/GristDoc';
import {ViewSectionHelper} from 'app/client/components/ViewLayout';
import {makeT} from 'app/client/lib/localization';
import {IEdit, IExternalTable, VirtualTable} from 'app/client/models/VirtualTable';
import {IEdit, IExternalTable, VirtualTableRegistration} from 'app/client/models/VirtualTable';
import {urlState} from 'app/client/models/gristUrlState';
import {docListHeader} from 'app/client/ui/DocMenuCss';
import {isNarrowScreenObs, mediaSmall} from 'app/client/ui2018/cssVars';
@@ -163,7 +163,7 @@ export class TimingPage extends DisposableWithEvents {
// And wire up the UI.
const ext = this.autoDispose(new TimingExternalTable(data));
new VirtualTable(this, this._gristDoc, ext);
this.autoDispose(new VirtualTableRegistration(this._gristDoc, ext));
this._data.set(data);
}
}

View File

@@ -2,7 +2,7 @@ import {GristDoc} from 'app/client/components/GristDoc';
import {ViewSectionHelper} from 'app/client/components/ViewLayout';
import {makeT} from 'app/client/lib/localization';
import {reportMessage, reportSuccess} from 'app/client/models/errors';
import {IEdit, IExternalTable, VirtualTable} from 'app/client/models/VirtualTable';
import {IEdit, IExternalTable, VirtualTableRegistration} from 'app/client/models/VirtualTable';
import {docListHeader} from 'app/client/ui/DocMenuCss';
import {bigPrimaryButton} from 'app/client/ui2018/buttons';
import {mediaSmall, testId} from 'app/client/ui2018/cssVars';
@@ -337,7 +337,7 @@ class WebhookExternalTable implements IExternalTable {
export class WebhookPage extends DisposableWithEvents {
public docApi = this.gristDoc.docPageModel.appModel.api.getDocAPI(this.gristDoc.docId());
public sharedTable: VirtualTable;
public sharedTable: VirtualTableRegistration;
private _webhookExternalTable: WebhookExternalTable;
@@ -345,10 +345,9 @@ export class WebhookPage extends DisposableWithEvents {
super();
//this._webhooks = observableArray<WebhookSummary>();
this._webhookExternalTable = new WebhookExternalTable(this.docApi);
const table = new VirtualTable(this, gristDoc, this._webhookExternalTable);
const table = this.autoDispose(new VirtualTableRegistration(gristDoc, this._webhookExternalTable));
this.listenTo(gristDoc, 'webhooks', async () => {
await table.lazySync();
});
}