@@ -26,7 +26,12 @@ import {
2626 TEMP_getUserRolesWithRecovery ,
2727 getAllUserRoles ,
2828} from '../../../transformers' ;
29- import { canArchitect , hasRoot } from '../../../users/checks' ;
29+ import {
30+ canArchitect ,
31+ hasRoot ,
32+ canFund ,
33+ canAdminister ,
34+ } from '../../../users/checks' ;
3035import {
3136 domainsAndRolesFetcher ,
3237 TEMP_userHasRecoveryRoleFetcher ,
@@ -82,55 +87,79 @@ const navigationItems = (
8287) : NavigationItem [ ] => {
8388 const items = [ ] as NavigationItem [ ] ;
8489
90+ const profileTab = {
91+ id : 1 ,
92+ title : MSG . tabProfile ,
93+ content : < ProfileEdit colony = { colony } /> ,
94+ } ;
95+ const tokensTab = {
96+ id : 2 ,
97+ title : MSG . tabTokens ,
98+ content : (
99+ < Tokens
100+ colonyAddress = { colony . colonyAddress }
101+ canMintNativeToken = { colony . canMintNativeToken }
102+ domains = { domains }
103+ nativeTokenAddress = { colony . nativeTokenAddress }
104+ rootRoles = { rootRoles }
105+ tokenAddresses = { colony . tokenAddresses }
106+ />
107+ ) ,
108+ } ;
109+ const domainsTab = {
110+ id : 3 ,
111+ title : MSG . tabDomains ,
112+ content : (
113+ < Domains
114+ colonyAddress = { colony . colonyAddress }
115+ domains = { domains }
116+ rootRoles = { rootRoles }
117+ />
118+ ) ,
119+ } ;
120+ const advancedTab = {
121+ id : 5 ,
122+ title : MSG . tabAdvanced ,
123+ content : < ProfileAdvanced colony = { colony } rootRoles = { rootRoles } /> ,
124+ } ;
125+ const permissionsTab = {
126+ id : 4 ,
127+ title : MSG . tabPermissions ,
128+ content : (
129+ < Permissions colonyAddress = { colony . colonyAddress } domains = { domains } />
130+ ) ,
131+ } ;
132+
133+ /*
134+ * @NOTE Root role needs have access to the colony's management
135+ */
85136 if ( hasRoot ( rootRoles ) ) {
86- items . push ( {
87- id : 1 ,
88- title : MSG . tabProfile ,
89- content : < ProfileEdit colony = { colony } /> ,
90- } ) ;
91- items . push ( {
92- id : 2 ,
93- title : MSG . tabTokens ,
94- content : (
95- < Tokens
96- colonyAddress = { colony . colonyAddress }
97- canMintNativeToken = { colony . canMintNativeToken }
98- domains = { domains }
99- nativeTokenAddress = { colony . nativeTokenAddress }
100- rootRoles = { rootRoles }
101- tokenAddresses = { colony . tokenAddresses }
102- />
103- ) ,
104- } ) ;
137+ items . push ( profileTab ) ;
105138 }
106139
140+ /*
141+ * @NOTE Architecture role can create new domains and change permissions
142+ * But what exact permissions can be changed is handled by the component
143+ */
107144 if ( canArchitect ( allRoles ) ) {
108- items . push ( {
109- id : 3 ,
110- title : MSG . tabDomains ,
111- content : (
112- < Domains
113- colonyAddress = { colony . colonyAddress }
114- domains = { domains }
115- rootRoles = { rootRoles }
116- />
117- ) ,
118- } ) ;
119- items . push ( {
120- id : 4 ,
121- title : MSG . tabPermissions ,
122- content : (
123- < Permissions colonyAddress = { colony . colonyAddress } domains = { domains } />
124- ) ,
125- } ) ;
145+ items . push ( domainsTab ) ;
146+ items . push ( permissionsTab ) ;
147+ }
148+
149+ /*
150+ * @NOTE Funding role can just transfer funds between *available* domains
151+ * It can't also mint more tokens, but that is being handled by the component itself
152+ */
153+ if ( canFund ( allRoles ) ) {
154+ items . push ( tokensTab ) ;
126155 }
127156
157+ /*
158+ * @NOTE Root role needs have access to the colony's management
159+ * This needs to be the last call, so that we have the required tab sorting
160+ */
128161 if ( hasRoot ( rootRoles ) ) {
129- items . push ( {
130- id : 5 ,
131- title : MSG . tabAdvanced ,
132- content : < ProfileAdvanced colony = { colony } rootRoles = { rootRoles } /> ,
133- } ) ;
162+ items . push ( advancedTab ) ;
134163 }
135164
136165 return items ;
@@ -184,7 +213,10 @@ const AdminDashboard = ({
184213 return < LoadingTemplate loadingText = { MSG . loadingText } /> ;
185214 }
186215
187- if ( ! hasRoot ( rootUserRoles ) && ! canArchitect ( allUserRoles ) ) {
216+ /*
217+ * @NOTE All roles require, in addition to the specific role, the administration role
218+ */
219+ if ( ! canAdminister ( rootUserRoles ) ) {
188220 return < Redirect to = { CURRENT_COLONY_ROUTE } /> ;
189221 }
190222
0 commit comments