Skip to content

Commit b2fdde7

Browse files
committed
UI: Notify users when upgrades are available
Notify when a new version of CloudStack or a restart is required for networks & VPCs
1 parent d41dc17 commit b2fdde7

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

ui/public/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@
14551455
"label.networkspeed": "Network speed",
14561456
"label.networktype": "Network type",
14571457
"label.networkwrite": "Network write",
1458+
"label.new.version.available": "Newer version available",
14581459
"label.new": "New",
14591460
"label.new.autoscale.vmgroup": "New AutoScale Instance Group",
14601461
"label.new.instance.group": "New Instance group",
@@ -3146,6 +3147,8 @@
31463147
"message.no.description": "No description entered.",
31473148
"message.offering.internet.protocol.warning": "WARNING: IPv6 supported Networks use static routing and will require upstream routes to be configured manually.",
31483149
"message.offering.ipv6.warning": "Please refer documentation for creating IPv6 enabled Network/VPC offering <a href='http://docs.cloudstack.apache.org/en/latest/plugins/ipv6.html#isolated-network-and-vpc-tier'>IPv6 support in CloudStack - Isolated Networks and VPC Network Tiers</a>",
3150+
"message.notification.restart.required.network": "Restart required for network(s). Click here to view network(s) which require restart.",
3151+
"message.notification.restart.required.vpc": "Restart required for VPC(s). Click here to view VPC(s) which require restart.",
31493152
"message.ovf.configurations": "OVF configurations available for the selected appliance. Please select the desired value. Incompatible compute offerings will get disabled.",
31503153
"message.path.description": "NFS: exported path from the server. VMFS: /datacenter name/datastore name. SharedMountPoint: path where primary storage is mounted, such as /mnt/primary.",
31513154
"message.please.confirm.remove.ssh.key.pair": "Please confirm that you want to remove this SSH key pair.",

ui/src/components/page/GlobalFooter.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
</div>
2323
<div class="line" v-if="$store.getters.userInfo.roletype === 'Admin'">
2424
CloudStack {{ $store.getters.features.cloudstackversion }}
25+
<span v-if="$store.getters.features.cloudstackversion && $store.getters.features.cloudstackversion.split('-')[0] !== $store.getters.latestVersion && $store.getters.latestVersion !== ''">
26+
<a-divider type="vertical" />
27+
<a
28+
:href="'https://github.com/apache/cloudstack/releases/tag/' + $store.getters.latestVersion"
29+
target="_blank">
30+
<info-circle-outlined />
31+
{{ $t('label.new.version.available') + ': ' + $store.getters.latestVersion }}
32+
</a>
33+
</span>
2534
<a-divider type="vertical" />
2635
<a href="https://github.com/apache/cloudstack/discussions" target="_blank">
2736
<github-outlined />

ui/src/store/getters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const getters = {
2828
apis: state => state.user.apis,
2929
features: state => state.user.features,
3030
userInfo: state => state.user.info,
31+
latestVersion: state => state.user.latestVersion,
3132
addRouters: state => state.permission.addRouters,
3233
multiTab: state => state.app.multiTab,
3334
listAllProjects: state => state.app.listAllProjects,

ui/src/store/modules/user.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import router from '@/router'
2424
import store from '@/store'
2525
import { oauthlogin, login, logout, api } from '@/api'
2626
import { i18n } from '@/locales'
27+
import { axios } from '../../utils/request'
2728

2829
import {
2930
ACCESS_TOKEN,
@@ -167,6 +168,9 @@ const user = {
167168
},
168169
SET_OAUTH_PROVIDER_USED_TO_LOGIN: (state, provider) => {
169170
vueProps.$localStorage.set(OAUTH_PROVIDER, provider)
171+
},
172+
SET_LATEST_VERSION: (state, version) => {
173+
state.latestVersion = version
170174
}
171175
},
172176

@@ -212,6 +216,7 @@ const user = {
212216
commit('SET_2FA_PROVIDER', result.providerfor2fa)
213217
commit('SET_2FA_ISSUER', result.issuerfor2fa)
214218
commit('SET_LOGIN_FLAG', false)
219+
commit('SET_LATEST_VERSION', '')
215220
notification.destroy()
216221

217222
resolve()
@@ -294,6 +299,20 @@ const user = {
294299
const result = response.listusersresponse.user[0]
295300
commit('SET_INFO', result)
296301
commit('SET_NAME', result.firstname + ' ' + result.lastname)
302+
if (result.rolename === 'Root Admin') {
303+
axios.get(
304+
'https://api.github.com/repos/apache/cloudstack/releases'
305+
).then(response => {
306+
for (const release of response) {
307+
if (release.tag_name.toLowerCase().includes('rc')) {
308+
continue
309+
} else {
310+
commit('SET_LATEST_VERSION', release.tag_name)
311+
break
312+
}
313+
}
314+
}).catch(ignored => {})
315+
}
297316
resolve(cachedApis)
298317
}).catch(error => {
299318
reject(error)
@@ -332,6 +351,42 @@ const user = {
332351
}).catch(error => {
333352
reject(error)
334353
})
354+
355+
api('listNetworks', { restartrequired: true }).then(response => {
356+
if (response.listnetworksresponse.count > 0) {
357+
notification.info({
358+
message: i18n.global.t('label.restartrequired'),
359+
description: i18n.global.t('message.notification.restart.required.network'),
360+
duration: 0,
361+
onClick: () => {
362+
router.push({ path: '/guestnetwork', query: { restartrequired: true } })
363+
},
364+
onClose: () => {
365+
let countNotify = store.getters.countNotify
366+
countNotify > 0 ? countNotify-- : countNotify = 0
367+
store.commit('SET_COUNT_NOTIFY', countNotify)
368+
}
369+
})
370+
}
371+
}).catch(ignored => {})
372+
373+
api('listVPCs', { restartrequired: true }).then(response => {
374+
if (response.listvpcsresponse.count > 0) {
375+
notification.info({
376+
message: i18n.global.t('label.restartrequired'),
377+
description: i18n.global.t('message.notification.restart.required.vpc'),
378+
duration: 0,
379+
onClick: () => {
380+
router.push({ path: '/vpc', query: { restartrequired: true } })
381+
},
382+
onClose: () => {
383+
let countNotify = store.getters.countNotify
384+
countNotify > 0 ? countNotify-- : countNotify = 0
385+
store.commit('SET_COUNT_NOTIFY', countNotify)
386+
}
387+
})
388+
}
389+
}).catch(ignored => {})
335390
}
336391

337392
api('listUsers', { username: Cookies.get('username') }).then(response => {

0 commit comments

Comments
 (0)