-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathExternalDataSource.tsx
78 lines (64 loc) · 2.69 KB
/
ExternalDataSource.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
import type {InfoViewerItem} from '../../../../components/InfoViewer';
import {InfoViewer} from '../../../../components/InfoViewer';
import {formatCommonItem} from '../../../../components/InfoViewer/formatters';
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
import {cn} from '../../../../utils/cn';
import {getEntityName} from '../../utils';
import i18n from '../i18n';
import './ExternalDataSource.scss';
const b = cn('ydb-external-data-source-info');
const prepareExternalDataSourceSummary = (data: TEvDescribeSchemeResult) => {
const info: InfoViewerItem[] = [
{
label: i18n('external-objects.source-type'),
value: data.PathDescription?.ExternalDataSourceDescription?.SourceType,
},
];
const createStep = data.PathDescription?.Self?.CreateStep;
if (Number(createStep)) {
info.push(formatCommonItem('CreateStep', data.PathDescription?.Self?.CreateStep));
}
return info;
};
const prepareExternalDataSourceInfo = (data: TEvDescribeSchemeResult): InfoViewerItem[] => {
const {Location, Auth} = data.PathDescription?.ExternalDataSourceDescription || {};
return [
...prepareExternalDataSourceSummary(data),
{
label: i18n('external-objects.location'),
value: (
<EntityStatus
name={Location}
showStatus={false}
hasClipboardButton
clipboardButtonAlwaysVisible
className={b('location')}
/>
),
},
{
label: i18n('external-objects.auth-method'),
value: Auth?.ServiceAccount
? i18n('external-objects.auth-method.service-account')
: i18n('external-objects.auth-method.none'),
},
];
};
interface ExternalDataSourceProps {
data?: TEvDescribeSchemeResult;
prepareData: (data: TEvDescribeSchemeResult) => InfoViewerItem[];
}
const ExternalDataSource = ({data, prepareData}: ExternalDataSourceProps) => {
const entityName = getEntityName(data?.PathDescription);
if (!data) {
return <div className="error">No {entityName} data</div>;
}
return <InfoViewer title={entityName} info={prepareData(data)} />;
};
export const ExternalDataSourceInfo = ({data}: {data?: TEvDescribeSchemeResult}) => {
return <ExternalDataSource data={data} prepareData={prepareExternalDataSourceInfo} />;
};
export const ExternalDataSourceSummary = ({data}: {data?: TEvDescribeSchemeResult}) => {
return <ExternalDataSource data={data} prepareData={prepareExternalDataSourceSummary} />;
};