File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
src/components/Extensibility/components Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -38,21 +38,15 @@ export function Badge({
3838 arrayItems,
3939 } ) ;
4040
41- const extractMessageAndCheckValidity = description => {
42- if ( ! description && typeof description !== 'string' ) {
43- return '' ;
44- }
45- // Extracts a message from the string.
46- const messageArray = description . split ( 'message' ) ;
47- // Removes the colon and blank, leaving only the value.
48- const messageValue = messageArray [ messageArray . length - 1 ] . replace (
49- / : | \s / g,
50- '' ,
41+ const getLatestStatusMessage = ( resource , defaultValue ) => {
42+ const getTime = date => new Date ( date ) ?. getTime ( ) ;
43+ const latestStatus = resource ?. status ?. conditions ?. reduce ( ( prev , current ) =>
44+ prev &&
45+ getTime ( prev . lastTransitionTime ) > getTime ( current . lastTransitionTime )
46+ ? prev
47+ : current ,
5148 ) ;
52- // Checks if it is valid.
53- return messageValue === 'null' || messageValue === 'undefined'
54- ? ''
55- : description ;
49+ return latestStatus ?. message ?? defaultValue ;
5650 } ;
5751
5852 const [ tooltip , tooltipError ] = jsonata ( structure ?. description ) ;
@@ -97,7 +91,7 @@ export function Badge({
9791 tooltipContent = {
9892 tooltip && ! tooltipError
9993 ? tooltip
100- : extractMessageAndCheckValidity ( structure . description )
94+ : getLatestStatusMessage ( originalResource , structure . description )
10195 }
10296 >
10397 { tExt ( value ) }
You can’t perform that action at this time.
0 commit comments