@@ -390,6 +410,7 @@ export default class Licenses extends Component {
data-registeredEmail={xoaRegistration.email}
data-selfLicenses={selfLicenses}
data-xosanSrs={xosanSrs}
+ data-xostorSrs={xostorSrs}
stateUrlParam='s'
/>
diff --git a/packages/xo-web/src/xo-app/xoa/licenses/xostor.js b/packages/xo-web/src/xo-app/xoa/licenses/xostor.js
index d403e907a..33e135d57 100644
--- a/packages/xo-web/src/xo-app/xoa/licenses/xostor.js
+++ b/packages/xo-web/src/xo-app/xoa/licenses/xostor.js
@@ -6,14 +6,15 @@ import Icon from 'icon'
import React from 'react'
import SelectLicense from 'select-license'
import SortedTable from 'sorted-table'
-import Tooltip from 'tooltip'
import { bindLicense } from 'xo'
import { connectStore } from 'utils'
-import { createGetObjectsOfType } from 'selectors'
+import { createGetObjectsOfType, createSelector } from 'selectors'
import { groupBy } from 'lodash'
import { injectState, provideState } from 'reaclette'
import { Pool, Sr } from 'render-xo-item'
+import BulkIcons from '../../../common/bulk-icons'
+
class XostorLicensesForm extends Component {
state = {
licenseId: 'none',
@@ -24,40 +25,72 @@ class XostorLicensesForm extends Component {
return bindLicense(this.state.licenseId, item.uuid).then(userData.updateLicenses)
}
+ getAlerts = createSelector(
+ () => this.props.item,
+ () => this.props.userData,
+ (sr, userData) => {
+ const alerts = []
+ const licenses = userData.licensesByXostorUuid[sr.id]
+
+ // Xostor bound to multiple licenses
+ if (licenses?.length > 1) {
+ alerts.push({
+ level: 'danger',
+ render: (
+
+ {_('xostorMultipleLicenses')}
+
+ {licenses.map(license => license.id.slice(-4)).join(',')}
+
+ ),
+ })
+ }
+
+ const license = licenses?.[0]
+ if (license?.expires < Date.now()) {
+ alerts.push({
+ level: 'danger',
+ render: _('licenseExpiredXostorWarning', { licenseId: license?.id.slice(-4) }),
+ })
+ }
+ return alerts
+ }
+ )
+
render() {
+ const alerts = this.getAlerts()
+ if (alerts.length > 0) {
+ return
+ }
+
const { item, userData } = this.props
const { licenseId } = this.state
const licenses = userData.licensesByXostorUuid[item.id]
-
- // Xostor bound to multiple licenses
- if (licenses?.length > 1) {
- return (
-
- {licenses.map(license => license.id.slice(-4)).join(',')}{' '}
-
-
-
-
- )
- }
-
const license = licenses?.[0]
+
return license !== undefined ? (
- {license.id.slice(-4)}
+ {license?.id.slice(-4)}
) : (
-
+
+ {license !== undefined && (
+
+ {_('licenseHasExpired')}
+
+ )}
+
+
)
}
}