-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathScopeDetailPage.tsx
More file actions
107 lines (97 loc) · 3.05 KB
/
ScopeDetailPage.tsx
File metadata and controls
107 lines (97 loc) · 3.05 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React, { useContext, useMemo, useCallback } from 'react'
import { Container, Row, Col } from 'Components'
import GluuFormDetailRow from 'Routes/Apps/Gluu/GluuFormDetailRow'
import { SCOPE } from 'Utils/ApiResources'
import { useTranslation } from 'react-i18next'
import { ThemeContext } from 'Context/theme/themeContext'
import customColors from '@/customColors'
import type { ScopeDetailPageProps } from './types'
const CONTAINER_STYLES = { backgroundColor: customColors.whiteSmoke } as const
const ScopeDetailPage: React.FC<ScopeDetailPageProps> = ({ row }) => {
const { t } = useTranslation()
const theme = useContext(ThemeContext)
const selectedTheme = useMemo(() => theme?.state?.theme || 'light', [theme?.state?.theme])
const defaultScopeValue = useMemo(
() => (row.defaultScope ? t('options.yes') : t('options.no')),
[row.defaultScope, t],
)
const attributeKeys = useMemo(() => Object.keys(row.attributes || {}), [row.attributes])
const defaultScopeBadgeColor = useMemo(
() => (row.defaultScope ? `primary-${selectedTheme}` : 'dimmed'),
[row.defaultScope, selectedTheme],
)
const renderAttributeRow = useCallback(
(item: string, key: number) => (
<GluuFormDetailRow
key={key}
label={item}
isBadge={true}
value={String(row.attributes?.[item as keyof typeof row.attributes])}
doc_category={SCOPE}
doc_entry={`attributes.${item}`}
/>
),
[row.attributes],
)
return (
<Container style={CONTAINER_STYLES}>
<Row>
<Col sm={6}>
<GluuFormDetailRow
label="fields.inum"
value={row.inum}
doc_category={SCOPE}
doc_entry="inum"
/>
</Col>
<Col sm={6}>
<GluuFormDetailRow label="fields.id" value={row.id} doc_category={SCOPE} doc_entry="id" />
</Col>
</Row>
<Row>
<Col sm={6}>
<GluuFormDetailRow
label="fields.description"
value={row.description}
doc_category={SCOPE}
doc_entry="description"
/>
</Col>
<Col sm={6}>
<GluuFormDetailRow
label="fields.displayname"
value={row.displayName}
doc_category={SCOPE}
doc_entry="displayName"
/>
</Col>
</Row>
<Row>
<Col sm={6}>
<GluuFormDetailRow
label="fields.scope_type"
value={row.scopeType}
doc_category={SCOPE}
doc_entry="scopeType"
isBadge
/>
</Col>
<Col sm={6}>
<GluuFormDetailRow
label="fields.default_scope"
isBadge
badgeColor={defaultScopeBadgeColor}
value={defaultScopeValue}
doc_category={SCOPE}
doc_entry="defaultScope"
/>
</Col>
</Row>
<Row>
<Col sm={3}>{t('fields.attributes')}:</Col>
<Col sm={9}>{attributeKeys.map(renderAttributeRow)}</Col>
</Row>
</Container>
)
}
export default ScopeDetailPage