fix: prevent restoring version if note is locked

This commit is contained in:
Antonella Sgarlatta
2021-07-12 19:30:57 -03:00
parent bd65ca0815
commit 86fd93ab0e
2 changed files with 7 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ import {
import template from '%/directives/revision-preview-modal.pug';
import { PayloadContent } from '@standardnotes/snjs';
import { confirmDialog } from '@/services/alertService';
import { STRING_RESTORE_LOCKED_ATTEMPT } from '@/strings';
interface RevisionPreviewScope {
uuid: string
@@ -108,6 +109,10 @@ class RevisionPreviewModalCtrl extends PureViewCtrl implements RevisionPreviewSc
};
if (!asCopy) {
if (this.originalNote.locked) {
this.application.alertService.alert(STRING_RESTORE_LOCKED_ATTEMPT);
return;
}
confirmDialog({
text: "Are you sure you want to replace the current note's contents with what you see in this preview?",
confirmButtonStyle: "danger"

View File

@@ -42,6 +42,8 @@ export const STRING_DELETE_LOCKED_ATTEMPT =
"This note had editing disabled. If you'd like to delete it, enable editing, and try again.";
export const STRING_EDIT_LOCKED_ATTEMPT =
"This note has editing disabled. If you'd like to edit its options, enable editing, and try again.";
export const STRING_RESTORE_LOCKED_ATTEMPT =
"This note has editing disabled. If you'd like to restore a different version if it, enable editing, and try again."
export function StringDeleteNote(title: string, permanently: boolean) {
return permanently
? `Are you sure you want to permanently delete ${title}?`