Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide fileList names as newFileMenu handler argument #752

Merged
merged 1 commit into from Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions __tests__/newFileMenu.spec.ts
Expand Up @@ -2,16 +2,8 @@

import { NewFileMenu, getNewFileMenu, type Entry } from '../lib/newFileMenu'
import logger from '../lib/utils/logger'
import { Folder, Permission, View } from '../lib'

Check warning on line 5 in __tests__/newFileMenu.spec.ts

View workflow job for this annotation

GitHub Actions / eslint

'View' is defined but never used

const view = new View({
id: 'files',
name: 'Files',
icon: '<svg></svg>',
getContents: async () => ({ folder: {}, contents: [] }),
order: 1,
})

describe('NewFileMenu init', () => {
test('Initializing NewFileMenu', () => {
logger.debug = vi.fn()
Expand Down Expand Up @@ -276,7 +268,7 @@
permissions: Permission.ALL,
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(2)
expect(entries[0]).toBe(entry1)
expect(entries[1]).toBe(entry2)
Expand Down Expand Up @@ -312,7 +304,7 @@
permissions: Permission.READ,
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(0)
})

Expand Down Expand Up @@ -346,7 +338,7 @@
root: '/files/admin',
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(1)
expect(entries[0]).toBe(entry1)
})
Expand Down
3 changes: 2 additions & 1 deletion lib/newFileMenu.ts
Expand Up @@ -48,8 +48,9 @@ export interface Entry {
/**
* Function to be run after creation
* @param {Folder} context the creation context. Usually the current folder
* @param {string[]} fileList list of file names present in the destination folder
*/
handler: (context: Folder) => void
handler: (context: Folder, fileList: string[]) => void
}

export class NewFileMenu {
Expand Down