Skip to content

Commit

Permalink
Merge pull request #1135 from nextcloud-libraries/fix/fileListAction-api
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Dec 12, 2024
2 parents af6640e + 0d773f3 commit 52dd3c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions __tests__/fileListAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('FileListAction creation', () => {
expect(testAction.displayName({} as unknown as View)).toBe('Test')
expect(testAction.iconSvgInline({} as unknown as View)).toBe('<svg></svg>')
expect(testAction.order).toBe(0)
expect(testAction.enabled?.({} as unknown as View, [], { folder: {} as Folder })).toBe(true)
await expect(testAction.exec({} as unknown as View, [], { folder: {} as Folder })).resolves.toBe(undefined)
expect(testAction.enabled?.({} as unknown as View, [], {} as Folder)).toBe(true)
await expect(testAction.exec({} as unknown as View, [], {} as Folder)).resolves.toBe(undefined)
})
})
22 changes: 9 additions & 13 deletions lib/fileListAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { Node } from './files/node.ts'
import { Folder } from './files/folder.ts'
import { View } from './navigation/view.ts'
import type { Folder } from './files/folder.ts'
import type { Node } from './files/node.ts'
import type { View } from './navigation/view.ts'
import logger from './utils/logger.ts'

interface ActionContext {
folder: Folder,
}

interface FileListActionData {
/** Unique ID */
id: string
Expand All @@ -28,20 +24,20 @@ interface FileListActionData {
/**
* Returns true if this action shoud be shown
*
* @param view The current view
* @param nodes The nodes in the current directory
* @param context The context
* @param context.folder The current folder
* @param folder The current folder
*/
enabled?: (view: View, nodes: Node[], context: ActionContext) => boolean
enabled?: (view: View, nodes: Node[], folder: Folder) => boolean

/**
* Function to execute
*
* @param view The current view
* @param nodes The nodes in the current directory
* @param context The context
* @param context.folder The current folder
* @param folder The current folder
*/
exec: (view: View, nodes: Node[], context: ActionContext) => Promise<void>
exec: (view: View, nodes: Node[], folder: Folder) => Promise<void>
}

export class FileListAction {
Expand Down

0 comments on commit 52dd3c8

Please sign in to comment.