Only show allocation if user has permission
prevents just a blank scetion in the details box if a sub user dosn't have the permission of `allocation.read` Also fixes the server router where it was set to `allocations` and not `allocation` making it not showup period even if the sub user had the correct permissions.
This commit is contained in:
parent
fc0f8ee48e
commit
c75a621c52
|
@ -6,6 +6,7 @@ import { bytesToHuman, megabytesToHuman } from '@/helpers';
|
||||||
import TitledGreyBox from '@/components/elements/TitledGreyBox';
|
import TitledGreyBox from '@/components/elements/TitledGreyBox';
|
||||||
import { ServerContext } from '@/state/server';
|
import { ServerContext } from '@/state/server';
|
||||||
import CopyOnClick from '@/components/elements/CopyOnClick';
|
import CopyOnClick from '@/components/elements/CopyOnClick';
|
||||||
|
import Can from '@/elements/Can';
|
||||||
|
|
||||||
interface Stats {
|
interface Stats {
|
||||||
memory: number;
|
memory: number;
|
||||||
|
@ -70,12 +71,14 @@ const ServerDetailsBlock = () => {
|
||||||
/>
|
/>
|
||||||
{!status ? 'Connecting...' : status}
|
{!status ? 'Connecting...' : status}
|
||||||
</p>
|
</p>
|
||||||
<CopyOnClick text={primaryAllocation}>
|
<Can action={'allocation.read'}>
|
||||||
<p css={tw`text-xs mt-2`}>
|
<CopyOnClick text={primaryAllocation}>
|
||||||
<FontAwesomeIcon icon={faEthernet} fixedWidth css={tw`mr-1`}/>
|
<p css={tw`text-xs mt-2`}>
|
||||||
<code css={tw`ml-1`}>{primaryAllocation}</code>
|
<FontAwesomeIcon icon={faEthernet} fixedWidth css={tw`mr-1`}/>
|
||||||
</p>
|
<code css={tw`ml-1`}>{primaryAllocation}</code>
|
||||||
</CopyOnClick>
|
</p>
|
||||||
|
</CopyOnClick>
|
||||||
|
</Can>
|
||||||
<p css={tw`text-xs mt-2`}>
|
<p css={tw`text-xs mt-2`}>
|
||||||
<FontAwesomeIcon icon={faMicrochip} fixedWidth css={tw`mr-1`}/> {stats.cpu.toFixed(2)}%
|
<FontAwesomeIcon icon={faMicrochip} fixedWidth css={tw`mr-1`}/> {stats.cpu.toFixed(2)}%
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -100,7 +100,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
||||||
<Can action={'backup.*'}>
|
<Can action={'backup.*'}>
|
||||||
<NavLink to={`${match.url}/backups`}>Backups</NavLink>
|
<NavLink to={`${match.url}/backups`}>Backups</NavLink>
|
||||||
</Can>
|
</Can>
|
||||||
<Can action={'allocations.*'}>
|
<Can action={'allocation.*'}>
|
||||||
<NavLink to={`${match.url}/network`}>Network</NavLink>
|
<NavLink to={`${match.url}/network`}>Network</NavLink>
|
||||||
</Can>
|
</Can>
|
||||||
<Can action={'startup.*'}>
|
<Can action={'startup.*'}>
|
||||||
|
|
Loading…
Reference in New Issue