diff --git a/changelog/unreleased/enhancement-configurable-resource-parentfolder b/changelog/unreleased/enhancement-configurable-resource-parentfolder new file mode 100644 index 000000000..002169628 --- /dev/null +++ b/changelog/unreleased/enhancement-configurable-resource-parentfolder @@ -0,0 +1,7 @@ +Enhancement: Configurable OcResource parentfolder name + +We've added a `parent-folder-name-default` property to the OcResource component. +Before, an empty parent resulted in a hardcoded "All files and folders" which +becomes misleading with the introduction of spaces in oCIS. + +https://github.com/owncloud/owncloud-design-system/pull/2029 diff --git a/src/components/organisms/OcResource/OcResource.spec.js b/src/components/organisms/OcResource/OcResource.spec.js index 06baf5db5..9ecb2b5f5 100644 --- a/src/components/organisms/OcResource/OcResource.spec.js +++ b/src/components/organisms/OcResource/OcResource.spec.js @@ -10,7 +10,6 @@ const fileResource = { name: "forest.jpg", path: "nature/forest.jpg", thumbnail: "https://cdn.pixabay.com/photo/2015/09/09/16/05/forest-931706_960_720.jpg", - indicators: [], type: "file", isFolder: false, extension: "jpg", @@ -18,10 +17,16 @@ const fileResource = { const folderResource = { name: "Documents", path: "", - indicators: [], type: "folder", isFolder: true, } +const fileResourceWithoutParentFoldername = { + name: "example.pdf", + path: "example.pdf", + type: "file", + isFolder: false, + extension: "pdf", +} describe("OcResource", () => { it("doesn't emit a click if the resource is a folder", () => { @@ -88,4 +93,17 @@ describe("OcResource", () => { expect(wrapper.find(".parent-folder").find("a").exists()).toBeFalsy() expect(wrapper.find(".parent-folder").attributes("style")).toEqual("cursor: default;") }) + + it("displays parent folder name default if calculated name is empty", () => { + const wrapper = mount(Resource, { + propsData: { + resource: fileResourceWithoutParentFoldername, + isPathDisplayed: true, + parentFolderNameDefault: "Example parent folder name", + }, + stubs, + }) + + expect(wrapper).toMatchSnapshot() + }) }) diff --git a/src/components/organisms/OcResource/OcResource.vue b/src/components/organisms/OcResource/OcResource.vue index 46a961136..9400c9d02 100644 --- a/src/components/organisms/OcResource/OcResource.vue +++ b/src/components/organisms/OcResource/OcResource.vue @@ -107,6 +107,14 @@ export default { type: Object, required: true, }, + /** + * The resource parent folder name to be displayed + */ + parentFolderNameDefault: { + type: String, + required: false, + default: "", + }, /** * Asserts whether the resource path should be displayed */ @@ -139,7 +147,7 @@ export default { parentFolder() { const folder = path.basename(path.dirname(this.resource.path)).replace(".", "") - return folder !== "" ? folder : this.$gettext("All files and folders") + return folder !== "" ? folder : this.parentFolderNameDefault }, parentFolderStyle() { @@ -236,10 +244,11 @@ export default { ```js