-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(systemtags): add systemtag manage keyboard shortcut
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
- Loading branch information
Showing
13 changed files
with
161 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { describe, it, vi, expect, beforeEach, beforeAll } from 'vitest' | ||
import { File, Permission, View } from '@nextcloud/files' | ||
|
||
import { getPinia } from '../../../files/src/store/index.ts' | ||
import { useActiveStore } from '../../../files/src/store/active.ts' | ||
|
||
import { action as bulkSystemTagsAction } from '../files_actions/bulkSystemTagsAction.ts' | ||
import { registerHotkeys } from './HotKeysService.ts' | ||
|
||
let file: File | ||
const view = { | ||
id: 'files', | ||
name: 'Files', | ||
} as View | ||
|
||
vi.mock('../files_actions/bulkSystemTagsAction.ts', { spy: true }) | ||
|
||
describe('HotKeysService testing', () => { | ||
const activeStore = useActiveStore(getPinia()) | ||
|
||
beforeAll(() => { | ||
registerHotkeys() | ||
}) | ||
|
||
beforeEach(() => { | ||
// Make sure the file is reset before each test | ||
file = new File({ | ||
id: 1, | ||
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', | ||
owner: 'admin', | ||
mime: 'text/plain', | ||
permissions: Permission.ALL, | ||
}) | ||
|
||
// Setting the view first as it reset the active node | ||
activeStore.onChangedView(view) | ||
activeStore.setActiveNode(file) | ||
}) | ||
|
||
it('Pressing t should open the tag management dialog', () => { | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT' })) | ||
|
||
// Modifier keys should not trigger the action | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', ctrlKey: true })) | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', altKey: true })) | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', shiftKey: true })) | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', metaKey: true })) | ||
|
||
expect(bulkSystemTagsAction.enabled).toHaveReturnedWith(true) | ||
expect(bulkSystemTagsAction.exec).toHaveBeenCalledOnce() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { useHotKey } from '@nextcloud/vue/dist/Composables/useHotKey.js' | ||
|
||
import { action as manageTagAction } from '../files_actions/bulkSystemTagsAction.ts' | ||
import { executeAction } from '../../../files/src/utils/actionUtils.ts' | ||
import logger from '../logger.ts' | ||
|
||
/** | ||
* This register the hotkeys for the Files app. | ||
* As much as possible, we try to have all the hotkeys in one place. | ||
* Please make sure to add tests for the hotkeys after adding a new one. | ||
*/ | ||
export const registerHotkeys = function() { | ||
// t opens the tag management dialog | ||
useHotKey('t', () => executeAction(manageTagAction), { | ||
stop: true, | ||
prevent: true, | ||
}) | ||
|
||
logger.debug('Hotkeys registered') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.