1
1
import { useMemo , useState } from 'react'
2
2
import { generatePath , Link , useRouteMatch } from 'react-router-dom'
3
+ import moment from 'moment'
3
4
4
5
import {
5
6
APIResponseHandler ,
@@ -10,17 +11,20 @@ import {
10
11
ComponentSizeType ,
11
12
DeleteConfirmationModal ,
12
13
GenericEmptyState ,
14
+ getAlphabetIcon ,
13
15
handleAnalyticsEvent ,
14
16
Icon ,
15
17
PortalContainer ,
16
18
SortableTableHeaderCell ,
17
19
stringComparatorBySortOrder ,
20
+ Tooltip ,
18
21
useAsync ,
19
22
useStateFilters ,
20
23
} from '@devtron-labs/devtron-fe-common-lib'
21
24
22
25
import { deleteChartValues } from '@Components/charts/charts.service'
23
26
import { SavedValueType } from '@Components/charts/SavedValues/types'
27
+ import { Moment12HourFormat } from '@Config/constants'
24
28
import { URLS } from '@Config/routes'
25
29
import { ApplicationDeletionInfo } from '@Pages/Shared/ApplicationDeletionInfo/ApplicationDeletionInfo'
26
30
@@ -66,7 +70,7 @@ export const ChartDetailsPresetValues = ({ searchKey, onClearFilters }: ChartDet
66
70
chartValuesTemplateList ,
67
71
chartValuesTemplateListErr ,
68
72
reloadChartValuesTemplateList ,
69
- ] = useAsync ( ( ) => fetchChartValuesTemplateList ( chartId ) , [ chartId ] )
73
+ ] = useAsync ( ( ) => fetchChartValuesTemplateList ( chartId ) , [ chartId ] , true , { resetOnChange : false } )
70
74
71
75
const { sortBy, sortOrder, handleSorting } = useStateFilters < 'name' > ( { initialSortKey : 'name' } )
72
76
@@ -103,10 +107,10 @@ export const ChartDetailsPresetValues = ({ searchKey, onClearFilters }: ChartDet
103
107
}
104
108
105
109
return (
106
- < div className = "flex-grow-1 flexbox-col bg__primary border__primary br-4 w-100 dc__overflow-hidden" >
110
+ < div className = "mh-500 flexbox-col bg__primary border__primary br-4 w-100 dc__overflow-hidden" >
107
111
< PortalContainer
108
112
portalParentId = { CHART_DETAILS_PORTAL_CONTAINER_ID }
109
- condition = { ! isFetchingChartValuesTemplateList && ! ! chartValuesTemplateList ? .length }
113
+ condition = { Array . isArray ( chartValuesTemplateList ) && ! ! chartValuesTemplateList . length }
110
114
>
111
115
< Button
112
116
dataTestId = "chart-preset-values-clear-filters"
@@ -149,26 +153,38 @@ export const ChartDetailsPresetValues = ({ searchKey, onClearFilters }: ChartDet
149
153
disabled = { false }
150
154
/>
151
155
< SortableTableHeaderCell title = "Version" isSortable = { false } />
156
+ < SortableTableHeaderCell title = "Last updated by" isSortable = { false } />
157
+ < SortableTableHeaderCell title = "Updated at" isSortable = { false } />
152
158
</ div >
153
- { filteredChartValuesTemplateList . map ( ( { chartVersion, id, name, ... rest } ) => (
159
+ { filteredChartValuesTemplateList . map ( ( { chartVersion, id, name, updatedBy , updatedOn } ) => (
154
160
< div
155
161
key = { id }
156
162
className = "chart-details-preset-value__row px-16 py-12 bg__hover dc__visible-hover dc__visible-hover--parent"
157
163
>
158
164
< Icon name = "ic-file" color = "N700" size = { 24 } />
159
165
< Link
160
- className = "fs-13 lh-20"
166
+ className = "fs-13 lh-20 dc__truncate "
161
167
to = { `${ generatePath ( path , { chartId } ) } ${ URLS . PRESET_VALUES } /${ id } ` }
162
168
>
163
169
{ name }
164
170
</ Link >
171
+ < span className = "fs-13 lh-20 cn-9" > { chartVersion } </ span >
172
+ < span className = "flex left" >
173
+ { updatedBy && getAlphabetIcon ( updatedBy ) }
174
+ < Tooltip content = { updatedBy } >
175
+ < span className = "fs-13 lh-20 cn-9 dc__truncate" > { updatedBy || '-' } </ span >
176
+ </ Tooltip >
177
+ </ span >
165
178
< div className = "flex dc__content-space" >
166
- < span className = "fs-13 lh-20 cn-9" > { chartVersion } </ span >
179
+ < span className = "fs-13 lh-20 cn-9" >
180
+ { updatedOn && ! updatedOn . startsWith ( '0001-01-01' )
181
+ ? moment ( updatedOn ) . format ( Moment12HourFormat )
182
+ : '-' }
183
+ </ span >
167
184
< div className = "flex dc__gap-4 dc__visible-hover--child" >
168
185
< Button
169
186
dataTestId = "chart-deploy-with-preset-value"
170
- ariaLabel = "chart-deploy-with-preset-value"
171
- showAriaLabelInTippy = { false }
187
+ ariaLabel = "Use value to deploy"
172
188
icon = { < Icon name = "ic-rocket-launch" color = { null } /> }
173
189
variant = { ButtonVariantType . borderLess }
174
190
style = { ButtonStyleType . neutral }
@@ -181,8 +197,7 @@ export const ChartDetailsPresetValues = ({ searchKey, onClearFilters }: ChartDet
181
197
/>
182
198
< Button
183
199
dataTestId = "chart-preset-value-edit"
184
- ariaLabel = "chart-preset-value-edit"
185
- showAriaLabelInTippy = { false }
200
+ ariaLabel = "Edit value"
186
201
icon = { < Icon name = "ic-edit" color = { null } /> }
187
202
variant = { ButtonVariantType . borderLess }
188
203
style = { ButtonStyleType . neutral }
@@ -195,13 +210,19 @@ export const ChartDetailsPresetValues = ({ searchKey, onClearFilters }: ChartDet
195
210
/>
196
211
< Button
197
212
dataTestId = "chart-preset-value-delete"
198
- ariaLabel = "chart-preset-value-delete"
199
- showAriaLabelInTippy = { false }
213
+ ariaLabel = "Delete value"
200
214
icon = { < Icon name = "ic-delete" color = { null } /> }
201
215
variant = { ButtonVariantType . borderLess }
202
- style = { ButtonStyleType . neutral }
216
+ style = { ButtonStyleType . negativeGrey }
203
217
size = { ComponentSizeType . xs }
204
- onClick = { showDeleteModal ( { chartVersion, id, name, ...rest } ) }
218
+ onClick = { showDeleteModal ( {
219
+ chartVersion,
220
+ id,
221
+ name,
222
+ updatedBy,
223
+ updatedOn,
224
+ isLoading : false ,
225
+ } ) }
205
226
/>
206
227
</ div >
207
228
</ div >
0 commit comments