focalboard/webapp/src/components/newVersionBanner.tsx
Miguel de la Cruz 3ede6df028
Show a refresh banner on plugin update (#1720)
* Reload plugin on plugin update

* Add a banner that shows when updating the plugin and asks the user to reload

* Fix linter
2021-11-10 16:33:56 +01:00

41 lines
1.1 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useState, useEffect} from 'react'
import {FormattedMessage} from 'react-intl'
import wsClient from '../wsclient'
import './newVersionBanner.scss'
const NewVersionBanner = () => {
const [appVersionChanged, setAppVersionChanged] = useState(false)
useEffect(() => {
wsClient.onAppVersionChangeHandler = setAppVersionChanged
}, [])
if (!appVersionChanged) {
return null
}
const newVersionReload = (e: any) => {
e.preventDefault()
location.reload()
}
return (
<div className='NewVersionBanner'>
<a
target='_blank'
rel='noreferrer'
onClick={newVersionReload}
>
<FormattedMessage
id='BoardPage.newVersion'
defaultMessage='A new version of Boards is available, click here to reload.'
/>
</a>
</div>
)
}
export default NewVersionBanner