diff --git a/apps/files_sharing/js/dist/additionalScripts.js b/apps/files_sharing/js/dist/additionalScripts.js index 6c8e60d09c110fc99fcd71a461e7fa0603520924..8c7865414ae12379527d6fa2776da8570641211d 100644 Binary files a/apps/files_sharing/js/dist/additionalScripts.js and b/apps/files_sharing/js/dist/additionalScripts.js differ diff --git a/apps/files_sharing/js/dist/additionalScripts.js.map b/apps/files_sharing/js/dist/additionalScripts.js.map index 45d207f470a2d88aba9eb933a44a9109325e0917..79fbae4187757c83678951693248b8557b57cee2 100644 Binary files a/apps/files_sharing/js/dist/additionalScripts.js.map and b/apps/files_sharing/js/dist/additionalScripts.js.map differ diff --git a/apps/files_sharing/js/dist/collaboration.js b/apps/files_sharing/js/dist/collaboration.js index aaa791a90479e3217d7c55754944ac1a3f8d5810..da7c67cd2d555eed30b613a1422a2a2d9419c52e 100644 Binary files a/apps/files_sharing/js/dist/collaboration.js and b/apps/files_sharing/js/dist/collaboration.js differ diff --git a/apps/files_sharing/js/dist/collaboration.js.map b/apps/files_sharing/js/dist/collaboration.js.map index 294bc0763a6711731299580d7e33c0f772d29eaa..60686d33e6dc4ee036715899f392d108fd67f745 100644 Binary files a/apps/files_sharing/js/dist/collaboration.js.map and b/apps/files_sharing/js/dist/collaboration.js.map differ diff --git a/apps/files_sharing/js/dist/files_sharing.js b/apps/files_sharing/js/dist/files_sharing.js index b8c19e4a8407063acfa8e76378c67456522931fc..ff5f3a4c3069186f4fb0ad823792266fa4391c69 100644 Binary files a/apps/files_sharing/js/dist/files_sharing.js and b/apps/files_sharing/js/dist/files_sharing.js differ diff --git a/apps/files_sharing/js/dist/files_sharing.js.map b/apps/files_sharing/js/dist/files_sharing.js.map index 4c96b89123b6e15c0bc4ff8e6fb4105a71222c10..2a7125276b4915767f352faa89f4707787d8cdb6 100644 Binary files a/apps/files_sharing/js/dist/files_sharing.js.map and b/apps/files_sharing/js/dist/files_sharing.js.map differ diff --git a/apps/files_sharing/js/dist/files_sharing_tab.js b/apps/files_sharing/js/dist/files_sharing_tab.js index c7a7387958f4994551159cb97e3079dcb4cdcf5e..06e33138bb1082b532c6c70f17d591a705774aae 100644 Binary files a/apps/files_sharing/js/dist/files_sharing_tab.js and b/apps/files_sharing/js/dist/files_sharing_tab.js differ diff --git a/apps/files_sharing/js/dist/files_sharing_tab.js.map b/apps/files_sharing/js/dist/files_sharing_tab.js.map index 40bda83585c5b42da95fe3843784e685dec71e54..8df7b23e8eaacd200737e0f9ce0a016352550e31 100644 Binary files a/apps/files_sharing/js/dist/files_sharing_tab.js.map and b/apps/files_sharing/js/dist/files_sharing_tab.js.map differ diff --git a/apps/files_sharing/js/dist/main.js b/apps/files_sharing/js/dist/main.js index eaff364433db280c4dcf62cc638861bb0ca42071..ddbbb4c74af0c61cd8d3daac11299c9f695d8b11 100644 Binary files a/apps/files_sharing/js/dist/main.js and b/apps/files_sharing/js/dist/main.js differ diff --git a/apps/files_sharing/js/dist/main.js.map b/apps/files_sharing/js/dist/main.js.map index f381cb011f2458688572cf451f35b0372c8226b2..cfc8d08c6c802d7c5493b644fa00048b6f7823c0 100644 Binary files a/apps/files_sharing/js/dist/main.js.map and b/apps/files_sharing/js/dist/main.js.map differ diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue index cde7d2ed2b17bc4c50035f39bf8d5264e63b844f..4d7f60cfa617fdd7156e5c489a43bbf70b7aab3e 100644 --- a/apps/files_sharing/src/components/SharingEntry.vue +++ b/apps/files_sharing/src/components/SharingEntry.vue @@ -119,8 +119,6 @@ import ActionInput from 'nextcloud-vue/dist/Components/ActionInput' import ActionTextEditable from 'nextcloud-vue/dist/Components/ActionTextEditable' import Tooltip from 'nextcloud-vue/dist/Directives/Tooltip' -// eslint-disable-next-line no-unused-vars -import Share from '../models/Share' import SharesMixin from '../mixins/SharesMixin' export default { diff --git a/apps/files_sharing/src/components/SharingEntryInherited.vue b/apps/files_sharing/src/components/SharingEntryInherited.vue new file mode 100644 index 0000000000000000000000000000000000000000..0d355ed6d22e68a7a00b27f877ec2da8f019ae54 --- /dev/null +++ b/apps/files_sharing/src/components/SharingEntryInherited.vue @@ -0,0 +1,112 @@ +<!-- + - @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com> + - + - @author John Molakvoæ <skjnldsv@protonmail.com> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. + - + --> + +<template> + <SharingEntrySimple + :key="share.id" + class="sharing-entry__inherited" + :title="share.shareWithDisplayName"> + <template #avatar> + <Avatar + :user="share.shareWith" + :display-name="share.shareWithDisplayName" + class="sharing-entry__avatar" + tooltip-message="" /> + </template> + <ActionText icon="icon-user"> + {{ t('files_sharing', 'Invited by {initiator}', { initiator: share.ownerDisplayName }) }} + </ActionText> + <ActionLink v-if="share.fileSource" + icon="icon-folder" + :href="fileTargetUrl"> + {{ t('files_sharing', 'Open folder') }} + </ActionLink> + <ActionButton v-if="share.canDelete" + icon="icon-delete" + @click.prevent="onDelete"> + {{ t('files_sharing', 'Delete share') }} + </actionbutton> + </SharingEntrySimple> +</template> + +<script> +import { generateUrl } from '@nextcloud/router' +import Avatar from 'nextcloud-vue/dist/Components/Avatar' +import ActionButton from 'nextcloud-vue/dist/Components/ActionButton' +import ActionLink from 'nextcloud-vue/dist/Components/ActionLink' +import ActionText from 'nextcloud-vue/dist/Components/ActionText' + +// eslint-disable-next-line no-unused-vars +import Share from '../models/Share' +import SharesMixin from '../mixins/SharesMixin' +import SharingEntrySimple from '../components/SharingEntrySimple' + +export default { + name: 'SharingEntryInherited', + + components: { + ActionButton, + ActionLink, + ActionText, + Avatar, + SharingEntrySimple + }, + + mixins: [SharesMixin], + + props: { + share: { + type: Share, + required: true + } + }, + + computed: { + fileTargetUrl() { + return generateUrl('/f/{fileid}', { + fileid: this.share.fileSource + }) + } + } +} +</script> + +<style lang="scss" scoped> +.sharing-entry { + display: flex; + align-items: center; + height: 44px; + &__desc { + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 8px; + line-height: 1.2em; + p { + color: var(--color-text-maxcontrast); + } + } + &__actions { + margin-left: auto; + } +} +</style> diff --git a/apps/files_sharing/src/views/SharingInherited.vue b/apps/files_sharing/src/views/SharingInherited.vue new file mode 100644 index 0000000000000000000000000000000000000000..be3c5ef2dc363f3c343a0847e21533b3cd8cb44c --- /dev/null +++ b/apps/files_sharing/src/views/SharingInherited.vue @@ -0,0 +1,164 @@ +<!-- + - @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com> + - + - @author John Molakvoæ <skjnldsv@protonmail.com> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. + - + --> + +<template> + <ul id="sharing-inherited-shares"> + <!-- Main collapsible entry --> + <SharingEntrySimple + class="sharing-entry__inherited" + :title="mainTitle"> + <template #avatar> + <div class="avatar-shared icon-more-white" /> + </template> + <ActionButton :icon="showInheritedSharesIcon" @click.prevent.stop="toggleInheritedShares"> + {{ toggleTooltip }} + </ActionButton> + </SharingEntrySimple> + + <!-- Inherited shares list --> + <SharingEntryInherited v-for="share in shares" + :key="share.id" + :share="share" /> + </ul> +</template> + +<script> +import { generateOcsUrl } from '@nextcloud/router' +import ActionButton from 'nextcloud-vue/dist/Components/ActionButton' +import axios from '@nextcloud/axios' + +import Share from '../models/Share' +import SharingEntryInherited from '../components/SharingEntryInherited' +import SharingEntrySimple from '../components/SharingEntrySimple' + +export default { + name: 'SharingInherited', + + components: { + ActionButton, + SharingEntryInherited, + SharingEntrySimple + }, + + props: { + fileInfo: { + type: Object, + default: () => {}, + required: true + } + }, + + data() { + return { + loaded: false, + loading: false, + showInheritedShares: false, + shares: [] + } + }, + computed: { + showInheritedSharesIcon() { + if (this.loading) { + return 'icon-loading-small' + } + if (this.showInheritedShares) { + return 'icon-triangle-n' + } + return 'icon-triangle-s' + }, + mainTitle() { + return t('files_sharing', 'Others with access {count}', { + count: this.loaded ? `: ${this.shares.length}` : '' + }) + }, + toggleTooltip() { + return this.fileInfo.type === 'dir' + ? t('files_sharing', 'Toggle list of others with access to this directory') + : t('files_sharing', 'Toggle list of others with access to this file') + }, + fullPath() { + const path = `${this.fileInfo.path}/${this.fileInfo.name}` + return path.replace('//', '/') + } + }, + watch: { + fileInfo() { + this.resetState() + } + }, + methods: { + /** + * Toggle the list view and fetch/reset the state + */ + toggleInheritedShares() { + this.showInheritedShares = !this.showInheritedShares + if (this.showInheritedShares) { + this.fetchInheritedShares() + } else { + this.resetState() + } + }, + /** + * Fetch the Inherited Shares array + */ + async fetchInheritedShares() { + this.loading = true + try { + const url = generateOcsUrl(`apps/files_sharing/api/v1/shares/inherited?format=json&path=${this.fullPath}`, 2) + const shares = await axios.get(url.replace(/\/$/, '')) + this.shares = shares.data.ocs.data + .map(share => new Share(share)) + .sort((a, b) => b.createdTime - a.createdTime) + console.info(this.shares) + this.loaded = true + } catch (error) { + OC.Notification.showTemporary(t('files_sharing', 'Unable to fetch inherited shares'), { type: 'error' }) + } finally { + this.loading = false + } + }, + /** + * Reset current component state + */ + resetState() { + this.loaded = false + this.loading = false + this.showInheritedShares = false + this.shares = [] + } + } +} +</script> + +<style lang="scss" scoped> +.sharing-entry__inherited { + .avatar-shared { + width: 32px; + height: 32px; + line-height: 32px; + font-size: 18px; + background-color: var(--color-text-maxcontrast); + border-radius: 50%; + flex-shrink: 0; + } +} +</style> diff --git a/apps/files_sharing/src/views/SharingTab.vue b/apps/files_sharing/src/views/SharingTab.vue index 216b2e74ffcdd6cb21894852419d9341b229e622..b15ec5e9a649440fb131be4a2ee42de2fc37877a 100644 --- a/apps/files_sharing/src/views/SharingTab.vue +++ b/apps/files_sharing/src/views/SharingTab.vue @@ -33,7 +33,7 @@ <!-- shared with me information --> <SharingEntrySimple v-if="isSharedWithMe" v-bind="sharedWithMe" class="sharing-entry__reshare"> <template #avatar> - <Avatar #avatar + <Avatar :user="sharedWithMe.user" :display-name="sharedWithMe.displayName" class="sharing-entry__avatar" @@ -61,6 +61,9 @@ :shares="shares" :file-info="fileInfo" /> + <!-- inherited shares --> + <SharingInherited v-if="!loading" :file-info="fileInfo" /> + <!-- internal link copy --> <SharingEntryInternal :file-info="fileInfo" /> @@ -82,11 +85,11 @@ </template> <script> +import { CollectionList } from 'nextcloud-vue-collections' import { generateOcsUrl } from '@nextcloud/router' -import Tab from 'nextcloud-vue/dist/Components/AppSidebarTab' import Avatar from 'nextcloud-vue/dist/Components/Avatar' import axios from '@nextcloud/axios' -import { CollectionList } from 'nextcloud-vue-collections' +import Tab from 'nextcloud-vue/dist/Components/AppSidebarTab' import { shareWithTitle } from '../utils/SharedWithMe' import Share from '../models/Share' @@ -95,6 +98,7 @@ import SharingEntryInternal from '../components/SharingEntryInternal' import SharingEntrySimple from '../components/SharingEntrySimple' import SharingInput from '../components/SharingInput' +import SharingInherited from './SharingInherited' import SharingLinkList from './SharingLinkList' import SharingList from './SharingList' @@ -106,6 +110,7 @@ export default { CollectionList, SharingEntryInternal, SharingEntrySimple, + SharingInherited, SharingInput, SharingLinkList, SharingList,