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

enh: Improvements on sharing details #49351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/src/components/AbsenceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default {
async getSuggestions(search) {

const shareType = [
ShareType.SHARE_TYPE_USER,
ShareType.User,
]

let request = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import type { IAccountData } from '../filters/AccountFilter.ts'

import { translate as t } from '@nextcloud/l10n'
import { ShareType } from '@nextcloud/sharing'
import { mdiAccountMultiple } from '@mdi/js'
import { useBrowserLocation } from '@vueuse/core'
import { computed, ref, watch } from 'vue'
Expand All @@ -49,7 +50,6 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import { ShareType } from '@nextcloud/sharing'

interface IUserSelectData {
id: string
Expand Down
20 changes: 11 additions & 9 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<template>
<li class="sharing-entry">
<NcAvatar class="sharing-entry__avatar"
:is-no-user="share.type !== SHARE_TYPES.SHARE_TYPE_USER"
:is-no-user="share.type !== ShareType.User"
:user="share.shareWith"
:display-name="share.shareWithDisplayName"
:menu-position="'left'"
Expand Down Expand Up @@ -41,6 +41,8 @@
</template>

<script>
import { ShareType } from '@nextcloud/sharing'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
Expand All @@ -67,15 +69,15 @@ export default {
computed: {
title() {
let title = this.share.shareWithDisplayName
if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_GROUP) {
if (this.share.type === ShareType.Group) {
title += ` (${t('files_sharing', 'group')})`
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_ROOM) {
} else if (this.share.type === ShareType.Room) {
title += ` (${t('files_sharing', 'conversation')})`
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE) {
} else if (this.share.type === ShareType.Remote) {
title += ` (${t('files_sharing', 'remote')})`
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP) {
} else if (this.share.type === ShareType.RemoteGroup) {
title += ` (${t('files_sharing', 'remote group')})`
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_GUEST) {
} else if (this.share.type === ShareType.Guest) {
title += ` (${t('files_sharing', 'guest')})`
}
return title
Expand All @@ -88,9 +90,9 @@ export default {
user: this.share.shareWithDisplayName,
owner: this.share.ownerDisplayName,
}
if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_GROUP) {
if (this.share.type === ShareType.Group) {
return t('files_sharing', 'Shared with the group {user} by {owner}', data)
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_ROOM) {
} else if (this.share.type === ShareType.Room) {
return t('files_sharing', 'Shared with the conversation {user} by {owner}', data)
}

Expand All @@ -103,7 +105,7 @@ export default {
* @return {boolean}
*/
hasStatus() {
if (this.share.type !== this.SHARE_TYPES.SHARE_TYPE_USER) {
if (this.share.type !== ShareType.User) {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default {
*/
isEmailShareType() {
return this.share
? this.share.type === this.SHARE_TYPES.SHARE_TYPE_EMAIL
? this.share.type === ShareType.Email
: false
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
</template>

<script>
import { ShareType } from '@nextcloud/sharing'
import DropdownIcon from 'vue-material-design-icons/TriangleSmallDown.vue'
import SharesMixin from '../mixins/SharesMixin.js'
import ShareDetails from '../mixins/ShareDetails.js'
import ShareTypes from '../mixins/ShareTypes.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import IconEyeOutline from 'vue-material-design-icons/EyeOutline.vue'
Expand All @@ -52,7 +52,7 @@ export default {
NcActionButton,
},

mixins: [SharesMixin, ShareDetails, ShareTypes],
mixins: [SharesMixin, ShareDetails],

props: {
share: {
Expand Down Expand Up @@ -122,7 +122,7 @@ export default {
supportsFileDrop() {
if (this.isFolder && this.config.isPublicUploadEnabled) {
const shareType = this.share.type ?? this.share.shareType
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
return [ShareType.Link, ShareType.Email].includes(shareType)
}
return false
},
Expand Down
60 changes: 27 additions & 33 deletions apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import Config from '../services/ConfigService.ts'
import Share from '../models/Share.ts'
import ShareRequests from '../mixins/ShareRequests.js'
import ShareTypes from '../mixins/ShareTypes.js'
import ShareDetails from '../mixins/ShareDetails.js'
import { ShareType } from '@nextcloud/sharing'

export default {
name: 'SharingInput',
Expand All @@ -48,7 +48,7 @@ export default {
NcSelect,
},

mixins: [ShareTypes, ShareRequests, ShareDetails],
mixins: [ShareRequests, ShareDetails],

props: {
shares: {
Expand Down Expand Up @@ -169,19 +169,18 @@ export default {
}

const shareType = [
this.SHARE_TYPES.SHARE_TYPE_USER,
this.SHARE_TYPES.SHARE_TYPE_GROUP,
this.SHARE_TYPES.SHARE_TYPE_REMOTE,
this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP,
this.SHARE_TYPES.SHARE_TYPE_CIRCLE,
this.SHARE_TYPES.SHARE_TYPE_ROOM,
this.SHARE_TYPES.SHARE_TYPE_GUEST,
this.SHARE_TYPES.SHARE_TYPE_DECK,
this.SHARE_TYPES.SHARE_TYPE_SCIENCEMESH,
ShareType.User,
ShareType.Group,
ShareType.Remote,
ShareType.RemoteGroup,
ShareType.Team,
ShareType.Room,
ShareType.Guest,
ShareType.Deck,
]

if (getCapabilities().files_sharing.public.enabled === true) {
shareType.push(this.SHARE_TYPES.SHARE_TYPE_EMAIL)
shareType.push(ShareType.Email)
}

let request = null
Expand Down Expand Up @@ -318,7 +317,7 @@ export default {
return arr
}
try {
if (share.value.shareType === this.SHARE_TYPES.SHARE_TYPE_USER) {
if (share.value.shareType === ShareType.User) {
// filter out current user
if (share.value.shareWith === getCurrentUser().uid) {
return arr
Expand All @@ -331,7 +330,7 @@ export default {
}

// filter out existing mail shares
if (share.value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
if (share.value.shareType === ShareType.Email) {
const emails = this.linkShares.map(elem => elem.shareWith)
if (emails.indexOf(share.value.shareWith.trim()) !== -1) {
return arr
Expand Down Expand Up @@ -369,46 +368,41 @@ export default {
*/
shareTypeToIcon(type) {
switch (type) {
case this.SHARE_TYPES.SHARE_TYPE_GUEST:
case ShareType.Guest:
// default is a user, other icons are here to differentiate
// themselves from it, so let's not display the user icon
// case this.SHARE_TYPES.SHARE_TYPE_REMOTE:
// case this.SHARE_TYPES.SHARE_TYPE_USER:
// case ShareType.Remote:
// case ShareType.User:
return {
icon: 'icon-user',
iconTitle: t('files_sharing', 'Guest'),
}
case this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP:
case this.SHARE_TYPES.SHARE_TYPE_GROUP:
case ShareType.RemoteGroup:
case ShareType.Group:
return {
icon: 'icon-group',
iconTitle: t('files_sharing', 'Group'),
}
case this.SHARE_TYPES.SHARE_TYPE_EMAIL:
case ShareType.Email:
return {
icon: 'icon-mail',
iconTitle: t('files_sharing', 'Email'),
}
case this.SHARE_TYPES.SHARE_TYPE_CIRCLE:
case ShareType.Team:
return {
icon: 'icon-teams',
iconTitle: t('files_sharing', 'Team'),
}
case this.SHARE_TYPES.SHARE_TYPE_ROOM:
case ShareType.Room:
return {
icon: 'icon-room',
iconTitle: t('files_sharing', 'Talk conversation'),
}
case this.SHARE_TYPES.SHARE_TYPE_DECK:
case ShareType.Deck:
return {
icon: 'icon-deck',
iconTitle: t('files_sharing', 'Deck board'),
}
case this.SHARE_TYPES.SHARE_TYPE_SCIENCEMESH:
return {
icon: 'icon-sciencemesh',
iconTitle: t('files_sharing', 'ScienceMesh'),
}
default:
return {}
}
Expand All @@ -422,13 +416,13 @@ export default {
*/
formatForMultiselect(result) {
let subname
if (result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_USER && this.config.shouldAlwaysShowUnique) {
if (result.value.shareType === ShareType.User && this.config.shouldAlwaysShowUnique) {
subname = result.shareWithDisplayNameUnique ?? ''
} else if ((result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_REMOTE
|| result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
} else if ((result.value.shareType === ShareType.Remote
|| result.value.shareType === ShareType.RemoteGroup
) && result.value.server) {
subname = t('files_sharing', 'on {server}', { server: result.value.server })
} else if (result.value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
} else if (result.value.shareType === ShareType.Email) {
subname = result.value.shareWith
} else {
subname = result.shareWithDescription ?? ''
Expand All @@ -438,7 +432,7 @@ export default {
shareWith: result.value.shareWith,
shareType: result.value.shareType,
user: result.uuid || result.value.shareWith,
isNoUser: result.value.shareType !== this.SHARE_TYPES.SHARE_TYPE_USER,
isNoUser: result.value.shareType !== ShareType.User,
displayName: result.name || result.label,
subname,
shareWithDisplayNameUnique: result.shareWithDisplayNameUnique || '',
Expand Down
14 changes: 0 additions & 14 deletions apps/files_sharing/src/mixins/ShareTypes.js

This file was deleted.

9 changes: 5 additions & 4 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { getCurrentUser } from '@nextcloud/auth'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { ShareType } from '@nextcloud/sharing'
import { emit } from '@nextcloud/event-bus'
import { fetchNode } from '../services/WebdavClient.ts'

Expand All @@ -13,7 +14,6 @@ import debounce from 'debounce'

import Share from '../models/Share.ts'
import SharesRequests from './ShareRequests.js'
import ShareTypes from './ShareTypes.js'
import Config from '../services/ConfigService.ts'
import logger from '../services/logger.ts'

Expand All @@ -22,7 +22,7 @@ import {
} from '../lib/SharePermissionsToolBox.js'

export default {
mixins: [SharesRequests, ShareTypes],
mixins: [SharesRequests],

props: {
fileInfo: {
Expand All @@ -44,6 +44,7 @@ export default {
return {
config: new Config(),
node: null,
ShareType,

// errors helpers
errors: {},
Expand Down Expand Up @@ -114,10 +115,10 @@ export default {
},
isPublicShare() {
const shareType = this.share.shareType ?? this.share.type
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
return [ShareType.Link, ShareType.Email].includes(shareType)
},
isRemoteShare() {
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
return this.share.type === ShareType.RemoteGroup || this.share.type === ShareType.Remote
},
isShareOwner() {
return this.share && this.share.owner === getCurrentUser().uid
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/src/services/ExternalShareActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class ExternalShareActions {
if (typeof action !== 'object'
|| typeof action.id !== 'string'
|| typeof action.data !== 'function' // () => {disabled: true}
|| !Array.isArray(action.shareType) // [\@nextcloud/sharing.Types.SHARE_TYPE_LINK, ...]
|| !Array.isArray(action.shareType) // [\@nextcloud/sharing.Types.Link, ...]
|| typeof action.handlers !== 'object' // {click: () => {}, ...}
|| !Object.values(action.handlers).every(handler => typeof handler === 'function')) {
console.error('Invalid action provided', action)
Expand Down
26 changes: 12 additions & 14 deletions apps/files_sharing/src/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* eslint-disable */
import escapeHTML from 'escape-html'

import { Type as ShareTypes } from '@nextcloud/sharing'
import { ShareType } from '@nextcloud/sharing'
import { getCapabilities } from '@nextcloud/capabilities'

(function() {
Expand Down Expand Up @@ -155,25 +155,23 @@ import { getCapabilities } from '@nextcloud/capabilities'
var hasShares = false
_.each(shareTypesStr.split(',') || [], function(shareTypeStr) {
let shareType = parseInt(shareTypeStr, 10)
if (shareType === ShareTypes.SHARE_TYPE_LINK) {
if (shareType === ShareType.Link) {
hasLink = true
} else if (shareType === ShareTypes.SHARE_TYPE_EMAIL) {
} else if (shareType === ShareType.Email) {
hasLink = true
} else if (shareType === ShareTypes.SHARE_TYPE_USER) {
} else if (shareType === ShareType.User) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_GROUP) {
} else if (shareType === ShareType.Group) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_REMOTE) {
} else if (shareType === ShareType.Remote) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_REMOTE_GROUP) {
} else if (shareType === ShareType.RemoteGroup) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_CIRCLE) {
} else if (shareType === ShareType.Team) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_ROOM) {
} else if (shareType === ShareType.Room) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_DECK) {
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_SCIENCEMESH) {
} else if (shareType === ShareType.Deck) {
hasShares = true
}
})
Expand Down Expand Up @@ -204,8 +202,8 @@ import { getCapabilities } from '@nextcloud/capabilities'
permissions: OC.PERMISSION_ALL,
iconClass: function(fileName, context) {
var shareType = parseInt(context.$file.data('share-types'), 10)
if (shareType === ShareTypes.SHARE_TYPE_EMAIL
|| shareType === ShareTypes.SHARE_TYPE_LINK) {
if (shareType === ShareType.Email
|| shareType === ShareType.Link) {
return 'icon-public'
}
return 'icon-shared'
Expand Down
Loading
Loading