aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2024-02-21 01:05:17 +0100
committerGitHub <noreply@github.com>2024-02-21 00:05:17 +0000
commita5c570c1e02302212a5d8f7cf7d91f24ab0578d5 (patch)
treec09f987b6eb48d801ef4ea73d3d1118198f64604 /web_src/js/features
parent3f73eabb666bd68af7a5317eaa2f97be52f35a26 (diff)
downloadgitea-a5c570c1e02302212a5d8f7cf7d91f24ab0578d5.tar.gz
gitea-a5c570c1e02302212a5d8f7cf7d91f24ab0578d5.zip
Remove jQuery .map() and enable eslint rules for it (#29272)
- Use case in `repo-commit` was tested until the point where the POST request was sent with the same payload. - Use case in `repo-legacy` was tested completely with comment editing. - `jquery/no-fade` was disabled as well to stay in sync with `no-jquery/no-fade`, had no violations.
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/repo-commit.js18
-rw-r--r--web_src/js/features/repo-legacy.js9
2 files changed, 11 insertions, 16 deletions
diff --git a/web_src/js/features/repo-commit.js b/web_src/js/features/repo-commit.js
index 76b34d2077..fc70ba41e4 100644
--- a/web_src/js/features/repo-commit.js
+++ b/web_src/js/features/repo-commit.js
@@ -14,17 +14,15 @@ export function initRepoEllipsisButton() {
}
export function initRepoCommitLastCommitLoader() {
- const entryMap = {};
-
- const entries = $('table#repo-files-table tr.notready')
- .map((_, v) => {
- entryMap[$(v).attr('data-entryname')] = $(v);
- return $(v).attr('data-entryname');
- })
- .get();
+ const notReadyEls = document.querySelectorAll('table#repo-files-table tr.notready');
+ if (!notReadyEls.length) return;
- if (entries.length === 0) {
- return;
+ const entryMap = {};
+ const entries = [];
+ for (const el of notReadyEls) {
+ const entryname = el.getAttribute('data-entryname');
+ entryMap[entryname] = $(el);
+ entries.push(entryname);
}
const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl');
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index ce1bff11a2..10ad836797 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -398,17 +398,14 @@ async function onEditContent(event) {
}
};
- const saveAndRefresh = (dz, $dropzone) => {
+ const saveAndRefresh = (dz) => {
showElem($renderContent);
hideElem($editContentZone);
- const $attachments = $dropzone.find('.files').find('[name=files]').map(function () {
- return $(this).val();
- }).get();
$.post($editContentZone.attr('data-update-url'), {
_csrf: csrfToken,
content: comboMarkdownEditor.value(),
context: $editContentZone.attr('data-context'),
- files: $attachments,
+ files: dz.files.map((file) => file.uuid),
}, (data) => {
if (!data.content) {
$renderContent.html($('#no-content').html());
@@ -452,7 +449,7 @@ async function onEditContent(event) {
});
$editContentZone.find('.save.button').on('click', (e) => {
e.preventDefault();
- saveAndRefresh(dz, $dropzone);
+ saveAndRefresh(dz);
});
} else {
comboMarkdownEditor = getComboMarkdownEditor($editContentZone.find('.combo-markdown-editor'));