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
2 changes: 1 addition & 1 deletion __tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { describe, expect, test } from 'vitest'
import { getFileActions, registerFileAction } from '../lib/actions/fileAction.ts'
import {
addNewFileMenuEntry,
File,
Expand All @@ -16,6 +15,7 @@ import {
Permission,
removeNewFileMenuEntry,
} from '../lib/index.ts'
import { getFileActions, registerFileAction } from '~/ui/actions/fileAction.ts'

describe('Exports checks', () => {
test('formatFileSize', () => {
Expand Down
5 changes: 4 additions & 1 deletion __tests__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"compilerOptions": {
// Allow us to pass js files to ts-jest without babel
"allowJs": true,
"rootDir": ".."
"rootDir": "..",
"paths": {
"~/*": ["../lib/*"]
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFileAction } from '../../lib/actions/index.ts'
import type { View } from '../../lib/navigation/view.ts'
import type { Folder, Node } from '../../lib/node/index.ts'
import type { IFolder, INode } from '~/node/index.ts'
import type { IFileAction } from '~/ui/index.ts'
import type { View } from '~/ui/navigation/index.ts'

import { beforeEach, describe, expect, test, vi } from 'vitest'
import { DefaultType, getFileActions, registerFileAction } from '../../lib/actions/index.ts'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { getRegistry } from '../../lib/registry.ts'
import logger from '../../lib/utils/logger.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { DefaultType, getFileActions, getFilesRegistry, registerFileAction } from '~/ui/index.ts'
import logger from '~/utils/logger.ts'

const folder = {} as Folder
const folder = {} as IFolder
const view = {} as View
describe('FileActions init', () => {
beforeEach(() => {
Expand Down Expand Up @@ -54,7 +53,7 @@ describe('FileActions init', () => {
exec: async () => true,
}

getRegistry().addEventListener('register:action', callback)
getFilesRegistry().addEventListener('register:action', callback)
registerFileAction(action)

expect(callback).toHaveBeenCalled()
Expand Down Expand Up @@ -248,7 +247,7 @@ describe('FileActions creation', () => {
},
}

const node = {} as Node
const node = {} as INode

expect(action.id).toBe('test')
expect(action.displayName({ view, folder, nodes: [], contents: [] })).toBe('Test')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFileListAction } from '../../lib/actions/index.ts'
import type { View } from '../../lib/navigation/view.ts'
import type { Folder } from '../../lib/node/index.ts'
import type { IFolder } from '~/node/index.ts'
import type { IFileListAction, View } from '~/ui/index.ts'

import { beforeEach, describe, expect, test, vi } from 'vitest'
import { getFileListActions, registerFileListAction } from '../../lib/actions/fileListAction.ts'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { getRegistry } from '../../lib/registry.ts'
import logger from '../../lib/utils/logger.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { getFileListActions, getFilesRegistry, registerFileListAction } from '~/ui/index.ts'
import logger from '~/utils/logger.ts'

const folder = {} as Folder
const folder = {} as IFolder
const view = {} as View

function mockAction(id: string): IFileListAction {
Expand Down Expand Up @@ -91,7 +89,7 @@ describe('FileListActions init', () => {
const callback = vi.fn()
const testAction = mockAction('test')

getRegistry().addEventListener('register:listAction', callback)
getFilesRegistry().addEventListener('register:listAction', callback)
registerFileListAction(testAction)

expect(callback).toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFileListFilterChip } from '../../lib/filters/index.ts'
import type { IFileListFilterChip } from '~/ui/index.ts'

import { beforeEach, describe, expect, test, vi } from 'vitest'
import { FileListFilter, getFileListFilters, registerFileListFilter, unregisterFileListFilter } from '../../lib/filters/index.ts'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { getRegistry } from '../../lib/registry.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { FileListFilter, getFileListFilters, getFilesRegistry, registerFileListFilter, unregisterFileListFilter } from '~/ui/index.ts'

class TestFilter extends FileListFilter {
public testUpdated() {
Expand Down Expand Up @@ -100,7 +99,7 @@ describe('File list filter functions', () => {
const filter = new FileListFilter('my:id')
const spy = vi.fn()

getRegistry().addEventListener('register:listFilter', spy)
getFilesRegistry().addEventListener('register:listFilter', spy)

expect(scopedGlobals.fileListFilters).toBe(undefined)

Expand Down Expand Up @@ -146,7 +145,7 @@ describe('File list filter functions', () => {
const spy = vi.fn()

registerFileListFilter(filter)
getRegistry().addEventListener('unregister:listFilter', spy)
getFilesRegistry().addEventListener('unregister:listFilter', spy)

unregisterFileListFilter(filter.id)
expect(spy).toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFileListHeader, IFolder, IView } from '../../lib/index.ts'
import type { IFileListHeader, IFolder, IView } from '~/index.ts'

import { beforeEach, describe, expect, test, vi } from 'vitest'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { getFileListHeaders, registerFileListHeader } from '../../lib/headers/index.ts'
import { getRegistry } from '../../lib/registry.ts'
import logger from '../../lib/utils/logger.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { getFileListHeaders, getFilesRegistry, registerFileListHeader } from '~/ui/index.ts'
import logger from '~/utils/logger.ts'

describe('FileListHeader init', () => {
beforeEach(() => {
Expand Down Expand Up @@ -48,7 +47,7 @@ describe('FileListHeader init', () => {
updated: () => {},
}

getRegistry().addEventListener('register:listHeader', callback)
getFilesRegistry().addEventListener('register:listHeader', callback)
registerFileListHeader(header)
expect(callback).toHaveBeenCalled()
expect(callback.mock.calls[0][0]).toBeInstanceOf(CustomEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

import { describe, expect, it, vi } from 'vitest'
import { scopedGlobals } from '../lib/globalScope.ts'
import { View } from '../lib/index.ts'
import { getNavigation, Navigation } from '../lib/navigation/navigation.ts'
import { mockView } from './fixtures/view.ts'
import { mockView } from '../../fixtures/view.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { View } from '~/index.ts'
import { getNavigation, Navigation } from '~/ui/navigation/navigation.ts'

describe('getNavigation', () => {
it('creates a new navigation if needed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IView } from '../lib/navigation/view.ts'
import type { IView } from '~/ui/navigation/view.ts'

import { describe, expect, test } from 'vitest'
import { View } from '../lib/navigation/view.ts'
import { mockView } from './fixtures/view.ts'
import { mockView } from '../../fixtures/view.ts'
import { View } from '~/ui/navigation/index.ts'

describe('Invalid View creation', () => {
test('Invalid id', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { NewMenuEntry } from '../../lib/newMenu/index.ts'
import type { NewMenuEntry } from '~/ui/index.ts'

import { afterEach, describe, expect, test, vi } from 'vitest'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { addNewFileMenuEntry, getNewFileMenu, getNewFileMenuEntries, removeNewFileMenuEntry } from '../../lib/newMenu/index.ts'
import { NewMenu, NewMenuEntryCategory } from '../../lib/newMenu/NewMenu.ts'
import { Folder } from '../../lib/node/index.ts'
import { Permission } from '../../lib/permissions.ts'
import logger from '../../lib/utils/logger.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { Folder } from '~/node/index.ts'
import { Permission } from '~/permissions.ts'
import { addNewFileMenuEntry, getNewFileMenu, getNewFileMenuEntries, removeNewFileMenuEntry } from '~/ui/index.ts'
import { NewMenu, NewMenuEntryCategory } from '~/ui/newMenu/NewMenu.ts'
import logger from '~/utils/logger.ts'

describe('NewFileMenu init', () => {
test('Initializing NewFileMenu', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { ISidebarTab } from '../../lib/sidebar/SidebarTab.ts'
import type { ISidebarTab } from '~/ui/index.ts'

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { scopedGlobals } from '../../lib/globalScope.ts'
import { getSidebarTabs, registerSidebarTab } from '../../lib/sidebar/SidebarTab.ts'
import { scopedGlobals } from '~/globalScope.ts'
import { getSidebarTabs, registerSidebarTab } from '~/ui/index.ts'

// missing in JSDom but supported by every browser!
import 'css.escape'
Expand Down
7 changes: 3 additions & 4 deletions lib/globalScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFileAction, IFileListAction } from './actions/index.ts'
import type { DavProperty } from './dav/index.ts'
import type {
IFileListFilter,
IFileListHeader,
Navigation,
NewMenu,
} from './index.ts'
import type { FilesRegistry } from './registry.ts'
import type { ISidebarTab } from './sidebar/index.ts'
import type { ISidebarAction } from './sidebar/SidebarAction.ts'
import type { IFileAction, IFileListAction } from './ui/actions/index.ts'
import type { FilesRegistry } from './ui/registry.ts'
import type { ISidebarAction, ISidebarTab } from './ui/sidebar/index.ts'

interface InternalGlobalScope {
davNamespaces?: DavProperty
Expand Down
11 changes: 1 addition & 10 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

export type * from './types.ts'

export * from './actions/index.ts'
export * from './filters/index.ts'
export * from './headers/index.ts'
export * from './navigation/index.ts'
export * from './newMenu/index.ts'
export * from './node/index.ts'
export * from './permissions.ts'
export * from './sidebar/index.ts'
export * from './ui/index.ts'
export * from './utils/index.ts'

export { getFilesRegistry } from './registry.ts'
4 changes: 2 additions & 2 deletions lib/actions/fileAction.ts → lib/ui/actions/fileAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import type { ActionContext, ActionContextSingle } from '../types.ts'

import { scopedGlobals } from '../globalScope.ts'
import { scopedGlobals } from '../../globalScope.ts'
import logger from '../../utils/logger.ts'
import { getRegistry } from '../registry.ts'
import logger from '../utils/logger.ts'

export const DefaultType = Object.freeze({
DEFAULT: 'default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import type { ViewActionContext } from '../types.ts'

import { scopedGlobals } from '../globalScope.ts'
import { scopedGlobals } from '../../globalScope.ts'
import logger from '../../utils/logger.ts'
import { getRegistry } from '../registry.ts'
import logger from '../utils/logger.ts'

export interface IFileListAction {
/** Unique ID */
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/filters/functions.ts → lib/ui/filters/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import type { IFileListFilter } from './listFilters.ts'

import { scopedGlobals } from '../globalScope.ts'
import { scopedGlobals } from '../../globalScope.ts'
import { getRegistry } from '../registry.ts'

/**
Expand Down
File renamed without changes.
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 { INode } from '../node/index.ts'
import type { INode } from '../../node/index.ts'

import { TypedEventTarget } from 'typescript-event-target'

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/headers/listHeaders.ts → lib/ui/headers/listHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFolder } from '../../node/folder.ts'
import type { IView } from '../navigation/view.ts'
import type { IFolder } from '../node/folder.ts'

import { scopedGlobals } from '../globalScope.ts'
import { scopedGlobals } from '../../globalScope.ts'
import logger from '../../utils/logger.ts'
import { getRegistry } from '../registry.ts'
import logger from '../utils/logger.ts'

export interface IFileListHeader {
/** Unique ID */
Expand Down
15 changes: 15 additions & 0 deletions lib/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

export type * from './types.ts'

export * from './actions/index.ts'
export * from './filters/index.ts'
export * from './headers/index.ts'
export * from './navigation/index.ts'
export * from './newMenu/index.ts'
export * from './sidebar/index.ts'

export { getFilesRegistry } from './registry.ts'
4 changes: 2 additions & 2 deletions lib/navigation/column.ts → lib/ui/navigation/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { INode } from '../node/node.ts'
import type { INode } from '../../node/node.ts'
import type { IView } from './view.ts'

import { checkOptionalProperty } from '../utils/objectValidation.ts'
import { checkOptionalProperty } from '../../utils/objectValidation.ts'

export interface IColumn {
/** Unique column ID */
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { IView } from './view.ts'

import { TypedEventTarget } from 'typescript-event-target'
import { scopedGlobals } from '../globalScope.ts'
import { scopedGlobals } from '../../globalScope.ts'
import { validateView } from './view.ts'

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/navigation/view.ts → lib/ui/navigation/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { IFolder, INode } from '../node/index.ts'
import type { IFolder, INode } from '../../node/index.ts'
import type { IColumn } from './column.ts'

import isSvg from 'is-svg'
import { checkOptionalProperty } from '../utils/objectValidation.ts'
import { checkOptionalProperty } from '../../utils/objectValidation.ts'
import { validateColumn } from './column.ts'

export type ContentsWithRoot = {
Expand Down
4 changes: 2 additions & 2 deletions lib/newMenu/NewMenu.ts → lib/ui/newMenu/NewMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

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

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

export const NewMenuEntryCategory = Object.freeze({
/**
Expand Down
Loading