aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/components/DiffCommitSelector.vue4
-rw-r--r--web_src/js/components/RepoActionView.vue2
-rw-r--r--web_src/js/components/RepoBranchTagSelector.vue8
-rw-r--r--web_src/js/features/admin/common.js4
-rw-r--r--web_src/js/features/common-global.js2
-rw-r--r--web_src/js/features/comp/SearchUserBox.js2
-rw-r--r--web_src/js/features/repo-diff.js3
-rw-r--r--web_src/js/features/repo-editor.js10
-rw-r--r--web_src/js/features/repo-findfile.js2
-rw-r--r--web_src/js/features/repo-home.js4
-rw-r--r--web_src/js/features/repo-issue.js14
-rw-r--r--web_src/js/features/repo-legacy.js12
-rw-r--r--web_src/js/features/repo-settings.js2
-rw-r--r--web_src/js/features/user-settings.js2
14 files changed, 31 insertions, 40 deletions
diff --git a/web_src/js/components/DiffCommitSelector.vue b/web_src/js/components/DiffCommitSelector.vue
index d58337e093..cbb1f20873 100644
--- a/web_src/js/components/DiffCommitSelector.vue
+++ b/web_src/js/components/DiffCommitSelector.vue
@@ -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()"
>
diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue
index 26dffcda9e..7a2dc02d08 100644
--- a/web_src/js/components/RepoActionView.vue
+++ b/web_src/js/components/RepoActionView.vue
@@ -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>
diff --git a/web_src/js/components/RepoBranchTagSelector.vue b/web_src/js/components/RepoBranchTagSelector.vue
index d297503b2e..4e977ab185 100644
--- a/web_src/js/components/RepoBranchTagSelector.vue
+++ b/web_src/js/components/RepoBranchTagSelector.vue
@@ -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}`;
diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js
index 3c485d67a6..4e64bff330 100644
--- a/web_src/js/features/admin/common.js
+++ b/web_src/js/features/admin/common.js
@@ -6,9 +6,7 @@ import {POST} from '../../modules/fetch.js';
const {appSubUrl} = window.config;
export function initAdminCommon() {
- if ($('.page-content.admin').length === 0) {
- return;
- }
+ if (!$('.page-content.admin').length) return;
// check whether appUrl(ROOT_URL) is correct, if not, show an error message
checkAppUrl();
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index e2ce01eb49..18849ba7c1 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -19,7 +19,7 @@ const {appUrl, appSubUrl, csrfToken, i18n} = window.config;
export function initGlobalFormDirtyLeaveConfirm() {
// Warn users that try to leave a page after entering data into a form.
// Except on sign-in pages, and for forms marked as 'ignore-dirty'.
- if ($('.user.signin').length === 0) {
+ if (!$('.user.signin').length) {
$('form:not(.ignore-dirty)').areYouSure();
}
}
diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js
index 83d7044f11..081c47425f 100644
--- a/web_src/js/features/comp/SearchUserBox.js
+++ b/web_src/js/features/comp/SearchUserBox.js
@@ -34,7 +34,7 @@ export function initCompSearchUserBox() {
}
});
- if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) {
+ if (allowEmailInput && !items.length && looksLikeEmailAddressCheck.test(searchQuery)) {
const resultItem = {
title: searchQuery,
description: allowEmailDescription,
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js
index 4c8b411c64..596b1ea380 100644
--- a/web_src/js/features/repo-diff.js
+++ b/web_src/js/features/repo-diff.js
@@ -212,8 +212,7 @@ function initRepoDiffShowMore() {
export function initRepoDiffView() {
initRepoDiffConversationForm();
- const $diffFileList = $('#diff-file-list');
- if ($diffFileList.length === 0) return;
+ if (!$('#diff-file-list').length) return;
initDiffFileTree();
initDiffCommitSelect();
initRepoDiffShowMore();
diff --git a/web_src/js/features/repo-editor.js b/web_src/js/features/repo-editor.js
index 1ab0a57865..da3bda8c1d 100644
--- a/web_src/js/features/repo-editor.js
+++ b/web_src/js/features/repo-editor.js
@@ -39,11 +39,9 @@ function initEditPreviewTab($form) {
}
function initEditorForm() {
- if ($('.repository .edit.form').length === 0) {
- return;
- }
-
- initEditPreviewTab($('.repository .edit.form'));
+ const $form = $('.repository .edit.form');
+ if (!$form) return;
+ initEditPreviewTab($form);
}
function getCursorPosition($e) {
@@ -165,7 +163,7 @@ export function initRepoEditor() {
commitButton?.addEventListener('click', (e) => {
// A modal which asks if an empty file should be committed
- if ($editArea.val().length === 0) {
+ if (!$editArea.val()) {
$('#edit-empty-content-modal').modal({
onApprove() {
$('.edit.form').trigger('submit');
diff --git a/web_src/js/features/repo-findfile.js b/web_src/js/features/repo-findfile.js
index 0411b51f9c..cff5068a1e 100644
--- a/web_src/js/features/repo-findfile.js
+++ b/web_src/js/features/repo-findfile.js
@@ -77,7 +77,7 @@ function filterRepoFiles(filter) {
const filterResult = filterRepoFilesWeighted(files, filter);
- toggleElem(repoFindFileNoResult, filterResult.length === 0);
+ toggleElem(repoFindFileNoResult, !filterResult.length);
for (const r of filterResult) {
const row = document.createElement('tr');
const cell = document.createElement('td');
diff --git a/web_src/js/features/repo-home.js b/web_src/js/features/repo-home.js
index 2b0e38f087..e195c23c37 100644
--- a/web_src/js/features/repo-home.js
+++ b/web_src/js/features/repo-home.js
@@ -153,11 +153,11 @@ export function initRepoTopicBar() {
$.fn.form.settings.rules.validateTopic = function (_values, regExp) {
const $topics = $topicDropdown.children('a.ui.label');
- const status = $topics.length === 0 || $topics.last()[0].getAttribute('data-value').match(regExp);
+ const status = !$topics.length || $topics.last()[0].getAttribute('data-value').match(regExp);
if (!status) {
$topics.last().removeClass('green').addClass('red');
}
- return status && $topicDropdown.children('a.ui.label.red').length === 0;
+ return status && !$topicDropdown.children('a.ui.label.red').length;
};
$topicForm.form({
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 492428b327..20a854fb47 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -362,7 +362,7 @@ export async function updateIssuesMeta(url, action, issue_ids, id) {
}
export function initRepoIssueComments() {
- if ($('.repository.view.issue .timeline').length === 0) return;
+ if (!$('.repository.view.issue .timeline').length) return;
$('.re-request-review').on('click', async function (e) {
e.preventDefault();
@@ -377,7 +377,7 @@ export function initRepoIssueComments() {
$(document).on('click', (event) => {
const $urlTarget = $(':target');
- if ($urlTarget.length === 0) return;
+ if (!$urlTarget.length) return;
const urlTargetId = $urlTarget.attr('id');
if (!urlTargetId) return;
@@ -385,7 +385,7 @@ export function initRepoIssueComments() {
const $target = $(event.target);
- if ($target.closest(`#${urlTargetId}`).length === 0) {
+ if (!$target.closest(`#${urlTargetId}`).length) {
const scrollPosition = $(window).scrollTop();
window.location.hash = '';
$(window).scrollTop(scrollPosition);
@@ -478,9 +478,7 @@ export function initRepoPullRequestReview() {
}
// The following part is only for diff views
- if ($('.repository.pull.diff').length === 0) {
- return;
- }
+ if (!$('.repository.pull.diff').length) return;
const $reviewBtn = $('.js-btn-review');
const $panel = $reviewBtn.parent().find('.review-box-panel');
@@ -529,7 +527,7 @@ export function initRepoPullRequestReview() {
const $td = $ntr.find(`.add-comment-${side}`);
const $commentCloud = $td.find('.comment-code-cloud');
- if ($commentCloud.length === 0 && !$ntr.find('button[name="pending_review"]').length) {
+ if (!$commentCloud.length && !$ntr.find('button[name="pending_review"]').length) {
try {
const response = await GET($(this).closest('[data-new-comment-url]').attr('data-new-comment-url'));
const html = await response.text();
@@ -626,7 +624,7 @@ export function initRepoIssueTitleEdit() {
};
const pullrequest_target_update_url = $(this).attr('data-target-update-url');
- if ($editInput.val().length === 0 || $editInput.val() === $issueTitle.text()) {
+ if (!$editInput.val().length || $editInput.val() === $issueTitle.text()) {
$editInput.val($issueTitle.text());
await pullrequest_targetbranch_change(pullrequest_target_update_url);
} else {
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index 838c131623..e96afe484e 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -50,9 +50,7 @@ function reloadConfirmDraftComment() {
export function initRepoCommentForm() {
const $commentForm = $('.comment.form');
- if ($commentForm.length === 0) {
- return;
- }
+ if (!$commentForm.length) return;
if ($commentForm.find('.field.combo-editor-dropzone').length) {
// at the moment, if a form has multiple combo-markdown-editors, it must be an issue template form
@@ -202,7 +200,7 @@ export function initRepoCommentForm() {
$($(this).data('id-selector')).addClass('tw-hidden');
}
});
- if (listIds.length === 0) {
+ if (!listIds.length) {
$noSelect.removeClass('tw-hidden');
} else {
$noSelect.addClass('tw-hidden');
@@ -329,7 +327,7 @@ async function onEditContent(event) {
let comboMarkdownEditor;
const setupDropzone = async ($dropzone) => {
- if ($dropzone.length === 0) return null;
+ if (!$dropzone.length) return null;
let disableRemovedfileEvent = false; // when resetting the dropzone (removeAllFiles), disable the "removedfile" event
let fileUuidDict = {}; // to record: if a comment has been saved, then the uploaded files won't be deleted from server when clicking the Remove in the dropzone
@@ -482,9 +480,7 @@ async function onEditContent(event) {
}
export function initRepository() {
- if ($('.page-content.repository').length === 0) {
- return;
- }
+ if (!$('.page-content.repository').length) return;
initRepoBranchTagSelector('.js-branch-tag-selector');
diff --git a/web_src/js/features/repo-settings.js b/web_src/js/features/repo-settings.js
index dc1db8ab29..0ea44130d0 100644
--- a/web_src/js/features/repo-settings.js
+++ b/web_src/js/features/repo-settings.js
@@ -71,7 +71,7 @@ export function initRepoSettingSearchTeamBox() {
}
export function initRepoSettingGitHook() {
- if ($('.edit.githook').length === 0) return;
+ if (!$('.edit.githook').length) return;
const filename = document.querySelector('.hook-filename').textContent;
const _promise = createMonaco($('#content')[0], filename, {language: 'shell'});
}
diff --git a/web_src/js/features/user-settings.js b/web_src/js/features/user-settings.js
index 0dd908f34a..2d8c53e457 100644
--- a/web_src/js/features/user-settings.js
+++ b/web_src/js/features/user-settings.js
@@ -1,7 +1,7 @@
import {hideElem, showElem} from '../utils/dom.js';
export function initUserSettings() {
- if (document.querySelectorAll('.user.settings.profile').length === 0) return;
+ if (!document.querySelectorAll('.user.settings.profile').length) return;
const usernameInput = document.getElementById('username');
if (!usernameInput) return;