feat: migrate FileAction from server

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2023-08-18 11:10:00 +02:00
parent b4e71ad0fb
commit 2c9acd5d5d
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
50 changed files with 71 additions and 293 deletions

View 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'

View file

@ -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({

View 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',

View file

@ -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 = ''

View 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'

View file

@ -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'

View 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'

View 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.

View file

@ -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',

View file

@ -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[]) {

View 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',

View 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

View 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 = {

View file

@ -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({

View file

@ -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 = {

View file

@ -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'

View 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',

View file

@ -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() {

View 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'

View 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'

View 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'

View 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'

View file

@ -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',

View 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'

View 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'

View file

@ -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()

View file

@ -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 || []
}

View 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'

View file

@ -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'))

View 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'

View 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'

View 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 {

View 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'

View 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'

View 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',

View 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'

View 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({

View 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'

View 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', () => {

View 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'

View 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({

View 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',

View file

@ -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({

View 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'

View 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({

View 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'

View file

@ -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({

View file

@ -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}`

View file

@ -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({

View file

@ -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, {