1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { Node } from '@nextcloud/files'
import { registerFileAction, FileAction, DefaultType, FileType } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { sharesViewId, sharedWithYouViewId, sharedWithOthersViewId, sharingByLinksViewId } from '../files_views/shares'
export const action = new FileAction({
id: 'open-in-files',
displayName: () => t('files_sharing', 'Open in Files'),
iconSvgInline: () => '',
enabled: (nodes, view) => [
sharesViewId,
sharedWithYouViewId,
sharedWithOthersViewId,
sharingByLinksViewId,
// Deleted and pending shares are not
// accessible in the files app.
].includes(view.id),
async exec(node: Node) {
const isFolder = node.type === FileType.Folder
window.OCP.Files.Router.goToRoute(
null, // use default route
{
view: 'files',
fileid: String(node.fileid),
},
{
// If this node is a folder open the folder in files
dir: isFolder ? node.path : node.dirname,
// otherwise if this is a file, we should open it
openfile: isFolder ? undefined : 'true',
},
)
return null
},
// Before openFolderAction
order: -1000,
default: DefaultType.HIDDEN,
})
registerFileAction(action)
|