From 38181b2afa28443fe27b53ef5893b434d0b78e2d Mon Sep 17 00:00:00 2001 From: Yashika <65132044+Yashikaone@users.noreply.github.com> Date: Thu, 10 Feb 2022 09:57:54 +0530 Subject: [PATCH] Optional chaining used to enhance readability (#5961) * Optional chaining used to enhance readability * Added Suggested change Co-authored-by: YashikaSarkar <65132044+YashikaSarkar@users.noreply.github.com> --- ui/src/components/header/ProjectMenu.vue | 2 +- ui/src/components/view/BulkActionProgress.vue | 2 +- ui/src/components/view/DedicateData.vue | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ui/src/components/header/ProjectMenu.vue b/ui/src/components/header/ProjectMenu.vue index 8a5f1da9300..959d8f3bcca 100644 --- a/ui/src/components/header/ProjectMenu.vue +++ b/ui/src/components/header/ProjectMenu.vue @@ -79,7 +79,7 @@ export default { const getNextPage = () => { this.loading = true api('listProjects', { listAll: true, details: 'min', page: page, pageSize: 500, showIcon: true }).then(json => { - if (json && json.listprojectsresponse && json.listprojectsresponse.project) { + if (json?.listprojectsresponse?.listprojectsresponse.project) { projects.push(...json.listprojectsresponse.project) } if (projects.length < json.listprojectsresponse.count) { diff --git a/ui/src/components/view/BulkActionProgress.vue b/ui/src/components/view/BulkActionProgress.vue index 73a6a3419e9..2146715f4d4 100644 --- a/ui/src/components/view/BulkActionProgress.vue +++ b/ui/src/components/view/BulkActionProgress.vue @@ -155,7 +155,7 @@ export default { this.tableChanged = true }, filterItems () { - if (this.appliedFilterStatus && this.appliedFilterStatus.length > 0) { + if (this.appliedFilterStatus?.length > 0) { this.filteredItems = this.selectedItems.filter(item => { if (this.appliedFilterStatus.includes(item.status)) { return item diff --git a/ui/src/components/view/DedicateData.vue b/ui/src/components/view/DedicateData.vue index 0818c70f151..a00cab5c98f 100644 --- a/ui/src/components/view/DedicateData.vue +++ b/ui/src/components/view/DedicateData.vue @@ -121,8 +121,7 @@ export default { api('listDedicatedZones', { zoneid: this.resource.id }).then(response => { - if (response.listdedicatedzonesresponse.dedicatedzone && - response.listdedicatedzonesresponse.dedicatedzone.length > 0) { + if (response?.listdedicatedzonesresponse?.dedicatedzone?.length > 0) { this.dedicatedDomainId = response.listdedicatedzonesresponse.dedicatedzone[0].domainid this.dedicatedAccountId = response.listdedicatedzonesresponse.dedicatedzone[0].accountid } @@ -134,8 +133,7 @@ export default { api('listDedicatedPods', { podid: this.resource.id }).then(response => { - if (response.listdedicatedpodsresponse.dedicatedpod && - response.listdedicatedpodsresponse.dedicatedpod.length > 0) { + if (response?.listdedicatedpodsresponse?.dedicatedpod?.length > 0) { this.dedicatedDomainId = response.listdedicatedpodsresponse.dedicatedpod[0].domainid this.dedicatedAccountId = response.listdedicatedpodsresponse.dedicatedpod[0].accountid } @@ -147,8 +145,7 @@ export default { api('listDedicatedClusters', { clusterid: this.resource.id }).then(response => { - if (response.listdedicatedclustersresponse.dedicatedcluster && - response.listdedicatedclustersresponse.dedicatedcluster.length > 0) { + if (response?.listdedicatedclustersresponse?.dedicatedcluster?.length > 0) { this.dedicatedDomainId = response.listdedicatedclustersresponse.dedicatedcluster[0].domainid this.dedicatedAccountId = response.listdedicatedclustersresponse.dedicatedcluster[0].accountid } @@ -160,8 +157,7 @@ export default { api('listDedicatedHosts', { hostid: this.resource.id }).then(response => { - if (response.listdedicatedhostsresponse.dedicatedhost && - response.listdedicatedhostsresponse.dedicatedhost.length > 0) { + if (response?.listdedicatedhostsresponse?.dedicatedhost?.length > 0) { this.dedicatedDomainId = response.listdedicatedhostsresponse.dedicatedhost[0].domainid this.dedicatedAccountId = response.listdedicatedhostsresponse.dedicatedhost[0].accountid }