simplify code using optional chaining in compute views (#5635)

This commit is contained in:
Daman Arora 2022-01-04 01:53:28 -05:00 committed by GitHub
parent bf3d1338e0
commit 610b2d0dd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -176,7 +176,7 @@ export default {
} else {
api('createSSHKeyPair', params).then(json => {
this.$message.success(this.$t('message.success.create.keypair') + ' ' + values.name)
if (json.createsshkeypairresponse && json.createsshkeypairresponse.keypair && json.createsshkeypairresponse.keypair.privatekey) {
if (json.createsshkeypairresponse?.keypair?.privatekey) {
this.isSubmitted = true
const key = json.createsshkeypairresponse.keypair.privatekey
this.hiddenElement = document.createElement('a')

View File

@ -299,7 +299,7 @@ export default {
fetchComments () {
this.clusterConfigLoading = true
api('listAnnotations', { entityid: this.resource.id, entitytype: 'KUBERNETES_CLUSTER', annotationfilter: 'all' }).then(json => {
if (json.listannotationsresponse && json.listannotationsresponse.annotation) {
if (json.listannotationsresponse?.annotation) {
this.annotations = json.listannotationsresponse.annotation
}
}).catch(error => {

View File

@ -309,7 +309,7 @@ export default {
this.$showNotification({
type: 'error',
message: this.$t('message.request.failed'),
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
description: (error.response?.headers?.['x-description']) || error.message,
duration: 0
})
}).finally(() => {