From adf9117c138dcf069c880f7dde52b10afb3f8216 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 4 Mar 2022 21:25:01 +0100 Subject: [PATCH 1/2] OcResource: Fix examples --- src/components/atoms/OcResourceIcon/OcResourceIcon.vue | 2 +- src/components/organisms/OcResource/OcResource.vue | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/atoms/OcResourceIcon/OcResourceIcon.vue b/src/components/atoms/OcResourceIcon/OcResourceIcon.vue index 1f3852030..d9d770d43 100644 --- a/src/components/atoms/OcResourceIcon/OcResourceIcon.vue +++ b/src/components/atoms/OcResourceIcon/OcResourceIcon.vue @@ -61,7 +61,7 @@ export default { return this.resource.isFolder }, extension() { - return this.resource.extension.toLowerCase() + return this.resource.extension?.toLowerCase() }, }, } diff --git a/src/components/organisms/OcResource/OcResource.vue b/src/components/organisms/OcResource/OcResource.vue index 7978aa283..063731f2c 100644 --- a/src/components/organisms/OcResource/OcResource.vue +++ b/src/components/organisms/OcResource/OcResource.vue @@ -307,7 +307,8 @@ export default { name: "Documents", path: "/Documents", indicators: [], - type: "folder" + type: "folder", + isFolder: true } }, notes() { @@ -316,7 +317,8 @@ export default { extension: "txt", path: "Documents/notes.txt", indicators: this.indicators, - type: "file" + type: "file", + isFolder: false } }, forest() { @@ -327,6 +329,7 @@ export default { thumbnail: "https://picsum.photos/200/300", indicators: [], type: "file", + isFolder: false, opensInNewWindow: true, } }, From b87ac0f01ddbdc3c68ad36c58c9e8610b56c2d93 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 4 Mar 2022 21:29:23 +0100 Subject: [PATCH 2/2] Introduce OcResourceLink to reduce code duplication... ... and fix icons/thumbnails not being shown if the resource is not clickable. --- ...-icon-only-visible-for-clickable-resources | 8 ++ .../atoms/OcResourceLink/OcResourceLink.vue | 104 ++++++++++++++++++ .../organisms/OcResource/OcResource.spec.js | 7 ++ .../organisms/OcResource/OcResource.vue | 98 ++++------------- 4 files changed, 142 insertions(+), 75 deletions(-) create mode 100644 changelog/unreleased/bugfix-icon-only-visible-for-clickable-resources create mode 100644 src/components/atoms/OcResourceLink/OcResourceLink.vue diff --git a/changelog/unreleased/bugfix-icon-only-visible-for-clickable-resources b/changelog/unreleased/bugfix-icon-only-visible-for-clickable-resources new file mode 100644 index 000000000..6602ea998 --- /dev/null +++ b/changelog/unreleased/bugfix-icon-only-visible-for-clickable-resources @@ -0,0 +1,8 @@ +Bugfix: Icons/Thumbnails were only visible for clickable resources + +We fixed that only clickable resources had icons/thumbnails in `OcResource`. +It was fixed by introducing an `OcResourceLink` component that reduces code +complexity and duplication when linking resources. + + +https://github.com/owncloud/owncloud-design-system/pull/2007 diff --git a/src/components/atoms/OcResourceLink/OcResourceLink.vue b/src/components/atoms/OcResourceLink/OcResourceLink.vue new file mode 100644 index 000000000..fc93f5c5b --- /dev/null +++ b/src/components/atoms/OcResourceLink/OcResourceLink.vue @@ -0,0 +1,104 @@ + + + diff --git a/src/components/organisms/OcResource/OcResource.spec.js b/src/components/organisms/OcResource/OcResource.spec.js index cfe075c7d..06baf5db5 100644 --- a/src/components/organisms/OcResource/OcResource.spec.js +++ b/src/components/organisms/OcResource/OcResource.spec.js @@ -1,7 +1,11 @@ import { mount } from "@vue/test-utils" import Resource from "./OcResource.vue" +import OcButton from "../../atoms/OcButton/OcButton.vue" +const stubs = { + "oc-button": OcButton, +} const fileResource = { name: "forest.jpg", path: "nature/forest.jpg", @@ -51,6 +55,7 @@ describe("OcResource", () => { propsData: { resource: fileResource, }, + stubs, }) wrapper.find(".oc-resource-name").trigger("click") @@ -64,6 +69,7 @@ describe("OcResource", () => { isPathDisplayed: true, parentFolderLink: {}, }, + stubs, }) expect(wrapper.find(".parent-folder").find("a").exists()).toBeTruthy() @@ -76,6 +82,7 @@ describe("OcResource", () => { resource: fileResource, isPathDisplayed: true, }, + stubs, }) expect(wrapper.find(".parent-folder").find("a").exists()).toBeFalsy() diff --git a/src/components/organisms/OcResource/OcResource.vue b/src/components/organisms/OcResource/OcResource.vue index 063731f2c..c514430b5 100644 --- a/src/components/organisms/OcResource/OcResource.vue +++ b/src/components/organisms/OcResource/OcResource.vue @@ -1,13 +1,10 @@