diff options
Diffstat (limited to 'apps/files_sharing/src/files_actions/openInFilesAction.ts')
-rw-r--r-- | apps/files_sharing/src/files_actions/openInFilesAction.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/files_sharing/src/files_actions/openInFilesAction.ts b/apps/files_sharing/src/files_actions/openInFilesAction.ts new file mode 100644 index 00000000000..133b4531bb5 --- /dev/null +++ b/apps/files_sharing/src/files_actions/openInFilesAction.ts @@ -0,0 +1,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: 'files_sharing: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) |