1
1
import { type FC , useState } from 'react' ;
2
- import { styled } from '@mui/material' ;
2
+ import {
3
+ Button ,
4
+ List ,
5
+ ListItemButton ,
6
+ ListItemIcon ,
7
+ ListItemText ,
8
+ styled ,
9
+ } from '@mui/material' ;
3
10
import { useNavigate } from 'react-router-dom' ;
4
11
import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveDialog' ;
5
12
import { FeatureArchiveNotAllowedDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveNotAllowedDialog' ;
@@ -15,7 +22,14 @@ import { capitalizeFirst } from 'utils/capitalizeFirst';
15
22
import { Collaborators } from './Collaborators' ;
16
23
import { EnvironmentVisibilityMenu } from './EnvironmentVisibilityMenu/EnvironmentVisibilityMenu' ;
17
24
import { Truncator } from 'component/common/Truncator/Truncator' ;
18
- import type { IFeatureToggle } from '../../../../../interfaces/featureToggle' ;
25
+ import type {
26
+ FeatureLink ,
27
+ IFeatureToggle ,
28
+ } from '../../../../../interfaces/featureToggle' ;
29
+ import AddIcon from '@mui/icons-material/Add' ;
30
+ import { useUiFlag } from 'hooks/useUiFlag' ;
31
+ import { Badge } from 'component/common/Badge/Badge' ;
32
+ import LinkIcon from '@mui/icons-material/Link' ;
19
33
20
34
const StyledMetaDataContainer = styled ( 'div' ) ( ( { theme } ) => ( {
21
35
padding : theme . spacing ( 3 ) ,
@@ -29,6 +43,7 @@ const StyledMetaDataContainer = styled('div')(({ theme }) => ({
29
43
[ theme . breakpoints . down ( 'md' ) ] : {
30
44
width : '100%' ,
31
45
} ,
46
+ marginBottom : theme . spacing ( 2 ) ,
32
47
} ) ) ;
33
48
34
49
const StyledTitle = styled ( 'h2' ) ( ( { theme } ) => ( {
@@ -65,13 +80,85 @@ export const StyledMetaDataItemValue = styled('div')(({ theme }) => ({
65
80
gap : theme . spacing ( 1 ) ,
66
81
} ) ) ;
67
82
83
+ export const StyledListItemIcon = styled ( ListItemIcon ) ( ( { theme } ) => ( {
84
+ minWidth : theme . spacing ( 5 ) ,
85
+ } ) ) ;
86
+
68
87
type FeatureOverviewMetaDataProps = {
69
88
hiddenEnvironments ?: string [ ] ;
70
89
onEnvironmentVisibilityChange ?: ( environment : string ) => void ;
71
90
feature : IFeatureToggle ;
72
91
onChange : ( ) => void ;
73
92
} ;
74
93
94
+ const FeatureLinks : FC < { links : FeatureLink [ ] } > = ( { links } ) => {
95
+ return links . length === 0 ? (
96
+ < StyledMetaDataContainer >
97
+ < StyledTitle >
98
+ You can now add links{ ' ' }
99
+ < Badge color = 'success' sx = { { ml : 1 } } >
100
+ New
101
+ </ Badge >
102
+ </ StyledTitle >
103
+ < StyledMetaDataItem >
104
+ Gather relevant links for external resources such as issue
105
+ trackers, code repositories or analytics tooling
106
+ </ StyledMetaDataItem >
107
+ < div >
108
+ < Button
109
+ size = 'small'
110
+ variant = 'text'
111
+ startIcon = { < AddIcon /> }
112
+ onClick = { ( ) => { } }
113
+ >
114
+ Add link
115
+ </ Button >
116
+ </ div >
117
+ </ StyledMetaDataContainer >
118
+ ) : (
119
+ < StyledMetaDataContainer >
120
+ < StyledTitle > Resources</ StyledTitle >
121
+ < List >
122
+ { links . map ( ( link ) => (
123
+ < ListItemButton
124
+ component = 'a'
125
+ href = { link . url }
126
+ target = '_blank'
127
+ rel = 'noopener noreferrer'
128
+ >
129
+ < StyledListItemIcon >
130
+ < LinkIcon color = 'primary' />
131
+ </ StyledListItemIcon >
132
+ < ListItemText
133
+ primary = { link . title }
134
+ secondary = { link . url }
135
+ secondaryTypographyProps = { {
136
+ sx : {
137
+ overflow : 'hidden' ,
138
+ textOverflow : 'ellipsis' ,
139
+ whiteSpace : 'nowrap' ,
140
+ display : 'block' ,
141
+ } ,
142
+ } }
143
+ />
144
+ </ ListItemButton >
145
+ ) ) }
146
+ </ List >
147
+
148
+ < div >
149
+ < Button
150
+ size = 'small'
151
+ variant = 'text'
152
+ startIcon = { < AddIcon /> }
153
+ onClick = { ( ) => { } }
154
+ >
155
+ Add link
156
+ </ Button >
157
+ </ div >
158
+ </ StyledMetaDataContainer >
159
+ ) ;
160
+ } ;
161
+
75
162
const FeatureOverviewMetaData : FC < FeatureOverviewMetaDataProps > = ( {
76
163
hiddenEnvironments,
77
164
onEnvironmentVisibilityChange,
@@ -89,8 +176,13 @@ const FeatureOverviewMetaData: FC<FeatureOverviewMetaDataProps> = ({
89
176
90
177
const showDependentFeatures = useShowDependentFeatures ( project ) ;
91
178
179
+ const featureLinksEnabled = useUiFlag ( 'featureLinks' ) ;
180
+
92
181
return (
93
182
< >
183
+ { featureLinksEnabled ? (
184
+ < FeatureLinks links = { feature . links || [ ] } />
185
+ ) : null }
94
186
< StyledMetaDataContainer >
95
187
< div >
96
188
< StyledTitle > Flag details</ StyledTitle >
0 commit comments