diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts index 99aeecfc0d6..174d748d7fc 100644 --- a/apps/files/src/actions/deleteAction.ts +++ b/apps/files/src/actions/deleteAction.ts @@ -9,6 +9,7 @@ import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw' import TrashCanSvg from '@mdi/svg/svg/trash-can-outline.svg?raw' import { FileAction, Permission } from '@nextcloud/files' import { loadState } from '@nextcloud/initial-state' +import { t } from '@nextcloud/l10n' import PQueue from 'p-queue' import { TRASHBIN_VIEW_ID } from '../../../files_trashbin/src/files_views/trashbinView.ts' import logger from '../logger.ts' @@ -110,4 +111,9 @@ export const action = new FileAction({ destructive: true, order: 100, + + hotkey: { + description: t('files', 'Delete'), + key: 'Delete', + }, }) diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts index 35aba241324..b571a547e85 100644 --- a/apps/files/src/actions/favoriteAction.ts +++ b/apps/files/src/actions/favoriteAction.ts @@ -21,10 +21,10 @@ export const ACTION_FAVORITE = 'favorite' const queue = new PQueue({ concurrency: 5 }) -// If any of the nodes is not favorited, we display the favorite action. /** + * If any of the nodes is not favorited, we display the favorite action. * - * @param nodes + * @param nodes - The nodes to check */ function shouldFavorite(nodes: Node[]): boolean { return nodes.some((node) => node.attributes.favorite !== 1) @@ -124,4 +124,9 @@ export const action = new FileAction({ }, order: -50, + + hotkey: { + description: t('files', 'Add or remove favorite'), + key: 'S', + }, }) diff --git a/apps/files/src/actions/renameAction.ts b/apps/files/src/actions/renameAction.ts index 960a09ff70a..55d004d0803 100644 --- a/apps/files/src/actions/renameAction.ts +++ b/apps/files/src/actions/renameAction.ts @@ -51,4 +51,9 @@ export const action = new FileAction({ }, order: 10, + + hotkey: { + description: t('files', 'Rename'), + key: 'F2', + }, }) diff --git a/apps/systemtags/src/files_actions/inlineSystemTagsAction.ts b/apps/systemtags/src/files_actions/inlineSystemTagsAction.ts index af6e1aad7ea..c40c49d4c89 100644 --- a/apps/systemtags/src/files_actions/inlineSystemTagsAction.ts +++ b/apps/systemtags/src/files_actions/inlineSystemTagsAction.ts @@ -19,6 +19,94 @@ import '../css/fileEntryInlineSystemTags.scss' // Init tag cache const cache: TagWithId[] = [] +export const action = new FileAction({ + id: 'system-tags', + displayName: () => '', + iconSvgInline: () => '', + + enabled(nodes: Node[]) { + // Only show the action on single nodes + if (nodes.length !== 1) { + return false + } + + // Always show the action, even if there are no tags + // This will render an empty tag list and allow events to update it + return true + }, + + exec: async () => null, + renderInline, + + order: 0, + + hotkey: { + description: t('files', 'Manage tags'), + key: 'T', + }, +}) + +// Subscribe to the events +subscribe('systemtags:node:updated', updateSystemTagsHtml) +subscribe('systemtags:tag:created', addTag) +subscribe('systemtags:tag:deleted', removeTag) +subscribe('systemtags:tag:updated', updateTag) + +/** + * Update the system tags html when the node is updated + * + * @param node - The updated node + */ +function updateSystemTagsHtml(node: Node) { + renderInline(node).then((systemTagsHtml) => { + document.querySelectorAll(`[data-systemtags-fileid="${node.fileid}"]`).forEach((element) => { + element.replaceWith(systemTagsHtml) + }) + }) +} + +/** + * Add and remove tags from the cache + * + * @param tag - The tag to add + */ +function addTag(tag: TagWithId) { + cache.push(tag) +} + +/** + * Remove a tag from the cache + * + * @param tag - The tag to remove + */ +function removeTag(tag: TagWithId) { + cache.splice(cache.findIndex((t) => t.id === tag.id), 1) +} + +/** + * Update a tag in the cache + * + * @param tag - The tag to update + */ +function updateTag(tag: TagWithId) { + const index = cache.findIndex((t) => t.id === tag.id) + if (index !== -1) { + cache[index] = tag + } + updateSystemTagsColorAttribute(tag) +} + +/** + * Update the color attribute of the system tags + * + * @param tag - The tag to update + */ +function updateSystemTagsColorAttribute(tag: TagWithId) { + document.querySelectorAll(`[data-systemtag-name="${tag.displayName}"]`).forEach((element) => { + (element as HTMLElement).style.setProperty('--systemtag-color', `#${tag.color}`) + }) +} + /** * * @param tag @@ -103,81 +191,3 @@ async function renderInline(node: Node): Promise { return systemTagsElement } - -export const action = new FileAction({ - id: 'system-tags', - displayName: () => '', - iconSvgInline: () => '', - - enabled(nodes: Node[]) { - // Only show the action on single nodes - if (nodes.length !== 1) { - return false - } - - // Always show the action, even if there are no tags - // This will render an empty tag list and allow events to update it - return true - }, - - exec: async () => null, - renderInline, - - order: 0, -}) - -// Update the system tags html when the node is updated -/** - * - * @param node - */ -function updateSystemTagsHtml(node: Node) { - renderInline(node).then((systemTagsHtml) => { - document.querySelectorAll(`[data-systemtags-fileid="${node.fileid}"]`).forEach((element) => { - element.replaceWith(systemTagsHtml) - }) - }) -} - -// Add and remove tags from the cache -/** - * - * @param tag - */ -function addTag(tag: TagWithId) { - cache.push(tag) -} -/** - * - * @param tag - */ -function removeTag(tag: TagWithId) { - cache.splice(cache.findIndex((t) => t.id === tag.id), 1) -} -/** - * - * @param tag - */ -function updateTag(tag: TagWithId) { - const index = cache.findIndex((t) => t.id === tag.id) - if (index !== -1) { - cache[index] = tag - } - updateSystemTagsColorAttribute(tag) -} -// Update the color attribute of the system tags -/** - * - * @param tag - */ -function updateSystemTagsColorAttribute(tag: TagWithId) { - document.querySelectorAll(`[data-systemtag-name="${tag.displayName}"]`).forEach((element) => { - (element as HTMLElement).style.setProperty('--systemtag-color', `#${tag.color}`) - }) -} - -// Subscribe to the events -subscribe('systemtags:node:updated', updateSystemTagsHtml) -subscribe('systemtags:tag:created', addTag) -subscribe('systemtags:tag:deleted', removeTag) -subscribe('systemtags:tag:updated', updateTag)