Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added publish context-menu option #1140

Draft
wants to merge 6 commits into
base: 1.x
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions assets/js/src/core/assets/icons/eye.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useRefreshTree } from '@Pimcore/modules/element/actions/refresh-tree/us
import { useCopyPaste } from '@Pimcore/modules/element/actions/copy-paste/use-copy-paste'
import { useLock } from '@Pimcore/modules/element/actions/lock/use-lock'
import { getElementActionCacheKey } from '@Pimcore/modules/element/element-helper'
import { usePublish } from '@Pimcore/modules/element/actions/publish/use-publish'

export interface DataObjectTreeContextMenuProps {
node: TreeNodeProps
Expand All @@ -38,13 +39,15 @@ export const DataObjectTreeContextMenu = (props: DataObjectTreeContextMenuProps)
const { refreshTreeContextMenuItem } = useRefreshTree('data-object')
const { copyTreeContextMenuItem, cutTreeContextMenuItem, pasteTreeContextMenuItem, pasteCutContextMenuItem } = useCopyPaste('data-object')
const { lockTreeContextMenuItem, lockAndPropagateTreeContextMenuItem, unlockTreeContextMenuItem, unlockAndPropagateTreeContextMenuItem, isLockMenuHidden } = useLock('data-object')
const { publishTreeContextMenuItem } = usePublish('data-object')

const items: DropdownMenuProps['items'] = [
addFolderTreeContextMenuItem(node),
renameTreeContextMenuItem(node),
copyTreeContextMenuItem(node),
pasteTreeContextMenuItem(node),
cutTreeContextMenuItem(node),
publishTreeContextMenuItem(node),
pasteCutContextMenuItem(parseInt(node.id)),
deleteTreeContextMenuItem(node),

Expand Down
50 changes: 50 additions & 0 deletions assets/js/src/core/modules/element/actions/publish/use-publish.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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 { type ItemType } from '@Pimcore/components/dropdown/dropdown'
import { type TreeNodeProps } from '@Pimcore/components/element-tree/node/tree-node'
import { Icon } from '@Pimcore/components/icon/icon'
import { TreePermission } from '@Pimcore/modules/perspectives/enums/tree-permission'
import { type ElementType } from '@Pimcore/types/enums/element/element-type'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useTreePermission } from '../../tree/provider/tree-permission-provider/use-tree-permission'

interface UsePublishHookReturn {
publishTreeContextMenuItem: (node: TreeNodeProps) => ItemType
}

export const usePublish = (elementType: ElementType): UsePublishHookReturn => {
const { t } = useTranslation()
const { isTreeActionAllowed } = useTreePermission()

const isPublishHidden = (node: TreeNodeProps): boolean => {
return !isTreeActionAllowed(TreePermission.Publish) || node.isLocked || node.isPublished === true
}

const publishTreeContextMenuItem = (node: TreeNodeProps): ItemType => {
return {
label: t('element.publish'),
key: 'publish',
icon: <Icon value='eye' />,
hidden: isPublishHidden(node),
onClick: () => {
console.log('TBI')
}
}
}

return {
publishTreeContextMenuItem
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/build/0e732180-7fa2-4618-afda-2b3804652720/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entrypoints": {
"core-dll": {
"css": [
"/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/core-dll.css"
],
"js": [
"/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/core-dll.js"
]
}
}
}
14 changes: 14 additions & 0 deletions public/build/0e732180-7fa2-4618-afda-2b3804652720/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/core-dll.css": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/core-dll.css",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/core-dll.js": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/core-dll.js",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/105.js": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/105.js",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Light.ttf": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Light.c7400fca.ttf",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Regular.ttf": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Regular.9d883d54.ttf",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Bold.ttf": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/fonts/Lato-Bold.636be8de.ttf",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet.svg": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet.a4e0eb7a.svg",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet-2x.png": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet-2x.7ea3a6d4.png",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet.png": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/spritesheet.ef32ea2b.png",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/marker-icon.png": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/marker-icon.2b3e1faf.png",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/layers-2x.png": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/layers-2x.8f2c4d11.png",
"bundles/pimcorestudioui/0e732180-7fa2-4618-afda-2b3804652720/images/layers.png": "/bundles/pimcorestudioui/build/0e732180-7fa2-4618-afda-2b3804652720/images/layers.416d9136.png"
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"vendor": {
"js": [
"/bundles/pimcorestudioui/build/5d249bd7-435b-4537-9dc5-87013e5a8cdb/vendor.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/5d249bd7-435b-4537-9dc5-87013e5a8cdb/vendor.js": "/bundles/pimcorestudioui/build/5d249bd7-435b-4537-9dc5-87013e5a8cdb/vendor.js"
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"main": {
"js": [
"/bundles/pimcorestudioui/build/a34fb18a-ed2a-4a1e-9f26-9386dd532b82/main.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/a34fb18a-ed2a-4a1e-9f26-9386dd532b82/main.js": "/bundles/pimcorestudioui/build/a34fb18a-ed2a-4a1e-9f26-9386dd532b82/main.js"
}
12 changes: 0 additions & 12 deletions public/build/ddbcb529-8b6e-4dcc-8164-a8d2ed7dd8c6/entrypoints.json

This file was deleted.

14 changes: 0 additions & 14 deletions public/build/ddbcb529-8b6e-4dcc-8164-a8d2ed7dd8c6/manifest.json

This file was deleted.

1 change: 1 addition & 0 deletions translations/studio.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ element.toolbar.copy-id: ID {{id}} - Copy
element.toolbar.copy-full-path-to-clipboard: Copy full path to clipboard
element.toolbar.copy-deep-link-to-clipboard: Copy deep link to clipboard
element.toolbar.copy-className: Class {{className}} - Copy
element.publish: Publish
male: Male
female: Female
other: Other
Expand Down