mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) implement a safe mode for opening documents with rule problems
Summary: Adds an "enter safe mode" option and explanation in modal that appears when a document fails to load, if user is owner. If "enter safe mode" is selected, document is reloaded on server in a special mode. Currently, the only difference is that if the acl rules fail to load, they are replaced with a fallback that grants full access to owners and no access to anyone else. An extra tag is shown to mark the document as safe mode, with an "x" for cancelling safe mode. There are other ways a document could fail to load than just acl rules, so this is just a start. Test Plan: added test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2686
This commit is contained in:
@@ -296,7 +296,8 @@ export class DocManager extends EventEmitter {
|
||||
clientId: docSession.client.clientId,
|
||||
doc: metaTables,
|
||||
log: recentActions,
|
||||
plugins: activeDoc.docPluginManager.getPlugins()
|
||||
plugins: activeDoc.docPluginManager.getPlugins(),
|
||||
recoveryMode: activeDoc.recoveryMode,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -364,12 +365,21 @@ export class DocManager extends EventEmitter {
|
||||
/**
|
||||
* Fetches an ActiveDoc object. Used by openDoc.
|
||||
*/
|
||||
public async fetchDoc(docSession: OptDocSession, docName: string): Promise<ActiveDoc> {
|
||||
public async fetchDoc(docSession: OptDocSession, docName: string,
|
||||
wantRecoveryMode?: boolean): Promise<ActiveDoc> {
|
||||
log.debug('DocManager.fetchDoc', docName);
|
||||
// Repeat until we acquire an ActiveDoc that is not muted (shutting down).
|
||||
for (;;) {
|
||||
if (this._activeDocs.has(docName) && wantRecoveryMode !== undefined) {
|
||||
const activeDoc = await this._activeDocs.get(docName);
|
||||
if (activeDoc && activeDoc.recoveryMode !== wantRecoveryMode && activeDoc.isOwner(docSession)) {
|
||||
// shutting doc down to have a chance to re-open in the correct mode.
|
||||
// TODO: there could be a battle with other users opening it in a different mode.
|
||||
await activeDoc.shutdown();
|
||||
}
|
||||
}
|
||||
if (!this._activeDocs.has(docName)) {
|
||||
const newDoc = this.gristServer.create.ActiveDoc(this, docName);
|
||||
const newDoc = this.gristServer.create.ActiveDoc(this, docName, wantRecoveryMode);
|
||||
// Propagate backupMade events from newly opened activeDocs (consolidate all to DocMan)
|
||||
newDoc.on('backupMade', (bakPath: string) => {
|
||||
this.emit('backupMade', bakPath);
|
||||
|
||||
Reference in New Issue
Block a user