From 1b0fb908e25cb27a7b251e1a4ea5971a447edcba Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 10:44:10 +0100 Subject: [PATCH 1/6] Webdav details followup --- .../SideBar/Details/FileDetails.vue | 8 +- packages/web-app-files/src/store/getters.ts | 9 + packages/web-app-files/src/store/mutations.ts | 6 + packages/web-app-files/src/store/state.ts | 3 +- .../web-pkg/src/components/AppBar/AppBar.vue | 30 +-- .../SideBar/Spaces/Details/SpaceDetails.vue | 9 +- .../web-runtime/src/container/bootstrap.ts | 26 +++ packages/web-runtime/src/index.ts | 5 +- packages/web-runtime/src/pages/account.vue | 216 +++++++++++------- 9 files changed, 200 insertions(+), 112 deletions(-) diff --git a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue index c86615bdff2..cb1a3859fb5 100644 --- a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue +++ b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue @@ -83,7 +83,7 @@ - + @@ -217,6 +217,9 @@ export default defineComponent({ matchingSpace: unref(space) || getMatchingSpace(unref(resource)) }) }) + const showWebDavDetails = computed(() => { + return store.state.Files.areWebDavDetailsShown + }) const formatDateRelative = (date) => { return formatRelativeDateFromJSDate(new Date(date), language.current) } @@ -248,7 +251,8 @@ export default defineComponent({ sharedAncestor, sharedAncestorRoute, formatDateRelative, - contextualHelper + contextualHelper, + showWebDavDetails } }, computed: { diff --git a/packages/web-app-files/src/store/getters.ts b/packages/web-app-files/src/store/getters.ts index df94306d1e6..6247b9ac4d8 100644 --- a/packages/web-app-files/src/store/getters.ts +++ b/packages/web-app-files/src/store/getters.ts @@ -67,5 +67,14 @@ export default { }, versions: (state) => { return state.versions + }, + areHiddenFilesShown: (state) => { + return state.areHiddenFilesShown + }, + areFileExtensionsShown: (state) => { + return state.areFileExtensionsShown + }, + areWebDavDetailsShown: (state) => { + return state.areWebDavDetailsShown } } diff --git a/packages/web-app-files/src/store/mutations.ts b/packages/web-app-files/src/store/mutations.ts index f0ef2588c20..c052df50ecc 100644 --- a/packages/web-app-files/src/store/mutations.ts +++ b/packages/web-app-files/src/store/mutations.ts @@ -214,6 +214,12 @@ export default { state.areFileExtensionsShown = value window.localStorage.setItem('oc_fileExtensionsShown', value) + }, + + SET_FILE_WEB_DAV_DETAILS_VISIBILITY(state, value) { + state.areWebDavDetailsShown = value + + window.localStorage.setItem('oc_webDavDetailsShown', value) } } diff --git a/packages/web-app-files/src/store/state.ts b/packages/web-app-files/src/store/state.ts index 090e15c880c..3450f9194af 100644 --- a/packages/web-app-files/src/store/state.ts +++ b/packages/web-app-files/src/store/state.ts @@ -19,5 +19,6 @@ export default { * View settings */ areHiddenFilesShown: true, - areFileExtensionsShown: true + areFileExtensionsShown: true, + areWebDavDetailsShown: false } diff --git a/packages/web-pkg/src/components/AppBar/AppBar.vue b/packages/web-pkg/src/components/AppBar/AppBar.vue index aad011ce93d..0dcd35b8999 100644 --- a/packages/web-pkg/src/components/AppBar/AppBar.vue +++ b/packages/web-pkg/src/components/AppBar/AppBar.vue @@ -296,7 +296,11 @@ export default defineComponent({ }, computed: { ...mapGetters('Files', ['files', 'selectedFiles']), - ...mapState('Files', ['areHiddenFilesShown', 'areFileExtensionsShown']), + ...mapState('Files', [ + 'areHiddenFilesShown', + 'areFileExtensionsShown', + 'areWebDavDetailsShown' + ]), showContextActions() { return last(this.breadcrumbs).allowContextActions @@ -331,26 +335,12 @@ export default defineComponent({ window.removeEventListener('resize', this.onResize) }, - created() { - // Storage returns a string so we need to convert it into a boolean - const areHiddenFilesShown = window.localStorage.getItem('oc_hiddenFilesShown') || 'false' - const areHiddenFilesShownBoolean = areHiddenFilesShown === 'true' - - if (areHiddenFilesShownBoolean !== this.areHiddenFilesShown) { - this.SET_HIDDEN_FILES_VISIBILITY(areHiddenFilesShownBoolean) - } - - // Storage returns a string so we need to convert it into a boolean - const areFileExtensionsShown = window.localStorage.getItem('oc_fileExtensionsShown') || 'true' - const areFileExtensionsShownBoolean = areFileExtensionsShown === 'true' - - if (areFileExtensionsShownBoolean !== this.areFileExtensionsShown) { - this.SET_FILE_EXTENSIONS_VISIBILITY(areFileExtensionsShownBoolean) - } - }, - methods: { - ...mapMutations('Files', ['SET_HIDDEN_FILES_VISIBILITY', 'SET_FILE_EXTENSIONS_VISIBILITY']), + ...mapMutations('Files', [ + 'SET_HIDDEN_FILES_VISIBILITY', + 'SET_FILE_EXTENSIONS_VISIBILITY', + 'SET_FILE_WEB_DAV_DETAILS_VISIBILITY' + ]), onResize() { const totalContentWidth = diff --git a/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue b/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue index 5abad882f44..a54f8b2ebc1 100644 --- a/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue +++ b/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue @@ -66,7 +66,7 @@ - + { + return store.state.Files.areWebDavDetailsShown + }) + return { loadImageTask, spaceImage, resource, - linkShareCount + linkShareCount, + showWebDavDetails } }, computed: { diff --git a/packages/web-runtime/src/container/bootstrap.ts b/packages/web-runtime/src/container/bootstrap.ts index ab16a35cad5..af7b6f6a160 100644 --- a/packages/web-runtime/src/container/bootstrap.ts +++ b/packages/web-runtime/src/container/bootstrap.ts @@ -659,3 +659,29 @@ export const registerSSEEventListeners = ({ onSSEProcessingFinishedEvent({ store, msg, clientService, resourceQueue }) ) } + +export const setViewOptions = ({ store }: { store: Store }): void => { + /** + * Storage returns a string so we need to convert it into a boolean + */ + const areHiddenFilesShown = window.localStorage.getItem('oc_hiddenFilesShown') || 'false' + const areHiddenFilesShownBoolean = areHiddenFilesShown === 'true' + + if (areHiddenFilesShownBoolean !== store.getters['Files/areHiddenFilesShown']) { + store.commit('Files/SET_HIDDEN_FILES_VISIBILITY', areHiddenFilesShownBoolean) + } + + const areFileExtensionsShown = window.localStorage.getItem('oc_fileExtensionsShown') || 'true' + const areFileExtensionsShownBoolean = areFileExtensionsShown === 'true' + + if (areFileExtensionsShownBoolean !== store.getters['Files/areFileExtensionsShownBoolean']) { + store.commit('Files/SET_FILE_EXTENSIONS_VISIBILITY', areFileExtensionsShownBoolean) + } + + const areWebDavDetailsShown = window.localStorage.getItem('oc_webDavDetailsShown') || 'false' + const areWebDavDetailsShownBoolean = areWebDavDetailsShown === 'true' + + if (areWebDavDetailsShownBoolean !== store.getters['Files/areWebDavDetailsShown']) { + store.commit('Files/SET_FILE_WEB_DAV_DETAILS_VISIBILITY', areWebDavDetailsShownBoolean) + } +} diff --git a/packages/web-runtime/src/index.ts b/packages/web-runtime/src/index.ts index 513c8c8cb86..352d6225e78 100644 --- a/packages/web-runtime/src/index.ts +++ b/packages/web-runtime/src/index.ts @@ -26,7 +26,8 @@ import { announcePreviewService, announcePasswordPolicyService, announceAdditionalTranslations, - registerSSEEventListeners + registerSSEEventListeners, + setViewOptions } from './container/bootstrap' import { applicationStore } from './container/store' import { @@ -133,6 +134,8 @@ export const bootstrapApp = async (configurationPath: string): Promise => app.mount('#owncloud') + setViewOptions({ store }) + const applications = Array.from(applicationStore.values()) applications.forEach((application) => application.mounted(app)) diff --git a/packages/web-runtime/src/pages/account.vue b/packages/web-runtime/src/pages/account.vue index 2e288b1cfbe..c74b05d8293 100644 --- a/packages/web-runtime/src/pages/account.vue +++ b/packages/web-runtime/src/pages/account.vue @@ -31,90 +31,115 @@ -

- +
+ + + +
+ + + + +
+

+ +

@@ -160,6 +185,7 @@ export default defineComponent({ const accountBundle = ref() const selectedLanguageValue = ref() const disableEmailNotificationsValue = ref() + const viewOptionWebDavDetailsValue = ref(store.getters['Files/areWebDavDetailsShown']) const sseEnabled = useCapabilityCoreSSE() // FIXME: Use settings service capability when we have it @@ -354,6 +380,22 @@ export default defineComponent({ } } + const updateViewOptionsWebDavDetails = async (option: boolean) => { + try { + store.commit('Files/SET_FILE_WEB_DAV_DETAILS_VISIBILITY', option) + viewOptionWebDavDetailsValue.value = option + store.dispatch('showMessage', { + title: $gettext('WebDav information view options preference saved successfully.') + }) + } catch (e) { + console.error(e) + store.dispatch('showErrorMessage', { + title: $gettext('Unable to save WebDav information view options…'), + error: e + }) + } + } + onMounted(async () => { await loadAccountBundleTask.perform() await loadValuesListTask.perform() @@ -388,9 +430,11 @@ export default defineComponent({ logoutUrl: configurationManager.logoutUrl, isLoading, disableEmailNotificationsValue, + viewOptionWebDavDetailsValue, loadAccountBundleTask, loadGraphUserTask, - loadValuesListTask + loadValuesListTask, + updateViewOptionsWebDavDetails } }, data() { @@ -431,8 +475,8 @@ export default defineComponent({ } }) - From 6719e935a7e4c1c53384c3e130287a31db4ccb23 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 10:49:09 +0100 Subject: [PATCH 2/6] Change announced messages --- .../src/components/SideBar/Details/FileDetails.vue | 2 +- .../SideBar/Spaces/Details/SpaceDetails.vue | 2 +- packages/web-runtime/src/pages/account.vue | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue index cb1a3859fb5..d3f6e5ea1b0 100644 --- a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue +++ b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue @@ -218,7 +218,7 @@ export default defineComponent({ }) }) const showWebDavDetails = computed(() => { - return store.state.Files.areWebDavDetailsShown + return store.getters['Files/areWebDavDetailsShown'] }) const formatDateRelative = (date) => { return formatRelativeDateFromJSDate(new Date(date), language.current) diff --git a/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue b/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue index a54f8b2ebc1..c573cb1ab58 100644 --- a/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue +++ b/packages/web-pkg/src/components/SideBar/Spaces/Details/SpaceDetails.vue @@ -136,7 +136,7 @@ export default defineComponent({ }) const showWebDavDetails = computed(() => { - return store.state.Files.areWebDavDetailsShown + return store.getters['Files/areWebDavDetailsShown'] }) return { diff --git a/packages/web-runtime/src/pages/account.vue b/packages/web-runtime/src/pages/account.vue index c74b05d8293..9d3e2d49637 100644 --- a/packages/web-runtime/src/pages/account.vue +++ b/packages/web-runtime/src/pages/account.vue @@ -350,12 +350,12 @@ export default defineComponent({ } store.dispatch('showMessage', { - title: $gettext('Language was saved successfully.') + title: $gettext('Preference saved.') }) } catch (e) { console.error(e) store.dispatch('showErrorMessage', { - title: $gettext('Saving language failed…'), + title: $gettext('Unable to save preference…'), error: e }) } @@ -369,12 +369,12 @@ export default defineComponent({ }) disableEmailNotificationsValue.value = option store.dispatch('showMessage', { - title: $gettext('Email notifications preference saved successfully.') + title: $gettext('Preference saved.') }) } catch (e) { console.error(e) store.dispatch('showErrorMessage', { - title: $gettext('Unable to save email notifications preference…'), + title: $gettext('Unable to save preference…'), error: e }) } @@ -385,12 +385,12 @@ export default defineComponent({ store.commit('Files/SET_FILE_WEB_DAV_DETAILS_VISIBILITY', option) viewOptionWebDavDetailsValue.value = option store.dispatch('showMessage', { - title: $gettext('WebDav information view options preference saved successfully.') + title: $gettext('Preference saved.') }) } catch (e) { console.error(e) store.dispatch('showErrorMessage', { - title: $gettext('Unable to save WebDav information view options…'), + title: $gettext('Unable to save preference…'), error: e }) } From 64e44c48345509434f82943dc3d5938d3572a091 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 10:51:53 +0100 Subject: [PATCH 3/6] Update snapshots --- .../ResourceDetails.spec.ts.snap | 27 +------------------ .../__snapshots__/SpaceDetails.spec.ts.snap | 3 +-- .../pages/__snapshots__/account.spec.ts.snap | 12 --------- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceDetails.spec.ts.snap b/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceDetails.spec.ts.snap index 7898c33f273..dfe995ba008 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceDetails.spec.ts.snap +++ b/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceDetails.spec.ts.snap @@ -54,32 +54,7 @@ exports[`ResourceDetails component renders resource details correctly 1`] = ` Size 24 kB - - WebDav path - -
- - - - - WebDav url - -
/
- - - + diff --git a/packages/web-pkg/tests/unit/components/sidebar/Spaces/Details/__snapshots__/SpaceDetails.spec.ts.snap b/packages/web-pkg/tests/unit/components/sidebar/Spaces/Details/__snapshots__/SpaceDetails.spec.ts.snap index e368c49aef7..faa79ec8037 100644 --- a/packages/web-pkg/tests/unit/components/sidebar/Spaces/Details/__snapshots__/SpaceDetails.spec.ts.snap +++ b/packages/web-pkg/tests/unit/components/sidebar/Spaces/Details/__snapshots__/SpaceDetails.spec.ts.snap @@ -11,7 +11,6 @@ exports[`Details SideBar Panel displays the details side panel 1`] = `

This space has 1 member.

- @@ -36,7 +35,7 @@ exports[`Details SideBar Panel displays the details side panel 1`] = ` - +
diff --git a/packages/web-runtime/tests/unit/pages/__snapshots__/account.spec.ts.snap b/packages/web-runtime/tests/unit/pages/__snapshots__/account.spec.ts.snap index bb19103d6c4..93392b416f8 100644 --- a/packages/web-runtime/tests/unit/pages/__snapshots__/account.spec.ts.snap +++ b/packages/web-runtime/tests/unit/pages/__snapshots__/account.spec.ts.snap @@ -23,12 +23,6 @@ exports[`account page account information displays basic user information 1`] = You are not part of any group - - `; From 4a7c6e48046ef7fd11932ed521a7a6fc48f0997c Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 11:01:30 +0100 Subject: [PATCH 4/6] Add tests --- packages/web-runtime/src/pages/account.vue | 6 +++--- .../web-runtime/tests/unit/pages/account.spec.ts | 16 ++++++++++++++++ .../src/mocks/store/filesModuleMockOptions.ts | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/web-runtime/src/pages/account.vue b/packages/web-runtime/src/pages/account.vue index 9d3e2d49637..55cffcdfcad 100644 --- a/packages/web-runtime/src/pages/account.vue +++ b/packages/web-runtime/src/pages/account.vue @@ -380,7 +380,7 @@ export default defineComponent({ } } - const updateViewOptionsWebDavDetails = async (option: boolean) => { + const updateViewOptionsWebDavDetails = (option: boolean) => { try { store.commit('Files/SET_FILE_WEB_DAV_DETAILS_VISIBILITY', option) viewOptionWebDavDetailsValue.value = option @@ -421,6 +421,7 @@ export default defineComponent({ selectedLanguageValue, updateSelectedLanguage, updateDisableEmailNotifications, + updateViewOptionsWebDavDetails, accountEditLink: store.getters.configuration?.options?.accountEditLink, isChangePasswordDisabled, showGdprExport, @@ -433,8 +434,7 @@ export default defineComponent({ viewOptionWebDavDetailsValue, loadAccountBundleTask, loadGraphUserTask, - loadValuesListTask, - updateViewOptionsWebDavDetails + loadValuesListTask } }, data() { diff --git a/packages/web-runtime/tests/unit/pages/account.spec.ts b/packages/web-runtime/tests/unit/pages/account.spec.ts index 438596ef22b..f967bb66f09 100644 --- a/packages/web-runtime/tests/unit/pages/account.spec.ts +++ b/packages/web-runtime/tests/unit/pages/account.spec.ts @@ -319,6 +319,22 @@ describe('account page', () => { expect(storeOptions.actions.showErrorMessage).toHaveBeenCalled() }) }) + + describe('Method "updateViewOptionsWebDavDetails', () => { + it('should show a message on success', async () => { + const { wrapper, storeOptions } = getWrapper({}) + + await wrapper.vm.loadAccountBundleTask.last + await wrapper.vm.loadValuesListTask.last + await wrapper.vm.loadGraphUserTask.last + + await wrapper.vm.updateViewOptionsWebDavDetails(true) + expect(storeOptions.actions.showMessage).toHaveBeenCalled() + expect( + storeOptions.modules.Files.mutations.SET_FILE_WEB_DAV_DETAILS_VISIBILITY + ).toHaveBeenCalled() + }) + }) }) function getWrapper({ diff --git a/packages/web-test-helpers/src/mocks/store/filesModuleMockOptions.ts b/packages/web-test-helpers/src/mocks/store/filesModuleMockOptions.ts index 61b677350dd..95f838c0b1a 100644 --- a/packages/web-test-helpers/src/mocks/store/filesModuleMockOptions.ts +++ b/packages/web-test-helpers/src/mocks/store/filesModuleMockOptions.ts @@ -26,6 +26,7 @@ export const filesModuleMockOptions = { RENAME_FILE: jest.fn(), SET_HIDDEN_FILES_VISIBILITY: jest.fn(), SET_FILE_EXTENSIONS_VISIBILITY: jest.fn(), + SET_FILE_WEB_DAV_DETAILS_VISIBILITY: jest.fn(), UPSERT_RESOURCE: jest.fn(), CLEAR_CURRENT_FILES_LIST: jest.fn(), SET_CURRENT_FOLDER: jest.fn(), From f4fe534f97d19a83d680ffab9d9995783c7765cc Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 11:06:58 +0100 Subject: [PATCH 5/6] Add changelog item --- .../enhancement-show-webdav-information-in-details | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 changelog/unreleased/enhancement-show-webdav-information-in-details diff --git a/changelog/unreleased/enhancement-show-webdav-information-in-details b/changelog/unreleased/enhancement-show-webdav-information-in-details new file mode 100644 index 00000000000..cb0be4a2767 --- /dev/null +++ b/changelog/unreleased/enhancement-show-webdav-information-in-details @@ -0,0 +1,9 @@ +Enhancement: Show webdav information in details view + +We've added WebDav path and WebDav url information to the details view, +this might be usefully when the user wants to add an external WebDav client. + +By default this view option is disabled but can be enabled via account->preferences view. + +https://github.com/owncloud/web/pull/10062 +https://github.com/owncloud/web/issues/9714 From 2dd1a354f582393f8eba3248c4cb76fe5c95e7be Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Fri, 24 Nov 2023 14:12:01 +0100 Subject: [PATCH 6/6] Rm unused code --- packages/web-pkg/src/components/AppBar/AppBar.vue | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/web-pkg/src/components/AppBar/AppBar.vue b/packages/web-pkg/src/components/AppBar/AppBar.vue index 0dcd35b8999..75801eda724 100644 --- a/packages/web-pkg/src/components/AppBar/AppBar.vue +++ b/packages/web-pkg/src/components/AppBar/AppBar.vue @@ -75,7 +75,7 @@