Skip to content

Commit

Permalink
refactor: remove vuex store
Browse files Browse the repository at this point in the history
Removes the vuex store dependency from the project after successfully migrating all store modules to pinia.
  • Loading branch information
JammingBen committed Jan 19, 2024
1 parent 7e70868 commit 5e7930b
Show file tree
Hide file tree
Showing 32 changed files with 69 additions and 253 deletions.
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
16 changes: 0 additions & 16 deletions changelog/unreleased/change-auth-store

This file was deleted.

11 changes: 0 additions & 11 deletions changelog/unreleased/change-capability-store

This file was deleted.

8 changes: 0 additions & 8 deletions changelog/unreleased/change-configuration-store

This file was deleted.

9 changes: 0 additions & 9 deletions changelog/unreleased/change-creating-modals

This file was deleted.

8 changes: 0 additions & 8 deletions changelog/unreleased/change-message-handling

This file was deleted.

10 changes: 0 additions & 10 deletions changelog/unreleased/change-resources-store

This file was deleted.

8 changes: 0 additions & 8 deletions changelog/unreleased/change-spaces-store

This file was deleted.

52 changes: 52 additions & 0 deletions changelog/unreleased/change-vuex-store-removed
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion packages/extension-sdk/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
3 changes: 1 addition & 2 deletions packages/web-app-draw-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 0 additions & 1 deletion packages/web-app-external/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 0 additions & 1 deletion packages/web-app-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
1 change: 0 additions & 1 deletion packages/web-app-ocm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 1 addition & 2 deletions packages/web-app-pdf-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"peerDependencies": {
"@ownclouders/web-pkg": "workspace:*",
"vue3-gettext": "2.4.0",
"vuex": "4.1.0"
"vue3-gettext": "2.4.0"
}
}
3 changes: 1 addition & 2 deletions packages/web-app-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 1 addition & 2 deletions packages/web-app-text-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 1 addition & 2 deletions packages/web-pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 0 additions & 3 deletions packages/web-pkg/src/apps/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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'

export interface AppReadyHookArgs {
globalProperties: ComponentCustomProperties & Record<string, any>
router: Router
store: Store<unknown>
instance?: App
portal?: any
}
Expand Down Expand Up @@ -92,7 +90,6 @@ export interface ApplicationTranslations {
/** ClassicApplicationScript reflects classic application script structure */
export interface ClassicApplicationScript {
appInfo?: ApplicationInformation
store?: Module<unknown, unknown>
routes?: ((...args) => RouteRecordRaw[]) | RouteRecordRaw[]
navItems?: ((...args) => AppNavigationItem[]) | AppNavigationItem[]
translations?: ApplicationTranslations
Expand Down
1 change: 0 additions & 1 deletion packages/web-pkg/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 0 additions & 1 deletion packages/web-pkg/src/composables/store/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/web-pkg/src/composables/store/useStore.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 1 addition & 43 deletions packages/web-runtime/src/container/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -105,27 +104,6 @@ const announceTranslations = (
})
}

/**
* inject application specific store into runtime
*
* @param applicationName
* @param store
* @param applicationStore
*/
const announceStore = (
applicationName: string,
store: Store<unknown>,
applicationStore: Module<unknown, unknown>
): void => {
const obtainedStore: Module<unknown, unknown> = 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
*
Expand All @@ -152,21 +130,6 @@ const openPortal = (
})
}

/**
* expose store to the application
*
* @deprecated use with caution
*
* @param store
*/
const requestStore = (store: Store<unknown>): Store<unknown> => {
if (isEqual(process.env.NODE_ENV, 'development')) {
console.warn('requestStore // store api is deprecated, use with caution')
}

return store
}

/**
* expose router to the application
*
Expand Down Expand Up @@ -198,15 +161,13 @@ const requestRouter = (router: Router): Router => {
export const buildRuntimeApi = ({
applicationName,
applicationId,
store,
router,
gettext,
supportedLanguages,
extensionRegistry
}: {
applicationName: string
applicationId: string
store: Store<unknown>
gettext: Language
router: Router
supportedLanguages: { [key: string]: string }
Expand All @@ -227,9 +188,6 @@ export const buildRuntimeApi = ({
announceNavigationItems(applicationId, extensionRegistry, navigationItems),
announceTranslations: (appTranslations: ApplicationTranslations): void =>
announceTranslations(supportedLanguages, gettext, appTranslations),
announceStore: (applicationStore: Module<unknown, unknown>): void =>
announceStore(applicationName, store, applicationStore),
requestStore: (): Store<unknown> => requestStore(store),
requestRouter: (): Router => requestRouter(router),
openPortal: (
instance: App,
Expand Down
Loading

0 comments on commit 5e7930b

Please sign in to comment.