Skip to content

Commit

Permalink
fix: update fileAction from server
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 18, 2023
1 parent befd766 commit 09e0f26
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/fileAction.ts
@@ -1,5 +1,5 @@
/**
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
Expand All @@ -24,6 +24,18 @@ import { Node } from './files/node'
import { View } from './navigation/view'
import logger from './utils/logger'

declare global {
interface Window {
OC: any;

Check warning on line 29 in lib/fileAction.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
_nc_fileactions: FileAction[] | undefined;
}
}

export enum DefaultType {
DEFAULT = 'default',
HIDDEN = 'hidden',
}

interface FileActionData {
/** Unique ID */
id: string
Expand All @@ -50,7 +62,7 @@ interface FileActionData {
/** This action order in the list */
order?: number,
/** Make this action the default */
default?: boolean,
default?: DefaultType,
/**
* If true, the renderInline function will be called
*/
Expand All @@ -59,7 +71,7 @@ interface FileActionData {
* If defined, the returned html element will be
* appended before the actions menu.
*/
renderInline?: (file: Node, view: View) => HTMLElement,
renderInline?: (file: Node, view: View) => Promise<HTMLElement | null>,
}

export class FileAction {
Expand Down Expand Up @@ -141,7 +153,7 @@ export class FileAction {
throw new Error('Invalid order')
}

if ('default' in action && typeof action.default !== 'boolean') {
if (action.default && !Object.values(DefaultType).includes(action.default)) {
throw new Error('Invalid default')
}

Expand Down

0 comments on commit 09e0f26

Please sign in to comment.