Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions lib/navigation/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Folder } from '../node/folder.ts'
import type { Node } from '../node/node.ts'
import type { IFolder, INode } from '../node/index.ts'

import isSvg from 'is-svg'
import { Column } from './column.ts'

export type ContentsWithRoot = {
folder: Folder,
contents: Node[]
folder: IFolder,
contents: INode[]
Comment on lines +12 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No ESLint here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not v9 yet 😔

}

export interface IGetContentsOptions {
/**
* Abort signal to be able to cancel the request.
*
*@see https://developer.mozilla.org/en-US/docs/Web/API/AbortController
*/
signal: AbortSignal
}

export interface IView {
Expand Down Expand Up @@ -42,11 +50,11 @@ export interface IView {
* This method _must_ also return the current directory
* information alongside with its content.
*
* Usually a abort signal is provided to be able to
* An abort signal is provided to be able to
* cancel the request if the user change directory
* {@see https://developer.mozilla.org/en-US/docs/Web/API/AbortController }.
*/
getContents(path: string, options: { signal: AbortSignal }): Promise<ContentsWithRoot>
getContents(path: string, options: IGetContentsOptions): Promise<ContentsWithRoot>

/**
* If set then the view will be hidden from the navigation unless its the active view.
Expand Down Expand Up @@ -95,8 +103,7 @@ export interface IView {
/**
* Method called to load child views if any
*/
// eslint-disable-next-line no-use-before-define
loadChildViews?: (view: View) => Promise<void>
loadChildViews?: (view: IView) => Promise<void>
}

export class View implements IView {
Expand Down
10 changes: 5 additions & 5 deletions lib/newMenu/NewMenu.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 { Folder, Node } from '../node/index.ts'
import type { IFolder, INode } from '../node/index.ts'

import logger from '../utils/logger.ts'

Expand Down Expand Up @@ -43,7 +43,7 @@ export interface NewMenuEntry {
* Condition wether this entry is shown or not
* @param context the creation context. Usually the current folder
*/
enabled?: (context: Folder) => boolean
enabled?: (context: IFolder) => boolean

/**
* Either iconSvgInline or iconClass must be defined
Expand All @@ -59,7 +59,7 @@ export interface NewMenuEntry {
* @param context - The creation context. Usually the current folder
* @param content - List of file/folders present in the context folder
*/
handler: (context: Folder, content: Node[]) => void
handler: (context: IFolder, content: INode[]) => void
}

export class NewMenu {
Expand Down Expand Up @@ -88,9 +88,9 @@ export class NewMenu {
/**
* Get the list of registered entries
*
* @param {Folder} context the creation context. Usually the current folder
* @param context - The creation context. Usually the current folder
*/
public getEntries(context?: Folder): Array<NewMenuEntry> {
public getEntries(context?: IFolder): Array<NewMenuEntry> {
if (context) {
return this._entries
.filter(entry => typeof entry.enabled === 'function' ? entry.enabled(context) : true)
Expand Down
6 changes: 3 additions & 3 deletions lib/newMenu/functions.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 { Folder } from '../node/index.ts'
import type { IFolder } from '../node/index.ts'
import type { NewMenuEntry } from './NewMenu.ts'

import { NewMenu } from './NewMenu.ts'
Expand Down Expand Up @@ -43,9 +43,9 @@ export function removeNewFileMenuEntry(entry: NewMenuEntry | string) {
/**
* Get the list of registered entries from the upload menu
*
* @param {Folder} context - The current folder to get the available entries
* @param context - The current folder to get the available entries
*/
export function getNewFileMenuEntries(context?: Folder): NewMenuEntry[] {
export function getNewFileMenuEntries(context?: IFolder): NewMenuEntry[] {
const newFileMenu = getNewFileMenu()
return newFileMenu.getEntries(context).sort((a: NewMenuEntry, b: NewMenuEntry) => {
// If defined and different, sort by order
Expand Down