From 5e7930b2590bb3b5c2a515334f5b6ed7c8fecdfa Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Fri, 19 Jan 2024 13:35:58 +0100 Subject: [PATCH] refactor: remove vuex store Removes the vuex store dependency from the project after successfully migrating all store modules to pinia. --- .npmrc | 1 - changelog/unreleased/change-auth-store | 16 ------ changelog/unreleased/change-capability-store | 11 ---- .../unreleased/change-configuration-store | 8 --- changelog/unreleased/change-creating-modals | 9 ---- changelog/unreleased/change-message-handling | 8 --- changelog/unreleased/change-resources-store | 10 ---- changelog/unreleased/change-spaces-store | 8 --- .../unreleased/change-vuex-store-removed | 52 +++++++++++++++++++ packages/extension-sdk/index.mjs | 1 - packages/web-app-draw-io/package.json | 3 +- packages/web-app-external/package.json | 1 - packages/web-app-files/package.json | 1 - packages/web-app-ocm/package.json | 1 - packages/web-app-pdf-viewer/package.json | 3 +- packages/web-app-preview/package.json | 3 +- packages/web-app-text-editor/package.json | 3 +- packages/web-pkg/package.json | 3 +- packages/web-pkg/src/apps/types.ts | 3 -- packages/web-pkg/src/composables/index.ts | 1 - .../web-pkg/src/composables/store/index.ts | 1 - .../web-pkg/src/composables/store/useStore.ts | 6 --- packages/web-runtime/package.json | 1 - packages/web-runtime/src/container/api.ts | 44 +--------------- .../src/container/application/classic.ts | 9 +--- .../src/container/application/index.ts | 6 --- .../web-runtime/src/container/bootstrap.ts | 18 ------- packages/web-runtime/src/container/types.ts | 3 -- packages/web-runtime/src/index.ts | 32 ++++-------- packages/web-runtime/src/store/index.ts | 10 ---- packages/web-test-helpers/package.json | 3 +- pnpm-lock.yaml | 43 --------------- 32 files changed, 69 insertions(+), 253 deletions(-) delete mode 100644 changelog/unreleased/change-auth-store delete mode 100644 changelog/unreleased/change-capability-store delete mode 100644 changelog/unreleased/change-configuration-store delete mode 100644 changelog/unreleased/change-creating-modals delete mode 100644 changelog/unreleased/change-message-handling delete mode 100644 changelog/unreleased/change-resources-store delete mode 100644 changelog/unreleased/change-spaces-store create mode 100644 changelog/unreleased/change-vuex-store-removed delete mode 100644 packages/web-pkg/src/composables/store/index.ts delete mode 100644 packages/web-pkg/src/composables/store/useStore.ts delete mode 100644 packages/web-runtime/src/store/index.ts diff --git a/.npmrc b/.npmrc index 852662a0b9b..8ecc26f15a0 100644 --- a/.npmrc +++ b/.npmrc @@ -16,7 +16,6 @@ public-hoist-pattern[]=webdav hoist-pattern[]=sass # @vue/test-utils (@1.3.0 ?) -hoist-pattern[]=vuex # eslint (public so they are picked up by IDEs) public-hoist-pattern[]=*eslint* diff --git a/changelog/unreleased/change-auth-store b/changelog/unreleased/change-auth-store deleted file mode 100644 index b6d1025d072..00000000000 --- a/changelog/unreleased/change-auth-store +++ /dev/null @@ -1,16 +0,0 @@ -Change: Auth store to pinia - -BREAKING CHANGE for developers: Auth information is no longer stored in a vuex store but in pinia instead. You can access all the store functionality via the new `useAuthStore` composable. - -Note that the following composables have also been removed in favour of the pinia composable: - -- `useAccessToken` -- `usePublicLinkContext` -- `usePublicLinkPassword` -- `usePublicLinkToken` -- `useUserContext` - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10323 -https://github.com/owncloud/web/issues/10210 diff --git a/changelog/unreleased/change-capability-store b/changelog/unreleased/change-capability-store deleted file mode 100644 index 66d981aa55b..00000000000 --- a/changelog/unreleased/change-capability-store +++ /dev/null @@ -1,11 +0,0 @@ -Change: Capability store - -BREAKING CHANGE for developers: The capabilities have been moved from vuex store to pinia. We also removed the `use...Capability` composables in favor of the new pinia store composable: `useCapabilityStore`. - -Furthermore, the `enabled` callback as well as the `name` callback of the `AppNavigationItem` no longer have the `capabilities` parameter. - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10296 -https://github.com/owncloud/web/issues/10210 -https://github.com/owncloud/web/issues/9748 diff --git a/changelog/unreleased/change-configuration-store b/changelog/unreleased/change-configuration-store deleted file mode 100644 index ac16a129228..00000000000 --- a/changelog/unreleased/change-configuration-store +++ /dev/null @@ -1,8 +0,0 @@ -Change: Configuration store to pinia - -BREAKING CHANGE for developers: Configuration is no longer stored in a vuex store but in pinia instead. You can access it via the new `useConfigStore` composable. The `ConfigurationManager` has also been removed in favour of this composable. - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10336 -https://github.com/owncloud/web/issues/10210 diff --git a/changelog/unreleased/change-creating-modals b/changelog/unreleased/change-creating-modals deleted file mode 100644 index 84dd4f4fe78..00000000000 --- a/changelog/unreleased/change-creating-modals +++ /dev/null @@ -1,9 +0,0 @@ -Change: Creating modals - -BREAKING CHANGE for developers: The way how to work with modals has been reworked. Modals can now be registered via the `dispatchModal` method provided by the `useModals` composable, instead of calling `createModal` or `hideModal` from the store. - -For more details on how to use the modal please see the linked PR down below. - -https://github.com/owncloud/web/pull/10212 -https://github.com/owncloud/web/pull/10239 -https://github.com/owncloud/web/issues/10095 diff --git a/changelog/unreleased/change-message-handling b/changelog/unreleased/change-message-handling deleted file mode 100644 index 384ad1108d5..00000000000 --- a/changelog/unreleased/change-message-handling +++ /dev/null @@ -1,8 +0,0 @@ -Change: Message handling to pinia - -BREAKING CHANGE for developers: Messages are no longer stored in a vuex store but in pinia instead. This means to display a message in the UI, you need to use the new `useMessages` composable. - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10309 -https://github.com/owncloud/web/issues/10210 diff --git a/changelog/unreleased/change-resources-store b/changelog/unreleased/change-resources-store deleted file mode 100644 index 0fb5eacd044..00000000000 --- a/changelog/unreleased/change-resources-store +++ /dev/null @@ -1,10 +0,0 @@ -Change: Resources store to pinia - -BREAKING CHANGE for developers: Resources are no longer stored in a vuex store module but in pinia instead. You can access all the store functionality via the new `useResourcesStore` composable. - -Technically the former vuex store was only supposed to be used inside the files app. However, it was reachable from the outside as well and was therefore quite frequently used by other apps. So we decided to declare this as a breaking change. - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10368 -https://github.com/owncloud/web/issues/10210 diff --git a/changelog/unreleased/change-spaces-store b/changelog/unreleased/change-spaces-store deleted file mode 100644 index 347ef86cbd6..00000000000 --- a/changelog/unreleased/change-spaces-store +++ /dev/null @@ -1,8 +0,0 @@ -Change: Spaces store to pinia - -BREAKING CHANGE for developers: Spaces are no longer stored in a vuex store but in pinia instead. You can access all the store functionality via the new `useSpacesStore` composable. - -For more details please see the linked PR down below. - -https://github.com/owncloud/web/pull/10316 -https://github.com/owncloud/web/issues/10210 diff --git a/changelog/unreleased/change-vuex-store-removed b/changelog/unreleased/change-vuex-store-removed new file mode 100644 index 00000000000..9da4007ee1f --- /dev/null +++ b/changelog/unreleased/change-vuex-store-removed @@ -0,0 +1,52 @@ +Change: Vuex store removed + +BREAKING CHANGE for developers: The vuex store has been removed in favor of pinia. + +All store modules have been migrated to a pinia store module. Please see the linked issue down below for a list of all migrated stores and how to use them now. + +There are a number of things that have been removed and/or moved into pinia composables instead: + +Globals: + +- `store` and `$store` variables have been removed. +- `ConfigurationManager` has been removed. The config now sits inside the configuration store. + +App framework: + +- `announceStore` has been removed. There is no need for apps to announce stores to the runtime. If you need to use a store in your app, simply create a pinia store module and use it. +- `announceExtensions` has been removed. The proper way for an app to register file extensions is via the `extensions` property inside the `appInfo` object. +- `requestStore` has been removed. There is no need to request specific stores. All stores that `web-pkg` provides can be imported and accessed via their composables. +- `enabled` callback as well as the `name` callback of the `AppNavigationItem` no longer have the `capabilities` parameter. +- `store` param of the `ClassicApplicationScript` has been removed. + +Composables: + +- `useStore` has been removed. Use the pinia for the store you want to use instead. +- `useAccessToken` has been removed. It now sits inside the auth store. +- `usePublicLinkContext` has been removed. It now sits inside the auth store. +- `usePublicLinkPassword` has been removed. It now sits inside the auth store. +- `usePublicLinkToken` has been removed. It now sits inside the auth store. +- `useUserContext` has been removed. It now sits inside the auth store. +- `useConfigurationManager` has been removed. The config now sits inside the configuration store. +- `use...Capability` composables have been removed. Capablities now sit inside the capability store. + +For store specific changes please see the linked issue and PRs down below. + +https://github.com/owncloud/web/issues/10210 +https://github.com/owncloud/web/pull/10212 +https://github.com/owncloud/web/pull/10240 +https://github.com/owncloud/web/pull/10307 +https://github.com/owncloud/web/pull/10309 +https://github.com/owncloud/web/pull/10316 +https://github.com/owncloud/web/pull/10323 +https://github.com/owncloud/web/pull/10326 +https://github.com/owncloud/web/pull/10329 +https://github.com/owncloud/web/pull/10331 +https://github.com/owncloud/web/pull/10336 +https://github.com/owncloud/web/pull/10338 +https://github.com/owncloud/web/pull/10341 +https://github.com/owncloud/web/pull/10346 +https://github.com/owncloud/web/pull/10349 +https://github.com/owncloud/web/pull/10362 +https://github.com/owncloud/web/pull/10363 +https://github.com/owncloud/web/pull/10368 diff --git a/packages/extension-sdk/index.mjs b/packages/extension-sdk/index.mjs index 4628aa6dcd9..973787adde3 100644 --- a/packages/extension-sdk/index.mjs +++ b/packages/extension-sdk/index.mjs @@ -56,7 +56,6 @@ export const defineConfig = (overrides = {}) => { // keep in sync with packages/web-runtime/src/container/application/index.ts external: [ 'vue', - 'vuex', 'luxon', 'vue3-gettext', diff --git a/packages/web-app-draw-io/package.json b/packages/web-app-draw-io/package.json index 7f412b0a45d..d762681cc74 100644 --- a/packages/web-app-draw-io/package.json +++ b/packages/web-app-draw-io/package.json @@ -10,7 +10,6 @@ "peerDependencies": { "@ownclouders/web-client": "workspace:*", "@ownclouders/web-pkg": "workspace:*", - "luxon": "3.2.1", - "vuex": "4.1.0" + "luxon": "3.2.1" } } diff --git a/packages/web-app-external/package.json b/packages/web-app-external/package.json index 433fb40a63e..26a919fbca4 100644 --- a/packages/web-app-external/package.json +++ b/packages/web-app-external/package.json @@ -13,7 +13,6 @@ "uuid": "9.0.1", "vue-concurrency": "4.0.1", "vue3-gettext": "2.4.0", - "vuex": "4.1.0", "zod": "3.22.4" } } diff --git a/packages/web-app-files/package.json b/packages/web-app-files/package.json index 5ef83465ac2..a36d94ab234 100644 --- a/packages/web-app-files/package.json +++ b/packages/web-app-files/package.json @@ -35,7 +35,6 @@ "vue-concurrency": "4.0.1", "vue-router": "4.2.5", "vue3-gettext": "2.4.0", - "vuex": "4.1.0", "web-app-files": "workspace:*", "web-app-search": "workspace:*", "web-runtime": "workspace:*", diff --git a/packages/web-app-ocm/package.json b/packages/web-app-ocm/package.json index 4953345b078..f81c2bc96ed 100644 --- a/packages/web-app-ocm/package.json +++ b/packages/web-app-ocm/package.json @@ -12,7 +12,6 @@ "lodash-es": "4.17.21", "vue-concurrency": "4.0.1", "uuid": "9.0.1", - "vuex": "4.1.0", "zod": "3.22.4" } } diff --git a/packages/web-app-pdf-viewer/package.json b/packages/web-app-pdf-viewer/package.json index b891f01ccc5..3b797442ed0 100644 --- a/packages/web-app-pdf-viewer/package.json +++ b/packages/web-app-pdf-viewer/package.json @@ -9,7 +9,6 @@ }, "peerDependencies": { "@ownclouders/web-pkg": "workspace:*", - "vue3-gettext": "2.4.0", - "vuex": "4.1.0" + "vue3-gettext": "2.4.0" } } diff --git a/packages/web-app-preview/package.json b/packages/web-app-preview/package.json index ab24e75266c..3f778319006 100644 --- a/packages/web-app-preview/package.json +++ b/packages/web-app-preview/package.json @@ -12,7 +12,6 @@ "@ownclouders/web-client": "workspace:*", "@ownclouders/web-pkg": "workspace:*", "@vueuse/core": "^10.3.0", - "vue3-gettext": "2.4.0", - "vuex": "4.1.0" + "vue3-gettext": "2.4.0" } } diff --git a/packages/web-app-text-editor/package.json b/packages/web-app-text-editor/package.json index b6a2439b642..a5800344949 100644 --- a/packages/web-app-text-editor/package.json +++ b/packages/web-app-text-editor/package.json @@ -13,7 +13,6 @@ "marked": "^4.0.12", "sanitize-html": "^2.7.0", "vue-concurrency": "4.0.1", - "vue3-gettext": "2.4.0", - "vuex": "4.1.0" + "vue3-gettext": "2.4.0" } } diff --git a/packages/web-pkg/package.json b/packages/web-pkg/package.json index 9d1785706c4..5f50627d805 100644 --- a/packages/web-pkg/package.json +++ b/packages/web-pkg/package.json @@ -47,7 +47,6 @@ "uuid": "9.0.1", "vue-concurrency": "4.0.1", "vue-router": "4.2.5", - "vue3-gettext": "2.4.0", - "vuex": "4.1.0" + "vue3-gettext": "2.4.0" } } diff --git a/packages/web-pkg/src/apps/types.ts b/packages/web-pkg/src/apps/types.ts index 07962fc8d4f..be63bc0e72e 100644 --- a/packages/web-pkg/src/apps/types.ts +++ b/packages/web-pkg/src/apps/types.ts @@ -1,6 +1,5 @@ import { App, ComponentCustomProperties, Ref } from 'vue' import { RouteLocationRaw, Router, RouteRecordRaw } from 'vue-router' -import { Module, Store } from 'vuex' import { Extension } from '../composables/piniaStores' import { IconFillType } from '../helpers' import { Resource, SpaceResource } from '@ownclouders/web-client' @@ -8,7 +7,6 @@ import { Resource, SpaceResource } from '@ownclouders/web-client' export interface AppReadyHookArgs { globalProperties: ComponentCustomProperties & Record router: Router - store: Store instance?: App portal?: any } @@ -92,7 +90,6 @@ export interface ApplicationTranslations { /** ClassicApplicationScript reflects classic application script structure */ export interface ClassicApplicationScript { appInfo?: ApplicationInformation - store?: Module routes?: ((...args) => RouteRecordRaw[]) | RouteRecordRaw[] navItems?: ((...args) => AppNavigationItem[]) | AppNavigationItem[] translations?: ApplicationTranslations diff --git a/packages/web-pkg/src/composables/index.ts b/packages/web-pkg/src/composables/index.ts index ce6147396e4..4c4d8a7cf7c 100644 --- a/packages/web-pkg/src/composables/index.ts +++ b/packages/web-pkg/src/composables/index.ts @@ -32,6 +32,5 @@ export * from './shares' export * from './sideBar' export * from './sort' export * from './spaces' -export * from './store' export * from './upload' export * from './viewMode' diff --git a/packages/web-pkg/src/composables/store/index.ts b/packages/web-pkg/src/composables/store/index.ts deleted file mode 100644 index 708e4f7dee3..00000000000 --- a/packages/web-pkg/src/composables/store/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useStore' diff --git a/packages/web-pkg/src/composables/store/useStore.ts b/packages/web-pkg/src/composables/store/useStore.ts deleted file mode 100644 index 82250dfdcab..00000000000 --- a/packages/web-pkg/src/composables/store/useStore.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Store } from 'vuex' -import { useService } from '../service' - -export const useStore = (): Store => { - return useService('store') -} diff --git a/packages/web-runtime/package.json b/packages/web-runtime/package.json index 29a51da10a0..34478cf7617 100644 --- a/packages/web-runtime/package.json +++ b/packages/web-runtime/package.json @@ -45,7 +45,6 @@ "vue-router": "4.2.5", "vue-select": "4.0.0-beta.6", "vue3-gettext": "2.4.0", - "vuex": "4.1.0", "web-runtime": "workspace:*", "webdav": "5.3.1", "webfontloader": "^1.6.28", diff --git a/packages/web-runtime/src/container/api.ts b/packages/web-runtime/src/container/api.ts index f1621424393..530178d4f6e 100644 --- a/packages/web-runtime/src/container/api.ts +++ b/packages/web-runtime/src/container/api.ts @@ -2,8 +2,7 @@ import { RouteRecordRaw, Router } from 'vue-router' import clone from 'lodash-es/clone' import { RuntimeApi } from './types' import { ApiError, ExtensionRegistry, SidebarNavExtension } from '@ownclouders/web-pkg' -import { get, isEqual, isObject, isArray, merge } from 'lodash-es' -import { Module, Store } from 'vuex' +import { isEqual, isObject, isArray, merge } from 'lodash-es' import { App, Component, computed, h } from 'vue' import { ApplicationTranslations, AppNavigationItem } from '@ownclouders/web-pkg' import type { Language } from 'vue3-gettext' @@ -105,27 +104,6 @@ const announceTranslations = ( }) } -/** - * inject application specific store into runtime - * - * @param applicationName - * @param store - * @param applicationStore - */ -const announceStore = ( - applicationName: string, - store: Store, - applicationStore: Module -): void => { - const obtainedStore: Module = get(applicationStore, 'default', applicationStore) - - if (!isObject(obtainedStore)) { - throw new ApiError("store can't be blank") - } - - store.registerModule(applicationName, obtainedStore) -} - /** * open a wormhole portal, this wraps vue-portal * @@ -152,21 +130,6 @@ const openPortal = ( }) } -/** - * expose store to the application - * - * @deprecated use with caution - * - * @param store - */ -const requestStore = (store: Store): Store => { - if (isEqual(process.env.NODE_ENV, 'development')) { - console.warn('requestStore // store api is deprecated, use with caution') - } - - return store -} - /** * expose router to the application * @@ -198,7 +161,6 @@ const requestRouter = (router: Router): Router => { export const buildRuntimeApi = ({ applicationName, applicationId, - store, router, gettext, supportedLanguages, @@ -206,7 +168,6 @@ export const buildRuntimeApi = ({ }: { applicationName: string applicationId: string - store: Store gettext: Language router: Router supportedLanguages: { [key: string]: string } @@ -227,9 +188,6 @@ export const buildRuntimeApi = ({ announceNavigationItems(applicationId, extensionRegistry, navigationItems), announceTranslations: (appTranslations: ApplicationTranslations): void => announceTranslations(supportedLanguages, gettext, appTranslations), - announceStore: (applicationStore: Module): void => - announceStore(applicationName, store, applicationStore), - requestStore: (): Store => requestStore(store), requestRouter: (): Router => requestRouter(router), openPortal: ( instance: App, diff --git a/packages/web-runtime/src/container/application/classic.ts b/packages/web-runtime/src/container/application/classic.ts index e922128e714..00d853a1468 100644 --- a/packages/web-runtime/src/container/application/classic.ts +++ b/packages/web-runtime/src/container/application/classic.ts @@ -3,7 +3,6 @@ import { buildRuntimeApi } from '../api' import { App } from 'vue' import { isFunction, isObject } from 'lodash-es' import { NextApplication } from './next' -import { Store } from 'vuex' import { Router } from 'vue-router' import { RuntimeError, useAppsStore } from '@ownclouders/web-pkg' import { AppConfigObject, AppReadyHookArgs, ClassicApplicationScript } from '@ownclouders/web-pkg' @@ -25,7 +24,7 @@ class ClassicApplication extends NextApplication { } initialize(): Promise { - const { routes, navItems, translations, store } = this.applicationScript + const { routes, navItems, translations } = this.applicationScript const { globalProperties } = this.app.config const _routes = typeof routes === 'function' ? routes(globalProperties) : routes const _navItems = typeof navItems === 'function' ? navItems(globalProperties) : navItems @@ -33,7 +32,6 @@ class ClassicApplication extends NextApplication { routes && this.runtimeApi.announceRoutes(_routes) navItems && this.runtimeApi.announceNavigationItems(_navItems) translations && this.runtimeApi.announceTranslations(translations) - store && this.runtimeApi.announceStore(store) return Promise.resolve(undefined) } @@ -59,7 +57,6 @@ class ClassicApplication extends NextApplication { } }), instance, - store: this.runtimeApi.requestStore(), router: this.runtimeApi.requestRouter(), globalProperties: this.app.config.globalProperties }) @@ -70,7 +67,6 @@ class ClassicApplication extends NextApplication { * * @param app * @param applicationPath - * @param store * @param router * @param translations * @param supportedLanguages @@ -79,7 +75,6 @@ export const convertClassicApplication = ({ app, applicationScript, applicationConfig, - store, router, gettext, supportedLanguages @@ -87,7 +82,6 @@ export const convertClassicApplication = ({ app: App applicationScript: ClassicApplicationScript applicationConfig: AppConfigObject - store: Store router: Router gettext: Language supportedLanguages: { [key: string]: string } @@ -121,7 +115,6 @@ export const convertClassicApplication = ({ const runtimeApi = buildRuntimeApi({ applicationName, applicationId, - store, router, gettext, supportedLanguages, diff --git a/packages/web-runtime/src/container/application/index.ts b/packages/web-runtime/src/container/application/index.ts index 4dfa7c06569..2fcba49e109 100644 --- a/packages/web-runtime/src/container/application/index.ts +++ b/packages/web-runtime/src/container/application/index.ts @@ -1,4 +1,3 @@ -import { Store } from 'vuex' import { Router } from 'vue-router' import { NextApplication } from './next' import { convertClassicApplication } from './classic' @@ -9,7 +8,6 @@ import type { Language } from 'vue3-gettext' // import modules to provide them to applications import * as vue from 'vue' // eslint-disable-line -import * as vuex from 'vuex' // eslint-disable-line import * as luxon from 'luxon' // eslint-disable-line import * as vueGettext from 'vue3-gettext' // eslint-disable-line import * as webPkg from '@ownclouders/web-pkg' @@ -30,7 +28,6 @@ const injectionMap = { luxon, vue, 'vue3-gettext': vueGettext, - vuex, '@ownclouders/web-pkg': webPkg, '@ownclouders/web-client': webClient, 'web-pkg': webPkg, @@ -63,7 +60,6 @@ export const buildApplication = async ({ app, applicationPath, applicationConfig, - store, router, gettext, supportedLanguages, @@ -72,7 +68,6 @@ export const buildApplication = async ({ app: App applicationPath: string applicationConfig: AppConfigObject - store: Store router: Router gettext: Language supportedLanguages: { [key: string]: string } @@ -125,7 +120,6 @@ export const buildApplication = async ({ app, applicationScript, applicationConfig, - store, router, gettext, supportedLanguages diff --git a/packages/web-runtime/src/container/bootstrap.ts b/packages/web-runtime/src/container/bootstrap.ts index 4af8e25e1ad..26212693432 100644 --- a/packages/web-runtime/src/container/bootstrap.ts +++ b/packages/web-runtime/src/container/bootstrap.ts @@ -1,6 +1,5 @@ import { registerClient } from '../services/clientRegistration' import { buildApplication, NextApplication } from './application' -import { Store } from 'vuex' import { RouteLocationRaw, Router, RouteRecordNormalized } from 'vue-router' import { App, computed, watch } from 'vue' import { loadTheme } from '../helpers/theme' @@ -37,7 +36,6 @@ import { PreviewService, UppyService } from '@ownclouders/web-pkg' -import { default as storeOptions } from '../store' import { init as sentryInit } from '@sentry/vue' import { webdav } from '@ownclouders/web-client/src/webdav' import { v4 as uuidV4 } from 'uuid' @@ -130,15 +128,6 @@ export const announceConfiguration = async ({ configStore.loadConfig(rawConfig) } -/** - * Announce and prepare vuex store with data that is needed before any application gets announced. - * - */ -export const announceStore = () => { - const store = new Store({ ...storeOptions }) - return store -} - /** * announce auth client to the runtime, currently only openIdConnect is supported here * @@ -174,14 +163,12 @@ export const announceClient = async (configStore: ConfigStore): Promise => export const initializeApplications = async ({ app, configStore, - store, router, gettext, supportedLanguages }: { app: App configStore: ConfigStore - store: Store router: Router gettext: Language supportedLanguages: { [key: string]: string } @@ -204,7 +191,6 @@ export const initializeApplications = async ({ app, applicationPath: rawApplication.path, applicationConfig: rawApplication.config, - store, supportedLanguages, router, gettext, @@ -302,7 +288,6 @@ const rewriteDeprecatedAppNames = (configStore: ConfigStore) => { * and designSystem has all needed information to render the customized ui * * @param themeLocation - * @param store * @param vue * @param designSystem */ @@ -389,7 +374,6 @@ export const announceAdditionalTranslations = ({ * * @param vue * @param configStore - * @param store */ export const announceClientService = ({ app, @@ -533,7 +517,6 @@ export const announcePasswordPolicyService = ({ app }: { app: App }): void => { * announce runtime defaults, this is usual the last needed announcement before rendering the actual ui * * @param vue - * @param store * @param router */ export const announceDefaults = ({ @@ -542,7 +525,6 @@ export const announceDefaults = ({ router, configStore }: { - store: Store appsStore: AppsStore router: Router extensionRegistry: ExtensionRegistry diff --git a/packages/web-runtime/src/container/types.ts b/packages/web-runtime/src/container/types.ts index 449ee0f5a3f..7993a076fe9 100644 --- a/packages/web-runtime/src/container/types.ts +++ b/packages/web-runtime/src/container/types.ts @@ -1,4 +1,3 @@ -import { Module, Store } from 'vuex' import { Router, RouteRecordRaw } from 'vue-router' import { App, Component } from 'vue' import { AppNavigationItem, ApplicationTranslations } from '@ownclouders/web-pkg' @@ -8,8 +7,6 @@ export interface RuntimeApi { announceRoutes: (routes: RouteRecordRaw[]) => void announceNavigationItems: (navigationItems: AppNavigationItem[]) => void announceTranslations: (appTranslations: ApplicationTranslations) => void - announceStore: (applicationStore: Module) => void - requestStore: () => Store requestRouter: () => Router openPortal: ( instance: App, diff --git a/packages/web-runtime/src/index.ts b/packages/web-runtime/src/index.ts index 8e0e79942d7..1dcd9bc14a8 100644 --- a/packages/web-runtime/src/index.ts +++ b/packages/web-runtime/src/index.ts @@ -13,7 +13,6 @@ import { announceClient, announceDefaults, announceClientService, - announceStore, announceTheme, announcePiniaStores, announceCustomStyles, @@ -38,7 +37,7 @@ import { PublicSpaceResource } from '@ownclouders/web-client/src/helpers' import { loadCustomTranslations } from 'web-runtime/src/helpers/customTranslations' -import { computed, createApp } from 'vue' +import { computed, createApp, watch } from 'vue' import PortalVue, { createWormhole } from 'portal-vue' import { createPinia } from 'pinia' import Avatar from './components/Avatar.vue' @@ -66,9 +65,6 @@ export const bootstrapApp = async (configurationPath: string): Promise => await announceConfiguration({ path: configurationPath, configStore }) startSentry(configStore, app) - const store = announceStore() - app.provide('store', store) - app.use(abilitiesPlugin, createMongoAbility([]), { useGlobalProperties: true }) const gettext = announceTranslations({ @@ -124,7 +120,6 @@ export const bootstrapApp = async (configurationPath: string): Promise => const applicationsPromise = initializeApplications({ app, configStore, - store, supportedLanguages, router, gettext @@ -150,10 +145,9 @@ export const bootstrapApp = async (configurationPath: string): Promise => }) announceCustomStyles({ configStore }) announceCustomScripts({ configStore }) - announceDefaults({ store, appsStore, router, extensionRegistry, configStore }) + announceDefaults({ appsStore, router, extensionRegistry, configStore }) app.use(router) - app.use(store) app.use(createHead()) app.component('AvatarImage', Avatar) @@ -166,7 +160,7 @@ export const bootstrapApp = async (configurationPath: string): Promise => const applications = Array.from(applicationStore.values()) applications.forEach((application) => application.mounted(app)) - store.watch( + watch( () => authStore.userContextReady || authStore.idpContextReady || authStore.publicLinkContextReady, async (newValue, oldValue) => { @@ -181,10 +175,8 @@ export const bootstrapApp = async (configurationPath: string): Promise => } ) - store.watch( - () => { - return authStore.userContextReady - }, + watch( + () => authStore.userContextReady, async (userContextReady) => { if (!userContextReady) { return @@ -217,10 +209,8 @@ export const bootstrapApp = async (configurationPath: string): Promise => immediate: true } ) - store.watch( - () => { - return authStore.publicLinkContextReady - }, + watch( + () => authStore.publicLinkContextReady, (publicLinkContextReady) => { if (!publicLinkContextReady) { return @@ -245,12 +235,10 @@ export const bootstrapApp = async (configurationPath: string): Promise => immediate: true } ) - store.watch( + watch( // only needed if a public link gets re-resolved with a changed password prop (changed or removed). // don't need to set { immediate: true } on the watcher. - () => { - return authStore.publicLinkPassword - }, + () => authStore.publicLinkPassword, (publicLinkPassword: string | undefined) => { const publicLinkToken = authStore.publicLinkToken const space = spacesStore.spaces.find((space) => { @@ -265,13 +253,11 @@ export const bootstrapApp = async (configurationPath: string): Promise => } export const bootstrapErrorApp = async (err: Error): Promise => { - const store = announceStore() const { capabilityStore, configStore } = announcePiniaStores() announceVersions({ capabilityStore }) const app = createApp(pages.failure) await announceTheme({ app, designSystem, configStore }) console.error(err) - app.use(store) announceTranslations({ app, availableLanguages: supportedLanguages, diff --git a/packages/web-runtime/src/store/index.ts b/packages/web-runtime/src/store/index.ts deleted file mode 100644 index 6f9f5875e28..00000000000 --- a/packages/web-runtime/src/store/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -const runtime = { - namespaced: true, - modules: {} -} - -export default { - modules: { - runtime - } -} diff --git a/packages/web-test-helpers/package.json b/packages/web-test-helpers/package.json index 82217ff27c2..34f4c15b33d 100644 --- a/packages/web-test-helpers/package.json +++ b/packages/web-test-helpers/package.json @@ -8,8 +8,7 @@ "axios": "1.6.5", "pinia": "2.1.7", "vue-router": "4.2.5", - "vue3-gettext": "2.4.0", - "vuex": "4.1.0" + "vue3-gettext": "2.4.0" }, "devDependencies": { "@pinia/testing": "^0.1.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f20651058e2..f13eccf1a46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -654,9 +654,6 @@ importers: luxon: specifier: 3.2.1 version: 3.2.1 - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: web-test-helpers: specifier: workspace:* @@ -679,9 +676,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) zod: specifier: 3.22.4 version: 3.22.4 @@ -761,9 +755,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) web-app-files: specifier: workspace:* version: 'link:' @@ -841,9 +832,6 @@ importers: vue-concurrency: specifier: 4.0.1 version: 4.0.1(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) zod: specifier: 3.22.4 version: 3.22.4 @@ -856,9 +844,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: web-test-helpers: specifier: workspace:* @@ -878,9 +863,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: '@panzoom/panzoom': specifier: ^4.5.1 @@ -950,9 +932,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: web-test-helpers: specifier: workspace:* @@ -1099,9 +1078,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: web-test-helpers: specifier: workspace:* @@ -1232,9 +1208,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) web-runtime: specifier: workspace:* version: 'link:' @@ -1284,9 +1257,6 @@ importers: vue3-gettext: specifier: 2.4.0 version: 2.4.0(@vue/compiler-sfc@3.3.8)(vue@3.3.8) - vuex: - specifier: 4.1.0 - version: 4.1.0(vue@3.3.8) devDependencies: '@pinia/testing': specifier: ^0.1.3 @@ -4928,10 +4898,6 @@ packages: dev: true optional: true - /@vue/devtools-api@6.4.5: - resolution: {integrity: sha512-JD5fcdIuFxU4fQyXUu3w2KpAJHzTVdN+p4iOX2lMWSHMOoQdMAcpFLZzm9Z/2nmsoZ1a96QEhZ26e50xLBsgOQ==} - dev: false - /@vue/devtools-api@6.5.1: resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==} @@ -18403,15 +18369,6 @@ packages: '@vue/shared': 3.3.8 typescript: 5.3.3 - /vuex@4.1.0(vue@3.3.8): - resolution: {integrity: sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==} - peerDependencies: - vue: ^3.2.0 - dependencies: - '@vue/devtools-api': 6.4.5 - vue: 3.3.8(typescript@5.3.3) - dev: false - /w3c-keyname@2.2.8: resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==} dev: true