From 8d9b192b81e13d385fd4664e2a5a1a1d97b32d95 Mon Sep 17 00:00:00 2001 From: Mo Date: Thu, 21 Oct 2021 13:06:49 -0500 Subject: [PATCH] feat: remove extensions manager (#696) * feat: remove extensions manager * fix: remove unused code Co-authored-by: Aman Harwara --- .env.sample | 2 - .github/workflows/beta.yml | 3 - .github/workflows/dev.yml | 3 - .github/workflows/prod.yml | 3 - .gitmodules | 10 -- Gemfile.lock | 3 + README.md | 10 -- .../javascripts/services/nativeExtManager.ts | 118 --------------- .../javascripts/ui_models/application.ts | 6 - .../ui_models/application_group.ts | 3 - .../javascripts/views/footer/footer-view.pug | 32 ---- .../javascripts/views/footer/footer_view.ts | 142 +----------------- app/extensions/extensions-manager | 1 - app/views/application/app.html.erb | 2 - index.html | 2 - package.json | 3 +- public/extensions/extensions-manager | 1 - 17 files changed, 12 insertions(+), 332 deletions(-) delete mode 100644 app/assets/javascripts/services/nativeExtManager.ts delete mode 160000 app/extensions/extensions-manager delete mode 160000 public/extensions/extensions-manager diff --git a/.env.sample b/.env.sample index 8626915d2..21b6626a9 100644 --- a/.env.sample +++ b/.env.sample @@ -9,12 +9,10 @@ SECRET_KEY_BASE=test APP_HOST=http://localhost:3001 PURCHASE_URL=https://standardnotes.com/purchase -EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html SF_DEFAULT_SERVER=http://localhost:3000 # Development options DEV_DEFAULT_SYNC_SERVER=https://api.standardnotes.com -DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html ENABLE_UNFINISHED_FEATURES=false DEV_WEBSOCKET_URL=wss://sockets-dev.standardnotes.com diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 183b866c2..d8dee60ec 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -31,9 +31,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Initiate submodules - run: git submodule update --init - - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@master with: diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 32a685848..088b40ed7 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -35,9 +35,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Initiate submodules - run: git submodule update --init - - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@master with: diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 04b9144b3..f1ebce04e 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -35,9 +35,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Initiate submodules - run: git submodule update --init - - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@master with: diff --git a/.gitmodules b/.gitmodules index adb7eaeaa..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,10 +0,0 @@ -[submodule "vendor/extensions/extensions-manager"] - path = vendor/extensions/extensions-manager - url = https://github.com/sn-extensions/extensions-manager.git -[submodule "app/extensions/extensions-manager"] - path = app/extensions/extensions-manager - url = https://github.com/sn-extensions/extensions-manager.git -[submodule "public/extensions/extensions-manager"] - path = public/extensions/extensions-manager - url = https://github.com/sn-extensions/extensions-manager.git - diff --git a/Gemfile.lock b/Gemfile.lock index d2fe3cd95..e6dbdab88 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,6 +107,8 @@ GEM racc (~> 1.4) nokogiri (1.11.1-x64-mingw32) racc (~> 1.4) + nokogiri (1.11.1-x86_64-darwin) + racc (~> 1.4) non-stupid-digest-assets (1.0.9) sprockets (>= 2.0) puma (4.3.5) @@ -200,6 +202,7 @@ GEM PLATFORMS ruby x64-mingw32 + x86_64-darwin-18 DEPENDENCIES byebug diff --git a/README.md b/README.md index e623f0f1f..e7512f18a 100644 --- a/README.md +++ b/README.md @@ -97,16 +97,6 @@ Then open your browser to `http://localhost:3001`. --- -**Extensions Manager and Batch Manager:** - -The web app makes use of two optional native extensions, which, when running the app with Rails, can be configured to work as follows: - -1. `git submodule update --init` (will load the submodules in the `public/extensions` folder) -1. Set the following environment variables in the .env file: - ``` - EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html - ``` - You can also set the `SF_DEFAULT_SERVER` environment variable to set the default server for login and registration. ``` diff --git a/app/assets/javascripts/services/nativeExtManager.ts b/app/assets/javascripts/services/nativeExtManager.ts deleted file mode 100644 index 890bc454b..000000000 --- a/app/assets/javascripts/services/nativeExtManager.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { isDesktopApplication } from '@/utils'; -import { - SNPredicate, - ContentType, - SNComponent, - ApplicationService, - ComponentAction, - FillItemContent, - ComponentMutator, - Copy, - PayloadContent, - ComponentPermission } from '@standardnotes/snjs'; - -/** A class for handling installation of system extensions */ -export class NativeExtManager extends ApplicationService { - extManagerId = 'org.standardnotes.extensions-manager'; - - /** @override */ - async onAppLaunch() { - super.onAppLaunch(); - this.reload(); - } - - get extManagerPred() { - const extManagerId = 'org.standardnotes.extensions-manager'; - return SNPredicate.CompoundPredicate([ - new SNPredicate('content_type', '=', ContentType.Component), - new SNPredicate('package_info.identifier', '=', extManagerId) - ]); - } - - get extMgrUrl() { - return (window as any)._extensions_manager_location; - } - - reload() { - this.application!.singletonManager!.registerPredicate(this.extManagerPred); - this.resolveExtensionsManager(); - } - - async resolveExtensionsManager() { - const extensionsManager = (await this.application!.singletonManager!.findOrCreateSingleton( - this.extManagerPred, - ContentType.Component, - this.extensionsManagerTemplateContent() - )) as SNComponent; - let needsSync = false; - if (isDesktopApplication()) { - if (!extensionsManager.local_url) { - await this.application!.changeItem(extensionsManager.uuid, (m) => { - const mutator = m as ComponentMutator; - mutator.local_url = this.extMgrUrl; - }); - needsSync = true; - } - } else { - if (!extensionsManager.hosted_url) { - await this.application!.changeItem(extensionsManager.uuid, (m) => { - const mutator = m as ComponentMutator; - mutator.hosted_url = this.extMgrUrl; - }); - needsSync = true; - } - } - // Handle addition of SN|ExtensionRepo permission - const permissions = Copy(extensionsManager!.permissions) as ComponentPermission[]; - const permission = permissions.find((p) => { - return p.name === ComponentAction.StreamItems; - }); - if (permission && !permission.content_types!.includes(ContentType.ExtensionRepo)) { - permission.content_types!.push(ContentType.ExtensionRepo); - await this.application!.changeItem(extensionsManager.uuid, (m) => { - const mutator = m as ComponentMutator; - mutator.permissions = permissions; - }); - needsSync = true; - } - if (needsSync) { - this.application!.saveItem(extensionsManager.uuid); - } - } - - extensionsManagerTemplateContent() { - const url = this.extMgrUrl; - if (!url) { - throw Error('this.extMgrUrl must be set.'); - } - const packageInfo = { - name: 'Extensions', - identifier: this.extManagerId - }; - const content = FillItemContent({ - name: packageInfo.name, - area: 'rooms', - package_info: packageInfo, - permissions: [ - { - name: ComponentAction.StreamItems, - content_types: [ - ContentType.Component, - ContentType.Theme, - ContentType.ServerExtension, - ContentType.ActionsExtension, - ContentType.Mfa, - ContentType.Editor, - ContentType.ExtensionRepo - ] - } - ] - }) as PayloadContent; - if (isDesktopApplication()) { - content.local_url = this.extMgrUrl; - } else { - content.hosted_url = this.extMgrUrl; - } - return content; - } -} diff --git a/app/assets/javascripts/ui_models/application.ts b/app/assets/javascripts/ui_models/application.ts index a11dd17d4..fbf1f7bad 100644 --- a/app/assets/javascripts/ui_models/application.ts +++ b/app/assets/javascripts/ui_models/application.ts @@ -21,7 +21,6 @@ import { AutolockService } from '@/services/autolock_service'; import { ArchiveManager } from '@/services/archiveManager'; import { DesktopManager } from '@/services/desktopManager'; import { IOService } from '@/services/ioService'; -import { NativeExtManager } from '@/services/nativeExtManager'; import { StatusManager } from '@/services/statusManager'; import { ThemeManager } from '@/services/themeManager'; import { AppVersion } from '@/version'; @@ -32,7 +31,6 @@ type WebServices = { desktopService: DesktopManager; autolockService: AutolockService; archiveService: ArchiveManager; - nativeExtService: NativeExtManager; statusManager: StatusManager; themeService: ThemeManager; io: IOService; @@ -133,10 +131,6 @@ export class WebApplication extends SNApplication { return this.webServices.archiveService; } - public getNativeExtService() { - return this.webServices.nativeExtService; - } - getStatusManager() { return this.webServices.statusManager; } diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index b9230eb1f..5b422a569 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -14,7 +14,6 @@ import { DesktopManager } from '@/services/desktopManager'; import { IOService } from '@/services/ioService'; import { AutolockService } from '@/services/autolock_service'; import { StatusManager } from '@/services/statusManager'; -import { NativeExtManager } from '@/services/nativeExtManager'; import { ThemeManager } from '@/services/themeManager'; export class ApplicationGroup extends SNApplicationGroup { @@ -85,7 +84,6 @@ export class ApplicationGroup extends SNApplicationGroup { platform === Platform.MacWeb || platform === Platform.MacDesktop ); const autolockService = new AutolockService(application); - const nativeExtService = new NativeExtManager(application); const statusManager = new StatusManager(); const themeService = new ThemeManager(application); application.setWebServices({ @@ -94,7 +92,6 @@ export class ApplicationGroup extends SNApplicationGroup { desktopService, io, autolockService, - nativeExtService, statusManager, themeService, }); diff --git a/app/assets/javascripts/views/footer/footer-view.pug b/app/assets/javascripts/views/footer/footer-view.pug index e24019f37..f4e95fbe3 100644 --- a/app/assets/javascripts/views/footer/footer-view.pug +++ b/app/assets/javascripts/views/footer/footer-view.pug @@ -39,23 +39,6 @@ app-state='ctrl.appState' application='ctrl.application' ng-if='ctrl.showQuickSettingsMenu',) - .sk-app-bar-item - a.no-decoration.sk-label.title( - href='https://standardnotes.com/help', - rel='noopener', - target='_blank' - ) - | Help - .sk-app-bar-item.border - .sk-app-bar-item(ng-repeat='room in ctrl.rooms track by room.uuid') - .sk-app-bar-item-column(ng-click='ctrl.selectRoom(room)') - .sk-label {{room.name}} - component-modal( - component-uuid='room.uuid', - ng-if='ctrl.roomShowState[room.uuid]', - on-dismiss='ctrl.onRoomDismiss(room)', - application='ctrl.application' - ) .sk-app-bar-item.border(ng-if="ctrl.state.showBetaWarning") .sk-app-bar-item(ng-if="ctrl.state.showBetaWarning") a.no-decoration.sk-label.title( @@ -89,21 +72,6 @@ ) .sk-app-bar-item(ng-if='ctrl.offline') .sk-label Offline - .sk-app-bar-item.border(ng-if='ctrl.state.dockShortcuts.length > 0') - .sk-app-bar-item.dock-shortcut(ng-repeat='shortcut in ctrl.state.dockShortcuts') - .sk-app-bar-item-column( - ng-class="{'underline': shortcut.component.active}", - ng-click='ctrl.selectShortcut(shortcut)' - ) - .div(ng-if="shortcut.icon.type == 'circle'" title='{{shortcut.name}}') - .sk-circle.small( - ng-style="{'background-color': shortcut.icon.background_color, 'border-color': shortcut.icon.border_color}" - ) - .div(ng-if="shortcut.icon.type == 'svg'" title='{{shortcut.name}}') - .svg-item( - elem-ready='ctrl.initSvgForShortcut(shortcut)', - ng-attr-id='dock-svg-{{shortcut.component.uuid}}' - ) .sk-app-bar-item.border(ng-if='ctrl.state.hasAccountSwitcher') .sk-app-bar-item( ng-if='ctrl.state.hasAccountSwitcher' diff --git a/app/assets/javascripts/views/footer/footer_view.ts b/app/assets/javascripts/views/footer/footer_view.ts index c0064484c..f508e6485 100644 --- a/app/assets/javascripts/views/footer/footer_view.ts +++ b/app/assets/javascripts/views/footer/footer_view.ts @@ -5,7 +5,6 @@ import { preventRefreshing } from '@/utils'; import { ApplicationEvent, ContentType, - SNComponent, SNTheme, ComponentArea, CollectionSort, @@ -31,34 +30,21 @@ import { AccountMenuPane } from '@/components/AccountMenu'; const ACCOUNT_SWITCHER_ENABLED = false; const ACCOUNT_SWITCHER_FEATURE_KEY = 'account_switcher'; -type DockShortcut = { - name: string; - component: SNComponent; - icon: { - type: string; - background_color: string; - border_color: string; - }; -}; - class FooterViewCtrl extends PureViewCtrl< unknown, { outOfSync: boolean; hasPasscode: boolean; dataUpgradeAvailable: boolean; - dockShortcuts: DockShortcut[]; hasAccountSwitcher: boolean; showBetaWarning: boolean; showDataUpgrade: boolean; } > { private $rootScope: ng.IRootScopeService; - private rooms: SNComponent[] = []; private themesWithIcons: SNTheme[] = []; private showSyncResolution = false; private unregisterComponent: any; - private rootScopeListener1: any; private rootScopeListener2: any; public arbitraryStatusMessage?: string; public user?: any; @@ -66,12 +52,8 @@ class FooterViewCtrl extends PureViewCtrl< public showAccountMenu = false; public showQuickSettingsMenu = false; private didCheckForOffline = false; - private queueExtReload = false; - private reloadInProgress = false; public hasError = false; public newUpdateAvailable = false; - public dockShortcuts: DockShortcut[] = []; - public roomShowState: Partial> = {}; private observerRemovers: Array<() => void> = []; private completedInitialSync = false; private showingDownloadStatus = false; @@ -92,16 +74,13 @@ class FooterViewCtrl extends PureViewCtrl< deinit() { for (const remove of this.observerRemovers) remove(); this.observerRemovers.length = 0; - this.rooms.length = 0; this.themesWithIcons.length = 0; this.unregisterComponent(); this.unregisterComponent = undefined; - this.rootScopeListener1(); this.rootScopeListener2(); - this.rootScopeListener1 = undefined; this.rootScopeListener2 = undefined; - (this.closeAccountMenu as any) = undefined; - (this.toggleSyncResolutionMenu as any) = undefined; + (this.closeAccountMenu as unknown) = undefined; + (this.toggleSyncResolutionMenu as unknown) = undefined; super.deinit(); } @@ -141,7 +120,6 @@ class FooterViewCtrl extends PureViewCtrl< outOfSync: false, dataUpgradeAvailable: false, hasPasscode: false, - dockShortcuts: [], descriptors: this.mainApplicationGroup.getDescriptors(), hasAccountSwitcher: false, showBetaWarning: false, @@ -185,12 +163,6 @@ class FooterViewCtrl extends PureViewCtrl< } addRootScopeListeners() { - this.rootScopeListener1 = this.$rootScope.$on( - RootScopeMessages.ReloadExtendedData, - () => { - this.reloadExtendedData(); - } - ); this.rootScopeListener2 = this.$rootScope.$on( RootScopeMessages.NewUpdateAvailable, () => { @@ -207,7 +179,6 @@ class FooterViewCtrl extends PureViewCtrl< switch (eventName) { case AppStateEvent.EditorFocused: if (data.eventSource === EventSource.UserInteraction) { - this.closeAllRooms(); this.closeAccountMenu(); } break; @@ -303,37 +274,21 @@ class FooterViewCtrl extends PureViewCtrl< } ); - this.observerRemovers.push( - this.application.streamItems(ContentType.Component, async () => { - const components = this.application.getItems( - ContentType.Component - ) as SNComponent[]; - this.rooms = components.filter((candidate) => { - return candidate.area === ComponentArea.Rooms && !candidate.deleted; - }); - if (this.queueExtReload) { - this.queueExtReload = false; - this.reloadExtendedData(); - } - }) - ); - this.observerRemovers.push( this.application.streamItems(ContentType.Theme, async () => { const themes = this.application.getDisplayableItems( ContentType.Theme ) as SNTheme[]; this.themesWithIcons = themes; - this.reloadDockShortcuts(); }) ); } registerComponentHandler() { this.unregisterComponent = - this.application.componentManager!.registerHandler({ + this.application.componentManager.registerHandler({ identifier: 'room-bar', - areas: [ComponentArea.Rooms, ComponentArea.Modal], + areas: [ComponentArea.Modal], focusHandler: (component, focused) => { if (component.isEditor() && focused) { if ( @@ -342,7 +297,6 @@ class FooterViewCtrl extends PureViewCtrl< ) { return; } - this.closeAllRooms(); this.closeAccountMenu(); } }, @@ -351,7 +305,7 @@ class FooterViewCtrl extends PureViewCtrl< updateSyncStatus() { const statusManager = this.application.getStatusManager(); - const syncStatus = this.application!.getSyncStatus(); + const syncStatus = this.application.getSyncStatus(); const stats = syncStatus.getStats(); if (syncStatus.hasError()) { statusManager.setMessage('Unable to Sync'); @@ -385,9 +339,9 @@ class FooterViewCtrl extends PureViewCtrl< updateLocalDataStatus() { const statusManager = this.application.getStatusManager(); - const syncStatus = this.application!.getSyncStatus(); + const syncStatus = this.application.getSyncStatus(); const stats = syncStatus.getStats(); - const encryption = this.application!.isEncryptionAvailable(); + const encryption = this.application.isEncryptionAvailable(); if (stats.localDataDone) { statusManager.setMessage(''); return; @@ -399,35 +353,6 @@ class FooterViewCtrl extends PureViewCtrl< statusManager.setMessage(loadingStatus); } - reloadExtendedData() { - if (this.reloadInProgress) { - return; - } - this.reloadInProgress = true; - - /** - * A reload consists of opening the extensions manager, - * then closing it after a short delay. - */ - const extWindow = this.rooms.find((room) => { - return ( - room.package_info.identifier === - this.application.getNativeExtService().extManagerId - ); - }); - if (!extWindow) { - this.queueExtReload = true; - this.reloadInProgress = false; - return; - } - this.selectRoom(extWindow); - this.$timeout(() => { - this.selectRoom(extWindow); - this.reloadInProgress = false; - this.$rootScope.$broadcast('ext-reload-complete'); - }, 2000); - } - updateOfflineStatus() { this.offline = this.application.noAccount(); } @@ -453,7 +378,6 @@ class FooterViewCtrl extends PureViewCtrl< accountMenuPressed() { this.appState.quickSettingsMenu.closeQuickSettingsMenu(); this.appState.accountMenu.toggleShow(); - this.closeAllRooms(); } quickSettingsPressed() { @@ -463,7 +387,6 @@ class FooterViewCtrl extends PureViewCtrl< } else { this.appState.preferences.openPreferences(); } - this.closeAllRooms(); } toggleSyncResolutionMenu() { @@ -485,56 +408,7 @@ class FooterViewCtrl extends PureViewCtrl< clickedNewUpdateAnnouncement() { this.newUpdateAvailable = false; - this.application.alertService!.alert(STRING_NEW_UPDATE_READY); - } - - reloadDockShortcuts() { - const shortcuts: DockShortcut[] = []; - this.setState({ - dockShortcuts: shortcuts.sort((a, b) => { - /** Circles first, then images */ - const aType = a.icon.type; - const bType = b.icon.type; - if (aType === 'circle' && bType === 'svg') { - return -1; - } else if (bType === 'circle' && aType === 'svg') { - return 1; - } else { - return a.name.localeCompare(b.name); - } - }), - }); - } - - initSvgForShortcut(shortcut: DockShortcut) { - const id = 'dock-svg-' + shortcut.component.uuid; - const element = document.getElementById(id)!; - const parser = new DOMParser(); - const svg = shortcut.component.package_info.dock_icon?.source; - if (svg != undefined) { - const doc = parser.parseFromString(svg, 'image/svg+xml'); - element.appendChild(doc.documentElement); - } - } - - selectShortcut(shortcut: DockShortcut) { - this.application.toggleComponent(shortcut.component); - } - - onRoomDismiss(room: SNComponent) { - this.roomShowState[room.uuid] = false; - } - - closeAllRooms() { - for (const room of this.rooms) { - this.roomShowState[room.uuid] = false; - } - } - - async selectRoom(room: SNComponent) { - this.$timeout(() => { - this.roomShowState[room.uuid] = !this.roomShowState[room.uuid]; - }); + this.application.alertService.alert(STRING_NEW_UPDATE_READY); } displayBetaDialog() { diff --git a/app/extensions/extensions-manager b/app/extensions/extensions-manager deleted file mode 160000 index 81642c6e4..000000000 --- a/app/extensions/extensions-manager +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 81642c6e4ee0ae8232732b8763e9bed91badce23 diff --git a/app/views/application/app.html.erb b/app/views/application/app.html.erb index c13c3c7d1..46d740df4 100644 --- a/app/views/application/app.html.erb +++ b/app/views/application/app.html.erb @@ -32,8 +32,6 @@