-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathSidebar.tsx
66 lines (56 loc) · 2.68 KB
/
Sidebar.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
/*
* Copyright (c) 2024. Devtron Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Icon, IconName, ModalSidebarPanel } from '@devtron-labs/devtron-fe-common-lib'
import { DOCUMENTATION } from '@Config/constants'
import { generatePath, NavLink, useParams } from 'react-router-dom'
import { URLS } from '@Config/routes'
import { CreateClusterParams } from './types'
import { SIDEBAR_CONFIG } from './constants'
const Sidebar = () => {
const { type } = useParams<CreateClusterParams>()
const selectedSidebarElement = SIDEBAR_CONFIG[type]
return (
<div className="w-250 p-20 flexbox-col dc__gap-24 dc__no-shrink dc__overflow-auto">
<div className="flexbox-col">
{Object.entries(SIDEBAR_CONFIG).map(([key, { title, iconName }]) => {
const isSelected = type.toLowerCase() === key.toLowerCase()
return (
<NavLink
className={`dc__transparent flex left dc__gap-8 py-6 px-8 br-4 ${isSelected ? 'bcb-1' : 'dc__hover-n50'}`}
to={generatePath(URLS.GLOBAL_CONFIG_CREATE_CLUSTER, { type: key })}
>
<span className="dc__fill-available-space dc__no-shrink icon-dim-16">
<Icon name={iconName as IconName} color={isSelected ? 'B500' : 'N600'} />
</span>
<span className={`fs-13 lh-20 dc__truncate ${isSelected ? 'cb-5 fw-6' : 'cn-9'}`}>
{title}
</span>
</NavLink>
)
})}
</div>
<div className="divider__secondary--horizontal" />
<ModalSidebarPanel
heading={selectedSidebarElement.documentationHeader ?? selectedSidebarElement.title}
documentationLink={DOCUMENTATION.CLUSTER_AND_ENVIRONMENT}
rootClassName="w-100 dc__no-background-imp"
>
<div className="flexbox-col dc__gap-24">{selectedSidebarElement.body}</div>
</ModalSidebarPanel>
</div>
)
}
export default Sidebar