Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

> Users must be able to say: “Nice enhancement, I'm eager to test it”

- [License] Display license plan when bounding licenses (PR [#6512](https://github.com/vatesfr/xen-orchestra/pull/6512))
Rajaa-BARHTAOUI marked this conversation as resolved.
Show resolved Hide resolved
pdonias marked this conversation as resolved.
Show resolved Hide resolved

### Bug fixes

> Users must be able to say: “I had this issue, happy to know it's fixed”
Expand All @@ -28,5 +30,6 @@
<!--packages-start-->

- xo-server patch
- 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 @@ -2408,15 +2408,15 @@ const messages = {

// Licenses
allHostsMustBeBound: 'All hosts must be bound to a license',
bound: 'Bound',
boundSelectLicense: 'Bound (Plan (ID), expiration date, host - pool)',
pdonias marked this conversation as resolved.
Show resolved Hide resolved
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 && <span>, {renderXoItemFromId(license.boundObjectId)}</span>}
Rajaa-BARHTAOUI marked this conversation as resolved.
Show resolved Hide resolved
</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