]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat: migrate FileAction from server
authorJohn Molakvoæ <skjnldsv@protonmail.com>
Fri, 18 Aug 2023 09:10:00 +0000 (11:10 +0200)
committerJohn Molakvoæ <skjnldsv@protonmail.com>
Wed, 23 Aug 2023 12:03:51 +0000 (14:03 +0200)
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
50 files changed:
apps/files/src/actions/deleteAction.spec.ts
apps/files/src/actions/deleteAction.ts
apps/files/src/actions/downloadAction.spec.ts
apps/files/src/actions/downloadAction.ts
apps/files/src/actions/editLocallyAction.spec.ts
apps/files/src/actions/editLocallyAction.ts
apps/files/src/actions/favoriteAction.spec.ts
apps/files/src/actions/favoriteAction.ts
apps/files/src/actions/openFolderAction.spec.ts
apps/files/src/actions/openFolderAction.ts
apps/files/src/actions/openInFilesAction.spec.ts
apps/files/src/actions/openInFilesAction.ts
apps/files/src/actions/renameAction.spec.ts
apps/files/src/actions/renameAction.ts
apps/files/src/actions/sidebarAction.spec.ts
apps/files/src/actions/sidebarAction.ts
apps/files/src/actions/viewInFolderAction.spec.ts
apps/files/src/actions/viewInFolderAction.ts
apps/files/src/components/FileEntry.vue
apps/files/src/components/FilesListFooter.vue
apps/files/src/components/FilesListHeaderActions.vue
apps/files/src/components/FilesListTableHeaderActions.vue
apps/files/src/components/NavigationQuota.vue
apps/files/src/components/VirtualList.vue
apps/files/src/main.ts
apps/files/src/services/Favorites.ts
apps/files/src/services/FileAction.ts [deleted file]
apps/files/src/services/Files.ts
apps/files/src/services/Recent.ts
apps/files/src/views/FilesList.vue
apps/files/src/views/favorites.spec.ts
apps/files/src/views/favorites.ts
apps/files_external/src/actions/enterCredentialsAction.spec.ts
apps/files_external/src/actions/enterCredentialsAction.ts
apps/files_external/src/actions/inlineStorageCheckAction.ts
apps/files_external/src/actions/openInFilesAction.spec.ts
apps/files_external/src/actions/openInFilesAction.ts
apps/files_external/src/services/externalStorage.ts
apps/files_external/src/utils/externalStorageUtils.spec.ts
apps/files_sharing/src/actions/acceptShareAction.spec.ts
apps/files_sharing/src/actions/acceptShareAction.ts
apps/files_sharing/src/actions/openInFilesAction.spec.ts
apps/files_sharing/src/actions/openInFilesAction.ts
apps/files_sharing/src/actions/rejectShareAction.spec.ts
apps/files_sharing/src/actions/rejectShareAction.ts
apps/files_sharing/src/actions/restoreShareAction.spec.ts
apps/files_sharing/src/actions/restoreShareAction.ts
apps/files_sharing/src/services/SharingService.ts
apps/files_trashbin/src/actions/restoreAction.ts
apps/files_trashbin/src/services/trashbin.ts

index d7b7cd5307d1664a1fe04b8c7363f6bacd5d7997..cf29d385240e585c3f5658051da9d353c03b95b7 100644 (file)
@@ -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'
index 6fd8fc467e321245771759310c61f19bccd30b2a..528a0faecabfd0f942b520b35e4fc06d88e8cd44 100644 (file)
  *
  */
 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({
index 35a4c0a277af649253c4487e92dd1b6908522195..bc9c87c0718ec82051314dab60901967b41e1b6a 100644 (file)
@@ -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',
index bf4e05ec8b0b55303ddcef2f0456299832899bf5..030e0e818eca8654e7478442441508f505e91c1d 100644 (file)
  * 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 = ''
index 3d2c31c468e1055cc2c50821defa6c050eaaaa6e..e7102b8defb42215ddbb78eb464253c2f48c85db 100644 (file)
@@ -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'
 
index ce693adc157fe17ff487a4c99a2edb79d6395885..c8e6f2955446858a6fd36d55567fec288d63c379 100644 (file)
  *
  */
 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'
index b24984dfdc26a3e05f06540a325bcceed2878d50..13d24c571790762c12d1e546b3f63ad8f2ffc507 100644 (file)
@@ -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'
index 7a067bb94074113755a8a6a1cee43ac3d8713867..1309539bad263f397301e70770e6ef6f9255e79a 100644 (file)
@@ -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.
index ff72f10b4d7edf6cb0abe897fb7763437399627b..98497a22fdc389e1eadbaea8f405c9edd4b65fc1 100644 (file)
  *
  */
 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',
index 0d28792f15e2cc7e5320f20fb727c0e5331490e0..2694667222dba454af1f5c75fe3be0087fc3346d 100644 (file)
  * 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[]) {
index 2097095c9ef955bf536064c677def63ec3b16696..866880670a3e960d1d58ffacef62f48558ee919d 100644 (file)
@@ -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',
index 9d3ceaf3b7b981cd56d1170567b1e0ee333675d5..ed3b781548c3757363691e47b2e38a3638062b18 100644 (file)
@@ -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
index 8e76bea4b84fd29664e9414dbddc96ade84cfd47..7166483f72cf16bd24b251b0be452c7b41ad4e85 100644 (file)
@@ -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 = {
index 02aaaa6d3b46558343f9e201929711d83af24df0..001bedfc73a891895675ff514a54a6ba93cb65b9 100644 (file)
  * 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({
index 1fb319599447272a337069d4c8f7014a1cce78b5..6d3105dba0914c8fb2f948b882b3b3df8925520d 100644 (file)
  *
  */
 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 = {
index 52244d9912a318c808d3a3807aef7399cf50909f..e9d18dbf7196769424c1f62ad0873ff2d62c405e 100644 (file)
  * 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'
index c26eb52e40052d3fd568f1f6c6ce915555baa5d1..147fd0c537b6fc6d967823f009b44182549305f9 100644 (file)
@@ -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',
index c8abcbb72f14b5ae57c32ddc90bdd6dc567f3960..a5a5896df0c44778ad2c1077b9b8aa3d6ff0b362 100644 (file)
  * 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() {
index 9384a4bf5e6e6eaab1a28b6a82dcb0ac27f18aab..9471e596f1da219a4018f9cc9f0a65b878bb28f1 100644 (file)
@@ -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'
index b4a2d7eda305b531da682086bcfffb8953d02737..3a89970a26d50fbbdbbc857d36384d5d9d64c521 100644 (file)
@@ -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'
index e419c8e5abd71ade4b9c7e974a9334ad690dd27a..b1544c4188851457392eecf6467c7c3e5e0499a1 100644 (file)
@@ -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'
index f55487d183bf90a5bcccd94afead736de9e70bcf..f2ba4b7a921394133ae68fa051cd696722e94e3f 100644 (file)
@@ -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'
index 8dd9790461bee9043728cdaf3ac38cc41e92cfb0..4a877049fa84387bb770c812cf0f61d94e16c814 100644 (file)
 </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',
index e028df9fea138b35c41f7424f2c9f3c468ab0d47..511053b2fa1792e15b099d11096fc87ba4927c8e 100644 (file)
@@ -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'
 
index 3094656ecc09b4b01b0597b0515a6829cc01ad9a..593baa493236e8d946e68fc5392e14f4c21c8c1c 100644 (file)
@@ -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'
index 2328a9e8af5a27c609372b1c22ec81bcbbc1f808..c993ef57d33e90892a88e9cb622fd9f5d13147a2 100644 (file)
  * 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 (file)
index a4f7e3d..0000000
+++ /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 || []
-}
index b9d6f65a0b995138455d1edc8589a071e181b043..93325decc9cd9cb93afd3e208baf64489ec716c1 100644 (file)
@@ -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'
index 75044fb45798c6a28bd3a19e4d76475e807fab2f..cec604ba8557af8a25f7e482dc0bf30608e56d32 100644 (file)
  * 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'))
 
index 8aa93dd41a5ff285ceddf7241b4d18b0d6781ea8..67dffb8773e1f4b9c9e2a0fd43e0829bf865ab8c 100644 (file)
@@ -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'
index f9cf5031f5f0fa3ebbc1c0ced2b685abf5131983..ed0747498e31889922f96bec56106cb25ab7c456 100644 (file)
@@ -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'
index 738f9b19e6b5366fcc9a5a280c99f9bc15836450..c72db86a727b9b502460f7359ea37cbdded3f0d5 100644 (file)
@@ -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 {
index ef3a767365b75f57b1f99a490c883587345fa849..d1aefd08efe5dbf9c872c81968d06b5185c24486 100644 (file)
@@ -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'
 
index 460909dfa84d23476e1ea090c485285233faa8dc..49b0ab4076eff12b9c0d2b875da92473440b182c 100644 (file)
@@ -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'
 
index bd509f8fde1a0873e7aaaaa64ea51273e655b609..fa2f567b1f718c7eafc06e36a9a0f3d5e5178e68 100644 (file)
@@ -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',
index 4f25d2449b4856f6871d3b78c0880da224041fa0..49ad623c8949406fb81493e26ff9a18c93a1d2b0 100644 (file)
@@ -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'
 
index 2c9579041ea54292ca245b5efa53b5b3fc3b15bf..0359e81998dd05e4da8f98fb47b6d17e8ecd5a04 100644 (file)
@@ -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({
index 95010c2b6a4a743d8b9785d2d35644e2d54c04c1..ea4db8a1fe8a20210971b292d408aa8164495a1f 100644 (file)
@@ -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'
index dc901544a98feeb56cba283f9d694ae2d69a0356..04fdd7de2b09631b612d60b6a5f48ea9912abece 100644 (file)
@@ -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', () => {
index 7ad8a42a1a66f6adf1484175cf3e88aabc377a78..b87cbef6a1cf9786bc3f97d8592b90b91c76284f 100644 (file)
@@ -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'
index 8bd8d6a5533eea08205ef8a66f0604bcb44508b6..6992b0b53ab4a60f8a155bb4ae177ba1faf9fc46 100644 (file)
@@ -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({
index 2d723770ee91ad81cdb67aac97c9cd425f106d26..a0ef71f830a679bab85bbd3f7acf98d30b3dc988 100644 (file)
@@ -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',
index ff7ccde2f36aba155649901cac65aa19741fdc18..0a92d5d20ae3345d885642c2f2b480d58859c862 100644 (file)
  * 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({
index bc666b7c081420becc55d248efc2a162208ff403..292aec4c630066f7eded1dcc86641cfb61f1fdeb 100644 (file)
@@ -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'
index 7fb04d3622757d15064c2e24cb48224551a5bcf1..d7ba1a5d560a384deb6184e50c1a13efc47c3b8c 100644 (file)
@@ -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({
index 2c37dd838577e830b34a6f714b7b797a0691df30..44460a6249573cab665762868c70504d56ad4e4f 100644 (file)
@@ -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'
index d1b67f10b08713d9a35923d446eb428ece08c7cb..c41f3f2c41333f5b37cf42c2c5462ba9ba2f7f7e 100644 (file)
 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({
index 2b5e2e0d329aa79136b1f192605d50e941f4d216..4534183a6370423637c738c35d81035eaeb94dc7 100644 (file)
 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}`
index ce8b407719527403ee755af20db0aee0e2ecfa3f..70b6922dba72c95458e69efd79e7e58db6d4244a 100644 (file)
 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({
index 2c4aa373a3fa67f8465b28c3348cf26e0e0f691f..5e7a31b2448f9047d86a817503f94ef75a184551 100644 (file)
  * 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, {