Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable7] NcActionLink - provide download attributes for single action button in NcAction #4293

Merged
merged 1 commit into from Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/components/NcActionLink/NcActionLink.vue
Expand Up @@ -26,20 +26,50 @@ This component is made to be used inside of the [NcActions](#NcActions) componen

```
<template>
<NcActions>
<NcActionLink href="https://nextcloud.com">
<template #icon>
<OpenInNew :size="20" />
</template>
Nextcloud website
</NcActionLink>
</NcActions>
<div style="display: flex; align-items: center;">
<NcActions>
<NcActionLink href="https://nextcloud.com">
<template #icon>
<OpenInNew :size="20" />
</template>
Nextcloud website
</NcActionLink>
</NcActions>

<NcActions>
<NcActionLink href="https://www.gnu.org/licenses/gpl.odt"
download="AGPL License text.odt">
<template #icon>
<Download :size="20" />
</template>
Download AGPL license text
</NcActionLink>
</NcActions>

<NcActions>
<NcActionLink href="https://nextcloud.com">
<template #icon>
<OpenInNew :size="20" />
</template>
Nextcloud website
</NcActionLink>
<NcActionLink href="https://www.gnu.org/licenses/gpl.odt"
download="AGPL License text.odt">
<template #icon>
<Download :size="20" />
</template>
Download AGPL license text
</NcActionLink>
</NcActions>
</div>
</template>
<script>
import Download from 'vue-material-design-icons/Download'
import OpenInNew from 'vue-material-design-icons/OpenInNew'

export default {
components: {
Download,
OpenInNew,
},
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/NcButton/NcButton.vue
Expand Up @@ -270,6 +270,14 @@ export default {
default: null,
},

/**
* Providing the download attribute with href downloads file when clicking.
*/
download: {
type: String,
default: null,
},

/**
* Providing the to attribute turns the button component into a `router-link`
* element. Takes precedence over the href attribute.
Expand Down Expand Up @@ -339,6 +347,9 @@ export default {
type: this.href ? null : this.nativeType,
role: this.href ? 'button' : null,
href: (!this.to && this.href) ? this.href : null,
target: (!this.to && this.href) ? '_self' : null,
rel: (!this.to && this.href) ? 'nofollow noreferrer noopener' : null,
download: (!this.to && this.href && this.download) ? this.download : null,
...this.$attrs,
},
on: {
Expand Down