Commit add4191 1 parent 000ee66 commit add4191 Copy full SHA for add4191
File tree 8 files changed +58
-1
lines changed
8 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { LicenseBanner } from './banners/internalBanners/LicenseBanner';
23
23
import { Demo } from './demo/Demo' ;
24
24
import { LoginRedirect } from './common/LoginRedirect/LoginRedirect' ;
25
25
import { SecurityBanner } from './banners/internalBanners/SecurityBanner' ;
26
+ import { MonthsOldVersionBanner } from './banners/internalBanners/MonthsOldVersionBanner' ;
26
27
27
28
const StyledContainer = styled ( 'div' ) ( ( ) => ( {
28
29
'& ul' : {
@@ -67,6 +68,7 @@ export const App = () => {
67
68
/>
68
69
< LicenseBanner />
69
70
< SecurityBanner />
71
+ < MonthsOldVersionBanner />
70
72
< ExternalBanners />
71
73
< InternalBanners />
72
74
< StyledContainer >
Original file line number Diff line number Diff line change
1
+ import { Banner } from '../Banner/Banner' ;
2
+ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig' ;
3
+ import { parseValidDate } from 'component/common/util' ;
4
+ import { differenceInMonths } from 'date-fns' ;
5
+
6
+ export const MonthsOldVersionBanner = ( ) => {
7
+ const {
8
+ uiConfig : { versionInfo } ,
9
+ } = useUiConfig ( ) ;
10
+
11
+ if ( ! versionInfo ?. buildDate ) return null ;
12
+
13
+ const buildDate = parseValidDate ( versionInfo . buildDate ) ;
14
+
15
+ if ( ! buildDate ) return null ;
16
+
17
+ const monthsOld = differenceInMonths ( new Date ( ) , new Date ( buildDate ) ) ;
18
+
19
+ const isOldBuild = monthsOld >= 3 ;
20
+
21
+ if ( ! isOldBuild ) return null ;
22
+
23
+ return (
24
+ < Banner
25
+ banner = { {
26
+ message : `Your Unleash version is ${ monthsOld } months old. Please consider upgrading.` ,
27
+ variant : 'warning' ,
28
+ link : 'https://github.com/Unleash/unleash/releases' ,
29
+ linkText : 'Changelog' ,
30
+ } }
31
+ />
32
+ ) ;
33
+ } ;
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export interface IVersionInfo {
102
102
isLatest : boolean ;
103
103
latest : Partial < IVersion > ;
104
104
current : IVersion ;
105
+ buildDate ?: string ;
105
106
}
106
107
107
108
export interface IVersion {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ exports[`should create default config 1`] = `
23
23
" initialAdminUser" : undefined ,
24
24
" type" : " open-source" ,
25
25
},
26
+ " buildDate" : undefined ,
26
27
" clientFeatureCaching" : {
27
28
" enabled" : true ,
28
29
" maxAge" : 3600000 ,
Original file line number Diff line number Diff line change @@ -795,6 +795,7 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
795
795
dailyMetricsStorageDays,
796
796
openAIAPIKey,
797
797
userInactivityThresholdInDays,
798
+ buildDate : process . env . BUILD_DATE ,
798
799
} ;
799
800
}
800
801
Original file line number Diff line number Diff line change @@ -56,6 +56,14 @@ export const versionSchema = {
56
56
description : 'The instance identifier of the Unleash instance' ,
57
57
example : '0d652a82-43db-4144-8e02-864b0b030710' ,
58
58
} ,
59
+ buildDate : {
60
+ description :
61
+ 'The date and time of when this Unleash instance version was built' ,
62
+ type : 'string' ,
63
+ format : 'date-time' ,
64
+ nullable : true ,
65
+ example : '2023-06-30T11:41:00.123Z' ,
66
+ } ,
59
67
} ,
60
68
components : { } ,
61
69
} as const ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export interface IVersionHolder {
15
15
latest : Partial < IVersionInfo > ;
16
16
isLatest : boolean ;
17
17
instanceId : string ;
18
+ buildDate ?: string ;
18
19
}
19
20
20
21
export interface IVersionResponse {
@@ -72,16 +73,23 @@ export default class VersionService {
72
73
73
74
private timer : NodeJS . Timeout ;
74
75
76
+ private readonly buildDate ?: string ;
77
+
75
78
constructor (
76
79
{ settingStore } : Pick < IUnleashStores , 'settingStore' > ,
77
80
{
78
81
getLogger,
79
82
versionCheck,
80
83
enterpriseVersion,
81
84
telemetry,
85
+ buildDate,
82
86
} : Pick <
83
87
IUnleashConfig ,
84
- 'getLogger' | 'versionCheck' | 'enterpriseVersion' | 'telemetry'
88
+ | 'getLogger'
89
+ | 'versionCheck'
90
+ | 'enterpriseVersion'
91
+ | 'telemetry'
92
+ | 'buildDate'
85
93
> ,
86
94
) {
87
95
this . logger = getLogger ( 'lib/services/version-service.js' ) ;
@@ -94,6 +102,7 @@ export default class VersionService {
94
102
this . telemetryEnabled = telemetry ;
95
103
this . versionCheckUrl = versionCheck . url ;
96
104
this . isLatest = true ;
105
+ this . buildDate = buildDate ;
97
106
}
98
107
99
108
private async readInstanceId ( ) : Promise < string | undefined > {
@@ -164,6 +173,7 @@ export default class VersionService {
164
173
latest : this . latest || { } ,
165
174
isLatest : this . isLatest ,
166
175
instanceId : instanceId || 'unresolved-instance-id' ,
176
+ buildDate : this . buildDate ,
167
177
} ;
168
178
}
169
179
}
Original file line number Diff line number Diff line change @@ -286,4 +286,5 @@ export interface IUnleashConfig {
286
286
feedbackUriPath ?: string ;
287
287
openAIAPIKey ?: string ;
288
288
userInactivityThresholdInDays : number ;
289
+ buildDate ?: string ;
289
290
}
You can’t perform that action at this time.
0 commit comments