fix(xo-web/license): display the license product ID in SelectLicense (#6512)

See zammad#10750
This commit is contained in:
Mathieu 2022-11-08 09:50:46 +01:00 committed by GitHub
parent 131643a91b
commit 249f124ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 28 deletions

View File

@ -11,6 +11,7 @@
- [Proxy] Can now upgrade proxies in VMs not connected to XO
- [REST API] Expose VM snapshots and templates
- [REST API] Expose VDI snapshots
- [Select license] Display product type in the options (PR [#6512](https://github.com/vatesfr/xen-orchestra/pull/6512))
### Bug fixes
@ -35,7 +36,7 @@
<!--packages-start-->
- xo-web patch
- xo-server minor
- xo-web minor
<!--packages-end-->

View File

@ -2409,7 +2409,7 @@ const messages = {
// Licenses
allHostsMustBeBound: 'All hosts must be bound to a license',
bound: 'Bound',
boundSelectLicense: 'Bound (Plan (ID), expiration date, host - pool)',
bindXcpngLicenses: 'Bind XCP-ng licenses',
confirmBindingOnUnsupportedHost:
'You are about to bind {nLicenses, number} professional support license{nLicenses, plural, one {} other {s}} on older and unsupported XCP-ng version{nLicenses, plural, one {} other {s}}. Are you sure you want to continue?',
@ -2417,7 +2417,7 @@ const messages = {
licenses: 'Licenses',
licensesBinding: 'Licenses binding',
notEnoughXcpngLicenses: 'Not enough XCP-ng licenses',
notBound: 'Not bound',
notBoundSelectLicense: 'Not bound (Plan (ID), expiration date)',
xosanUnregisteredDisclaimer:
'You are not registered and therefore will not be able to create or manage your XOSAN SRs. {link}',
xosanSourcesDisclaimer:

View File

@ -8,27 +8,18 @@ import { map } from 'lodash'
import { renderXoItemFromId } from './render-xo-item'
const LicenseOptions = ({ license, formatTime }) =>
_(
'expiresOn',
{
date:
license.expires !== undefined
? formatTime(license.expires, {
day: 'numeric',
month: 'numeric',
year: 'numeric',
})
: '',
},
expirationDate => (
const LicenseOptions = ({ license, formatDate }) => {
const productId = license.productId.split('-')[1]
return (
<option value={license.id}>
<span>
{license.id.slice(-4)} {expirationDate} {license.boundObjectId && renderXoItemFromId(license.boundObjectId)}
{productId.charAt(0).toUpperCase() + productId.slice(1)} ({license.id.slice(-4)}),{' '}
{license.expires !== undefined ? formatDate(license.expires) : '-'}
{license.boundObjectId !== undefined && <span>, {renderXoItemFromId(license.boundObjectId)}</span>}
</span>
</option>
)
)
}
const SelectLicense = decorate([
injectIntl,
@ -53,7 +44,7 @@ const SelectLicense = decorate([
},
}),
injectState,
({ state: { licenses }, intl: { formatTime }, onChange, showBoundLicenses }) =>
({ state: { licenses }, intl: { formatDate }, onChange, showBoundLicenses }) =>
licenses?.licenseError !== undefined ? (
<span>
<em className='text-danger'>{_('getLicensesError')}</em>
@ -66,18 +57,18 @@ const SelectLicense = decorate([
</option>
))}
{_('notBound', i18nNotBound => (
{_('notBoundSelectLicense', i18nNotBound => (
<optgroup label={i18nNotBound}>
{map(licenses?.notBound, license => (
<LicenseOptions formatTime={formatTime} key={license.id} license={license} />
<LicenseOptions formatDate={formatDate} key={license.id} license={license} />
))}
</optgroup>
))}
{showBoundLicenses &&
_('bound', i18nBound => (
_('boundSelectLicense', i18nBound => (
<optgroup label={i18nBound}>
{map(licenses?.bound, license => (
<LicenseOptions formatTime={formatTime} key={license.id} license={license} />
<LicenseOptions formatDate={formatDate} key={license.id} license={license} />
))}
</optgroup>
))}