Skip to content

Commit

Permalink
fix(xo-web/license): display the license product ID in SelectLicense (#…
Browse files Browse the repository at this point in the history
…6512)

See zammad#10750
  • Loading branch information
MathieuRA authored and ByScripts committed Dec 14, 2022
1 parent 54b5dad commit ce4e066
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -35,7 +36,7 @@
<!--packages-start-->

- xo-web patch
- xo-server minor
- xo-web minor

<!--packages-end-->
4 changes: 2 additions & 2 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2409,15 +2409,15 @@ 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?',
confirmRebindLicenseFromFullySupportedPool: 'The following pools will no longer be fully supported',
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:
Expand Down
41 changes: 16 additions & 25 deletions packages/xo-web/src/common/select-license.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => (
<option value={license.id}>
<span>
{license.id.slice(-4)} {expirationDate} {license.boundObjectId && renderXoItemFromId(license.boundObjectId)}
</span>
</option>
)
const LicenseOptions = ({ license, formatDate }) => {
const productId = license.productId.split('-')[1]
return (
<option value={license.id}>
<span>
{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,
Expand All @@ -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>
Expand All @@ -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>
))}
Expand Down

0 comments on commit ce4e066

Please sign in to comment.