diff --git a/pkg/webui/console/containers/shortcut-panel/index.js b/pkg/webui/console/containers/shortcut-panel/index.js index b50b6edccf..1fd9d401d3 100644 --- a/pkg/webui/console/containers/shortcut-panel/index.js +++ b/pkg/webui/console/containers/shortcut-panel/index.js @@ -14,7 +14,7 @@ import React from 'react' import { defineMessages } from 'react-intl' -import { useDispatch } from 'react-redux' +import { useDispatch, useSelector } from 'react-redux' import { APPLICATION } from '@console/constants/entities' @@ -29,6 +29,15 @@ import { import sharedMessages from '@ttn-lw/lib/shared-messages' +import { + checkFromState, + mayCreateApplications, + mayCreateDevices, + mayCreateGateways, + mayCreateOrganizations, + mayViewOrEditUserApiKeys, +} from '@console/lib/feature-checks' + import { setSearchOpen, setSearchScope } from '@console/store/actions/search' import Panel from '../../../components/panel' @@ -50,39 +59,55 @@ const ShortcutPanel = () => { dispatch(setSearchOpen(true)) }, [dispatch]) + const showApplicationButton = useSelector(state => checkFromState(mayCreateApplications, state)) + const showEndDeviceButton = useSelector(state => checkFromState(mayCreateDevices, state)) + const showOrganizationButton = useSelector(state => checkFromState(mayCreateOrganizations, state)) + const showUserApiKeys = useSelector(state => checkFromState(mayViewOrEditUserApiKeys, state)) + const showGatewaysButton = useSelector(state => checkFromState(mayCreateGateways, state)) + return (
- - - - - + {showApplicationButton && ( + + )} + {showEndDeviceButton && ( + + )} + {showGatewaysButton && ( + + )} + {showUserApiKeys && ( + + )} + {showOrganizationButton && ( + + )}
) diff --git a/pkg/webui/console/lib/feature-checks.js b/pkg/webui/console/lib/feature-checks.js index 163be25c40..61d6e772a9 100644 --- a/pkg/webui/console/lib/feature-checks.js +++ b/pkg/webui/console/lib/feature-checks.js @@ -92,6 +92,11 @@ export const mayViewOrEditUserApiKeys = { check: rights => rights.includes('RIGHT_USER_SETTINGS_API_KEYS'), } +export const mayCreateDevices = { + rightsSelector: selectUserRights, + check: rights => rights.includes('RIGHT_APPLICATION_DEVICES_WRITE'), +} + // Application related feature checks. export const mayViewApplicationInfo = { rightsSelector: selectApplicationRights,