Refactor all .length === 0
patterns in JS (#30045)
This pattern comes of often during review, so let's fix it once and for all. Did not test, but changes are trivial enough imho.
This commit is contained in:
parent
f73d891fc4
commit
8fe26fb314
14 changed files with 31 additions and 40 deletions
|
@ -103,7 +103,7 @@ export default {
|
|||
this.menuVisible = !this.menuVisible;
|
||||
// load our commits when the menu is not yet visible (it'll be toggled after loading)
|
||||
// and we got no commits
|
||||
if (this.commits.length === 0 && this.menuVisible && !this.isLoading) {
|
||||
if (!this.commits.length && this.menuVisible && !this.isLoading) {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
await this.fetchCommits();
|
||||
|
@ -216,7 +216,7 @@ export default {
|
|||
<div
|
||||
v-if="lastReviewCommitSha != null" role="menuitem"
|
||||
class="vertical item"
|
||||
:class="{disabled: commitsSinceLastReview === 0}"
|
||||
:class="{disabled: !commitsSinceLastReview}"
|
||||
@keydown.enter="changesSinceLastReviewClick()"
|
||||
@click="changesSinceLastReviewClick()"
|
||||
>
|
||||
|
|
|
@ -453,7 +453,7 @@ export function initRepositoryActionView() {
|
|||
{{ locale.showFullScreen }}
|
||||
</a>
|
||||
<div class="divider"/>
|
||||
<a :class="['item', currentJob.steps.length === 0 ? 'disabled' : '']" :href="run.link+'/jobs/'+jobIndex+'/logs'" target="_blank">
|
||||
<a :class="['item', !currentJob.steps.length ? 'disabled' : '']" :href="run.link+'/jobs/'+jobIndex+'/logs'" target="_blank">
|
||||
<i class="icon"><SvgIcon name="octicon-download"/></i>
|
||||
{{ locale.downloadLogs }}
|
||||
</a>
|
||||
|
|
|
@ -19,17 +19,19 @@ const sfc = {
|
|||
});
|
||||
|
||||
// TODO: fix this anti-pattern: side-effects-in-computed-properties
|
||||
this.active = (items.length === 0 && this.showCreateNewBranch ? 0 : -1);
|
||||
this.active = !items.length && this.showCreateNewBranch ? 0 : -1;
|
||||
return items;
|
||||
},
|
||||
showNoResults() {
|
||||
return this.filteredItems.length === 0 && !this.showCreateNewBranch;
|
||||
return !this.filteredItems.length && !this.showCreateNewBranch;
|
||||
},
|
||||
showCreateNewBranch() {
|
||||
if (this.disableCreateBranch || !this.searchTerm) {
|
||||
return false;
|
||||
}
|
||||
return this.items.filter((item) => item.name.toLowerCase() === this.searchTerm.toLowerCase()).length === 0;
|
||||
return !this.items.filter((item) => {
|
||||
return item.name.toLowerCase() === this.searchTerm.toLowerCase();
|
||||
}).length;
|
||||
},
|
||||
formActionUrl() {
|
||||
return `${this.repoLink}/branches/_new/${this.branchNameSubURL}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue