diff options
50 files changed, 71 insertions, 293 deletions
diff --git a/apps/files/src/actions/deleteAction.spec.ts b/apps/files/src/actions/deleteAction.spec.ts index d7b7cd5307d..cf29d385240 100644 --- a/apps/files/src/actions/deleteAction.spec.ts +++ b/apps/files/src/actions/deleteAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './deleteAction' import { expect } from '@jest/globals' -import { File, Folder, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Folder, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import logger from '../logger' diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts index 6fd8fc467e3..528a0faecab 100644 --- a/apps/files/src/actions/deleteAction.ts +++ b/apps/files/src/actions/deleteAction.ts @@ -20,12 +20,11 @@ * */ import { emit } from '@nextcloud/event-bus' -import { Permission, Node, View } from '@nextcloud/files' +import { Permission, Node, View, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw' -import { registerFileAction, FileAction } from '../services/FileAction' import logger from '../logger.js' export const action = new FileAction({ diff --git a/apps/files/src/actions/downloadAction.spec.ts b/apps/files/src/actions/downloadAction.spec.ts index 35a4c0a277a..bc9c87c0718 100644 --- a/apps/files/src/actions/downloadAction.spec.ts +++ b/apps/files/src/actions/downloadAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './downloadAction' import { expect } from '@jest/globals' -import { File, Folder, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Folder, Permission, View, FileAction } from '@nextcloud/files' const view = { id: 'files', diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts index bf4e05ec8b0..030e0e818ec 100644 --- a/apps/files/src/actions/downloadAction.ts +++ b/apps/files/src/actions/downloadAction.ts @@ -19,13 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { Permission, Node, FileType, View } from '@nextcloud/files' +import { generateUrl } from '@nextcloud/router' +import { registerFileAction, FileAction, Permission, Node, FileType, View } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import ArrowDownSvg from '@mdi/svg/svg/arrow-down.svg?raw' -import { registerFileAction, FileAction } from '../services/FileAction' -import { generateUrl } from '@nextcloud/router' - const triggerDownload = function(url: string) { const hiddenElement = document.createElement('a') hiddenElement.download = '' diff --git a/apps/files/src/actions/editLocallyAction.spec.ts b/apps/files/src/actions/editLocallyAction.spec.ts index 3d2c31c468e..e7102b8defb 100644 --- a/apps/files/src/actions/editLocallyAction.spec.ts +++ b/apps/files/src/actions/editLocallyAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './editLocallyAction' import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Permission, View, FileAction } from '@nextcloud/files' import * as ncDialogs from '@nextcloud/dialogs' import axios from '@nextcloud/axios' diff --git a/apps/files/src/actions/editLocallyAction.ts b/apps/files/src/actions/editLocallyAction.ts index ce693adc157..c8e6f295544 100644 --- a/apps/files/src/actions/editLocallyAction.ts +++ b/apps/files/src/actions/editLocallyAction.ts @@ -20,15 +20,14 @@ * */ import { encodePath } from '@nextcloud/paths' -import { Permission, type Node } from '@nextcloud/files' -import { translate as t } from '@nextcloud/l10n' -import axios from '@nextcloud/axios' -import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' - import { generateOcsUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' -import { registerFileAction, FileAction, DefaultType } from '../services/FileAction' +import { registerFileAction, FileAction, Permission, type Node } from '@nextcloud/files' import { showError } from '@nextcloud/dialogs' +import { translate as t } from '@nextcloud/l10n' +import axios from '@nextcloud/axios' + +import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' const openLocalClient = async function(path: string) { const link = generateOcsUrl('apps/files/api/v1') + '/openlocaleditor?format=json' diff --git a/apps/files/src/actions/favoriteAction.spec.ts b/apps/files/src/actions/favoriteAction.spec.ts index b24984dfdc2..13d24c57179 100644 --- a/apps/files/src/actions/favoriteAction.spec.ts +++ b/apps/files/src/actions/favoriteAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './favoriteAction' import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' import * as favoriteAction from './favoriteAction' import axios from '@nextcloud/axios' diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts index 7a067bb9407..1309539bad2 100644 --- a/apps/files/src/actions/favoriteAction.ts +++ b/apps/files/src/actions/favoriteAction.ts @@ -21,7 +21,7 @@ */ import { emit } from '@nextcloud/event-bus' import { generateUrl } from '@nextcloud/router' -import { Permission, type Node, View } from '@nextcloud/files' +import { Permission, type Node, View, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import Vue from 'vue' @@ -29,7 +29,6 @@ import Vue from 'vue' import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw' import StarSvg from '@mdi/svg/svg/star.svg?raw' -import { registerFileAction, FileAction } from '../services/FileAction' import logger from '../logger.js' // If any of the nodes is not favorited, we display the favorite action. diff --git a/apps/files/src/actions/openFolderAction.spec.ts b/apps/files/src/actions/openFolderAction.spec.ts index ff72f10b4d7..98497a22fdc 100644 --- a/apps/files/src/actions/openFolderAction.spec.ts +++ b/apps/files/src/actions/openFolderAction.spec.ts @@ -20,10 +20,9 @@ * */ import { expect } from '@jest/globals' -import { File, Folder, Node, Permission, View } from '@nextcloud/files' +import { File, Folder, Node, Permission, View, DefaultType, FileAction } from '@nextcloud/files' import { action } from './openFolderAction' -import { DefaultType, FileAction } from '../services/FileAction' const view = { id: 'files', diff --git a/apps/files/src/actions/openFolderAction.ts b/apps/files/src/actions/openFolderAction.ts index 0d28792f15e..2694667222d 100644 --- a/apps/files/src/actions/openFolderAction.ts +++ b/apps/files/src/actions/openFolderAction.ts @@ -19,13 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { Permission, Node, FileType, View } from '@nextcloud/files' +import { join } from 'path' +import { Permission, Node, FileType, View, registerFileAction, FileAction, DefaultType } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import FolderSvg from '@mdi/svg/svg/folder.svg?raw' -import { join } from 'path' -import { registerFileAction, FileAction, DefaultType } from '../services/FileAction' - export const action = new FileAction({ id: 'open-folder', displayName(files: Node[]) { diff --git a/apps/files/src/actions/openInFilesAction.spec.ts b/apps/files/src/actions/openInFilesAction.spec.ts index 2097095c9ef..866880670a3 100644 --- a/apps/files/src/actions/openInFilesAction.spec.ts +++ b/apps/files/src/actions/openInFilesAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './openInFilesAction' import { expect } from '@jest/globals' -import { File, Folder, Permission, View } from '@nextcloud/files' -import { DefaultType, FileAction } from '../../../files/src/services/FileAction' +import { File, Folder, Permission, View, DefaultType, FileAction } from '@nextcloud/files' const view = { id: 'files', diff --git a/apps/files/src/actions/openInFilesAction.ts b/apps/files/src/actions/openInFilesAction.ts index 9d3ceaf3b7b..ed3b781548c 100644 --- a/apps/files/src/actions/openInFilesAction.ts +++ b/apps/files/src/actions/openInFilesAction.ts @@ -22,7 +22,7 @@ import { translate as t } from '@nextcloud/l10n' import { FileType, type Node } from '@nextcloud/files' -import { registerFileAction, FileAction, DefaultType } from '../../../files/src/services/FileAction' +import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files' /** * TODO: Move away from a redirect and handle diff --git a/apps/files/src/actions/renameAction.spec.ts b/apps/files/src/actions/renameAction.spec.ts index 8e76bea4b84..7166483f72c 100644 --- a/apps/files/src/actions/renameAction.spec.ts +++ b/apps/files/src/actions/renameAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './renameAction' import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' const view = { diff --git a/apps/files/src/actions/renameAction.ts b/apps/files/src/actions/renameAction.ts index 02aaaa6d3b4..001bedfc73a 100644 --- a/apps/files/src/actions/renameAction.ts +++ b/apps/files/src/actions/renameAction.ts @@ -19,13 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { Permission, type Node } from '@nextcloud/files' +import { emit } from '@nextcloud/event-bus' +import { Permission, type Node, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import PencilSvg from '@mdi/svg/svg/pencil.svg?raw' -import { emit } from '@nextcloud/event-bus' -import { registerFileAction, FileAction } from '../services/FileAction' - export const ACTION_DETAILS = 'details' export const action = new FileAction({ diff --git a/apps/files/src/actions/sidebarAction.spec.ts b/apps/files/src/actions/sidebarAction.spec.ts index 1fb31959944..6d3105dba09 100644 --- a/apps/files/src/actions/sidebarAction.spec.ts +++ b/apps/files/src/actions/sidebarAction.spec.ts @@ -20,10 +20,9 @@ * */ import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' +import { File, Permission, View, FileAction } from '@nextcloud/files' import { action } from './sidebarAction' -import { FileAction } from '../services/FileAction' import logger from '../logger' const view = { diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index 52244d9912a..e9d18dbf719 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -19,11 +19,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { Permission, type Node, View } from '@nextcloud/files' +import { Permission, type Node, View, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw' -import { registerFileAction, FileAction } from '../services/FileAction' import logger from '../logger.js' export const ACTION_DETAILS = 'details' diff --git a/apps/files/src/actions/viewInFolderAction.spec.ts b/apps/files/src/actions/viewInFolderAction.spec.ts index c26eb52e400..147fd0c537b 100644 --- a/apps/files/src/actions/viewInFolderAction.spec.ts +++ b/apps/files/src/actions/viewInFolderAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './viewInFolderAction' import { expect } from '@jest/globals' -import { File, Folder, Node, Permission, View } from '@nextcloud/files' -import { FileAction } from '../services/FileAction' +import { File, Folder, Node, Permission, View, FileAction } from '@nextcloud/files' const view = { id: 'files', diff --git a/apps/files/src/actions/viewInFolderAction.ts b/apps/files/src/actions/viewInFolderAction.ts index c8abcbb72f1..a5a5896df0c 100644 --- a/apps/files/src/actions/viewInFolderAction.ts +++ b/apps/files/src/actions/viewInFolderAction.ts @@ -19,12 +19,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { Node, FileType, Permission, View } from '@nextcloud/files' +import { Node, FileType, Permission, View, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw' -import { registerFileAction, FileAction } from '../services/FileAction' - export const action = new FileAction({ id: 'view-in-folder', displayName() { diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 9384a4bf5e6..9471e596f1d 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -170,8 +170,8 @@ import { CancelablePromise } from 'cancelable-promise' import { debounce } from 'debounce' import { emit } from '@nextcloud/event-bus' import { extname } from 'path' -import { formatFileSize, FileType, Permission } from '@nextcloud/files' import { generateUrl } from '@nextcloud/router' +import { getFileActions, DefaultType, FileType, formatFileSize, Permission } from '@nextcloud/files' import { showError, showSuccess } from '@nextcloud/dialogs' import { translate } from '@nextcloud/l10n' import { vOnClickOutside } from '@vueuse/components' @@ -187,7 +187,6 @@ import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js' import Vue from 'vue' import { ACTION_DETAILS } from '../actions/sidebarAction.ts' -import { getFileActions, DefaultType } from '../services/FileAction.ts' import { hashCode } from '../utils/hashUtils.ts' import { isCachedPreview } from '../services/PreviewService.ts' import { useActionsMenuStore } from '../store/actionsmenu.ts' diff --git a/apps/files/src/components/FilesListFooter.vue b/apps/files/src/components/FilesListFooter.vue index b4a2d7eda30..3a89970a26d 100644 --- a/apps/files/src/components/FilesListFooter.vue +++ b/apps/files/src/components/FilesListFooter.vue @@ -57,9 +57,9 @@ </template> <script lang="ts"> +import Vue from 'vue' import { formatFileSize } from '@nextcloud/files' import { translate } from '@nextcloud/l10n' -import Vue from 'vue' import { useFilesStore } from '../store/files.ts' import { usePathsStore } from '../store/paths.ts' diff --git a/apps/files/src/components/FilesListHeaderActions.vue b/apps/files/src/components/FilesListHeaderActions.vue index e419c8e5abd..b1544c41888 100644 --- a/apps/files/src/components/FilesListHeaderActions.vue +++ b/apps/files/src/components/FilesListHeaderActions.vue @@ -49,8 +49,7 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' import Vue from 'vue' -import { getFileActions } from '../services/FileAction.ts' -import { useActionsMenuStore } from '../store/actionsmenu.ts' +import { getFileActions, useActionsMenuStore } from '../store/actionsmenu.ts' import { useFilesStore } from '../store/files.ts' import { useSelectionStore } from '../store/selection.ts' import filesListWidthMixin from '../mixins/filesListWidth.ts' diff --git a/apps/files/src/components/FilesListTableHeaderActions.vue b/apps/files/src/components/FilesListTableHeaderActions.vue index f55487d183b..f2ba4b7a921 100644 --- a/apps/files/src/components/FilesListTableHeaderActions.vue +++ b/apps/files/src/components/FilesListTableHeaderActions.vue @@ -42,6 +42,7 @@ </template> <script lang="ts"> +import { getFileActions } from '@nextcloud/files' import { showError, showSuccess } from '@nextcloud/dialogs' import { translate } from '@nextcloud/l10n' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' @@ -49,7 +50,6 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' import Vue from 'vue' -import { getFileActions } from '../services/FileAction.ts' import { useActionsMenuStore } from '../store/actionsmenu.ts' import { useFilesStore } from '../store/files.ts' import { useSelectionStore } from '../store/selection.ts' diff --git a/apps/files/src/components/NavigationQuota.vue b/apps/files/src/components/NavigationQuota.vue index 8dd9790461b..4a877049fa8 100644 --- a/apps/files/src/components/NavigationQuota.vue +++ b/apps/files/src/components/NavigationQuota.vue @@ -19,11 +19,12 @@ </template> <script> +import { debounce, throttle } from 'throttle-debounce' import { formatFileSize } from '@nextcloud/files' import { generateUrl } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' import { showError } from '@nextcloud/dialogs' -import { debounce, throttle } from 'throttle-debounce' +import { subscribe } from '@nextcloud/event-bus' import { translate } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import ChartPie from 'vue-material-design-icons/ChartPie.vue' @@ -31,7 +32,6 @@ import NcAppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationI import NcProgressBar from '@nextcloud/vue/dist/Components/NcProgressBar.js' import logger from '../logger.js' -import { subscribe } from '@nextcloud/event-bus' export default { name: 'NavigationQuota', diff --git a/apps/files/src/components/VirtualList.vue b/apps/files/src/components/VirtualList.vue index e028df9fea1..511053b2fa1 100644 --- a/apps/files/src/components/VirtualList.vue +++ b/apps/files/src/components/VirtualList.vue @@ -32,8 +32,7 @@ </template> <script lang="ts"> -import { File, Folder } from '@nextcloud/files' -import { debounce } from 'debounce' +import { File, Folder, debounce } from 'debounce' import Vue from 'vue' import logger from '../logger.js' diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts index 3094656ecc0..593baa49323 100644 --- a/apps/files/src/main.ts +++ b/apps/files/src/main.ts @@ -10,7 +10,6 @@ import './actions/openInFilesAction.js' import './actions/renameAction' import './actions/sidebarAction' import './actions/viewInFolderAction' -import './newMenu/newFolder' import Vue from 'vue' import { createPinia, PiniaVuePlugin } from 'pinia' diff --git a/apps/files/src/services/Favorites.ts b/apps/files/src/services/Favorites.ts index 2328a9e8af5..c993ef57d33 100644 --- a/apps/files/src/services/Favorites.ts +++ b/apps/files/src/services/Favorites.ts @@ -19,13 +19,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ +import type { ContentsWithRoot } from '@nextcloud/files' +import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav' + import { File, Folder, davParsePermissions } from '@nextcloud/files' import { generateRemoteUrl } from '@nextcloud/router' -import { getClient, rootPath } from './WebdavClient' import { getCurrentUser } from '@nextcloud/auth' + +import { getClient, rootPath } from './WebdavClient' import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties' -import type { ContentsWithRoot } from './Navigation' -import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav' const client = getClient() diff --git a/apps/files/src/services/FileAction.ts b/apps/files/src/services/FileAction.ts deleted file mode 100644 index a4f7e3ddf17..00000000000 --- a/apps/files/src/services/FileAction.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @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 type { Node } from '@nextcloud/files' -import logger from '../logger' -import type { Navigation } from './Navigation' - -declare global { - interface Window { - OC: any; - _nc_fileactions: FileAction[] | undefined; - } -} - -export enum DefaultType { - DEFAULT = 'default', - HIDDEN = 'hidden', -} - -/** - * TODO: remove and move to @nextcloud/files - * @see https://github.com/nextcloud/nextcloud-files/pull/608 - */ -interface FileActionData { - /** Unique ID */ - id: string - /** Translatable string displayed in the menu */ - displayName: (files: Node[], view: Navigation) => string - /** Svg as inline string. <svg><path fill="..." /></svg> */ - iconSvgInline: (files: Node[], view: Navigation) => string - /** Condition wether this action is shown or not */ - enabled?: (files: Node[], view: Navigation) => boolean - /** - * Function executed on single file action - * @returns true if the action was executed, false otherwise - * @throws Error if the action failed - */ - exec: (file: Node, view: Navigation, dir: string) => Promise<boolean|null>, - /** - * Function executed on multiple files action - * @returns true if the action was executed successfully, - * false otherwise and null if the action is silent/undefined. - * @throws Error if the action failed - */ - execBatch?: (files: Node[], view: Navigation, dir: string) => Promise<(boolean|null)[]> - /** This action order in the list */ - order?: number, - /** Make this action the default */ - default?: DefaultType, - /** - * If true, the renderInline function will be called - */ - inline?: (file: Node, view: Navigation) => boolean, - /** - * If defined, the returned html element will be - * appended before the actions menu. - */ - renderInline?: (file: Node, view: Navigation) => Promise<HTMLElement | null>, -} - -export class FileAction { - - private _action: FileActionData - - constructor(action: FileActionData) { - this.validateAction(action) - this._action = action - } - - get id() { - return this._action.id - } - - get displayName() { - return this._action.displayName - } - - get iconSvgInline() { - return this._action.iconSvgInline - } - - get enabled() { - return this._action.enabled - } - - get exec() { - return this._action.exec - } - - get execBatch() { - return this._action.execBatch - } - - get order() { - return this._action.order - } - - get default() { - return this._action.default - } - - get inline() { - return this._action.inline - } - - get renderInline() { - return this._action.renderInline - } - - private validateAction(action: FileActionData) { - if (!action.id || typeof action.id !== 'string') { - throw new Error('Invalid id') - } - - if (!action.displayName || typeof action.displayName !== 'function') { - throw new Error('Invalid displayName function') - } - - if (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') { - throw new Error('Invalid iconSvgInline function') - } - - if (!action.exec || typeof action.exec !== 'function') { - throw new Error('Invalid exec function') - } - - // Optional properties -------------------------------------------- - if ('enabled' in action && typeof action.enabled !== 'function') { - throw new Error('Invalid enabled function') - } - - if ('execBatch' in action && typeof action.execBatch !== 'function') { - throw new Error('Invalid execBatch function') - } - - if ('order' in action && typeof action.order !== 'number') { - throw new Error('Invalid order') - } - - if (action.default && !Object.values(DefaultType).includes(action.default)) { - throw new Error('Invalid default') - } - - if ('inline' in action && typeof action.inline !== 'function') { - throw new Error('Invalid inline function') - } - - if ('renderInline' in action && typeof action.renderInline !== 'function') { - throw new Error('Invalid renderInline function') - } - } - -} - -export const registerFileAction = function(action: FileAction): void { - if (typeof window._nc_fileactions === 'undefined') { - window._nc_fileactions = [] - logger.debug('FileActions initialized') - } - - // Check duplicates - if (window._nc_fileactions.find(search => search.id === action.id)) { - logger.error(`FileAction ${action.id} already registered`, { action }) - return - } - - window._nc_fileactions.push(action) -} - -export const getFileActions = function(): FileAction[] { - return window._nc_fileactions || [] -} diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts index b9d6f65a0b9..93325decc9c 100644 --- a/apps/files/src/services/Files.ts +++ b/apps/files/src/services/Files.ts @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { ContentsWithRoot } from './Navigation' +import type { ContentsWithRoot } from '@nextcloud/files' import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav' import { File, Folder, davParsePermissions } from '@nextcloud/files' diff --git a/apps/files/src/services/Recent.ts b/apps/files/src/services/Recent.ts index 75044fb4579..cec604ba855 100644 --- a/apps/files/src/services/Recent.ts +++ b/apps/files/src/services/Recent.ts @@ -19,13 +19,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ +import type { ContentsWithRoot } from '@nextcloud/files' +import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav' + import { File, Folder, Permission, davParsePermissions } from '@nextcloud/files' import { generateRemoteUrl } from '@nextcloud/router' -import { getClient, rootPath } from './WebdavClient' import { getCurrentUser } from '@nextcloud/auth' + +import { getClient, rootPath } from './WebdavClient' import { getDavNameSpaces, getDavProperties } from './DavProperties' -import type { ContentsWithRoot } from './Navigation' -import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav' const client = getClient(generateRemoteUrl('dav')) diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index 8aa93dd41a5..67dffb8773e 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -66,8 +66,7 @@ import type { Route } from 'vue-router' import type { UserConfig } from '../types.ts' -import { Folder, Node, type View, type ContentsWithRoot } from '@nextcloud/files' -import { join } from 'path' +import { Folder, Node, type View, type ContentsWithRoot, join } from 'path' import { orderBy } from 'natural-orderby' import { translate } from '@nextcloud/l10n' import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js' diff --git a/apps/files/src/views/favorites.spec.ts b/apps/files/src/views/favorites.spec.ts index f9cf5031f5f..ed0747498e3 100644 --- a/apps/files/src/views/favorites.spec.ts +++ b/apps/files/src/views/favorites.spec.ts @@ -21,8 +21,7 @@ */ import { expect } from '@jest/globals' import * as initialState from '@nextcloud/initial-state' -import { Folder, getNavigation } from '@nextcloud/files' -import { basename } from 'path' +import { Folder, getNavigation, basename } from 'path' import * as eventBus from '@nextcloud/event-bus' import { action } from '../actions/favoriteAction' diff --git a/apps/files/src/views/favorites.ts b/apps/files/src/views/favorites.ts index 738f9b19e6b..c72db86a727 100644 --- a/apps/files/src/views/favorites.ts +++ b/apps/files/src/views/favorites.ts @@ -27,8 +27,7 @@ import { basename } from 'path' import { getContents } from '../services/Favorites' import { hashCode } from '../utils/hashUtils' import { loadState } from '@nextcloud/initial-state' -import { Node, FileType, View, getNavigation } from '@nextcloud/files' -import { subscribe } from '@nextcloud/event-bus' +import { Node, FileType, View, getNavigation, subscribe } from '@nextcloud/event-bus' import logger from '../logger' export const generateFolderView = function(folder: string, index = 0): View { diff --git a/apps/files_external/src/actions/enterCredentialsAction.spec.ts b/apps/files_external/src/actions/enterCredentialsAction.spec.ts index ef3a767365b..d1aefd08efe 100644 --- a/apps/files_external/src/actions/enterCredentialsAction.spec.ts +++ b/apps/files_external/src/actions/enterCredentialsAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './enterCredentialsAction' import { expect } from '@jest/globals' -import { File, Folder, Permission, View } from '@nextcloud/files' -import { DefaultType, FileAction } from '../../../files/src/services/FileAction' +import { File, Folder, Permission, View, DefaultType, FileAction } from '@nextcloud/files' import type { StorageConfig } from '../services/externalStorage' import { STORAGE_STATUS } from '../utils/credentialsUtils' diff --git a/apps/files_external/src/actions/enterCredentialsAction.ts b/apps/files_external/src/actions/enterCredentialsAction.ts index 460909dfa84..49b0ab4076e 100644 --- a/apps/files_external/src/actions/enterCredentialsAction.ts +++ b/apps/files_external/src/actions/enterCredentialsAction.ts @@ -31,7 +31,7 @@ import axios from '@nextcloud/axios' import LoginSvg from '@mdi/svg/svg/login.svg?raw' import Vue from 'vue' -import { registerFileAction, FileAction, DefaultType } from '../../../files/src/services/FileAction' +import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files' import { STORAGE_STATUS, isMissingAuthConfig } from '../utils/credentialsUtils' import { isNodeExternalStorage } from '../utils/externalStorageUtils' diff --git a/apps/files_external/src/actions/inlineStorageCheckAction.ts b/apps/files_external/src/actions/inlineStorageCheckAction.ts index bd509f8fde1..fa2f567b1f7 100644 --- a/apps/files_external/src/actions/inlineStorageCheckAction.ts +++ b/apps/files_external/src/actions/inlineStorageCheckAction.ts @@ -32,7 +32,7 @@ import '../css/fileEntryStatus.scss' import { getStatus, type StorageConfig } from '../services/externalStorage' import { isMissingAuthConfig, STORAGE_STATUS } from '../utils/credentialsUtils' import { isNodeExternalStorage } from '../utils/externalStorageUtils' -import { registerFileAction, FileAction } from '../../../files/src/services/FileAction' +import { registerFileAction, FileAction } from '@nextcloud/files' export const action = new FileAction({ id: 'check-external-storage', diff --git a/apps/files_external/src/actions/openInFilesAction.spec.ts b/apps/files_external/src/actions/openInFilesAction.spec.ts index 4f25d2449b4..49ad623c894 100644 --- a/apps/files_external/src/actions/openInFilesAction.spec.ts +++ b/apps/files_external/src/actions/openInFilesAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './openInFilesAction' import { expect } from '@jest/globals' -import { Folder, Permission, View } from '@nextcloud/files' -import { DefaultType, FileAction } from '../../../files/src/services/FileAction' +import { Folder, Permission, View, DefaultType, FileAction } from '@nextcloud/files' import type { StorageConfig } from '../services/externalStorage' import { STORAGE_STATUS } from '../utils/credentialsUtils' diff --git a/apps/files_external/src/actions/openInFilesAction.ts b/apps/files_external/src/actions/openInFilesAction.ts index 2c9579041ea..0359e81998d 100644 --- a/apps/files_external/src/actions/openInFilesAction.ts +++ b/apps/files_external/src/actions/openInFilesAction.ts @@ -25,7 +25,7 @@ import type { StorageConfig } from '../services/externalStorage' import { generateUrl } from '@nextcloud/router' import { translate as t } from '@nextcloud/l10n' -import { registerFileAction, FileAction, DefaultType } from '../../../files/src/services/FileAction' +import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files' import { STORAGE_STATUS } from '../utils/credentialsUtils' export const action = new FileAction({ diff --git a/apps/files_external/src/services/externalStorage.ts b/apps/files_external/src/services/externalStorage.ts index 95010c2b6a4..ea4db8a1fe8 100644 --- a/apps/files_external/src/services/externalStorage.ts +++ b/apps/files_external/src/services/externalStorage.ts @@ -22,8 +22,9 @@ // eslint-disable-next-line n/no-extraneous-import import type { AxiosResponse } from 'axios' import type { OCSResponse } from '../../../files_sharing/src/services/SharingService' +import type { ContentsWithRoot } from '@nextcloud/files' -import { Folder, Permission, type ContentsWithRoot } from '@nextcloud/files' +import { Folder, Permission } from '@nextcloud/files' import { generateOcsUrl, generateRemoteUrl, generateUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import axios from '@nextcloud/axios' diff --git a/apps/files_external/src/utils/externalStorageUtils.spec.ts b/apps/files_external/src/utils/externalStorageUtils.spec.ts index dc901544a98..04fdd7de2b0 100644 --- a/apps/files_external/src/utils/externalStorageUtils.spec.ts +++ b/apps/files_external/src/utils/externalStorageUtils.spec.ts @@ -19,8 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { File, Folder, Permission } from '@nextcloud/files' -import { isNodeExternalStorage } from './externalStorageUtils' +import { File, Folder, Permission, isNodeExternalStorage } from './externalStorageUtils' import { expect } from '@jest/globals' describe('Is node an external storage', () => { diff --git a/apps/files_sharing/src/actions/acceptShareAction.spec.ts b/apps/files_sharing/src/actions/acceptShareAction.spec.ts index 7ad8a42a1a6..b87cbef6a1c 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.spec.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './acceptShareAction' import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' -import { FileAction } from '../../../files/src/services/FileAction' +import { File, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' diff --git a/apps/files_sharing/src/actions/acceptShareAction.ts b/apps/files_sharing/src/actions/acceptShareAction.ts index 8bd8d6a5533..6992b0b53ab 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.ts @@ -23,11 +23,11 @@ import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' +import { registerFileAction, FileAction } from '@nextcloud/files' import { translatePlural as n } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import CheckSvg from '@mdi/svg/svg/check.svg?raw' -import { FileAction, registerFileAction } from '../../../files/src/services/FileAction' import { pendingSharesViewId } from '../views/shares' export const action = new FileAction({ diff --git a/apps/files_sharing/src/actions/openInFilesAction.spec.ts b/apps/files_sharing/src/actions/openInFilesAction.spec.ts index 2d723770ee9..a0ef71f830a 100644 --- a/apps/files_sharing/src/actions/openInFilesAction.spec.ts +++ b/apps/files_sharing/src/actions/openInFilesAction.spec.ts @@ -24,8 +24,7 @@ import { File, Permission, View } from '@nextcloud/files' import '../main' import { action } from './openInFilesAction' -import { DefaultType, FileAction } from '../../../files/src/services/FileAction' -import { deletedSharesViewId, pendingSharesViewId, sharedWithOthersViewId, sharedWithYouViewId, sharesViewId, sharingByLinksViewId } from '../views/shares' +import { DefaultType, FileAction, deletedSharesViewId, pendingSharesViewId, sharedWithOthersViewId, sharedWithYouViewId, sharesViewId, sharingByLinksViewId } from '../views/shares' const view = { id: 'files', diff --git a/apps/files_sharing/src/actions/openInFilesAction.ts b/apps/files_sharing/src/actions/openInFilesAction.ts index ff7ccde2f36..0a92d5d20ae 100644 --- a/apps/files_sharing/src/actions/openInFilesAction.ts +++ b/apps/files_sharing/src/actions/openInFilesAction.ts @@ -19,10 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { translate as t } from '@nextcloud/l10n' import type { Node } from '@nextcloud/files' -import { registerFileAction, FileAction, DefaultType } from '../../../files/src/services/FileAction' +import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files' +import { translate as t } from '@nextcloud/l10n' + import { sharesViewId, sharedWithYouViewId, sharedWithOthersViewId, sharingByLinksViewId } from '../views/shares' export const action = new FileAction({ diff --git a/apps/files_sharing/src/actions/rejectShareAction.spec.ts b/apps/files_sharing/src/actions/rejectShareAction.spec.ts index bc666b7c081..292aec4c630 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.spec.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './rejectShareAction' import { expect } from '@jest/globals' -import { File, Folder, Permission, View } from '@nextcloud/files' -import { FileAction } from '../../../files/src/services/FileAction' +import { File, Folder, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' diff --git a/apps/files_sharing/src/actions/rejectShareAction.ts b/apps/files_sharing/src/actions/rejectShareAction.ts index 7fb04d36227..d7ba1a5d560 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.ts @@ -23,11 +23,11 @@ import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' +import { registerFileAction, FileAction } from '@nextcloud/files' import { translatePlural as n } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import CloseSvg from '@mdi/svg/svg/close.svg?raw' -import { FileAction, registerFileAction } from '../../../files/src/services/FileAction' import { pendingSharesViewId } from '../views/shares' export const action = new FileAction({ diff --git a/apps/files_sharing/src/actions/restoreShareAction.spec.ts b/apps/files_sharing/src/actions/restoreShareAction.spec.ts index 2c37dd83857..44460a62495 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.spec.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.spec.ts @@ -21,8 +21,7 @@ */ import { action } from './restoreShareAction' import { expect } from '@jest/globals' -import { File, Permission, View } from '@nextcloud/files' -import { FileAction } from '../../../files/src/services/FileAction' +import { File, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' diff --git a/apps/files_sharing/src/actions/restoreShareAction.ts b/apps/files_sharing/src/actions/restoreShareAction.ts index d1b67f10b08..c41f3f2c413 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.ts @@ -22,12 +22,12 @@ import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' +import { FileAction, registerFileAction } from '@nextcloud/files' import { generateOcsUrl } from '@nextcloud/router' import { translatePlural as n } from '@nextcloud/l10n' -import axios from '@nextcloud/axios' import ArrowULeftTopSvg from '@mdi/svg/svg/arrow-u-left-top.svg?raw' +import axios from '@nextcloud/axios' -import { FileAction, registerFileAction } from '../../../files/src/services/FileAction' import { deletedSharesViewId } from '../views/shares' export const action = new FileAction({ diff --git a/apps/files_sharing/src/services/SharingService.ts b/apps/files_sharing/src/services/SharingService.ts index 2b5e2e0d329..4534183a637 100644 --- a/apps/files_sharing/src/services/SharingService.ts +++ b/apps/files_sharing/src/services/SharingService.ts @@ -23,9 +23,10 @@ import type { AxiosPromise } from 'axios' import { Folder, File, type ContentsWithRoot } from '@nextcloud/files' -import { generateOcsUrl, generateRemoteUrl, generateUrl } from '@nextcloud/router' +import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import axios from '@nextcloud/axios' + import logger from './logger' export const rootPath = `/files/${getCurrentUser()?.uid}` diff --git a/apps/files_trashbin/src/actions/restoreAction.ts b/apps/files_trashbin/src/actions/restoreAction.ts index ce8b4077195..70b6922dba7 100644 --- a/apps/files_trashbin/src/actions/restoreAction.ts +++ b/apps/files_trashbin/src/actions/restoreAction.ts @@ -22,12 +22,11 @@ import { emit } from '@nextcloud/event-bus' import { generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' -import { Permission, Node, View } from '@nextcloud/files' +import { Permission, Node, View, registerFileAction, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import History from '@mdi/svg/svg/history.svg?raw' -import { registerFileAction, FileAction } from '../../../files/src/services/FileAction' import logger from '../../../files/src/logger.js' registerFileAction(new FileAction({ diff --git a/apps/files_trashbin/src/services/trashbin.ts b/apps/files_trashbin/src/services/trashbin.ts index 2c4aa373a3f..5e7a31b2448 100644 --- a/apps/files_trashbin/src/services/trashbin.ts +++ b/apps/files_trashbin/src/services/trashbin.ts @@ -19,12 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -/* eslint-disable */ -import { getCurrentUser } from '@nextcloud/auth' import { File, Folder, davParsePermissions, type ContentsWithRoot } from '@nextcloud/files' import { generateRemoteUrl, generateUrl } from '@nextcloud/router' - +import { getCurrentUser } from '@nextcloud/auth' import type { FileStat, ResponseDataDetailed } from 'webdav' + import { getDavNameSpaces, getDavProperties } from '../../../files/src/services/DavProperties' import client, { rootPath } from './client' @@ -40,7 +39,6 @@ const data = `<?xml version="1.0"?> </d:prop> </d:propfind>` - const resultToNode = function(node: FileStat): File | Folder { const permissions = davParsePermissions(node.props?.permissions) const owner = getCurrentUser()?.uid as string @@ -72,7 +70,7 @@ const resultToNode = function(node: FileStat): File | Folder { : new Folder(nodeData) } -export const getContents = async (path: string = '/'): Promise<ContentsWithRoot> => { +export const getContents = async (path = '/'): Promise<ContentsWithRoot> => { // TODO: use only one request when webdav-client supports it // @see https://github.com/perry-mitchell/webdav-client/pull/334 const rootResponse = await client.stat(path, { |