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>
This commit is contained in:
Yashika 2022-02-10 09:57:54 +05:30 committed by GitHub
parent 41d25d54a7
commit 38181b2afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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
}