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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 14 additions & 13 deletions assets/js/src/core/modules/app/base-layout/main-nav/main-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ROLES_WIDGET, USERS_WIDGET } from '@Pimcore/modules/user'
import { CUSTOM_REPORTS_WIDGET, REPORTS_WIDGET } from '@Pimcore/modules/reports'
import { REDIRECTS_WIDGET } from '@Pimcore/modules/redirects'
import { TAG_CONFIGURATION_WIDGET } from '@Pimcore/modules/tags'
import { UserPermission } from '@Pimcore/modules/auth/enums/user-permission'

export const MainNav = (): React.JSX.Element => {
const { t } = useTranslation()
Expand Down Expand Up @@ -213,24 +214,24 @@ export const MainNav = (): React.JSX.Element => {
})
}

useHandleKeyBindings(() => { handleOpen('data-object') }, 'openObject', true)
useHandleKeyBindings(() => { handleOpen('document') }, 'openDocument', true)
useHandleKeyBindings(() => { handleOpen('asset') }, 'openAsset', true)
useHandleKeyBindings(() => { handleOpen('data-object') }, 'openObject', true, UserPermission.Objects)
useHandleKeyBindings(() => { handleOpen('document') }, 'openDocument', true, UserPermission.Documents)
useHandleKeyBindings(() => { handleOpen('asset') }, 'openAsset', true, UserPermission.Assets)

useHandleKeyBindings(() => { openMainWidget(TRANSLATIONS_WIDGET) }, 'sharedTranslations', true)
useHandleKeyBindings(() => { openMainWidget(RECYCLE_BIN_WIDGET) }, 'recycleBin', true)
useHandleKeyBindings(() => { openMainWidget(NOTES_AND_EVENTS_WIDGET) }, 'notesEvents', true)
useHandleKeyBindings(() => { openMainWidget(TRANSLATIONS_WIDGET) }, 'sharedTranslations', true, UserPermission.Translations)
useHandleKeyBindings(() => { openMainWidget(RECYCLE_BIN_WIDGET) }, 'recycleBin', true, UserPermission.RecycleBin)
useHandleKeyBindings(() => { openMainWidget(NOTES_AND_EVENTS_WIDGET) }, 'notesEvents', true, UserPermission.NotesAndEvents)

useHandleKeyBindings(() => { openMainWidget(USERS_WIDGET) }, 'users', true)
useHandleKeyBindings(() => { openMainWidget(ROLES_WIDGET) }, 'roles', true)
useHandleKeyBindings(() => { openMainWidget(USERS_WIDGET) }, 'users', true, UserPermission.Users)
useHandleKeyBindings(() => { openMainWidget(ROLES_WIDGET) }, 'roles', true, UserPermission.Users)

useHandleKeyBindings(() => { openMainWidget(REPORTS_WIDGET) }, 'reports', true)
useHandleKeyBindings(() => { openMainWidget(CUSTOM_REPORTS_WIDGET) }, 'customReports', true)
useHandleKeyBindings(() => { openMainWidget(REPORTS_WIDGET) }, 'reports', true, UserPermission.Reports)
useHandleKeyBindings(() => { openMainWidget(CUSTOM_REPORTS_WIDGET) }, 'customReports', true, UserPermission.ReportsConfig)

useHandleKeyBindings(() => { openMainWidget(APPLICATION_LOGGER_WIDGET) }, 'applicationLogger', true)
useHandleKeyBindings(() => { openMainWidget(APPLICATION_LOGGER_WIDGET) }, 'applicationLogger', true, UserPermission.ApplicationLogger)

useHandleKeyBindings(() => { openMainWidget(REDIRECTS_WIDGET) }, 'redirects', true)
useHandleKeyBindings(() => { openMainWidget(TAG_CONFIGURATION_WIDGET) }, 'tagConfiguration', true)
useHandleKeyBindings(() => { openMainWidget(REDIRECTS_WIDGET) }, 'redirects', true, UserPermission.Redirects)
useHandleKeyBindings(() => { openMainWidget(TAG_CONFIGURATION_WIDGET) }, 'tagConfiguration', true, UserPermission.TagsConfiguration)

return (
<div ref={ elRef }>
Expand Down
9 changes: 7 additions & 2 deletions assets/js/src/core/modules/app/hook/use-handle-keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { useUserDraft } from '@Pimcore/modules/auth/hooks/use-user-draft'
import { type KeyBindingForAUser } from '@Pimcore/modules/auth/user/user-api-slice.gen'
import { useIsActiveMainWidget } from '@Pimcore/modules/widget-manager/hooks/use-is-active-main-widget'
import { useMergedKeyBindings } from '@Pimcore/modules/user/hooks/use-merged-keybindings'
import { isAllowed } from '@Pimcore/modules/auth/permission-helper'
import type { UserPermission } from '@Pimcore/modules/auth/enums/user-permission'
// import { useWidgetManager } from '@Pimcore/modules/widget-manager/hooks/use-widget-manager'

export const useHandleKeyBindings = (callback: (evt: KeyboardEvent) => void, actionName: string, alwaysActive = false): void => {
export const useHandleKeyBindings = (callback: (evt: KeyboardEvent) => void, actionName: string, alwaysActive = false, permission?: UserPermission): void => {
const isWidgetActive = useIsActiveMainWidget()
const { user } = useUserDraft()
const { mergedKeyBindings } = useMergedKeyBindings(user?.keyBindings)
Expand All @@ -36,10 +38,13 @@ export const useHandleKeyBindings = (callback: (evt: KeyboardEvent) => void, act
const { keyCode, ctrlKey, altKey, shiftKey } = evt

if (config?.key !== undefined && config.key === keyCode && config.ctrl === ctrlKey && config.shift === shiftKey && config.alt === altKey) {
if (permission !== undefined && !isAllowed(permission)) {
return
}
evt.preventDefault()
callback(evt)
}
}, [callback, actionName])
}, [callback, actionName, permission])

useEffect(() => {
document.removeEventListener('keydown', eventHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ import { useLocateInTree } from '@Pimcore/modules/element/actions/locate-in-tree
import { type Element } from '@Pimcore/modules/element/element-helper'
import { type DataObject } from '@Pimcore/modules/data-object/data-object-api-slice.gen'
import { type Document } from '@Pimcore/modules/document/document-api-slice.gen'
import { isNull } from 'lodash'
import { has, isNull } from 'lodash'
import { isWorkflowAvailable } from '@Pimcore/modules/element/utils/workflow-availability'
import { checkElementPermission } from '@Pimcore/modules/element/permissions/permission-helper'
import { TreePermission } from '@Pimcore/modules/perspectives/enums/tree-permission'
import {
useTreePermission
} from '@Pimcore/components/element-tree/provider/tree-permission-provider/use-tree-permission'

export const TabsContainer = ({ elementEditorType }: { elementEditorType: ElementEditorType }): React.JSX.Element => {
const { t } = useTranslation()
Expand All @@ -41,6 +46,7 @@ export const TabsContainer = ({ elementEditorType }: { elementEditorType: Elemen
const { unpublishTreeNode } = useUnpublish(elementType)
const { refreshElement } = useElementRefresh(elementType)
const { locateInTree } = useLocateInTree(elementType)
const { isTreeActionAllowed } = useTreePermission()

const preparedTabs = tabs.map((tab, index) => {
const baseTab = {
Expand All @@ -57,9 +63,9 @@ export const TabsContainer = ({ elementEditorType }: { elementEditorType: Elemen
return baseTab
})

useHandleKeyBindings(() => { if (element != null) rename(element.id, getElementKey(element as unknown as Element, elementType)) }, 'rename')
useHandleKeyBindings(() => { if (element != null) publishNode(element as unknown as Element) }, 'publish')
useHandleKeyBindings(() => { if (element != null && !isNull(elementType) && elementType !== 'asset') unpublishTreeNode(element as unknown as DataObject | Document) }, 'unpublish')
useHandleKeyBindings(() => { if (element != null && checkElementPermission(element.permissions, 'rename') && !(element as unknown as Element).isLocked) rename(element.id, getElementKey(element as unknown as Element, elementType)) }, 'rename')
useHandleKeyBindings(() => { if (element != null && isTreeActionAllowed(TreePermission.Publish) && !(element as unknown as Element).isLocked && (has(element, 'published') && element.published === false)) publishNode(element as unknown as Element) }, 'publish')
useHandleKeyBindings(() => { if (element != null && !isNull(elementType) && elementType !== 'asset' && checkElementPermission(element.permissions, 'unpublish') && !(element as unknown as Element).isLocked) unpublishTreeNode(element as unknown as DataObject | Document) }, 'unpublish')
useHandleKeyBindings(() => { if (element != null) refreshElement(element.id) }, 'refresh')
useHandleKeyBindings(() => { if (element != null) locateInTree(element.id) }, 'openInTree')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import React from 'react'
import { useSearch } from '../../provider/use-search'
import { useHandleKeyBindings } from '@Pimcore/modules/app/hook/use-handle-keybindings'
import { elementTypes } from '@Pimcore/types/enums/element/element-type'
import { UserPermission } from '@Pimcore/modules/auth/enums/user-permission'

export const SearchButton = (): React.JSX.Element => {
const { open } = useSearch()

useHandleKeyBindings(() => { open('all') }, 'quickSearch', true)
useHandleKeyBindings(() => { open(elementTypes.asset) }, 'searchAsset', true)
useHandleKeyBindings(() => { open(elementTypes.dataObject) }, 'searchObject', true)
useHandleKeyBindings(() => { open(elementTypes.document) }, 'searchDocument', true)
useHandleKeyBindings(() => { open(elementTypes.asset) }, 'searchAsset', true, UserPermission.Assets)
useHandleKeyBindings(() => { open(elementTypes.dataObject) }, 'searchObject', true, UserPermission.Objects)
useHandleKeyBindings(() => { open(elementTypes.document) }, 'searchDocument', true, UserPermission.Documents)

return (
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
GENERAL_FIELDS,
NAVIGATION_FIELDS,
SEARCH_FIELDS,
SEO_FIELDS,
SYSTEM_FIELDS
} from '@Pimcore/modules/user/management/detail/tabs/key-bindings/constants'

Expand Down Expand Up @@ -124,7 +125,7 @@ const KeyBindings = ({ values, modified, onChange, onResetKeyBindings, ...props
getAccordionItem('navigation', NAVIGATION_FIELDS),
getAccordionItem('search', SEARCH_FIELDS),
getAccordionItem('system', SYSTEM_FIELDS),
getAccordionItem('seo', SEARCH_FIELDS),
getAccordionItem('seo', SEO_FIELDS),
...(!isEmpty(bundleFields) ? [getAccordionItem(BUNDLES, bundleFields!)] : [])
]

Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions public/build/0d446908-ec86-4573-b3a6-5762bb8c25e7/entrypoints.json

This file was deleted.

35 changes: 0 additions & 35 deletions public/build/0d446908-ec86-4573-b3a6-5762bb8c25e7/manifest.json

This file was deleted.

23 changes: 23 additions & 0 deletions public/build/3eef943c-f8c8-4ed5-9a60-7ed068a5b559/entrypoints.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading