feat(xo-web/trial): end of trial info banner (#5374)

See company#558
This commit is contained in:
Mathieu 2020-11-27 10:37:51 +01:00 committed by GitHub
parent 31b19725b7
commit d1d4839a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -14,6 +14,7 @@
- [VIF] Ability for admins to set any allowed IPs, including IPv6 and IPs that are not in an IP pool [#2535](https://github.com/vatesfr/xen-orchestra/issues/2535) [#1872](https://github.com/vatesfr/xen-orchestra/issues/1872) (PR [#5367](https://github.com/vatesfr/xen-orchestra/pull/5367)) - [VIF] Ability for admins to set any allowed IPs, including IPv6 and IPs that are not in an IP pool [#2535](https://github.com/vatesfr/xen-orchestra/issues/2535) [#1872](https://github.com/vatesfr/xen-orchestra/issues/1872) (PR [#5367](https://github.com/vatesfr/xen-orchestra/pull/5367))
- [Proxy] Ability to restore a file from VM backup (PR [#5359](https://github.com/vatesfr/xen-orchestra/pull/5359)) - [Proxy] Ability to restore a file from VM backup (PR [#5359](https://github.com/vatesfr/xen-orchestra/pull/5359))
- [Web Hooks] `backupNg.runJob` is now triggered by scheduled runs [#5205](https://github.com/vatesfr/xen-orchestra/issues/5205) (PR [#5360](https://github.com/vatesfr/xen-orchestra/pull/5360)) - [Web Hooks] `backupNg.runJob` is now triggered by scheduled runs [#5205](https://github.com/vatesfr/xen-orchestra/issues/5205) (PR [#5360](https://github.com/vatesfr/xen-orchestra/pull/5360))
- [Licensing] Add trial end information banner (PR [#5374](https://github.com/vatesfr/xen-orchestra/pull/5374))
### Bug fixes ### Bug fixes

View File

@ -2303,6 +2303,8 @@ const messages = {
starterLicense: 'Starter license', starterLicense: 'Starter license',
enterpriseLicense: 'Enterprise license', enterpriseLicense: 'Enterprise license',
premiumLicense: 'Premium license', premiumLicense: 'Premium license',
trialLicenseInfo:
'You are currently in a {edition} trial period that will end on {date, date, medium}',
// ----- proxies ----- // ----- proxies -----
forgetProxyApplianceTitle: 'Forget prox{n, plural, one {y} other {ies}}', forgetProxyApplianceTitle: 'Forget prox{n, plural, one {y} other {ies}}',

View File

@ -9,9 +9,10 @@ import React from 'react'
import Shortcuts from 'shortcuts' import Shortcuts from 'shortcuts'
import themes from 'themes' import themes from 'themes'
import _, { IntlProvider } from 'intl' import _, { IntlProvider } from 'intl'
import { blockXoaAccess } from 'xoa-updater' import { blockXoaAccess, isTrialRunning } from 'xoa-updater'
import { connectStore, getXoaPlan, routes } from 'utils' import { connectStore, getXoaPlan, routes } from 'utils'
import { Notification } from 'notification' import { Notification } from 'notification'
import { productId2Plan } from 'xoa-plans'
import { ShortcutManager } from 'react-shortcuts' import { ShortcutManager } from 'react-shortcuts'
import { ThemeProvider } from 'styled-components' import { ThemeProvider } from 'styled-components'
import { TooltipViewer } from 'tooltip' import { TooltipViewer } from 'tooltip'
@ -124,6 +125,7 @@ export default class XoApp extends Component {
state = { state = {
dismissedSourceBanner: Boolean(cookies.get('dismissedSourceBanner')), dismissedSourceBanner: Boolean(cookies.get('dismissedSourceBanner')),
dismissedTrialBanner: Boolean(cookies.get('dismissedTrialBanner')),
} }
displayOpenSourceDisclaimer() { displayOpenSourceDisclaimer() {
@ -153,6 +155,11 @@ export default class XoApp extends Component {
this.setState({ dismissedSourceBanner: true }) this.setState({ dismissedSourceBanner: true })
} }
dismissTrialBanner = () => {
cookies.set('dismissedTrialBanner', true, { expires: 1 })
this.setState({ dismissedTrialBanner: true })
}
componentDidMount() { componentDidMount() {
this.refs.bodyWrapper.style.minHeight = this.refs.menu.getWrappedInstance().height + 'px' this.refs.bodyWrapper.style.minHeight = this.refs.menu.getWrappedInstance().height + 'px'
if (+process.env.XOA_PLAN === 5) { if (+process.env.XOA_PLAN === 5) {
@ -259,6 +266,17 @@ export default class XoApp extends Component {
</button> </button>
</div> </div>
)} )}
{isTrialRunning(trial.trial) && !this.state.dismissedTrialBanner && (
<div className='alert alert-info mb-0'>
{_('trialLicenseInfo', {
edition: getXoaPlan(productId2Plan[trial.trial.productId]),
date: new Date(trial.trial.end),
})}
<button className='close' onClick={this.dismissTrialBanner}>
&times;
</button>
</div>
)}
<div style={CONTAINER_STYLE}> <div style={CONTAINER_STYLE}>
<Shortcuts <Shortcuts
name='XoApp' name='XoApp'