Skip to content

Commit

Permalink
fix(xo-web/license): fix undefined expiration date (#6730)
Browse files Browse the repository at this point in the history
Fix zammad#13319

The Pro support icon displayed in "Home/pool" considered that the licenses without expiration date had expired
  • Loading branch information
MathieuRA committed Mar 16, 2023
1 parent ca6cdbf commit 72822c9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
- [Backup/Restore] Fix restore via a proxy showing as interupted (PR [#6702](https://github.com/vatesfr/xen-orchestra/pull/6702))
- [REST API] Backup logs are now available at `/rest/v0/backups/logs`
- [Plugin/auth-oidc] Fix empty user names when using default config [Forum#59587](https://xcp-ng.org/forum/post/59587)
- [Pool/Pro License] Fix handling of licenses with no expiration date (PR [#6730](https://github.com/vatesfr/xen-orchestra/pull/6730))
- [ESXI import] Fix failing imports when using non default datacenter name [Forum#59543](https://xcp-ng.org/forum/post/59543) PR [#6729](https://github.com/vatesfr/xen-orchestra/pull/6729)
- [Pool/Pro License] Fix handling of licenses with no expiration date (PR [#6730](https://github.com/vatesfr/xen-orchestra/pull/6730))

### Packages to release

Expand Down
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const messages = {
browseFiles: 'Browse files',
showLogs: 'Show logs',
noValue: 'None',
noExpiration: 'No expiration',
compression: 'Compression',
core: 'Core',
cpu: 'CPU',
Expand Down
5 changes: 4 additions & 1 deletion packages/xo-web/src/xo-app/home/pool-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export default class PoolItem extends Component {
tooltip = _('poolSupportSourceUsers')
}
if (supportLevel === 'total') {
tooltip = _('earliestExpirationDate', { dateString: <ShortDate timestamp={earliestExpirationDate} /> })
tooltip = _('earliestExpirationDate', {
dateString:
earliestExpirationDate === Infinity ? _('noExpiration') : <ShortDate timestamp={earliestExpirationDate} />,
})
}
if (supportLevel === 'partial') {
tooltip = _('poolPartialSupport', { nHostsLicense: nHostsUnderLicense, nHosts })
Expand Down
7 changes: 6 additions & 1 deletion packages/xo-web/src/xo-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ export const ICON_POOL_LICENSE = {

for (const host of hosts) {
const license = xcpngLicenseByBoundObjectId[host.id]
if (license !== undefined && license.expires > Date.now()) {
if (license === undefined) {
continue
}
license.expires = license.expires ?? Infinity

if (license.expires > Date.now()) {
nHostsUnderLicense++
if (earliestExpirationDate === undefined || license.expires < earliestExpirationDate) {
earliestExpirationDate = license.expires
Expand Down

0 comments on commit 72822c9

Please sign in to comment.