Skip to content

Commit ba5b1ae

Browse files
committed
refactor: group all UI integrations in folder structure
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent df03c45 commit ba5b1ae

35 files changed

Lines changed: 106 additions & 95 deletions

__tests__/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { describe, expect, test } from 'vitest'
7-
import { getFileActions, registerFileAction } from '../lib/actions/fileAction.ts'
87
import {
98
addNewFileMenuEntry,
109
File,
@@ -16,6 +15,7 @@ import {
1615
Permission,
1716
removeNewFileMenuEntry,
1817
} from '../lib/index.ts'
18+
import { getFileActions, registerFileAction } from '~/ui/actions/fileAction.ts'
1919

2020
describe('Exports checks', () => {
2121
test('formatFileSize', () => {

__tests__/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"compilerOptions": {
55
// Allow us to pass js files to ts-jest without babel
66
"allowJs": true,
7-
"rootDir": ".."
7+
"rootDir": "..",
8+
"paths": {
9+
"~/*": ["../lib/*"]
10+
}
811
}
912
}
1013

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

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

1010
import { beforeEach, describe, expect, test, vi } from 'vitest'
11-
import { DefaultType, getFileActions, registerFileAction } from '../../lib/actions/index.ts'
12-
import { scopedGlobals } from '../../lib/globalScope.ts'
13-
import { getRegistry } from '../../lib/registry.ts'
14-
import logger from '../../lib/utils/logger.ts'
11+
import { scopedGlobals } from '~/globalScope.ts'
12+
import { DefaultType, getFileActions, getFilesRegistry, registerFileAction } from '~/ui/index.ts'
13+
import logger from '~/utils/logger.ts'
1514

16-
const folder = {} as Folder
15+
const folder = {} as IFolder
1716
const view = {} as View
1817
describe('FileActions init', () => {
1918
beforeEach(() => {
@@ -54,7 +53,7 @@ describe('FileActions init', () => {
5453
exec: async () => true,
5554
}
5655

57-
getRegistry().addEventListener('register:action', callback)
56+
getFilesRegistry().addEventListener('register:action', callback)
5857
registerFileAction(action)
5958

6059
expect(callback).toHaveBeenCalled()
@@ -248,7 +247,7 @@ describe('FileActions creation', () => {
248247
},
249248
}
250249

251-
const node = {} as Node
250+
const node = {} as INode
252251

253252
expect(action.id).toBe('test')
254253
expect(action.displayName({ view, folder, nodes: [], contents: [] })).toBe('Test')

__tests__/actions/fileListAction.spec.ts renamed to __tests__/ui/actions/fileListAction.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { IFileListAction } from '../../lib/actions/index.ts'
7-
import type { View } from '../../lib/navigation/view.ts'
8-
import type { Folder } from '../../lib/node/index.ts'
6+
import type { IFolder } from '~/node/index.ts'
7+
import type { IFileListAction, View } from '~/ui/index.ts'
98

109
import { beforeEach, describe, expect, test, vi } from 'vitest'
11-
import { getFileListActions, registerFileListAction } from '../../lib/actions/fileListAction.ts'
12-
import { scopedGlobals } from '../../lib/globalScope.ts'
13-
import { getRegistry } from '../../lib/registry.ts'
14-
import logger from '../../lib/utils/logger.ts'
10+
import { scopedGlobals } from '~/globalScope.ts'
11+
import { getFileListActions, getFilesRegistry, registerFileListAction } from '~/ui/index.ts'
12+
import logger from '~/utils/logger.ts'
1513

16-
const folder = {} as Folder
14+
const folder = {} as IFolder
1715
const view = {} as View
1816

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

94-
getRegistry().addEventListener('register:listAction', callback)
92+
getFilesRegistry().addEventListener('register:listAction', callback)
9593
registerFileListAction(testAction)
9694

9795
expect(callback).toHaveBeenCalled()
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { IFileListFilterChip } from '../../lib/filters/index.ts'
6+
import type { IFileListFilterChip } from '~/ui/index.ts'
77

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

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

103-
getRegistry().addEventListener('register:listFilter', spy)
102+
getFilesRegistry().addEventListener('register:listFilter', spy)
104103

105104
expect(scopedGlobals.fileListFilters).toBe(undefined)
106105

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

148147
registerFileListFilter(filter)
149-
getRegistry().addEventListener('unregister:listFilter', spy)
148+
getFilesRegistry().addEventListener('unregister:listFilter', spy)
150149

151150
unregisterFileListFilter(filter.id)
152151
expect(spy).toHaveBeenCalled()
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

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

88
import { beforeEach, describe, expect, test, vi } from 'vitest'
9-
import { scopedGlobals } from '../../lib/globalScope.ts'
10-
import { getFileListHeaders, registerFileListHeader } from '../../lib/headers/index.ts'
11-
import { getRegistry } from '../../lib/registry.ts'
12-
import logger from '../../lib/utils/logger.ts'
9+
import { scopedGlobals } from '~/globalScope.ts'
10+
import { getFileListHeaders, getFilesRegistry, registerFileListHeader } from '~/ui/index.ts'
11+
import logger from '~/utils/logger.ts'
1312

1413
describe('FileListHeader init', () => {
1514
beforeEach(() => {
@@ -48,7 +47,7 @@ describe('FileListHeader init', () => {
4847
updated: () => {},
4948
}
5049

51-
getRegistry().addEventListener('register:listHeader', callback)
50+
getFilesRegistry().addEventListener('register:listHeader', callback)
5251
registerFileListHeader(header)
5352
expect(callback).toHaveBeenCalled()
5453
expect(callback.mock.calls[0][0]).toBeInstanceOf(CustomEvent)

__tests__/navigation.spec.ts renamed to __tests__/ui/navigation/navigation.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
import { describe, expect, it, vi } from 'vitest'
7-
import { scopedGlobals } from '../lib/globalScope.ts'
8-
import { View } from '../lib/index.ts'
9-
import { getNavigation, Navigation } from '../lib/navigation/navigation.ts'
10-
import { mockView } from './fixtures/view.ts'
7+
import { mockView } from '../../fixtures/view.ts'
8+
import { scopedGlobals } from '~/globalScope.ts'
9+
import { View } from '~/index.ts'
10+
import { getNavigation, Navigation } from '~/ui/navigation/navigation.ts'
1111

1212
describe('getNavigation', () => {
1313
it('creates a new navigation if needed', () => {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { IView } from '../lib/navigation/view.ts'
6+
import type { IView } from '~/ui/navigation/view.ts'
77

88
import { describe, expect, test } from 'vitest'
9-
import { View } from '../lib/navigation/view.ts'
10-
import { mockView } from './fixtures/view.ts'
9+
import { mockView } from '../../fixtures/view.ts'
10+
import { View } from '~/ui/navigation/index.ts'
1111

1212
describe('Invalid View creation', () => {
1313
test('Invalid id', () => {
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { NewMenuEntry } from '../../lib/newMenu/index.ts'
6+
import type { NewMenuEntry } from '~/ui/index.ts'
77

88
import { afterEach, describe, expect, test, vi } from 'vitest'
9-
import { scopedGlobals } from '../../lib/globalScope.ts'
10-
import { addNewFileMenuEntry, getNewFileMenu, getNewFileMenuEntries, removeNewFileMenuEntry } from '../../lib/newMenu/index.ts'
11-
import { NewMenu, NewMenuEntryCategory } from '../../lib/newMenu/NewMenu.ts'
12-
import { Folder } from '../../lib/node/index.ts'
13-
import { Permission } from '../../lib/permissions.ts'
14-
import logger from '../../lib/utils/logger.ts'
9+
import { scopedGlobals } from '~/globalScope.ts'
10+
import { Folder } from '~/node/index.ts'
11+
import { Permission } from '~/permissions.ts'
12+
import { addNewFileMenuEntry, getNewFileMenu, getNewFileMenuEntries, removeNewFileMenuEntry } from '~/ui/index.ts'
13+
import { NewMenu, NewMenuEntryCategory } from '~/ui/newMenu/NewMenu.ts'
14+
import logger from '~/utils/logger.ts'
1515

1616
describe('NewFileMenu init', () => {
1717
test('Initializing NewFileMenu', () => {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

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

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

1212
// missing in JSDom but supported by every browser!
1313
import 'css.escape'

0 commit comments

Comments
 (0)