Copilot commented on code in PR #13161:
URL: https://github.com/apache/cloudstack/pull/13161#discussion_r3273138298
##########
ui/src/components/view/ImageDeployInstanceButton.vue:
##########
@@ -83,15 +83,16 @@ export default {
computed: {
allowed () {
return (this.$route.meta.name === 'template' ||
- (this.$route.meta.name === 'iso' && this.resource.bootable))
+ (this.$route.meta.name === 'iso' && this.resource?.bootable)) &&
+ this.resource?.state === 'Ready'
}
Review Comment:
This change alters when the deploy button is rendered and when the zones API
call is triggered. There are existing Vue unit tests in
`ui/tests/unit/components/view/` but none covering this component; adding a
small unit test for `allowed`/readiness gating would help prevent regressions
(e.g., not-ready images never showing the deploy action).
##########
ui/src/components/view/ImageDeployInstanceButton.vue:
##########
@@ -83,15 +83,16 @@ export default {
computed: {
allowed () {
return (this.$route.meta.name === 'template' ||
- (this.$route.meta.name === 'iso' && this.resource.bootable))
+ (this.$route.meta.name === 'iso' && this.resource?.bootable)) &&
+ this.resource?.state === 'Ready'
}
},
methods: {
fetchData () {
this.fetchResourceData()
},
fetchResourceData () {
- if (!this.resource || !this.resource.id) {
+ if (!this.resource || !this.resource.id || this.resource.state !==
'Ready') {
Review Comment:
This early-return uses `this.resource.state !== 'Ready'`, which depends on a
UI-derived `state` string. Using the API’s boolean `resource.isready` here
would be more robust and avoid regressions if the display value changes or if
`state` is not populated in some call paths.
##########
ui/src/components/view/ImageDeployInstanceButton.vue:
##########
@@ -83,15 +83,16 @@ export default {
computed: {
allowed () {
return (this.$route.meta.name === 'template' ||
- (this.$route.meta.name === 'iso' && this.resource.bootable))
+ (this.$route.meta.name === 'iso' && this.resource?.bootable)) &&
+ this.resource?.state === 'Ready'
}
Review Comment:
Readiness is determined by comparing `resource.state` to the hard-coded
string `'Ready'`. For templates/ISOs, `state` is a UI-derived display value,
while the API provides the canonical boolean `isready` (used elsewhere). To
avoid coupling this component’s behavior to column-rendering/display strings,
gate on `resource.isready` (and keep the ISO `bootable` check) instead of
`resource.state === 'Ready'`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]