From a023b5b2d524cf0c1526e07b19f34f53ee4d01a7 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 5 Feb 2026 15:17:26 +0100 Subject: [PATCH] refactor(files_external): adjust for files library interfaces Signed-off-by: Ferdinand Thiessen --- .../src/actions/enterCredentialsAction.spec.ts | 9 ++++----- .../files_external/src/actions/enterCredentialsAction.ts | 8 ++++---- .../src/actions/inlineStorageCheckAction.ts | 6 +++--- .../files_external/src/actions/openInFilesAction.spec.ts | 9 ++++----- apps/files_external/src/actions/openInFilesAction.ts | 7 ++++--- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/apps/files_external/src/actions/enterCredentialsAction.spec.ts b/apps/files_external/src/actions/enterCredentialsAction.spec.ts index 5e353f716f0..0c1777fe8be 100644 --- a/apps/files_external/src/actions/enterCredentialsAction.spec.ts +++ b/apps/files_external/src/actions/enterCredentialsAction.spec.ts @@ -3,10 +3,10 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { View } from '@nextcloud/files' +import type { IView } from '@nextcloud/files' import type { IStorage } from '../types.ts' -import { DefaultType, File, FileAction, Folder, Permission } from '@nextcloud/files' +import { DefaultType, File, Folder, Permission } from '@nextcloud/files' import { describe, expect, test } from 'vitest' import { StorageStatus } from '../types.ts' import { action } from './enterCredentialsAction.ts' @@ -14,12 +14,12 @@ import { action } from './enterCredentialsAction.ts' const view = { id: 'files', name: 'Files', -} as View +} as IView const externalStorageView = { id: 'extstoragemounts', name: 'External storage', -} as View +} as IView describe('Enter credentials action conditions tests', () => { test('Default values', () => { @@ -36,7 +36,6 @@ describe('Enter credentials action conditions tests', () => { }, }) - expect(action).toBeInstanceOf(FileAction) expect(action.id).toBe('credentials-external-storage') expect(action.displayName({ view: externalStorageView, diff --git a/apps/files_external/src/actions/enterCredentialsAction.ts b/apps/files_external/src/actions/enterCredentialsAction.ts index 4eec3d11865..20d54e64cf0 100644 --- a/apps/files_external/src/actions/enterCredentialsAction.ts +++ b/apps/files_external/src/actions/enterCredentialsAction.ts @@ -4,14 +4,14 @@ */ import type { AxiosResponse } from '@nextcloud/axios' -import type { INode } from '@nextcloud/files' +import type { IFileAction, INode } from '@nextcloud/files' import type { IStorage } from '../types.ts' import LoginSvg from '@mdi/svg/svg/login.svg?raw' import axios from '@nextcloud/axios' import { showError, showSuccess } from '@nextcloud/dialogs' import { emit } from '@nextcloud/event-bus' -import { DefaultType, FileAction } from '@nextcloud/files' +import { DefaultType } from '@nextcloud/files' import { t } from '@nextcloud/l10n' import { addPasswordConfirmationInterceptors, PwdConfirmationMode } from '@nextcloud/password-confirmation' import { generateUrl } from '@nextcloud/router' @@ -60,7 +60,7 @@ async function setCredentials(node: INode, login: string, password: string): Pro export const ACTION_CREDENTIALS_EXTERNAL_STORAGE = 'credentials-external-storage' -export const action = new FileAction({ +export const action: IFileAction = { id: ACTION_CREDENTIALS_EXTERNAL_STORAGE, displayName: () => t('files', 'Enter missing credentials'), iconSvgInline: () => LoginSvg, @@ -104,4 +104,4 @@ export const action = new FileAction({ order: -1000, default: DefaultType.DEFAULT, inline: () => true, -}) +} diff --git a/apps/files_external/src/actions/inlineStorageCheckAction.ts b/apps/files_external/src/actions/inlineStorageCheckAction.ts index 2e481993f9a..2a34af8b938 100644 --- a/apps/files_external/src/actions/inlineStorageCheckAction.ts +++ b/apps/files_external/src/actions/inlineStorageCheckAction.ts @@ -4,12 +4,12 @@ */ import type { AxiosError } from '@nextcloud/axios' +import type { IFileAction } from '@nextcloud/files' import type { IStorage } from '../types.ts' import AlertSvg from '@mdi/svg/svg/alert-circle.svg?raw' import { showWarning } from '@nextcloud/dialogs' import { emit } from '@nextcloud/event-bus' -import { FileAction } from '@nextcloud/files' import { t } from '@nextcloud/l10n' import { getStatus } from '../services/externalStorage.ts' import { StorageStatus } from '../types.ts' @@ -18,7 +18,7 @@ import { isNodeExternalStorage } from '../utils/externalStorageUtils.ts' import '../css/fileEntryStatus.scss' -export const action = new FileAction({ +export const action: IFileAction = { id: 'check-external-storage', displayName: () => '', iconSvgInline: () => '', @@ -88,4 +88,4 @@ export const action = new FileAction({ }, order: 10, -}) +} diff --git a/apps/files_external/src/actions/openInFilesAction.spec.ts b/apps/files_external/src/actions/openInFilesAction.spec.ts index fff1688ec18..369116bb4af 100644 --- a/apps/files_external/src/actions/openInFilesAction.spec.ts +++ b/apps/files_external/src/actions/openInFilesAction.spec.ts @@ -3,11 +3,11 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { View } from '@nextcloud/files' +import type { IView } from '@nextcloud/files' import type { IStorage } from '../types.ts' import * as dialogs from '@nextcloud/dialogs' -import { DefaultType, FileAction, Folder, Permission } from '@nextcloud/files' +import { DefaultType, Folder, Permission } from '@nextcloud/files' import { describe, expect, test, vi } from 'vitest' import { StorageStatus } from '../types.ts' import { action } from './openInFilesAction.ts' @@ -17,12 +17,12 @@ vi.mock('@nextcloud/dialogs', { spy: true }) const view = { id: 'files', name: 'Files', -} as View +} as IView const externalStorageView = { id: 'extstoragemounts', name: 'External storage', -} as View +} as IView describe('Open in files action conditions tests', () => { test('Default values', () => { @@ -39,7 +39,6 @@ describe('Open in files action conditions tests', () => { }, }) - expect(action).toBeInstanceOf(FileAction) expect(action.id).toBe('open-in-files-external-storage') expect(action.displayName({ nodes: [storage], diff --git a/apps/files_external/src/actions/openInFilesAction.ts b/apps/files_external/src/actions/openInFilesAction.ts index d6bccb9e9e1..81f02314c85 100644 --- a/apps/files_external/src/actions/openInFilesAction.ts +++ b/apps/files_external/src/actions/openInFilesAction.ts @@ -3,16 +3,17 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import type { IFileAction } from '@nextcloud/files' import type { IStorage } from '../types.ts' import { getCurrentUser } from '@nextcloud/auth' import { showConfirmation } from '@nextcloud/dialogs' -import { DefaultType, FileAction } from '@nextcloud/files' +import { DefaultType } from '@nextcloud/files' import { t } from '@nextcloud/l10n' import { generateUrl } from '@nextcloud/router' import { StorageStatus } from '../types.ts' -export const action = new FileAction({ +export const action: IFileAction = { id: 'open-in-files-external-storage', displayName: ({ nodes }) => { const config = nodes?.[0]?.attributes?.config as IStorage || { status: StorageStatus.Indeterminate } @@ -54,4 +55,4 @@ export const action = new FileAction({ // Before openFolderAction order: -1000, default: DefaultType.HIDDEN, -}) +}