@@ -33,6 +33,44 @@ export const WfoHamburgerMenu = ({}) => {
3333 error : versionFetchError ,
3434 } = useGetVersionsQuery ( ) ;
3535
36+ const getVersionItems = ( ) => {
37+ if ( versionFetchError ) {
38+ console . error ( versionFetchError ) ;
39+ return [
40+ {
41+ name : 'Error fetching application version data' ,
42+ icon : < WfoXCircleFill color = { theme . colors . danger } /> ,
43+ } ,
44+ ] ;
45+ }
46+ if ( isFetching ) {
47+ return [ { name : '' , icon : < WfoLoading /> } ] ;
48+ }
49+ // initial array contains orchestrator-ui-components library version
50+ const versionsArr : [ { name : string ; icon : EmotionJSX . Element } ] = [
51+ {
52+ name : `orchestrator-ui-components: ${ ORCHESTRATOR_UI_LIBRARY_VERSION } ` ,
53+ icon : < WfoSquareStack3dStack /> ,
54+ } ,
55+ ] ;
56+
57+ if ( data === undefined ) {
58+ return versionsArr ;
59+ }
60+
61+ const orchApiVersions = data . versions . applicationVersions . map (
62+ ( item ) => {
63+ return {
64+ name : item ,
65+ icon : < WfoSquareStack3dStack /> ,
66+ } ;
67+ } ,
68+ ) ;
69+
70+ // orchestrator-ui-components library version + versions returned from orchestrator api
71+ return versionsArr . concat ( orchApiVersions ) ;
72+ } ;
73+
3674 const logoutItem = {
3775 name : t ( 'logout' ) ,
3876 icon : (
@@ -60,45 +98,7 @@ export const WfoHamburgerMenu = ({}) => {
6098 const versionItem = {
6199 name : t ( 'softwareVersions' ) ,
62100 icon : < WfoSquareStack3dStack width = { 24 } height = { 24 } /> ,
63- panel : 4 ,
64- } ;
65-
66- if ( versionFetchError ) {
67- console . error ( versionFetchError ) ;
68- }
69-
70- const applicationVersions : [ { name : string ; icon : EmotionJSX . Element } ] = [
71- {
72- name : `orchestrator-ui-components: ${ ORCHESTRATOR_UI_LIBRARY_VERSION } ` ,
73- icon : < WfoSquareStack3dStack /> ,
74- } ,
75- ] ;
76- const appVersionsItem = {
77- id : 4 ,
78- title : 'Software Versions' ,
79- items : isFetching
80- ? applicationVersions . concat ( [
81- { name : 'Loading ...' , icon : < WfoLoading /> } ,
82- ] )
83- : versionFetchError
84- ? [
85- {
86- name : 'Error fetching application version data' ,
87- icon : < WfoXCircleFill color = { theme . colors . danger } /> ,
88- } ,
89- ]
90- : applicationVersions . concat (
91- data === undefined
92- ? [ ]
93- : Array . from (
94- data . versions . applicationVersions . map ( ( item ) => {
95- return {
96- name : item ,
97- icon : < WfoSquareStack3dStack /> ,
98- } ;
99- } ) ,
100- ) ,
101- ) ,
101+ panel : 1 ,
102102 } ;
103103
104104 const panelItems = [
@@ -112,7 +112,11 @@ export const WfoHamburgerMenu = ({}) => {
112112 id : 0 ,
113113 items : panelItems ,
114114 } ,
115- appVersionsItem ,
115+ {
116+ id : 1 ,
117+ title : t ( 'softwareVersions' ) ,
118+ items : getVersionItems ( ) ,
119+ } ,
116120 ] ;
117121
118122 return (
0 commit comments