Skip to content

Commit

Permalink
Navigation (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
sholzer authored Dec 6, 2024
1 parent 0936c11 commit a580818
Show file tree
Hide file tree
Showing 49 changed files with 2,647 additions and 1,956 deletions.
3 changes: 3 additions & 0 deletions assets/js/src/core/assets/icons/AppstoreOutlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/FileOutlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/ShopOutlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/ToolOutlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions assets/js/src/core/assets/icons/bar-chart-08.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/book.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/js/src/core/assets/icons/brush-03.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/pimcore.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/pin-02-outlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/src/core/assets/icons/users-01.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,7 +23,7 @@ export const useStlyes = createStyles(({
top: 0;
left: 0;
bottom: 0;
z-index: 2;
z-index: 1001;
pointer-events: none;
.left-sidebar__avatar {
Expand All @@ -38,6 +38,25 @@ export const useStlyes = createStyles(({
vertical-align: 0;
}
}
.left-sidebar__nav {
list-style: none;
padding: ${token.paddingXXS}px 0;
margin: ${token.marginSM}px 0;
position: relative;
pointer-events: auto;
text-align: center;
&:before {
content: '';
position: absolute;
top: 0;
left: ${token.paddingSM}px;
right: ${token.paddingSM}px;
height: 1px;
background: ${token.Divider.colorSplit};
}
}
`
}
}, { hashPriority: 'low' })
68 changes: 68 additions & 0 deletions assets/js/src/core/modules/app/base-layout/left-sidebar-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,71 @@ import { Avatar } from 'antd'
import React from 'react'
import { useStlyes } from './left-sidebar-view.styles'
import { Icon } from '@Pimcore/components/icon/icon'
import { MainNav } from '@Pimcore/modules/app/nav/main-nav'
import { useMainNav } from '@Pimcore/modules/app/nav/hooks/use-main-nav'

export const LeftSidebarView = (): React.JSX.Element => {
const { styles } = useStlyes()
const { addNavItem } = useMainNav()

addNavItem({
path: 'Settings/Document Types',
permission: 'documents'
})

addNavItem({
path: 'Tools/Glossary'
})

addNavItem({
path: 'Settings/User & Roles/Users',
className: 'item-style-modifier',
widgetConfig: {
name: 'Users',
id: 'user-management',
component: 'user-management',
config: {
icon: {
type: 'name',
value: 'user-01'
}
}
}
})

addNavItem({
path: 'Settings/User & Roles/Open ID Connect Config/Configuration'
})

addNavItem({
path: 'Settings',
icon: 'appstore-outlined'
})

addNavItem({
path: 'Tools',
icon: 'tools-outlined'
})

addNavItem({
path: 'Marketing',
icon: 'bar-chart-08'
})

addNavItem({
path: 'Customers',
icon: 'shopping-car-outlined'
})

addNavItem({
path: 'Cache',
icon: 'brush-03'
})

addNavItem({
path: 'System Related',
icon: 'shield-02'
})

return (
<div className={ styles.leftSidebar }>
Expand All @@ -26,6 +88,12 @@ export const LeftSidebarView = (): React.JSX.Element => {
icon={ <Icon value='user-01' /> }
size={ 26 }
/>

<ul className='left-sidebar__nav'>
<li>
<MainNav />
</li>
</ul>
</div>
)
}
48 changes: 48 additions & 0 deletions assets/js/src/core/modules/app/nav/hooks/use-main-nav.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* 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 { useAppDispatch, useAppSelector } from '@Pimcore/app/store'
import {
addNavItem as addNavItemAction,
type IMainNavItem
} from '@Pimcore/modules/app/nav/main-nav-slice'
import { isAllowed } from '@Pimcore/modules/auth/permission-helper'

interface IUseMainNavReturn {
addNavItem: (item: IMainNavItem) => void
getNavItems: IMainNavItem[]
}

export const useMainNav = (): IUseMainNavReturn => {
const dispatch = useAppDispatch()

function addNavItem (item: IMainNavItem): void {
let userIsAllowed = true
if (item.permission !== undefined) {
userIsAllowed = isAllowed(item.permission)
}

if (!userIsAllowed) {
return
}

dispatch(addNavItemAction(item))
}

const getNavItems = useAppSelector(state => state['main-nav'].items)

return {
addNavItem,
getNavItems
}
}
Loading

0 comments on commit a580818

Please sign in to comment.