Skip to content

Commit

Permalink
console: Fix panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaplots committed Jan 28, 2025
1 parent 65c9a4d commit ae592e3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 71 deletions.
2 changes: 1 addition & 1 deletion pkg/webui/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Header.defaultProps = {
profileDropdownItems: undefined,
onMenuClick: () => null,
handleHideSidebar: () => null,
hasCreateRights: true,
hasCreateRights: false,
}

export default Header
117 changes: 47 additions & 70 deletions pkg/webui/console/containers/shortcut-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,95 +81,72 @@ const ShortcutPanel = ({ panelClassName, mobile }) => {
dispatch(setSearchOpen(true))
}, [dispatch])

const shortcutItems = [
{
hasRight: mayCreateApps,
icon: IconApplication,
title: sharedMessages.createApplication,
link: '/applications/add',
},
{
hasRight: mayCreateDev,
icon: IconDevice,
title: m.addEndDevice,
action: handleRegisterDeviceClick,
},
{
hasRight: mayCreateOrgs,
icon: IconUsersGroup,
title: sharedMessages.createOrganization,
link: '/organizations/add',
},
{
hasRight: mayCreateKeys,
icon: IconKey,
title: sharedMessages.addApiKey,
link: '/user-settings/api-keys/add',
},
{
hasRight: mayCreateGtws,
icon: IconGateway,
title: sharedMessages.registerGateway,
link: '/gateways/add',
}
]

if (!hasCreateRights) {
return null
}

if (mobile) {
return (
<div className="d-flex gap-cs-s">
{mayCreateApps && (
<ShortcutItem
icon={IconApplication}
title={sharedMessages.createApplication}
link="/applications/add"
mobile
/>
)}
{mayCreateDev && (
{shortcutItems.filter((item) => item.hasRight).map(({ icon, title, link, action }, index) => (
<ShortcutItem
icon={IconDevice}
title={sharedMessages.addEndDevice}
action={handleRegisterDeviceClick}
key={index}
icon={icon}
title={title}
link={link}
action={action}
mobile
/>
)}
{mayCreateOrgs && (
<ShortcutItem
icon={IconUsersGroup}
title={sharedMessages.createOrganization}
link="/organizations/add"
mobile
/>
)}
{mayCreateKeys && (
<ShortcutItem
icon={IconKey}
title={sharedMessages.addApiKey}
link="/user-settings/api-keys/add"
mobile
/>
)}
{mayCreateGtws && (
<ShortcutItem
icon={IconGateway}
title={sharedMessages.registerGateway}
link="/gateways/add"
mobile
/>
)}
))}
</div>
)
}

return (
<Panel title={m.shortcuts} icon={IconBolt} className={classNames(panelClassName, 'h-full')}>
<div className="d-flex gap-cs-xs w-full">
{mayCreateApps && (
<ShortcutItem
icon={IconApplication}
title={sharedMessages.createApplication}
link="/applications/add"
/>
)}
{mayCreateDevices && (
<ShortcutItem
icon={IconDevice}
title={sharedMessages.registerEndDevice}
action={handleRegisterDeviceClick}
/>
)}
{mayCreateOrgs && (
<ShortcutItem
icon={IconUsersGroup}
title={sharedMessages.createOrganization}
link="/organizations/add"
/>
)}
{mayCreateKeys && (
<ShortcutItem
icon={IconKey}
title={sharedMessages.addApiKey}
link="/user-settings/api-keys/add"
/>
)}
{mayCreateGtws && (
{shortcutItems.filter((item) => item.hasRight).map(({ icon, title, link, action }, index) => (
<ShortcutItem
icon={IconGateway}
title={sharedMessages.registerGateway}
link="/gateways/add"
key={index}
icon={icon}
title={title}
link={link}
action={action}
/>
)}
))}
</div>
</Panel>
)
Expand Down

0 comments on commit ae592e3

Please sign in to comment.