This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce OcResourceLink to reduce code duplication...
... and fix icons/thumbnails not being shown if the resource is not clickable.
- Loading branch information
Showing
4 changed files
with
142 additions
and
75 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
changelog/unreleased/bugfix-icon-only-visible-for-clickable-resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<template> | ||
<component | ||
:is="componentType" | ||
v-bind="componentProps" | ||
v-if="isResourceClickable" | ||
:target="linkTargetBlank" | ||
:aria-describedby="opensInNewWindowDescriptionId" | ||
@click.stop="emitClick" | ||
@click.native.stop | ||
> | ||
<slot :opensInNewWindowDescriptionId="opensInNewWindowDescriptionId" /> | ||
</component> | ||
<span v-else> | ||
<slot /> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import uniqueId from "../../../utils/uniqueId" | ||
/** | ||
* Wraps content in a resource link | ||
*/ | ||
export default { | ||
name: "OcResourceLink", | ||
status: "prototype", | ||
release: "unreleased", | ||
props: { | ||
/** | ||
* The resource folder link | ||
*/ | ||
folderLink: { | ||
type: Object, | ||
required: false, | ||
default: null, | ||
}, | ||
/** | ||
* The resource to be displayed | ||
*/ | ||
resource: { | ||
type: Object, | ||
required: true, | ||
}, | ||
/** | ||
* Asserts whether clicking on the resource name triggers any action | ||
*/ | ||
isResourceClickable: { | ||
type: Boolean, | ||
required: false, | ||
default: true, | ||
}, | ||
}, | ||
computed: { | ||
isFolder() { | ||
return this.resource.isFolder | ||
}, | ||
componentType() { | ||
return this.isFolder ? "router-link" : "oc-button" | ||
}, | ||
componentProps() { | ||
if (!this.isRouterLink) { | ||
return { | ||
appearance: "raw", | ||
gapSize: "none", | ||
justifyContent: "left", | ||
} | ||
} | ||
return { | ||
to: this.folderLink, | ||
} | ||
}, | ||
opensInNewWindowDescriptionId() { | ||
if (this.resource.opensInNewWindow) { | ||
return uniqueId("oc-link-description-") | ||
} | ||
return null | ||
}, | ||
isRouterLink() { | ||
return this.isResourceClickable && this.isFolder | ||
}, | ||
linkTargetBlank() { | ||
if (this.isRouterLink && this.resource.opensInNewWindow) { | ||
return "_blank" | ||
} | ||
return null | ||
}, | ||
}, | ||
methods: { | ||
emitClick() { | ||
if (this.isFolder) { | ||
return | ||
} | ||
/** | ||
* Triggered when the resource is a file and the name is clicked | ||
*/ | ||
this.$emit("click") | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters