(core) Error message on Duplicate Document

Summary: Fixing error message when user can't copy document.

Test Plan: Updated tests

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3130
This commit is contained in:
Jarosław Sadziński
2021-11-09 11:34:26 +01:00
parent 267640c277
commit 96fa7ad562
4 changed files with 27 additions and 9 deletions

View File

@@ -304,6 +304,7 @@ export class Notifier extends Disposable implements INotifier {
// This is exposed primarily for tests.
public clearAppErrors() {
this._appErrorList.splice(0);
this._appErrorToast.clear();
}
/**

View File

@@ -154,9 +154,18 @@ class SaveCopyModal extends Disposable {
const org = this._destOrg.get();
const docWorker = await api.getWorkerAPI('import');
const destName = this._destName.get() + '.grist';
const uploadId = await docWorker.copyDoc(this._doc.id, this._asTemplate.get(), destName);
const {id} = await docWorker.importDocToWorkspace(uploadId, ws.id);
await urlState().pushUrl({org: org?.domain || undefined, doc: id, docPage: urlState().state.get().docPage});
try {
const uploadId = await docWorker.copyDoc(this._doc.id, this._asTemplate.get(), destName);
const {id} = await docWorker.importDocToWorkspace(uploadId, ws.id);
await urlState().pushUrl({org: org?.domain || undefined, doc: id, docPage: urlState().state.get().docPage});
} catch(err) {
// Convert access denied errors to normal Error to make it consistent with other endpoints.
// TODO: Should not allow to click this button when user doesn't have permissions.
if (err.status === 403) {
throw new Error(err.details.userError || err.message);
}
throw err;
}
}
public buildDom() {