diff --git a/changelog/unreleased/change-resources-store b/changelog/unreleased/change-resources-store new file mode 100644 index 00000000000..0fb5eacd044 --- /dev/null +++ b/changelog/unreleased/change-resources-store @@ -0,0 +1,10 @@ +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/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue b/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue index 71287022183..c7689a090f5 100644 --- a/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue +++ b/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue @@ -8,7 +8,6 @@ import { computed, defineComponent, PropType, unref } from 'vue' import { SpaceResource } from '@ownclouders/web-client' import { ContextActionMenu } from '@ownclouders/web-pkg' -import { useStore } from '@ownclouders/web-pkg' import { useSpaceActionsDelete, @@ -30,10 +29,9 @@ export default defineComponent({ } }, setup(props) { - const store = useStore() const filterParams = computed(() => ({ resources: props.items })) - const { actions: deleteActions } = useSpaceActionsDelete({ store }) + const { actions: deleteActions } = useSpaceActionsDelete() const { actions: disableActions } = useSpaceActionsDisable() const { actions: editQuotaActions } = useSpaceActionsEditQuota() const { actions: editDescriptionActions } = useSpaceActionsEditDescription() diff --git a/packages/web-app-admin-settings/src/components/Spaces/SideBar/ActionsPanel.vue b/packages/web-app-admin-settings/src/components/Spaces/SideBar/ActionsPanel.vue index e6eea650240..bb2a2ea9ec3 100644 --- a/packages/web-app-admin-settings/src/components/Spaces/SideBar/ActionsPanel.vue +++ b/packages/web-app-admin-settings/src/components/Spaces/SideBar/ActionsPanel.vue @@ -24,13 +24,11 @@ import { } from '@ownclouders/web-pkg' import { computed, defineComponent, inject, unref } from 'vue' import { SpaceResource } from '@ownclouders/web-client' -import { useStore } from '@ownclouders/web-pkg' export default defineComponent({ name: 'ActionsPanel', components: { ActionMenuItem }, setup() { - const store = useStore() const resource = inject('resource') const resources = computed(() => { return [unref(resource)] @@ -39,7 +37,7 @@ export default defineComponent({ resources: unref(resources) })) - const { actions: deleteActions } = useSpaceActionsDelete({ store }) + const { actions: deleteActions } = useSpaceActionsDelete() const { actions: disableActions } = useSpaceActionsDisable() const { actions: editDescriptionActions } = useSpaceActionsEditDescription() const { actions: editQuotaActions } = useSpaceActionsEditQuota() diff --git a/packages/web-app-admin-settings/src/views/Spaces.vue b/packages/web-app-admin-settings/src/views/Spaces.vue index 685ae19c712..646586ca685 100644 --- a/packages/web-app-admin-settings/src/views/Spaces.vue +++ b/packages/web-app-admin-settings/src/views/Spaces.vue @@ -74,7 +74,6 @@ import { useSpaceActionsDisable, useSpaceActionsRestore, useSpaceActionsEditQuota, - useStore, useConfigStore } from '@ownclouders/web-pkg' import { buildSpace, SpaceResource } from '@ownclouders/web-client/src/helpers' @@ -97,7 +96,6 @@ export default defineComponent({ } }, setup() { - const store = useStore() const spaces = ref([]) const clientService = useClientService() const { $gettext } = useGettext() @@ -161,7 +159,7 @@ export default defineComponent({ selectedSpaces.value.splice(0, selectedSpaces.value.length) } - const { actions: deleteActions } = useSpaceActionsDelete({ store }) + const { actions: deleteActions } = useSpaceActionsDelete() const { actions: disableActions } = useSpaceActionsDisable() const { actions: editQuotaActions } = useSpaceActionsEditQuota() const { actions: restoreActions } = useSpaceActionsRestore() diff --git a/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts b/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts index a34543a1597..6f1915f0f08 100644 --- a/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts @@ -1,10 +1,8 @@ import { ref } from 'vue' import AppTemplate from '../../../src/components/AppTemplate.vue' import { - createStore, defaultComponentMocks, defaultPlugins, - defaultStoreMockOptions, RouteLocation, shallowMount } from 'web-test-helpers' @@ -25,8 +23,6 @@ const elSelectors = { jest.mock('@ownclouders/web-pkg') -afterEach(() => jest.clearAllMocks()) - describe('AppTemplate', () => { describe('loading is true', () => { it('should show app loading spinner component', () => { @@ -114,9 +110,6 @@ describe('AppTemplate', () => { }) }) -const storeOptions = { ...defaultStoreMockOptions } -const store = createStore(storeOptions) - function getWrapper({ props = {}, isMobileWidth = false } = {}) { return { wrapper: shallowMount(AppTemplate, { @@ -129,7 +122,7 @@ function getWrapper({ props = {}, isMobileWidth = false } = {}) { ...props }, global: { - plugins: [...defaultPlugins(), store], + plugins: [...defaultPlugins()], provide: { isMobileWidth: ref(isMobileWidth) }, stubs: { OcButton: false diff --git a/packages/web-app-admin-settings/tests/unit/components/Groups/ContextActions.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Groups/ContextActions.spec.ts index 33f130c4ffc..d21eed2f423 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Groups/ContextActions.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Groups/ContextActions.spec.ts @@ -1,4 +1,4 @@ -import { defaultPlugins, defaultStoreMockOptions, mount } from 'web-test-helpers' +import { defaultPlugins, mount } from 'web-test-helpers' import { mock } from 'jest-mock-extended' import { Resource } from '@ownclouders/web-client/src/helpers' import ContextActions from '../../../../src/components/Groups/ContextActions.vue' @@ -63,9 +63,7 @@ describe.skip('ContextActions', () => { }) function getWrapper() { - const storeOptions = { ...defaultStoreMockOptions } return { - storeOptions, wrapper: mount(ContextActions, { props: { items: [mock()] diff --git a/packages/web-app-admin-settings/tests/unit/components/Groups/CreateGroupModal.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Groups/CreateGroupModal.spec.ts index 25e8ce24ab6..31bc097baf6 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Groups/CreateGroupModal.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Groups/CreateGroupModal.spec.ts @@ -1,9 +1,7 @@ import CreateGroupModal from '../../../../src/components/Groups/CreateGroupModal.vue' import { - createStore, defaultComponentMocks, defaultPlugins, - defaultStoreMockOptions, mockAxiosReject, mockAxiosResolve, shallowMount @@ -114,12 +112,9 @@ describe('CreateGroupModal', () => { function getWrapper() { const mocks = defaultComponentMocks() - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) return { mocks, - storeOptions, wrapper: shallowMount(CreateGroupModal, { props: { modal: mock() @@ -127,7 +122,7 @@ function getWrapper() { global: { mocks, provide: mocks, - plugins: [...defaultPlugins(), store] + plugins: [...defaultPlugins()] } }) } diff --git a/packages/web-app-admin-settings/tests/unit/components/Groups/SideBar/EditPanel.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Groups/SideBar/EditPanel.spec.ts index 5b8d427c706..420a1164b1b 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Groups/SideBar/EditPanel.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Groups/SideBar/EditPanel.spec.ts @@ -1,12 +1,5 @@ import EditPanel from '../../../../../src/components/Groups/SideBar/EditPanel.vue' -import { - createStore, - defaultComponentMocks, - defaultPlugins, - defaultStoreMockOptions, - mockAxiosReject, - mount -} from 'web-test-helpers' +import { defaultComponentMocks, defaultPlugins, mockAxiosReject, mount } from 'web-test-helpers' import { mock } from 'jest-mock-extended' import { AxiosResponse } from 'axios' @@ -79,8 +72,6 @@ describe('EditPanel', () => { function getWrapper() { const mocks = defaultComponentMocks() - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) return { mocks, @@ -91,7 +82,7 @@ function getWrapper() { global: { mocks, provide: mocks, - plugins: [...defaultPlugins(), store], + plugins: [...defaultPlugins()], stubs: { 'oc-text-input': true, 'avatar-image': true, diff --git a/packages/web-app-admin-settings/tests/unit/components/Spaces/ContextActions.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Spaces/ContextActions.spec.ts index afd00f4825b..e32eeb22fc5 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Spaces/ContextActions.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Spaces/ContextActions.spec.ts @@ -1,11 +1,4 @@ -import { - createStore, - defaultComponentMocks, - defaultPlugins, - defaultStoreMockOptions, - defaultStubs, - mount -} from 'web-test-helpers' +import { defaultComponentMocks, defaultPlugins, defaultStubs, mount } from 'web-test-helpers' import { mock } from 'jest-mock-extended' import { Resource } from '@ownclouders/web-client/src/helpers' import ContextActions from '../../../../src/components/Spaces/ContextActions.vue' @@ -55,13 +48,10 @@ describe.skip('ContextActions', () => { }) function getWrapper() { - const storeOptions = { ...defaultStoreMockOptions } - const store = createStore(storeOptions) const mocks = { ...defaultComponentMocks() } return { - storeOptions, mocks, wrapper: mount(ContextActions, { props: { @@ -70,7 +60,7 @@ function getWrapper() { global: { mocks, stubs: { ...defaultStubs, 'action-menu-item': true }, - plugins: [...defaultPlugins(), store] + plugins: [...defaultPlugins()] } }) } diff --git a/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/ActionsPanel.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/ActionsPanel.spec.ts index 54d385159eb..3b8168ed398 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/ActionsPanel.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/ActionsPanel.spec.ts @@ -1,11 +1,4 @@ -import { - createStore, - defaultComponentMocks, - defaultPlugins, - defaultStoreMockOptions, - defaultStubs, - mount -} from 'web-test-helpers' +import { defaultComponentMocks, defaultPlugins, defaultStubs, mount } from 'web-test-helpers' import { mock } from 'jest-mock-extended' import { Resource } from '@ownclouders/web-client/src/helpers' import ActionsPanel from '../../../../../src/components/Spaces/SideBar/ActionsPanel.vue' @@ -66,13 +59,10 @@ describe('ActionsPanel', () => { }) function getWrapper() { - const storeOptions = { ...defaultStoreMockOptions } - const store = createStore(storeOptions) const mocks = { ...defaultComponentMocks() } return { - storeOptions, mocks, wrapper: mount(ActionsPanel, { props: { @@ -81,7 +71,7 @@ function getWrapper() { global: { mocks, stubs: { ...defaultStubs, 'action-menu-item': true }, - plugins: [...defaultPlugins(), store] + plugins: [...defaultPlugins()] } }) } diff --git a/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsDelete.spec.ts b/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsDelete.spec.ts index d617bddc3b7..5c18e475820 100644 --- a/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsDelete.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsDelete.spec.ts @@ -3,12 +3,7 @@ import { mock } from 'jest-mock-extended' import { unref } from 'vue' import { Group } from '@ownclouders/web-client/src/generated' import { eventBus } from '@ownclouders/web-pkg' -import { - createStore, - defaultComponentMocks, - defaultStoreMockOptions, - getComposableWrapper -} from 'web-test-helpers' +import { defaultComponentMocks, getComposableWrapper } from 'web-test-helpers' describe('useGroupActionsDelete', () => { describe('method "isEnabled"', () => { @@ -69,24 +64,20 @@ function getWrapper({ setup: ( instance: ReturnType, { - storeOptions, clientService }: { - storeOptions: typeof defaultStoreMockOptions clientService: ReturnType['$clientService'] } ) => void }) { - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) const mocks = defaultComponentMocks() return { wrapper: getComposableWrapper( () => { const instance = useGroupActionsDelete() - setup(instance, { storeOptions, clientService: mocks.$clientService }) + setup(instance, { clientService: mocks.$clientService }) }, - { store, mocks, provide: mocks } + { mocks, provide: mocks } ) } } diff --git a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts index 28fd497ec0d..4f23f15a210 100644 --- a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts @@ -3,13 +3,7 @@ import { mock } from 'jest-mock-extended' import { unref } from 'vue' import { User } from '@ownclouders/web-client/src/generated' import { eventBus, useCapabilityStore } from '@ownclouders/web-pkg' -import { - createStore, - defaultComponentMocks, - defaultStoreMockOptions, - getComposableWrapper, - writable -} from 'web-test-helpers' +import { defaultComponentMocks, getComposableWrapper, writable } from 'web-test-helpers' describe('useUserActionsDelete', () => { describe('method "isEnabled"', () => { @@ -65,24 +59,20 @@ function getWrapper({ setup: ( instance: ReturnType, { - storeOptions, clientService }: { - storeOptions: typeof defaultStoreMockOptions clientService: ReturnType['$clientService'] } ) => void }) { - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) const mocks = defaultComponentMocks() return { wrapper: getComposableWrapper( () => { const instance = useUserActionsDelete() - setup(instance, { storeOptions, clientService: mocks.$clientService }) + setup(instance, { clientService: mocks.$clientService }) }, - { store, mocks, provide: mocks } + { mocks, provide: mocks } ) } } diff --git a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditLogin.spec.ts b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditLogin.spec.ts index 5ebe06a257a..86c7aee76e2 100644 --- a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditLogin.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditLogin.spec.ts @@ -2,12 +2,7 @@ import { useUserActionsEditLogin } from '../../../../../src/composables/actions/ import { mock } from 'jest-mock-extended' import { unref } from 'vue' import { User } from '@ownclouders/web-client/src/generated' -import { - createStore, - defaultStoreMockOptions, - getComposableWrapper, - writable -} from 'web-test-helpers' +import { getComposableWrapper, writable } from 'web-test-helpers' import { useCapabilityStore, useModals } from '@ownclouders/web-pkg' describe('useUserActionsEditLogin', () => { @@ -50,25 +45,12 @@ describe('useUserActionsEditLogin', () => { function getWrapper({ setup }: { - setup: ( - instance: ReturnType, - { - storeOptions - }: { - storeOptions: typeof defaultStoreMockOptions - } - ) => void + setup: (instance: ReturnType) => void }) { - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) - return { - wrapper: getComposableWrapper( - () => { - const instance = useUserActionsEditLogin() - setup(instance, { storeOptions }) - }, - { store } - ) + wrapper: getComposableWrapper(() => { + const instance = useUserActionsEditLogin() + setup(instance) + }) } } diff --git a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditQuota.spec.ts b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditQuota.spec.ts index 526bf8d1296..ee7c741cb66 100644 --- a/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditQuota.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsEditQuota.spec.ts @@ -1,12 +1,5 @@ import { useUserActionsEditQuota } from '../../../../../src/composables/actions/users/useUserActionsEditQuota' - -import { - createStore, - defaultComponentMocks, - defaultStoreMockOptions, - getComposableWrapper, - writable -} from 'web-test-helpers' +import { defaultComponentMocks, getComposableWrapper, writable } from 'web-test-helpers' import { unref } from 'vue' import { useCapabilityStore, useModals } from '@ownclouders/web-pkg' @@ -86,31 +79,17 @@ function getWrapper({ setup }: { canEditSpaceQuota?: boolean - setup: ( - instance: ReturnType, - { - storeOptions - }: { - storeOptions: typeof defaultStoreMockOptions - } - ) => void + setup: (instance: ReturnType) => void }) { const mocks = defaultComponentMocks() - const storeOptions = { - ...defaultStoreMockOptions, - modules: { ...defaultStoreMockOptions.modules, user: { state: { id: 'alice', uuid: 1 } } } - } - const store = createStore(storeOptions) - return { wrapper: getComposableWrapper( () => { const instance = useUserActionsEditQuota() - setup(instance, { storeOptions }) + setup(instance) }, { - store, mocks, pluginOptions: { abilities: canEditSpaceQuota ? [{ action: 'set-quota-all', subject: 'Drive' }] : [] diff --git a/packages/web-app-admin-settings/tests/unit/views/Groups.spec.ts b/packages/web-app-admin-settings/tests/unit/views/Groups.spec.ts index d7a86c2c7c7..361abfef173 100644 --- a/packages/web-app-admin-settings/tests/unit/views/Groups.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/views/Groups.spec.ts @@ -2,13 +2,7 @@ import Groups from '../../../src/views/Groups.vue' import { mockAxiosResolve, mockAxiosReject } from 'web-test-helpers/src/mocks' import { mock, mockDeep } from 'jest-mock-extended' import { ClientService, eventBus, useMessages } from '@ownclouders/web-pkg' -import { - createStore, - defaultComponentMocks, - defaultPlugins, - defaultStoreMockOptions, - mount -} from 'web-test-helpers' +import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers' import { Group } from '@ownclouders/web-client/src/generated' const selectors = { batchActionsStub: 'batch-actions-stub' } @@ -125,13 +119,11 @@ describe('Groups view', () => { function getWrapper({ clientService = getClientServiceMock() } = {}) { const mocks = { ...defaultComponentMocks(), $clientService: clientService } - const storeOptions = { ...defaultStoreMockOptions } - const store = createStore(storeOptions) + return { - storeOptions, wrapper: mount(Groups, { global: { - plugins: [...defaultPlugins(), store], + plugins: [...defaultPlugins()], mocks, provide: mocks, stubs: { diff --git a/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts b/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts index 8884a4afaeb..8eb82af3215 100644 --- a/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts @@ -2,13 +2,7 @@ import { mockAxiosResolve } from 'web-test-helpers/src/mocks' import { Graph } from '@ownclouders/web-client' import { mockDeep } from 'jest-mock-extended' import { ClientService, useAppDefaults } from '@ownclouders/web-pkg' -import { - createStore, - defaultComponentMocks, - defaultPlugins, - defaultStoreMockOptions, - mount -} from 'web-test-helpers' +import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers' import Spaces from '../../../src/views/Spaces.vue' import { useAppDefaultsMock } from 'web-test-helpers/src/mocks/useAppDefaultsMock' @@ -122,13 +116,10 @@ function getWrapper({ spaces = [{ name: 'Some Space' }] } = {}) { $clientService } - const storeOptions = { ...defaultStoreMockOptions } - const store = createStore(storeOptions) - return { wrapper: mount(Spaces, { global: { - plugins: [...defaultPlugins(), store], + plugins: [...defaultPlugins()], mocks, provide: mocks, stubs: { diff --git a/packages/web-app-external/tests/unit/app.spec.ts b/packages/web-app-external/tests/unit/app.spec.ts index 17da59a7489..323d2cc7b68 100644 --- a/packages/web-app-external/tests/unit/app.spec.ts +++ b/packages/web-app-external/tests/unit/app.spec.ts @@ -1,10 +1,5 @@ import { mock } from 'jest-mock-extended' -import { - createStore, - defaultPlugins, - defaultStoreMockOptions, - shallowMount -} from 'web-test-helpers' +import { defaultPlugins, shallowMount } from 'web-test-helpers' import { useRequest, useRouteQuery } from '@ownclouders/web-pkg' import { ref } from 'vue' @@ -83,9 +78,6 @@ function createShallowMountWrapper(makeRequest = jest.fn().mockResolvedValue({ s jest.mocked(useRouteQuery).mockImplementation(() => ref('example-app')) - const storeOptions = defaultStoreMockOptions - const store = createStore(storeOptions) - const capabilities = { files: { app_providers: [{ apps_url: '/app/list', enabled: true, open_url: '/app/open' }] @@ -104,8 +96,7 @@ function createShallowMountWrapper(makeRequest = jest.fn().mockResolvedValue({ s capabilityState: { capabilities }, configState: { options: { editor: { openAsPreview: true } } } } - }), - store + }) ] } }) diff --git a/packages/web-app-files/src/App.vue b/packages/web-app-files/src/App.vue index ea76f7018d7..0b9758d1700 100644 --- a/packages/web-app-files/src/App.vue +++ b/packages/web-app-files/src/App.vue @@ -6,15 +6,15 @@