11import React from 'react' ;
22import './Header.css'
3+ import { MessageBarButton } from 'office-ui-fabric-react' ;
34import { CommandBar , ICommandBarItemProps } from 'office-ui-fabric-react/lib/CommandBar' ;
5+ import { MessageBar , MessageBarType } from 'office-ui-fabric-react/lib/MessageBar' ;
46import { getTheme } from '@uifabric/styling' ;
57import SettingsModal , { SettingsChanges } from './settings/SettingsModal' ;
68import AboutModal from './AboutModal' ;
79import config from './services/config' ;
10+ import api from './services/api' ;
811import { getSnippetsMenuItems , SnippetMenuItem } from './utils/headerutils' ;
912import {
1013 Connect ,
@@ -19,13 +22,12 @@ import {
1922} from './store' ;
2023import ChangeLogModal from "./ChangeLogModal" ;
2124
22-
23-
2425interface HeaderState {
2526 showSettings : boolean
2627 showAbout : boolean
2728 showChangelog : boolean
2829 loading : boolean
30+ showUpdateBanner : boolean
2931}
3032
3133@Connect ( s => ( { darkMode : s . settings . darkMode , loading : s . status ?. loading } ) )
@@ -39,7 +41,8 @@ export class Header extends React.Component<any, HeaderState> {
3941 showSettings : false ,
4042 showAbout : false ,
4143 showChangelog : false ,
42- loading : false
44+ loading : false ,
45+ showUpdateBanner : false
4346 } ;
4447 }
4548
@@ -49,6 +52,13 @@ export class Header extends React.Component<any, HeaderState> {
4952 fileElement . accept = '.go' ;
5053 fileElement . addEventListener ( 'change' , ( ) => this . onItemSelect ( ) , false ) ;
5154 this . fileInput = fileElement ;
55+
56+ // show update popover
57+ api . getVersion ( ) . then ( r => {
58+ const { version} = r ;
59+ if ( ! version ) return ;
60+ this . setState ( { showUpdateBanner : version !== config . appVersion } ) ;
61+ } ) . catch ( err => console . warn ( 'failed to check server API version: ' , err ) ) ;
5262 }
5363
5464 onItemSelect ( ) {
@@ -208,6 +218,23 @@ export class Header extends React.Component<any, HeaderState> {
208218
209219 render ( ) {
210220 return < header className = 'header' style = { this . styles } >
221+ < MessageBar
222+ className = { this . state . showUpdateBanner ? 'app__update app__update--visible' : 'app__update' }
223+ messageBarType = { MessageBarType . warning }
224+ onDismiss = { ( ) => this . setState ( { showUpdateBanner : false } ) }
225+ dismissButtonAriaLabel = "Close"
226+ isMultiline = { false }
227+ actions = {
228+ < div >
229+ < MessageBarButton onClick = { ( ) => {
230+ this . setState ( { showUpdateBanner : false } ) ;
231+ config . forceRefreshPage ( ) ;
232+ } } > Action</ MessageBarButton >
233+ </ div >
234+ }
235+ >
236+ Web application was updated, click < b > Reload</ b > to apply changes
237+ </ MessageBar >
211238 < img
212239 src = '/go-logo-blue.svg'
213240 className = 'header__logo'
0 commit comments