Skip to content

Commit f059936

Browse files
committed
fix: review
1 parent 0de62d4 commit f059936

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/containers/App/Content.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,23 @@ function ContentWrapper(props: ContentWrapperProps) {
230230
const {singleClusterMode, isAuthenticated} = props;
231231
const isForbidded = useAccessTotallyRestricted();
232232

233-
if (isForbidded) {
234-
return <AccessDenied />;
235-
}
233+
const renderNotAuthenticated = () => {
234+
if (isForbidded) {
235+
return <AccessDenied />;
236+
}
237+
return <Authentication />;
238+
};
236239

237240
return (
238241
<Switch>
239-
<Route path={routes.auth}>
240-
<Authentication closable />
241-
</Route>
242+
{!isForbidded && (
243+
<Route path={routes.auth}>
244+
<Authentication closable />
245+
</Route>
246+
)}
242247
<Route>
243248
<div className={b({embedded: singleClusterMode})}>
244-
{isAuthenticated ? props.children : <Authentication />}
249+
{isAuthenticated ? props.children : renderNotAuthenticated()}
245250
</div>
246251
</Route>
247252
</Switch>

src/containers/AsideNavigation/YdbInternalUser/YdbInternalUser.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {useHistory} from 'react-router-dom';
44

55
import routes, {createHref} from '../../../routes';
66
import {authenticationApi} from '../../../store/reducers/authentication/authentication';
7+
import {useAccessTotallyRestricted} from '../../../store/reducers/capabilities/hooks';
78
import {cn} from '../../../utils/cn';
89
import {useDatabaseFromQuery} from '../../../utils/hooks/useDatabaseFromQuery';
910
import i18n from '../i18n';
@@ -14,6 +15,7 @@ const b = cn('kv-ydb-internal-user');
1415

1516
export function YdbInternalUser({login}: {login?: string}) {
1617
const [logout] = authenticationApi.useLogoutMutation();
18+
const isForbidded = useAccessTotallyRestricted();
1719
const database = useDatabaseFromQuery();
1820

1921
const history = useHistory();
@@ -30,6 +32,17 @@ export function YdbInternalUser({login}: {login?: string}) {
3032
logout(undefined);
3133
};
3234

35+
const renderLoginButton = () => {
36+
if (isForbidded) {
37+
return null;
38+
}
39+
return (
40+
<Button view="flat-secondary" title={i18n('account.login')} onClick={handleLoginClick}>
41+
<Icon data={ArrowRightToSquare} />
42+
</Button>
43+
);
44+
};
45+
3346
return (
3447
<div className={b()}>
3548
<div className={b('user-info-wrapper')}>
@@ -41,13 +54,7 @@ export function YdbInternalUser({login}: {login?: string}) {
4154
<Icon data={ArrowRightFromSquare} />
4255
</Button>
4356
) : (
44-
<Button
45-
view="flat-secondary"
46-
title={i18n('account.login')}
47-
onClick={handleLoginClick}
48-
>
49-
<Icon data={ArrowRightToSquare} />
50-
</Button>
57+
renderLoginButton()
5158
)}
5259
</div>
5360
);

0 commit comments

Comments
 (0)