diff --git a/changelog/unreleased/change-creating-modals b/changelog/unreleased/change-creating-modals new file mode 100644 index 00000000000..49a39eac2c7 --- /dev/null +++ b/changelog/unreleased/change-creating-modals @@ -0,0 +1,8 @@ +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/issues/10095 diff --git a/packages/design-system/src/components/OcModal/OcModal.vue b/packages/design-system/src/components/OcModal/OcModal.vue index c8cfaae15e9..98e81417e5f 100644 --- a/packages/design-system/src/components/OcModal/OcModal.vue +++ b/packages/design-system/src/components/OcModal/OcModal.vue @@ -40,11 +40,9 @@ v-model="userInputValue" class="oc-modal-body-input" :error-message="inputError" - :placeholder="inputPlaceholder" :label="inputLabel" :type="inputType" :description-message="inputDescription" - :disabled="inputDisabled" :fix-message-line="true" :selection-range="inputSelectionRange" @update:model-value="inputOnInput" @@ -54,24 +52,24 @@
${this.$gettext( - 'Moving files from one space to another is not possible. Do you want to copy instead?' - )}
${this.$gettext( - 'Note: Links and shares of the original file are not copied.' - )}
`, - cancelText: this.$gettext('Cancel'), + customComponent: SpaceMoveInfoModal, confirmText: this.$gettext('Copy here'), onCancel: () => { - this.hideModal() resolve(false) }, - onConfirm: () => { - this.hideModal() - resolve(true) - } - } - this.createModal(modal) + onConfirm: () => Promise.resolve(resolve(true)) + }) }) } } diff --git a/packages/web-pkg/tests/unit/components/AppBanner.spec.ts b/packages/web-pkg/tests/unit/components/AppBanner.spec.ts index 473f6edd950..6b6457cd685 100644 --- a/packages/web-pkg/tests/unit/components/AppBanner.spec.ts +++ b/packages/web-pkg/tests/unit/components/AppBanner.spec.ts @@ -3,7 +3,6 @@ import AppBanner from '../../../src/components/AppBanner.vue' import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router' import { useSessionStorage } from '@vueuse/core' import { ref } from 'vue' -import { createMockThemeStore } from 'web-test-helpers/src/mocks/pinia' jest.mock('@vueuse/core') @@ -62,15 +61,20 @@ function getWrapper({ fileId, sessionStorageReturnValue }) { }, global: { plugins: [ - ...defaultPlugins(), - createMockThemeStore({ - appBanner: { - title: 'ownCloud', - publisher: 'ownCloud GmbH', - additionalInformation: '', - ctaText: 'OPEN', - icon: 'themes/owncloud/assets/owncloud-app-icon.png', - appScheme: 'owncloud' + ...defaultPlugins({ + piniaOptions: { + themeState: { + currentTheme: { + appBanner: { + title: 'ownCloud', + publisher: 'ownCloud GmbH', + additionalInformation: '', + ctaText: 'OPEN', + icon: 'themes/owncloud/assets/owncloud-app-icon.png', + appScheme: 'owncloud' + } + } + } } }) ], diff --git a/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts b/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts index 2f816716553..90193d401b2 100644 --- a/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts +++ b/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts @@ -126,28 +126,38 @@ describe('CreateLinkModal', () => { }) describe('method "confirm"', () => { it('shows an error if a password is enforced but empty', async () => { + jest.spyOn(console, 'error').mockImplementation(undefined) const { wrapper } = getWrapper({ passwordEnforced: true }) - await wrapper.find(selectors.confirmBtn).trigger('click') + try { + await wrapper.vm.onConfirm() + } catch (error) {} + expect(wrapper.vm.password.error).toBeDefined() }) it('does not create links when the password policy is not fulfilled', async () => { - const { wrapper, storeOptions } = getWrapper({ passwordPolicyFulfilled: false }) - await wrapper.find(selectors.confirmBtn).trigger('click') - expect(storeOptions.actions.hideModal).not.toHaveBeenCalled() + jest.spyOn(console, 'error').mockImplementation(undefined) + const callbackFn = jest.fn() + const { wrapper } = getWrapper({ passwordPolicyFulfilled: false, callbackFn }) + try { + await wrapper.vm.onConfirm() + } catch (error) {} + + expect(callbackFn).not.toHaveBeenCalled() }) it('creates links for all resources', async () => { + const callbackFn = jest.fn() const resources = [mock