mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #40517 from nextcloud/feat/sharing-status
This commit is contained in:
commit
4ddbc55d5d
17 changed files with 200 additions and 18 deletions
|
|
@ -31,7 +31,7 @@ export const action = new FileAction({
|
|||
id: 'delete',
|
||||
displayName(nodes: Node[], view: View) {
|
||||
return view.id === 'trashbin'
|
||||
? t('files_trashbin', 'Delete permanently')
|
||||
? t('files', 'Delete permanently')
|
||||
: t('files', 'Delete')
|
||||
},
|
||||
iconSvgInline: () => TrashCanSvg,
|
||||
|
|
|
|||
|
|
@ -109,9 +109,11 @@
|
|||
<!-- Render actions -->
|
||||
<CustomElementRender v-for="action in enabledRenderActions"
|
||||
:key="action.id"
|
||||
:class="'files-list__row-action-' + action.id"
|
||||
:current-view="currentView"
|
||||
:render="action.renderInline"
|
||||
:source="source" />
|
||||
:source="source"
|
||||
class="files-list__row-action--inline" />
|
||||
|
||||
<!-- Menu actions -->
|
||||
<NcActions v-if="visible"
|
||||
|
|
@ -119,6 +121,7 @@
|
|||
:boundaries-element="getBoundariesElement()"
|
||||
:container="getBoundariesElement()"
|
||||
:disabled="source._loading"
|
||||
:force-name="true"
|
||||
:force-menu="enabledInlineActions.length === 0 /* forceMenu only if no inline actions */"
|
||||
:inline="enabledInlineActions.length"
|
||||
:open.sync="openedMenu">
|
||||
|
|
|
|||
|
|
@ -461,6 +461,10 @@ export default Vue.extend({
|
|||
}
|
||||
}
|
||||
|
||||
.files-list__row-action--inline {
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
.files-list__row-mtime,
|
||||
.files-list__row-size {
|
||||
// Right align text
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class LoadAdditionalListener implements IEventListener {
|
|||
|
||||
$shareManager = \OC::$server->get(IManager::class);
|
||||
if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) {
|
||||
Util::addScript(Application::APP_ID, 'files_sharing', 'files');
|
||||
Util::addInitScript(Application::APP_ID, 'init');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
|
|
@ -22,3 +19,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
// Only when rendered inline, when not enough space, this is put in the menu
|
||||
.action-items > .files-list__row-action-sharing-status {
|
||||
// put icon at the end of the button
|
||||
direction: rtl;
|
||||
// align icons with textless inline actions
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
svg.sharing-status__avatar {
|
||||
height: 32px !important;
|
||||
width: 32px !important;
|
||||
border-radius: 32px;
|
||||
overflow: hidden;
|
||||
}
|
||||
117
apps/files_sharing/src/actions/sharingStatusAction.ts
Normal file
117
apps/files_sharing/src/actions/sharingStatusAction.ts
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
import { Node, View, registerFileAction, FileAction, Permission } from '@nextcloud/files'
|
||||
import { translate as t } from '@nextcloud/l10n'
|
||||
import { Type } from '@nextcloud/sharing'
|
||||
|
||||
import AccountGroupSvg from '@mdi/svg/svg/account-group.svg?raw'
|
||||
import AccountPlusSvg from '@mdi/svg/svg/account-plus.svg?raw'
|
||||
import LinkSvg from '@mdi/svg/svg/link.svg?raw'
|
||||
import CircleSvg from '../../../../core/img/apps/circles.svg?raw'
|
||||
|
||||
import { action as sidebarAction } from '../../../files/src/actions/sidebarAction'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
|
||||
import './sharingStatusAction.scss'
|
||||
|
||||
const generateAvatarSvg = (userId: string) => {
|
||||
const avatarUrl = generateUrl('/avatar/{userId}/32', { userId })
|
||||
return `<svg width="32" height="32" viewBox="0 0 32 32"
|
||||
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
|
||||
<image href="${avatarUrl}" height="32" width="32" />
|
||||
</svg>`
|
||||
}
|
||||
|
||||
export const action = new FileAction({
|
||||
id: 'sharing-status',
|
||||
displayName(nodes: Node[]) {
|
||||
const node = nodes[0]
|
||||
const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[]
|
||||
if (shareTypes.length > 0) {
|
||||
return t('files_sharing', 'Shared')
|
||||
}
|
||||
|
||||
const ownerId = node?.attributes?.['owner-id']
|
||||
if (ownerId && ownerId !== getCurrentUser()?.uid) {
|
||||
return t('files_sharing', 'Shared')
|
||||
}
|
||||
|
||||
return ''
|
||||
},
|
||||
iconSvgInline(nodes: Node[]) {
|
||||
const node = nodes[0]
|
||||
const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[]
|
||||
|
||||
// Link shares
|
||||
if (shareTypes.includes(Type.SHARE_TYPE_LINK)
|
||||
|| shareTypes.includes(Type.SHARE_TYPE_EMAIL)) {
|
||||
return LinkSvg
|
||||
}
|
||||
|
||||
// Group shares
|
||||
if (shareTypes.includes(Type.SHARE_TYPE_GROUP)
|
||||
|| shareTypes.includes(Type.SHARE_TYPE_REMOTE_GROUP)) {
|
||||
return AccountGroupSvg
|
||||
}
|
||||
|
||||
// Circle shares
|
||||
if (shareTypes.includes(Type.SHARE_TYPE_CIRCLE)) {
|
||||
return CircleSvg
|
||||
}
|
||||
|
||||
const ownerId = node?.attributes?.['owner-id']
|
||||
if (ownerId && ownerId !== getCurrentUser()?.uid) {
|
||||
return generateAvatarSvg(ownerId)
|
||||
}
|
||||
|
||||
return AccountPlusSvg
|
||||
},
|
||||
|
||||
enabled(nodes: Node[]) {
|
||||
if (nodes.length !== 1) {
|
||||
return false
|
||||
}
|
||||
|
||||
const node = nodes[0]
|
||||
const ownerId = node?.attributes?.['owner-id']
|
||||
if (ownerId && ownerId !== getCurrentUser()?.uid) {
|
||||
return true
|
||||
}
|
||||
|
||||
return (node.permissions & Permission.SHARE) !== 0
|
||||
},
|
||||
|
||||
async exec(node: Node, view: View, dir: string) {
|
||||
// You need read permissions to see the sidebar
|
||||
if ((node.permissions & Permission.READ) !== 0) {
|
||||
window.OCA?.Files?.Sidebar?.setActiveTab?.('sharing')
|
||||
return sidebarAction.exec(node, view, dir)
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
||||
inline: () => true,
|
||||
|
||||
})
|
||||
|
||||
registerFileAction(action)
|
||||
|
|
@ -26,5 +26,6 @@ import './actions/acceptShareAction'
|
|||
import './actions/openInFilesAction'
|
||||
import './actions/rejectShareAction'
|
||||
import './actions/restoreShareAction'
|
||||
import './actions/sharingStatusAction'
|
||||
|
||||
registerSharingViews()
|
||||
4
dist/core-common.js
vendored
4
dist/core-common.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-common.js.map
vendored
2
dist/core-common.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/files_sharing-files_sharing.js
vendored
3
dist/files_sharing-files_sharing.js
vendored
File diff suppressed because one or more lines are too long
1
dist/files_sharing-files_sharing.js.map
vendored
1
dist/files_sharing-files_sharing.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/files_sharing-init.js
vendored
Normal file
3
dist/files_sharing-init.js
vendored
Normal file
File diff suppressed because one or more lines are too long
46
dist/files_sharing-init.js.LICENSE.txt
vendored
Normal file
46
dist/files_sharing-init.js.LICENSE.txt
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
1
dist/files_sharing-init.js.map
vendored
Normal file
1
dist/files_sharing-init.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -64,7 +64,7 @@ module.exports = {
|
|||
additionalScripts: path.join(__dirname, 'apps/files_sharing/src', 'additionalScripts.js'),
|
||||
collaboration: path.join(__dirname, 'apps/files_sharing/src', 'collaborationresourceshandler.js'),
|
||||
files_sharing_tab: path.join(__dirname, 'apps/files_sharing/src', 'files_sharing_tab.js'),
|
||||
files_sharing: path.join(__dirname, 'apps/files_sharing/src', 'files_sharing.ts'),
|
||||
init: path.join(__dirname, 'apps/files_sharing/src', 'init.ts'),
|
||||
main: path.join(__dirname, 'apps/files_sharing/src', 'main.ts'),
|
||||
'personal-settings': path.join(__dirname, 'apps/files_sharing/src', 'personal-settings.js'),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue