feat: add migration pref pane (#825)

* feat: add migration pane

* style: clean imports

* removeme: beta version

* fix: do no show dropzone when tag has no parent

* fix: hide the Folders toggle

* fix: hide migrations option when user has no folders

* fix: add delimiter on Folders mark

* removeme: bump beta

* fix: remove component viewer for tag folders

* removeme: bump beta

* chore(deps): snjs
This commit is contained in:
Laurent Senta
2022-02-01 02:18:14 +01:00
committed by GitHub
parent ed729ab4ef
commit 3c0bc79768
12 changed files with 181 additions and 145 deletions

View File

@@ -5,18 +5,14 @@ import { AccountMenuState } from '@/ui_models/app_state/account_menu_state';
import { isDesktopApplication } from '@/utils';
import {
ApplicationEvent,
ComponentArea,
ContentType,
DeinitSource,
isPayloadSourceInternalChange,
NoteViewController,
PayloadSource,
PrefKey,
SNComponent,
SNNote,
SNSmartTag,
ComponentViewer,
SNTag,
NoteViewController,
} from '@standardnotes/snjs';
import pull from 'lodash/pull';
import {
@@ -91,14 +87,11 @@ export class AppState {
readonly tags: TagsState;
readonly notesView: NotesViewState;
public foldersComponentViewer?: ComponentViewer;
isSessionsModalVisible = false;
private appEventObserverRemovers: (() => void)[] = [];
private readonly tagChangedDisposer: IReactionDisposer;
private readonly foldersComponentViewerDisposer: () => void;
/* @ngInject */
constructor(application: WebApplication, private bridge: Bridge) {
@@ -157,8 +150,6 @@ export class AppState {
this.showBetaWarning = false;
}
this.foldersComponentViewer = undefined;
makeObservable(this, {
selectedTag: computed,
@@ -170,14 +161,9 @@ export class AppState {
disableBetaWarning: action,
openSessionsModal: action,
closeSessionsModal: action,
foldersComponentViewer: observable.ref,
setFoldersComponent: action,
});
this.tagChangedDisposer = this.tagChangedNotifier();
this.foldersComponentViewerDisposer =
this.subscribeToFoldersComponentChanges();
}
deinit(source: DeinitSource): void {
@@ -197,7 +183,6 @@ export class AppState {
document.removeEventListener('visibilitychange', this.onVisibilityChange);
this.onVisibilityChange = undefined;
this.tagChangedDisposer();
this.foldersComponentViewerDisposer();
}
openSessionsModal(): void {
@@ -302,51 +287,6 @@ export class AppState {
);
}
setFoldersComponent(component?: SNComponent) {
const foldersComponentViewer = this.foldersComponentViewer;
if (foldersComponentViewer) {
this.application.componentManager.destroyComponentViewer(
foldersComponentViewer
);
this.foldersComponentViewer = undefined;
}
if (component) {
this.foldersComponentViewer =
this.application.componentManager.createComponentViewer(
component,
undefined,
this.tags.onFoldersComponentMessage.bind(this.tags)
);
}
}
private subscribeToFoldersComponentChanges() {
return this.application.streamItems(
[ContentType.Component],
async (items, source) => {
if (
isPayloadSourceInternalChange(source) ||
source === PayloadSource.InitialObserverRegistrationPush
) {
return;
}
const components = items as SNComponent[];
const hasFoldersChange = !!components.find(
(component) => component.area === ComponentArea.TagsList
);
if (hasFoldersChange) {
const componentViewer = this.application.componentManager
.componentsForArea(ComponentArea.TagsList)
.find((component) => component.active);
this.setFoldersComponent(componentViewer);
}
}
);
}
public get selectedTag(): SNTag | SNSmartTag | undefined {
return this.tags.selected;
}

View File

@@ -195,6 +195,11 @@ export class TagsState {
return this.application.isValidTagParent(parentUuid, tagUuid);
}
public hasParent(tagUuid: UuidString): boolean {
const item = this.application.findItem(tagUuid);
return !!item && !!(item as SNTag).parentId;
}
public async assignParent(
tagUuid: string,
futureParentUuid: string | undefined