Skip to content

Commit

Permalink
Hide new public link share button if user lacks permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed May 26, 2021
1 parent 38a97a4 commit 60afb29
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/bugfix-hide-new-link-button
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Hide "Create new public link" button

The button to create new public links was visible even if the user lacked
the permissions to create one. It is now being hidden unless the user is
allowed to create a share of the respective file.

https://github.com/owncloud/web/pull/5126
28 changes: 22 additions & 6 deletions packages/web-app-files/src/components/FileLinkSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<template v-else>
<private-link-item />
<h4 v-translate class="oc-text-bold oc-m-rm oc-text-initial">Public Links</h4>
<p v-translate class="oc-text-muted oc-my-rm">
Any external person with the respective link can access this resource. No sign-in
required. Assign a password to avoid unintended document exposure.
</p>
<div class="oc-my-s">
<div v-if="canCreatePublicLinks" class="oc-my-s">
<p v-translate class="oc-text-muted">
Any external person with the respective link can access this resource. No sign-in
required. Assign a password to avoid unintended document exposure.
</p>
<oc-button
id="files-file-link-add"
icon="add"
Expand All @@ -25,6 +25,7 @@
{{ $_addButtonLabel }}
</oc-button>
</div>
<p v-else class="oc-mt-s" v-text="noResharePermsMessage" />
<transition-group
class="uk-list uk-list-divider uk-overflow-hidden oc-m-rm"
:enter-active-class="$_transitionGroupEnter"
Expand All @@ -36,7 +37,12 @@
<public-link-list-item :link="link" />
</li>
</transition-group>
<p v-if="$_noPublicLinks" key="oc-file-links-no-results" v-translate class="oc-my-rm">
<p
v-if="$_noPublicLinks && canCreatePublicLinks"
key="oc-file-links-no-results"
v-translate
class="oc-my-rm"
>
No public links
</p>
</template>
Expand Down Expand Up @@ -102,6 +108,16 @@ export default {
return 'uk-animation-slide-right-medium uk-animation-reverse'
},
canCreatePublicLinks() {
return this.highlightedFile.canShare()
},
noResharePermsMessage() {
const translatedFile = this.$gettext("You don't have permission to share this file.")
const translatedFolder = this.$gettext("You don't have permission to share this folder.")
return this.highlightedFile.type === 'file' ? translatedFile : translatedFolder
},
linksLoading() {
return this.currentFileOutgoingSharesLoading || this.sharesTreeLoading
},
Expand Down

0 comments on commit 60afb29

Please sign in to comment.