11import React from 'react' ;
22
3- import type { DefinitionListItem } from '@gravity-ui/components' ;
43import { DefinitionList } from '@gravity-ui/components' ;
4+ import type { DefinitionListItem } from '@gravity-ui/components' ;
55
66import { ResponseError } from '../../../components/Errors/ResponseError' ;
77import { Loader } from '../../../components/Loader' ;
88import { schemaAclApi } from '../../../store/reducers/schemaAcl/schemaAcl' ;
99import type { TACE } from '../../../types/api/acl' ;
1010import { valueIsDefined } from '../../../utils' ;
1111import { cn } from '../../../utils/cn' ;
12- import i18n from '../i18n' ;
12+
13+ import i18n from './i18n' ;
1314
1415import './Acl.scss' ;
1516
@@ -113,26 +114,28 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] {
113114 } ) ;
114115}
115116
116- function getOwnerItem ( owner ?: string ) {
117+ function getOwnerItem ( owner ?: string ) : DefinitionListItem [ ] {
117118 const preparedOwner = prepareLogin ( owner ) ;
118119 if ( ! preparedOwner ) {
119120 return [ ] ;
120121 }
121122 return [
122123 {
123124 name : < span className = { b ( 'owner' ) } > { preparedOwner } </ span > ,
124- content : < span className = { b ( 'owner' ) } > { i18n ( 'acl.owner ' ) } </ span > ,
125+ content : < span className = { b ( 'owner' ) } > { i18n ( 'title_owner ' ) } </ span > ,
125126 } ,
126- ] as DefinitionListItem [ ] ;
127+ ] ;
127128}
128129
129130export const Acl = ( { path} : { path : string } ) => {
130131 const { currentData, isFetching, error} = schemaAclApi . useGetSchemaAclQuery ( { path} ) ;
131132
132133 const loading = isFetching && ! currentData ;
133- const { acl, owner} = currentData || { } ;
134+
135+ const { acl, effectiveAcl, owner} = currentData || { } ;
134136
135137 const aclListItems = getAclListItems ( acl ) ;
138+ const effectiveAclListItems = getAclListItems ( effectiveAcl ) ;
136139
137140 const ownerItem = getOwnerItem ( owner ) ;
138141
@@ -144,21 +147,33 @@ export const Acl = ({path}: {path: string}) => {
144147 return < ResponseError error = { error } /> ;
145148 }
146149
147- if ( ! acl && ! owner ) {
148- return < React . Fragment > { i18n ( 'acl.empty ' ) } </ React . Fragment > ;
150+ if ( ! acl && ! owner && ! effectiveAcl ) {
151+ return < React . Fragment > { i18n ( 'description_empty ' ) } </ React . Fragment > ;
149152 }
150153
154+ const accessRightsItems = ownerItem . concat ( aclListItems ) ;
155+
151156 return (
152157 < div className = { b ( ) } >
153- { ownerItem . length ? (
154- < DefinitionList
155- items = { ownerItem }
156- nameMaxWidth = { 200 }
157- className = { b ( 'owner-container' ) }
158- />
158+ { accessRightsItems . length ? (
159+ < React . Fragment >
160+ < div className = { b ( 'list-title' ) } > { i18n ( 'title_rights' ) } </ div >
161+ < DefinitionList
162+ items = { accessRightsItems }
163+ nameMaxWidth = { 200 }
164+ className = { b ( 'result' ) }
165+ />
166+ </ React . Fragment >
159167 ) : null }
160- { aclListItems . length ? (
161- < DefinitionList items = { aclListItems } nameMaxWidth = { 200 } className = { b ( 'result' ) } />
168+ { effectiveAclListItems . length ? (
169+ < React . Fragment >
170+ < div className = { b ( 'list-title' ) } > { i18n ( 'title_effective-rights' ) } </ div >
171+ < DefinitionList
172+ items = { effectiveAclListItems }
173+ nameMaxWidth = { 200 }
174+ className = { b ( 'result' ) }
175+ />
176+ </ React . Fragment >
162177 ) : null }
163178 </ div >
164179 ) ;
0 commit comments