Skip to content

Commit 6f14843

Browse files
refactor: create component for access denied
1 parent 2c55107 commit 6f14843

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import EmptyState from '../../EmptyState/EmptyState';
2+
import {Illustration} from '../../Illustration';
3+
4+
import i18n from '../i18n';
5+
6+
interface AccessDeniedProps {
7+
title?: string;
8+
description?: string;
9+
}
10+
11+
export const AccessDenied = ({title, description}: AccessDeniedProps) => {
12+
return (
13+
<EmptyState
14+
image={<Illustration name="403" />}
15+
title={title || i18n('403.title')}
16+
description={description || i18n('403.description')}
17+
/>
18+
);
19+
};

src/components/Errors/403/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './AccessDenied';

src/components/Errors/i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"403.title": "Access denied",
3+
"403.description": "You don’t have the necessary roles to view this page."
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {i18n, Lang} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
import ru from './ru.json';
5+
6+
const COMPONENT = 'ydb-errors-access-denied';
7+
8+
i18n.registerKeyset(Lang.En, COMPONENT, en);
9+
i18n.registerKeyset(Lang.Ru, COMPONENT, ru);
10+
11+
export default i18n.keyset(COMPONENT);

src/components/Errors/i18n/ru.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"403.title": "Доступ запрещен",
3+
"403.description": "У вас недостаточно прав для просмотра данной страницы."
4+
}

src/containers/Tenant/Tenant.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import cn from 'bem-cn-lite';
44
import {useLocation} from 'react-router';
55
import qs from 'qs';
66

7-
import EmptyState from '../../components/EmptyState/EmptyState';
8-
import {Illustration} from '../../components/Illustration';
7+
import {AccessDenied} from '../../components/Errors/403';
98

109
import {setHeader} from '../../store/reducers/header';
1110
import ObjectGeneralTabs from './ObjectGeneralTabs/ObjectGeneralTabs';
@@ -129,11 +128,7 @@ function Tenant(props: TenantProps) {
129128
return (
130129
<div className={b()}>
131130
{showBlockingError ? (
132-
<EmptyState
133-
image={<Illustration name="403" />}
134-
title="Access denied"
135-
description="You don’t have the necessary roles to view this page."
136-
/>
131+
<AccessDenied />
137132
) : (
138133
<>
139134
<ObjectGeneralTabs />

0 commit comments

Comments
 (0)