diff --git a/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/preview/flex-container.tsx b/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/preview/flex-container.tsx index c5fc590b5..cbd72d842 100644 --- a/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/preview/flex-container.tsx +++ b/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/preview/flex-container.tsx @@ -24,6 +24,7 @@ import { Icon } from '@Pimcore/components/icon/icon' import { useRename } from '@Pimcore/modules/element/actions/rename/use-rename' import { useDelete } from '@Pimcore/modules/element/actions/delete/use-delete' import { useDownload } from '@Pimcore/modules/asset/actions/download/use-download' +import { useOpen } from '@Pimcore/modules/element/actions/open/open' interface FlexContainerProps { assets: AssetGetTreeApiResponse @@ -36,6 +37,7 @@ const FlexContainer = (props: FlexContainerProps): React.JSX.Element => { const { renameContextMenuItem } = useRename('asset') const { deleteContextMenuItem } = useDelete('asset') const { downloadContextMenuItem } = useDownload() + const { openContextMenuItem } = useOpen('asset') const cards: ReactNode[] = [] assets.items.forEach((asset) => { @@ -48,6 +50,7 @@ const FlexContainer = (props: FlexContainerProps): React.JSX.Element => { } const dropdownItems: DropdownProps['menu']['items'] = [ + openContextMenuItem(asset), { key: 'locate-in-tree', icon: , diff --git a/assets/js/src/core/modules/element/actions/open/open.tsx b/assets/js/src/core/modules/element/actions/open/open.tsx new file mode 100644 index 000000000..b6861ec7d --- /dev/null +++ b/assets/js/src/core/modules/element/actions/open/open.tsx @@ -0,0 +1,49 @@ +/** +* Pimcore +* +* This source file is available under two different licenses: +* - Pimcore Open Core License (POCL) +* - Pimcore Commercial License (PCL) +* Full copyright and license information is available in +* LICENSE.md which is distributed with this source code. +* +* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) +* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL +*/ + +import React from 'react' +import { type ItemType } from '@Pimcore/components/dropdown/dropdown' +import { Icon } from '@Pimcore/components/icon/icon' +import { checkElementPermission } from '@Pimcore/modules/element/permissions/permission-helper' +import { useTranslation } from 'react-i18next' +import { type Element } from '@Pimcore/modules/element/element-helper' +import { useElementHelper } from '@Pimcore/modules/element/hooks/use-element-helper' +import { type ElementType } from 'types/element-type.d' + +export interface UseOpenHookReturn { + openContextMenuItem: (node: Element, onFinish?: () => void) => ItemType +} + +export const useOpen = (elementType: ElementType): UseOpenHookReturn => { + const { t } = useTranslation() + const { openElement } = useElementHelper() + + const openContextMenuItem = (node: Element): ItemType => { + return { + label: t('element.open'), + key: 'open', + icon: , + hidden: !checkElementPermission(node.permissions!, 'rename') || node.isLocked, + onClick: async () => { + await openElement({ + id: node.id, + type: elementType + }) + } + } + } + + return { + openContextMenuItem + } +} diff --git a/translations/studio.en.yaml b/translations/studio.en.yaml index 5f46e70da..48eab7ab2 100644 --- a/translations/studio.en.yaml +++ b/translations/studio.en.yaml @@ -323,6 +323,7 @@ element.delete: Delete element.delete.confirmation.title: Delete item element.delete.confirmation.text: Do you really want to delete this item? element.delete.confirmation.ok: Delete permanently +element.open: Open male: Male female: Female other: Other @@ -363,4 +364,4 @@ processing: Processing upload: Upload upload.assets-items-failed-message: Some items could not be uploaded. quantity-value.converted-units: Converted Units -structured-table.empty.confirm: Are you sure you want to clear all data? \ No newline at end of file +structured-table.empty.confirm: Are you sure you want to clear all data?