feat: show protected warning after protecting a note without protections
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
#editor-column.section.editor.sn-component(aria-label='Note')
|
#editor-column.section.editor.sn-component(aria-label='Note')
|
||||||
protected-note-panel.h-full.flex.justify-center.items-center(
|
protected-note-panel.h-full.flex.justify-center.items-center(
|
||||||
ng-if='self.note.protected && !self.state.showEditor'
|
ng-if='self.state.showProtectedWarning'
|
||||||
app-state='self.appState'
|
app-state='self.appState'
|
||||||
on-view-note='self.dismissProtectedWarning()'
|
on-view-note='self.dismissProtectedWarning()'
|
||||||
)
|
)
|
||||||
.flex-grow.flex.flex-col(
|
.flex-grow.flex.flex-col(
|
||||||
ng-if='self.state.showEditor'
|
ng-if='!self.state.showProtectedWarning'
|
||||||
)
|
)
|
||||||
.sn-component
|
.sn-component
|
||||||
.sk-app-bar.no-edges(
|
.sk-app-bar.no-edges(
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ type EditorState = {
|
|||||||
textareaUnloading: boolean
|
textareaUnloading: boolean
|
||||||
/** Fields that can be directly mutated by the template */
|
/** Fields that can be directly mutated by the template */
|
||||||
mutable: any
|
mutable: any
|
||||||
showEditor: boolean
|
showProtectedWarning: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditorValues = {
|
type EditorValues = {
|
||||||
@@ -225,7 +225,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
mutable: {
|
mutable: {
|
||||||
tagsString: ''
|
tagsString: ''
|
||||||
},
|
},
|
||||||
showEditor: false,
|
showProtectedWarning: false,
|
||||||
} as EditorState;
|
} as EditorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
async handleEditorNoteChange() {
|
async handleEditorNoteChange() {
|
||||||
this.cancelPendingSetStatus();
|
this.cancelPendingSetStatus();
|
||||||
const note = this.editor.note;
|
const note = this.editor.note;
|
||||||
const showEditor = !note.protected;
|
const showProtectedWarning = note.protected && !this.application.hasProtectionSources();
|
||||||
await this.setState({
|
await this.setState({
|
||||||
showActionsMenu: false,
|
showActionsMenu: false,
|
||||||
showOptionsMenu: false,
|
showOptionsMenu: false,
|
||||||
@@ -283,7 +283,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
showHistoryMenu: false,
|
showHistoryMenu: false,
|
||||||
altKeyDown: false,
|
altKeyDown: false,
|
||||||
noteStatus: undefined,
|
noteStatus: undefined,
|
||||||
showEditor,
|
showProtectedWarning,
|
||||||
});
|
});
|
||||||
this.editorValues.title = note.title;
|
this.editorValues.title = note.title;
|
||||||
this.editorValues.text = note.text;
|
this.editorValues.text = note.text;
|
||||||
@@ -292,14 +292,14 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
this.reloadPreferences();
|
this.reloadPreferences();
|
||||||
this.reloadStackComponents();
|
this.reloadStackComponents();
|
||||||
this.reloadNoteTagsComponent();
|
this.reloadNoteTagsComponent();
|
||||||
if (note.safeText().length === 0 && showEditor) {
|
if (note.safeText().length === 0 && !showProtectedWarning) {
|
||||||
this.focusTitle();
|
this.focusTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async dismissProtectedWarning() {
|
async dismissProtectedWarning() {
|
||||||
await this.setState({
|
await this.setState({
|
||||||
showEditor: true
|
showProtectedWarning: false
|
||||||
});
|
});
|
||||||
this.focusTitle();
|
this.focusTitle();
|
||||||
}
|
}
|
||||||
@@ -730,13 +730,9 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
} else {
|
} else {
|
||||||
const note = await this.application.protectNote(this.note);
|
const note = await this.application.protectNote(this.note);
|
||||||
if (note?.protected && !this.application.hasProtectionSources()) {
|
if (note?.protected && !this.application.hasProtectionSources()) {
|
||||||
if (await confirmDialog({
|
this.setState({
|
||||||
text: Strings.protectingNoteWithoutProtectionSources,
|
showProtectedWarning: true
|
||||||
confirmButtonText: Strings.openAccountMenu,
|
});
|
||||||
confirmButtonStyle: 'info',
|
|
||||||
})) {
|
|
||||||
this.appState.accountMenu.setShow(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user