From 4d0d4bdb51808329c8bd2b83f15247a0408dc89a Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 17:00:41 +0200 Subject: [PATCH 01/11] Remove unused code, rename share path --- .../web-pkg/src/components/Search/ResourcePreview.vue | 9 --------- .../web-pkg/src/composables/folderLink/useFolderLink.ts | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/web-pkg/src/components/Search/ResourcePreview.vue b/packages/web-pkg/src/components/Search/ResourcePreview.vue index 630aefee931..6d75b0b0074 100644 --- a/packages/web-pkg/src/components/Search/ResourcePreview.vue +++ b/packages/web-pkg/src/components/Search/ResourcePreview.vue @@ -81,21 +81,12 @@ export default defineComponent({ const space = computed(() => getMatchingSpace(unref(resource))) - const spaceName = computed(() => { - if (isShareSpaceResource(unref(space))) { - return path.join($gettext('Shared with me'), unref(space).name) - } - - return unref(space).name - }) - const resourceDisabled = computed(() => { return unref(resource).disabled === true }) return { space, - spaceName, ...useFileActions(), getInternalSpace, getMatchingSpace, diff --git a/packages/web-pkg/src/composables/folderLink/useFolderLink.ts b/packages/web-pkg/src/composables/folderLink/useFolderLink.ts index 9a329448645..cf7008713aa 100644 --- a/packages/web-pkg/src/composables/folderLink/useFolderLink.ts +++ b/packages/web-pkg/src/composables/folderLink/useFolderLink.ts @@ -28,7 +28,7 @@ export const useFolderLink = (options: ResourceRouteResolverOptions = {}) => { } if (isShareSpaceResource(space)) { - return path.join($gettext('Shares'), $gettext('Shared with me'), space.name) + return path.join($gettext('Shares/Shared'), space.name) } return space.name From 1b072cfb1cc98631c347f016697f780246c1fccd Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 17:01:39 +0200 Subject: [PATCH 02/11] Fix --- packages/web-pkg/src/composables/folderLink/useFolderLink.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-pkg/src/composables/folderLink/useFolderLink.ts b/packages/web-pkg/src/composables/folderLink/useFolderLink.ts index cf7008713aa..ab2cf8e45c8 100644 --- a/packages/web-pkg/src/composables/folderLink/useFolderLink.ts +++ b/packages/web-pkg/src/composables/folderLink/useFolderLink.ts @@ -28,7 +28,7 @@ export const useFolderLink = (options: ResourceRouteResolverOptions = {}) => { } if (isShareSpaceResource(space)) { - return path.join($gettext('Shares/Shared'), space.name) + return path.join($gettext('Shares'), space.name) } return space.name From bcc1e68f20af2f28b37dcdb82c415cb72a8b2e10 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 19:32:48 +0200 Subject: [PATCH 03/11] Add changelog item --- .../enhancement-add-editors-to-application-menu | 10 ++++++++++ .../web-pkg/src/components/Search/ResourcePreview.vue | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/enhancement-add-editors-to-application-menu diff --git a/changelog/unreleased/enhancement-add-editors-to-application-menu b/changelog/unreleased/enhancement-add-editors-to-application-menu new file mode 100644 index 00000000000..6733ba7176c --- /dev/null +++ b/changelog/unreleased/enhancement-add-editors-to-application-menu @@ -0,0 +1,10 @@ +Enhancement: Add editors to the application menu + +We've added 'text-editor' and 'draw.io' to the application menu, so the user can easily +open those apps with a one-click approach. +We've also fixed a bug, where the full path of a resource was missing while hovering it, for example in +the search preview. + +https://github.com/owncloud/web/pull/9809 +https://github.com/owncloud/web/pull/9843 +https://github.com/owncloud/web/issues/9807 diff --git a/packages/web-pkg/src/components/Search/ResourcePreview.vue b/packages/web-pkg/src/components/Search/ResourcePreview.vue index 6d75b0b0074..ef59bbb57df 100644 --- a/packages/web-pkg/src/components/Search/ResourcePreview.vue +++ b/packages/web-pkg/src/components/Search/ResourcePreview.vue @@ -28,18 +28,14 @@ import { debounce } from 'lodash-es' import { computed, defineComponent, PropType, ref, unref } from 'vue' import { mapGetters } from 'vuex' import { createLocationShares, createLocationSpaces } from '../../router' -import path, { dirname } from 'path' +import { dirname } from 'path' import { useCapabilityShareJailEnabled, useGetMatchingSpace, useFileActions, useFolderLink } from '../../composables' -import { - isProjectSpaceResource, - isShareSpaceResource, - Resource -} from '@ownclouders/web-client/src/helpers' +import { isProjectSpaceResource, Resource } from '@ownclouders/web-client/src/helpers' import { eventBus } from '../../services' import { createFileRouteOptions, isResourceTxtFileAlmostEmpty } from '../../helpers' import { SearchResultValue } from './types' From 2e7a1c830c5f4707ba45386c2e92f80d4af54f88 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 19:40:28 +0200 Subject: [PATCH 04/11] Remove duplicated code --- .../src/components/Search/ResourcePreview.vue | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/web-pkg/src/components/Search/ResourcePreview.vue b/packages/web-pkg/src/components/Search/ResourcePreview.vue index ef59bbb57df..334df11fc00 100644 --- a/packages/web-pkg/src/components/Search/ResourcePreview.vue +++ b/packages/web-pkg/src/components/Search/ResourcePreview.vue @@ -27,19 +27,17 @@ import { VisibilityObserver } from '../../observer' import { debounce } from 'lodash-es' import { computed, defineComponent, PropType, ref, unref } from 'vue' import { mapGetters } from 'vuex' -import { createLocationShares, createLocationSpaces } from '../../router' -import { dirname } from 'path' +import { createLocationSpaces } from '../../router' import { useCapabilityShareJailEnabled, useGetMatchingSpace, useFileActions, useFolderLink } from '../../composables' -import { isProjectSpaceResource, Resource } from '@ownclouders/web-client/src/helpers' +import { Resource } from '@ownclouders/web-client/src/helpers' import { eventBus } from '../../services' import { createFileRouteOptions, isResourceTxtFileAlmostEmpty } from '../../helpers' import { SearchResultValue } from './types' -import { useGettext } from 'vue3-gettext' const visibilityObserver = new VisibilityObserver() @@ -60,9 +58,13 @@ export default defineComponent({ }, setup(props) { const { getInternalSpace, getMatchingSpace } = useGetMatchingSpace() - const { getPathPrefix, getParentFolderName, getParentFolderLinkIconAdditionalAttributes } = - useFolderLink() - const { $gettext } = useGettext() + const { + getPathPrefix, + getParentFolderName, + getParentFolderLink, + getParentFolderLinkIconAdditionalAttributes, + getFolderLink + } = useFolderLink() const previewData = ref() const resource = computed((): Resource => { @@ -90,6 +92,8 @@ export default defineComponent({ previewData, resource, resourceDisabled, + parentFolderLink: getParentFolderLink(unref(resource)), + folderLink: getFolderLink(unref(resource)), pathPrefix: getPathPrefix(unref(resource)), parentFolderName: getParentFolderName(unref(resource)), parentFolderLinkIconAdditionalAttributes: getParentFolderLinkIconAdditionalAttributes( @@ -124,18 +128,6 @@ export default defineComponent({ !this.configuration?.options?.disablePreviews && !isResourceTxtFileAlmostEmpty(this.resource) ) - }, - folderLink() { - return this.createFolderLink(this.resource.path, this.resource.fileId) - }, - parentFolderLink() { - if (this.resource.shareId && this.resource.path === '/') { - return createLocationShares('files-shares-with-me') - } - if (isProjectSpaceResource(this.resource)) { - return createLocationSpaces('files-spaces-projects') - } - return this.createFolderLink(dirname(this.resource.path), this.resource.parentFolderId) } }, mounted() { From a6522d8d13c08a5c31d2672cec83368f50dca8e9 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 20:05:01 +0200 Subject: [PATCH 05/11] Fix bug where clicking on a folder in search preview doesnt close the dropdown --- .../src/components/OcResource/OcResource.vue | 181 +++++++++--------- .../src/components/Search/ResourcePreview.vue | 20 +- .../components/Search/ResourcePreview.spec.ts | 14 -- .../__snapshots__/AppTopBar.spec.ts.snap | 10 +- 4 files changed, 102 insertions(+), 123 deletions(-) diff --git a/packages/design-system/src/components/OcResource/OcResource.vue b/packages/design-system/src/components/OcResource/OcResource.vue index 20f1d3929e3..2e7615102f2 100644 --- a/packages/design-system/src/components/OcResource/OcResource.vue +++ b/packages/design-system/src/components/OcResource/OcResource.vue @@ -56,6 +56,7 @@ :full-path="resource.path" :is-path-displayed="isPathDisplayed" :is-extension-displayed="isExtensionDisplayed" + @click="$emit('clickFolder')" />
@@ -65,7 +66,7 @@ :to="parentFolderLink" :style="parentFolderStyle" class="parent-folder" - @click.stop="$emit('parentFolderClicked')" + @click.stop="$emit('clickParentFolder')" > @@ -189,7 +190,7 @@ export default defineComponent({ default: true } }, - emits: ['click', 'parentFolderClicked'], + emits: ['click', 'clickFolder', 'clickParentFolder'], computed: { parentFolderComponentType() { return this.parentFolderLink !== null ? 'router-link' : 'span' @@ -253,6 +254,7 @@ export default defineComponent({ methods: { emitClick() { + console.log('EMIT CLICK') /** * Triggered when the resource is a file and the name is clicked */ @@ -301,6 +303,7 @@ export default defineComponent({ a { text-decoration: none; } + a:hover, a:focus { outline-offset: 0; @@ -345,94 +348,94 @@ export default defineComponent({ - ```js - - - ``` + } + }, + } + +``` diff --git a/packages/web-pkg/src/components/Search/ResourcePreview.vue b/packages/web-pkg/src/components/Search/ResourcePreview.vue index 334df11fc00..5a305cc44e5 100644 --- a/packages/web-pkg/src/components/Search/ResourcePreview.vue +++ b/packages/web-pkg/src/components/Search/ResourcePreview.vue @@ -16,7 +16,8 @@ :parent-folder-link-icon-additional-attributes="parentFolderLinkIconAdditionalAttributes" :parent-folder-name="parentFolderName" :is-thumbnail-displayed="displayThumbnails" - @parent-folder-clicked="parentFolderClicked" + @click-parent-folder="folderClicked" + @click-folder="folderClicked" /> @@ -27,7 +28,6 @@ import { VisibilityObserver } from '../../observer' import { debounce } from 'lodash-es' import { computed, defineComponent, PropType, ref, unref } from 'vue' import { mapGetters } from 'vuex' -import { createLocationSpaces } from '../../router' import { useCapabilityShareJailEnabled, useGetMatchingSpace, @@ -36,7 +36,7 @@ import { } from '../../composables' import { Resource } from '@ownclouders/web-client/src/helpers' import { eventBus } from '../../services' -import { createFileRouteOptions, isResourceTxtFileAlmostEmpty } from '../../helpers' +import { isResourceTxtFileAlmostEmpty } from '../../helpers' import { SearchResultValue } from './types' const visibilityObserver = new VisibilityObserver() @@ -108,7 +108,7 @@ export default defineComponent({ attrs() { return this.resource.isFolder ? { - to: this.createFolderLink(this.resource.path, this.resource.fileId) + to: this.folderLink } : {} }, @@ -158,18 +158,8 @@ export default defineComponent({ visibilityObserver.disconnect() }, methods: { - parentFolderClicked() { + folderClicked() { eventBus.publish('app.search.options-drop.hide') - }, - createFolderLink(p: string, fileId: string | number) { - if (!this.space) { - return {} - } - - return createLocationSpaces( - 'files-spaces-generic', - createFileRouteOptions(this.space, { path: p, fileId }) - ) } } }) diff --git a/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts b/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts index 957c0a177d6..24181ce30fc 100644 --- a/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts +++ b/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts @@ -31,20 +31,6 @@ describe('Preview component', () => { expect(ocResource.props().resource).toMatchObject(wrapper.vm.searchResult.data) }) - describe('computed parentFolderLink', () => { - it('should use the items storageId for the resource target location if present', () => { - const driveAliasAndItem = '1' - const { wrapper } = getWrapper({ - space: mock({ - id: '1', - driveType: 'project', - name: 'New space', - getDriveAliasAndItem: () => driveAliasAndItem - }) - }) - expect(wrapper.vm.parentFolderLink.params.driveAliasAndItem).toEqual(driveAliasAndItem) - }) - }) }) function getWrapper({ diff --git a/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap b/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap index dbf7655debc..e1f85b08fd4 100644 --- a/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap +++ b/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap @@ -5,7 +5,7 @@ exports[`AppTopBar if a resource is present renders a resource and dropdownActio
- +
@@ -23,7 +23,7 @@ exports[`AppTopBar if a resource is present renders a resource and dropdownActio
- +
@@ -41,7 +41,7 @@ exports[`AppTopBar if a resource is present renders a resource and mainActions (
- +
@@ -58,7 +58,7 @@ exports[`AppTopBar if a resource is present renders a resource and no actions (i
- +
@@ -75,7 +75,7 @@ exports[`AppTopBar if no resource is present renders only a close button 1`] = `
- +
From 72a8d57ff2b13a4c4d3cead04168fab8c9757527 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Mon, 23 Oct 2023 20:06:12 +0200 Subject: [PATCH 06/11] Remove console.log --- packages/design-system/src/components/OcResource/OcResource.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/design-system/src/components/OcResource/OcResource.vue b/packages/design-system/src/components/OcResource/OcResource.vue index 2e7615102f2..a3f303eea39 100644 --- a/packages/design-system/src/components/OcResource/OcResource.vue +++ b/packages/design-system/src/components/OcResource/OcResource.vue @@ -254,7 +254,6 @@ export default defineComponent({ methods: { emitClick() { - console.log('EMIT CLICK') /** * Triggered when the resource is a file and the name is clicked */ From d7149b31a0e8af0d02895bfe9561d03b9b2814e0 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Tue, 24 Oct 2023 09:44:48 +0200 Subject: [PATCH 07/11] Add additional changelog item --- changelog/unreleased/bugfix-display-path-on-resources | 7 +++++++ .../unreleased/enhancement-add-editors-to-application-menu | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/bugfix-display-path-on-resources diff --git a/changelog/unreleased/bugfix-display-path-on-resources b/changelog/unreleased/bugfix-display-path-on-resources new file mode 100644 index 00000000000..25d2a2bd629 --- /dev/null +++ b/changelog/unreleased/bugfix-display-path-on-resources @@ -0,0 +1,7 @@ +Bugfix: Fix display path on resources + +We've fixed a bug, where the display path of a resource was missing parts. +For example the respective space name or the folder name of a share. + +https://github.com/owncloud/web/pull/9843 + diff --git a/changelog/unreleased/enhancement-add-editors-to-application-menu b/changelog/unreleased/enhancement-add-editors-to-application-menu index 6733ba7176c..f54be84b6a8 100644 --- a/changelog/unreleased/enhancement-add-editors-to-application-menu +++ b/changelog/unreleased/enhancement-add-editors-to-application-menu @@ -2,8 +2,6 @@ Enhancement: Add editors to the application menu We've added 'text-editor' and 'draw.io' to the application menu, so the user can easily open those apps with a one-click approach. -We've also fixed a bug, where the full path of a resource was missing while hovering it, for example in -the search preview. https://github.com/owncloud/web/pull/9809 https://github.com/owncloud/web/pull/9843 From 7d5f87c94ea967716cc258dc477bf6dbc25fb98e Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Tue, 24 Oct 2023 11:52:57 +0200 Subject: [PATCH 08/11] Remove bullshit --- .../src/components/OcResource/OcResource.vue | 2 +- .../src/components/Search/ResourcePreview.vue | 61 +++++++------------ 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/packages/design-system/src/components/OcResource/OcResource.vue b/packages/design-system/src/components/OcResource/OcResource.vue index a3f303eea39..0a3191279a1 100644 --- a/packages/design-system/src/components/OcResource/OcResource.vue +++ b/packages/design-system/src/components/OcResource/OcResource.vue @@ -66,7 +66,7 @@ :to="parentFolderLink" :style="parentFolderStyle" class="parent-folder" - @click.stop="$emit('clickParentFolder')" + @click="$emit('clickParentFolder')" > diff --git a/packages/web-pkg/src/components/Search/ResourcePreview.vue b/packages/web-pkg/src/components/Search/ResourcePreview.vue index 5a305cc44e5..e6f90be96a3 100644 --- a/packages/web-pkg/src/components/Search/ResourcePreview.vue +++ b/packages/web-pkg/src/components/Search/ResourcePreview.vue @@ -1,25 +1,18 @@ From ad5d02b77553935e625b05ce230ed98f2ab32725 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Tue, 24 Oct 2023 13:18:06 +0200 Subject: [PATCH 11/11] fix test --- .../unit/components/Search/ResourcePreview.spec.ts | 12 +++++++----- .../__snapshots__/ResourcePreview.spec.ts.snap | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 packages/web-pkg/tests/unit/components/Search/__snapshots__/ResourcePreview.spec.ts.snap diff --git a/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts b/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts index 24181ce30fc..02fe65b3cf5 100644 --- a/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts +++ b/packages/web-pkg/tests/unit/components/Search/ResourcePreview.spec.ts @@ -18,7 +18,7 @@ jest.mock('../../../../src/composables/spaces/useGetMatchingSpace', () => ({ describe('Preview component', () => { const driveAliasAndItem = '1' jest.mocked(useGetMatchingSpace).mockImplementation(() => useGetMatchingSpaceMock()) - it('should set correct props on oc-resource component', () => { + it('should render preview component', () => { const { wrapper } = getWrapper({ space: mock({ id: '1', @@ -27,9 +27,7 @@ describe('Preview component', () => { getDriveAliasAndItem: () => driveAliasAndItem }) }) - const ocResource = wrapper.findComponent('oc-resource-stub') - - expect(ocResource.props().resource).toMatchObject(wrapper.vm.searchResult.data) + expect(wrapper.html()).toMatchSnapshot() }) }) @@ -59,6 +57,9 @@ function getWrapper({ } = {}) { jest.mocked(useGetMatchingSpace).mockImplementation(() => useGetMatchingSpaceMock({ + isResourceAccessible() { + return true + }, getMatchingSpace() { return space } @@ -76,7 +77,8 @@ function getWrapper({ }), capabilities: () => ({ spaces: { - share_jail: hasShareJail + share_jail: hasShareJail, + projects: { enabled: true } } }), user: () => user diff --git a/packages/web-pkg/tests/unit/components/Search/__snapshots__/ResourcePreview.spec.ts.snap b/packages/web-pkg/tests/unit/components/Search/__snapshots__/ResourcePreview.spec.ts.snap new file mode 100644 index 00000000000..5598ec4e6e1 --- /dev/null +++ b/packages/web-pkg/tests/unit/components/Search/__snapshots__/ResourcePreview.spec.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Preview component should render preview component 1`] = ``;