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 - [Proxy] Can now upgrade proxies in VMs not connected to XO
- [REST API] Expose VM snapshots and templates - [REST API] Expose VM snapshots and templates
- [REST API] Expose VDI snapshots - [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 ### Bug fixes
@ -35,7 +36,7 @@
<!--packages-start--> <!--packages-start-->
- xo-web patch
- xo-server minor - xo-server minor
- xo-web minor
<!--packages-end--> <!--packages-end-->

View File

@ -2409,7 +2409,7 @@ const messages = {
// Licenses // Licenses
allHostsMustBeBound: 'All hosts must be bound to a license', allHostsMustBeBound: 'All hosts must be bound to a license',
bound: 'Bound', boundSelectLicense: 'Bound (Plan (ID), expiration date, host - pool)',
bindXcpngLicenses: 'Bind XCP-ng licenses', bindXcpngLicenses: 'Bind XCP-ng licenses',
confirmBindingOnUnsupportedHost: 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?', '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', licenses: 'Licenses',
licensesBinding: 'Licenses binding', licensesBinding: 'Licenses binding',
notEnoughXcpngLicenses: 'Not enough XCP-ng licenses', notEnoughXcpngLicenses: 'Not enough XCP-ng licenses',
notBound: 'Not bound', notBoundSelectLicense: 'Not bound (Plan (ID), expiration date)',
xosanUnregisteredDisclaimer: xosanUnregisteredDisclaimer:
'You are not registered and therefore will not be able to create or manage your XOSAN SRs. {link}', 'You are not registered and therefore will not be able to create or manage your XOSAN SRs. {link}',
xosanSourcesDisclaimer: xosanSourcesDisclaimer:

View File

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