Skip to content

Commit c75a621

Browse files
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.
1 parent fc0f8ee commit c75a621

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

resources/scripts/components/server/ServerDetailsBlock.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { bytesToHuman, megabytesToHuman } from '@/helpers';
66
import TitledGreyBox from '@/components/elements/TitledGreyBox';
77
import { ServerContext } from '@/state/server';
88
import CopyOnClick from '@/components/elements/CopyOnClick';
9+
import Can from '@/elements/Can';
910

1011
interface Stats {
1112
memory: number;
@@ -70,12 +71,14 @@ const ServerDetailsBlock = () => {
7071
/>
7172
 {!status ? 'Connecting...' : status}
7273
</p>
73-
<CopyOnClick text={primaryAllocation}>
74-
<p css={tw`text-xs mt-2`}>
75-
<FontAwesomeIcon icon={faEthernet} fixedWidth css={tw`mr-1`}/>
76-
<code css={tw`ml-1`}>{primaryAllocation}</code>
77-
</p>
78-
</CopyOnClick>
74+
<Can action={'allocation.read'}>
75+
<CopyOnClick text={primaryAllocation}>
76+
<p css={tw`text-xs mt-2`}>
77+
<FontAwesomeIcon icon={faEthernet} fixedWidth css={tw`mr-1`}/>
78+
<code css={tw`ml-1`}>{primaryAllocation}</code>
79+
</p>
80+
</CopyOnClick>
81+
</Can>
7982
<p css={tw`text-xs mt-2`}>
8083
<FontAwesomeIcon icon={faMicrochip} fixedWidth css={tw`mr-1`}/> {stats.cpu.toFixed(2)}%
8184
</p>

resources/scripts/routers/ServerRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
100100
<Can action={'backup.*'}>
101101
<NavLink to={`${match.url}/backups`}>Backups</NavLink>
102102
</Can>
103-
<Can action={'allocations.*'}>
103+
<Can action={'allocation.*'}>
104104
<NavLink to={`${match.url}/network`}>Network</NavLink>
105105
</Can>
106106
<Can action={'startup.*'}>

0 commit comments

Comments
 (0)