Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions __tests__/actions/fileAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Node } from '../../lib/node/index.ts'
import type { Folder, Node } from '../../lib/node/index.ts'
import type { View } from '../../lib/navigation/view.ts'

import { beforeEach, describe, expect, test, vi } from 'vitest'
Expand Down Expand Up @@ -248,8 +248,8 @@ describe('FileActions creation', () => {
expect(action.displayName([], {} as unknown as View)).toBe('Test')
expect(action.title?.([], {} as unknown as View)).toBe('Test title')
expect(action.iconSvgInline([], {} as unknown as View)).toBe('<svg></svg>')
await expect(action.exec({} as unknown as Node, {} as unknown as View, '/')).resolves.toBe(true)
await expect(action.execBatch?.([], {} as unknown as View, '/')).resolves.toStrictEqual([true])
await expect(action.exec({} as unknown as Node, {} as unknown as View, {} as unknown as Folder, [])).resolves.toBe(true)
await expect(action.execBatch?.([], {} as unknown as View, {} as unknown as Folder, [])).resolves.toStrictEqual([true])
expect(action.enabled?.([], {} as unknown as View)).toBe(true)
expect(action.order).toBe(100)
expect(action.parent).toBe('123')
Expand Down
5 changes: 3 additions & 2 deletions lib/actions/fileAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Node } from '../node/node.ts'
import type { View } from '../navigation/view.ts'

import logger from '../utils/logger.ts'
import { Folder } from '../node/folder.ts'

export enum DefaultType {
DEFAULT = 'default',
Expand Down Expand Up @@ -62,14 +63,14 @@ export interface FileActionData {
* false otherwise and null if the action is silent/undefined.
* @throws Error if the action failed
*/
exec: (file: Node, view: View, dir: string) => Promise<boolean|null>,
exec: (file: Node, view: View, folder: Folder, contents: Node[]) => Promise<boolean|null>,
/**
* Function executed on multiple files action
* @return 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: View, dir: string) => Promise<(boolean|null)[]>
execBatch?: (files: Node[], view: View, folder: Folder, contents: Node[]) => Promise<(boolean|null)[]>

/** This action order in the list */
order?: number
Expand Down