Skip to content

Commit 610b2d0

Browse files
authored
simplify code using optional chaining in compute views (#5635)
1 parent bf3d133 commit 610b2d0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

ui/src/views/compute/CreateSSHKeyPair.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default {
176176
} else {
177177
api('createSSHKeyPair', params).then(json => {
178178
this.$message.success(this.$t('message.success.create.keypair') + ' ' + values.name)
179-
if (json.createsshkeypairresponse && json.createsshkeypairresponse.keypair && json.createsshkeypairresponse.keypair.privatekey) {
179+
if (json.createsshkeypairresponse?.keypair?.privatekey) {
180180
this.isSubmitted = true
181181
const key = json.createsshkeypairresponse.keypair.privatekey
182182
this.hiddenElement = document.createElement('a')

ui/src/views/compute/KubernetesServiceTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export default {
299299
fetchComments () {
300300
this.clusterConfigLoading = true
301301
api('listAnnotations', { entityid: this.resource.id, entitytype: 'KUBERNETES_CLUSTER', annotationfilter: 'all' }).then(json => {
302-
if (json.listannotationsresponse && json.listannotationsresponse.annotation) {
302+
if (json.listannotationsresponse?.annotation) {
303303
this.annotations = json.listannotationsresponse.annotation
304304
}
305305
}).catch(error => {

ui/src/views/compute/MigrateWizard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export default {
309309
this.$showNotification({
310310
type: 'error',
311311
message: this.$t('message.request.failed'),
312-
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
312+
description: (error.response?.headers?.['x-description']) || error.message,
313313
duration: 0
314314
})
315315
}).finally(() => {

0 commit comments

Comments
 (0)