Skip to content

Commit

Permalink
chore(files): Fix ESLint issues with files and files_sharing app
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 9, 2024
1 parent 24c0169 commit d0951b4
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions apps/files/src/actions/favoriteAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const favoriteView = {
name: 'Favorites',
} as View

global.window.OC = {
// @ts-expect-error This constant is currently missing in @nextcloud/typings
window.OC = {
...window.OC,
TAG_FAVORITE: '_$!<Favorite>!$_',
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/openFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('Open folder action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/FooBar' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/FooBar' })
})

test('Open folder fails without node', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/openFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const action = new FileAction({

window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ view: view.id, fileid: String(node.fileid) },
{ dir: node.path },
)
return null
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/actions/openInFilesAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo', openfile: 'true' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/Foo', openfile: 'true' })
})

test('Open in files with folder', async () => {
Expand All @@ -81,6 +81,6 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar', openfile: 'true' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/Foo/Bar', openfile: 'true' })
})
})
2 changes: 1 addition & 1 deletion apps/files/src/actions/openInFilesAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const action = new FileAction({

window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: node.fileid },
{ view: 'files', fileid: String(node.fileid) },
{ dir, openfile: 'true' },
)
return null
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/sidebarAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Open sidebar action exec tests', () => {
expect(openMock).toBeCalledWith('/foobar.txt')
expect(goToRouteMock).toBeCalledWith(
null,
{ view: view.id, fileid: 1 },
{ view: view.id, fileid: '1' },
{ dir: '/' },
true,
)
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/sidebarAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const action = new FileAction({
// Silently update current fileid
window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: node.fileid },
{ view: view.id, fileid: String(node.fileid) },
{ ...window.OCP.Files.Router.query, dir },
true,
)
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/actions/viewInFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('View in folder action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/' })
})

test('View in (sub) folder', async () => {
Expand All @@ -150,7 +150,7 @@ describe('View in folder action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/Foo/Bar' })
})

test('View in folder fails without node', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/viewInFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const action = new FileAction({

window.OCP.Files.Router.goToRoute(
null,
{ view: 'files', fileid: node.fileid },
{ view: 'files', fileid: String(node.fileid) },
{ dir: node.dirname },
)
return null
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default defineComponent({
},
fileId() {
return parseInt(this.$route.params.fileid) || null
return Number.parseInt(this.$route.params.fileid ?? '0') || null
},
/**
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/views/favorites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jest.mock('webdav/dist/node/request.js', () => ({
request: jest.fn(),
}))

global.window.OC = {
window.OC = {
...window.OC,
TAG_FAVORITE: '_$!<Favorite>!$_',
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/src/actions/openInFilesAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ describe('Open in files action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo', openfile: 'true' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: '1', view: 'files' }, { dir: '/Foo', openfile: 'true' })
})
})
2 changes: 1 addition & 1 deletion apps/files_sharing/src/actions/openInFilesAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const action = new FileAction({
async exec(node: Node) {
window.OCP.Files.Router.goToRoute(
null, // use default route
{ view: 'files', fileid: node.fileid },
{ view: 'files', fileid: String(node.fileid) },
{ dir: node.dirname, openfile: 'true' },
)
return null
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/src/services/SharingService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { getContents } from './SharingService'
import { File, Folder } from '@nextcloud/files'
import logger from './logger'

global.window.OC = {
window.OC = {
...window.OC,
TAG_FAVORITE: '_$!<Favorite>!$_',
}

Expand Down

0 comments on commit d0951b4

Please sign in to comment.