feat: batch manager protection + react challenge modal + eslint fix

This commit is contained in:
Baptiste Grob
2021-01-22 11:37:58 +01:00
parent c6ff28b40e
commit 5d65364885
25 changed files with 1009 additions and 829 deletions

View File

@@ -10,6 +10,7 @@ import {
UuidString,
SyncOpStatus,
PrefKey,
Challenge,
} from '@standardnotes/snjs';
import { WebApplication } from '@/ui_models/application';
import { Editor } from '@/ui_models/editor';
@@ -289,10 +290,7 @@ export class AppState {
} else if (
note.archived &&
!this.selectedTag?.isArchiveTag &&
!this.application.getPreference(
PrefKey.NotesShowArchived,
false
)
!this.application.getPreference(PrefKey.NotesShowArchived, false)
) {
this.closeEditor(editor);
}

View File

@@ -7,7 +7,6 @@ import { PasswordWizardType, PasswordWizardScope } from '@/types';
import {
SNApplication,
platformFromString,
Challenge,
SNComponent,
PermissionDialog,
DeinitSource,
@@ -42,9 +41,9 @@ type WebServices = {
export class WebApplication extends SNApplication {
private scope?: ng.IScope
private scope?: angular.IScope
private webServices!: WebServices
private currentAuthenticationElement?: JQLite
private currentAuthenticationElement?: angular.IRootElementService
public editorGroup: EditorGroup
public componentGroup: ComponentGroup
@@ -52,8 +51,8 @@ export class WebApplication extends SNApplication {
constructor(
deviceInterface: WebDeviceInterface,
identifier: string,
private $compile: ng.ICompileService,
scope: ng.IScope,
private $compile: angular.ICompileService,
scope: angular.IScope,
defaultSyncServerHost: string,
private bridge: Bridge,
) {
@@ -98,10 +97,10 @@ export class WebApplication extends SNApplication {
* to complete before destroying the global application instance and all its services */
setTimeout(() => {
super.deinit(source);
}, 0)
}, 0);
}
onStart() {
onStart(): void {
super.onStart();
this.componentManager!.openModalComponent = this.openModalComponent;
this.componentManager!.presentPermissionsDialog = this.presentPermissionsDialog;
@@ -158,18 +157,6 @@ export class WebApplication extends SNApplication {
this.applicationElement.append(el);
}
promptForChallenge(challenge: Challenge) {
const scope: any = this.scope!.$new(true);
scope.challenge = challenge;
scope.application = this;
const el = this.$compile!(
"<challenge-modal " +
"class='sk-modal' application='application' challenge='challenge'>" +
"</challenge-modal>"
)(scope);
this.applicationElement.append(el);
}
authenticationInProgress() {
return this.currentAuthenticationElement != null;
}
@@ -214,7 +201,12 @@ export class WebApplication extends SNApplication {
this.applicationElement.append(el);
}
openModalComponent(component: SNComponent) {
async openModalComponent(component: SNComponent): Promise<void> {
if (component.package_info?.identifier === "org.standardnotes.batch-manager") {
if (!await this.authorizeBatchManagerAccess()) {
return;
}
}
const scope = this.scope!.$new(true) as Partial<ComponentModalScope>;
scope.componentUuid = component.uuid;
scope.application = this;

View File

@@ -1,13 +1,13 @@
import { SNComponent, ComponentArea, removeFromArray, addIfUnique } from '@standardnotes/snjs';
import { SNComponent, ComponentArea, removeFromArray, addIfUnique , UuidString } from '@standardnotes/snjs';
import { WebApplication } from './application';
import { UuidString } from '@standardnotes/snjs';
/** Areas that only allow a single component to be active */
const SingleComponentAreas = [
ComponentArea.Editor,
ComponentArea.NoteTags,
ComponentArea.TagsList
]
];
export class ComponentGroup {
@@ -20,7 +20,7 @@ export class ComponentGroup {
}
get componentManager() {
return this.application?.componentManager!;
return this.application.componentManager!;
}
public deinit() {
@@ -91,7 +91,7 @@ export class ComponentGroup {
callback();
return () => {
removeFromArray(this.changeObservers, callback);
}
};
}
private notifyObservers() {

View File

@@ -68,7 +68,7 @@ export class EditorGroup {
}
return () => {
removeFromArray(this.changeObservers, callback);
}
};
}
private notifyObservers() {