simplify code using optional chaining in multiple views (#5630)

* simplify code using optional chaining in multiple views

* Undo simplify chaining in CreateL2NetworkForm
This commit is contained in:
Daman Arora 2022-02-06 08:09:41 -05:00 committed by GitHub
parent e3f0e3b544
commit 649be0d8c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -546,8 +546,7 @@ export default {
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
description: error.response.data.createvlaniprangeresponse
? error.response.data.createvlaniprangeresponse.errortext : error.response.data.errorresponse.errortext,
description: error.response.data.createvlaniprangeresponse?.errortext || error.response.data.errorresponse.errortext,
duration: 0
})
}).finally(() => {
@ -578,8 +577,7 @@ export default {
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
description: error.response.data.updatevlaniprangeresponse
? error.response.data.updatevlaniprangeresponse.errortext : error.response.data.errorresponse.errortext,
description: error.response.data.updatevlaniprangeresponse?.errortext || error.response.data.errorresponse.errortext,
duration: 0
})
}).finally(() => {

View File

@ -235,7 +235,7 @@ export default {
},
returnPodName (id) {
const match = this.pods.find(i => i.id === id)
return match ? match.name : null
return match?.name || null
},
handleOpenAddIpRangeModal () {
this.addIpRangeModal = true

View File

@ -144,7 +144,7 @@ export default {
const params = {}
if (args.mapping) {
Object.keys(args.mapping).map(key => {
params[key] = 'value' in args.mapping[key] ? args.mapping[key].value(this.resource) : null
params[key] = 'value' in args.mapping[key]?.value(this.resource) || null
})
}
params.page = this.page
@ -190,7 +190,7 @@ export default {
this.listData[args.title].loading = false
this.$notification.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
})
}
this.$forceUpdate()