From 23687a0a71c1a678ef7b443d8427eb840fdcedf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aindri=C3=BA=20Mac=20Giolla=20Eoin?= Date: Sat, 21 Dec 2024 04:56:08 +0000 Subject: [PATCH 01/21] Update i18n.go - Language Picker (#32933) --- modules/setting/i18n.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/setting/i18n.go b/modules/setting/i18n.go index c3076c0ab7..6e0767320f 100644 --- a/modules/setting/i18n.go +++ b/modules/setting/i18n.go @@ -11,6 +11,7 @@ var defaultI18nLangNames = []string{ "zh-TW", "繁體中文(台灣)", "de-DE", "Deutsch", "fr-FR", "Français", + "ga-IE", "Gaeilge", "nl-NL", "Nederlands", "lv-LV", "Latviešu", "ru-RU", "Русский", From 09a0041965ead62ba96a96bc47a0e8699ec99650 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 22 Dec 2024 01:11:22 +0800 Subject: [PATCH 02/21] Fix areYouSure confirm (#32941) See the comment --- web_src/js/features/common-fetch-action.ts | 3 ++- web_src/js/features/repo-editor.ts | 4 ++-- web_src/js/features/repo-issue.ts | 3 ++- web_src/js/vendor/jquery.are-you-sure.ts | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web_src/js/features/common-fetch-action.ts b/web_src/js/features/common-fetch-action.ts index 1a5b38e3e5..bc72f4089a 100644 --- a/web_src/js/features/common-fetch-action.ts +++ b/web_src/js/features/common-fetch-action.ts @@ -3,6 +3,7 @@ import {showErrorToast} from '../modules/toast.ts'; import {addDelegatedEventListener, submitEventSubmitter} from '../utils/dom.ts'; import {confirmModal} from './comp/ConfirmModal.ts'; import type {RequestOpts} from '../types.ts'; +import {ignoreAreYouSure} from '../vendor/jquery.are-you-sure.ts'; const {appSubUrl, i18n} = window.config; @@ -27,7 +28,7 @@ async function fetchActionDoRequest(actionElem: HTMLElement, url: string, opt: R if (resp.status === 200) { let {redirect} = await resp.json(); redirect = redirect || actionElem.getAttribute('data-redirect'); - actionElem.classList.remove('dirty'); // remove the areYouSure check before reloading + ignoreAreYouSure(actionElem); // ignore the areYouSure check before reloading if (redirect) { fetchActionDoRedirect(redirect); } else { diff --git a/web_src/js/features/repo-editor.ts b/web_src/js/features/repo-editor.ts index 32d0b84f4c..64d0402d84 100644 --- a/web_src/js/features/repo-editor.ts +++ b/web_src/js/features/repo-editor.ts @@ -6,7 +6,7 @@ import {attachRefIssueContextPopup} from './contextpopup.ts'; import {POST} from '../modules/fetch.ts'; import {initDropzone} from './dropzone.ts'; import {confirmModal} from './comp/ConfirmModal.ts'; -import {applyAreYouSure} from '../vendor/jquery.are-you-sure.ts'; +import {applyAreYouSure, ignoreAreYouSure} from '../vendor/jquery.are-you-sure.ts'; import {fomanticQuery} from '../modules/fomantic/base.ts'; function initEditPreviewTab(elForm: HTMLFormElement) { @@ -188,7 +188,7 @@ export function initRepoEditor() { header: elForm.getAttribute('data-text-empty-confirm-header'), content: elForm.getAttribute('data-text-empty-confirm-content'), })) { - elForm.classList.remove('dirty'); + ignoreAreYouSure(elForm); elForm.submit(); } } diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index 1e1bbd64f0..f47e05c47c 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -16,6 +16,7 @@ import {GET, POST} from '../modules/fetch.ts'; import {showErrorToast} from '../modules/toast.ts'; import {initRepoIssueSidebar} from './repo-issue-sidebar.ts'; import {fomanticQuery} from '../modules/fomantic/base.ts'; +import {ignoreAreYouSure} from '../vendor/jquery.are-you-sure.ts'; const {appSubUrl} = window.config; @@ -578,7 +579,7 @@ export function initRepoIssueTitleEdit() { } } } - issueTitleEditor.classList.remove('dirty'); + ignoreAreYouSure(issueTitleEditor); window.location.reload(); } catch (error) { console.error(error); diff --git a/web_src/js/vendor/jquery.are-you-sure.ts b/web_src/js/vendor/jquery.are-you-sure.ts index 7f0bef8040..51359c87a7 100644 --- a/web_src/js/vendor/jquery.are-you-sure.ts +++ b/web_src/js/vendor/jquery.are-you-sure.ts @@ -204,3 +204,9 @@ export function applyAreYouSure(selectorOrEl: string|Element|$, opts = {}) { export function reinitializeAreYouSure(selectorOrEl: string|Element|$) { $(selectorOrEl).trigger('reinitialize.areYouSure'); } + +export function ignoreAreYouSure(selectorOrEl: string|Element|$) { + // here we should only add "ignore-dirty" but not remove "dirty". + // because when using "enter" to submit a form, the "dirty" class will appear again before reloading. + $(selectorOrEl).addClass('ignore-dirty'); +} From c0e80dbe26c77453dfdc33979c9f69eb6eba18c4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 21 Dec 2024 19:59:25 +0100 Subject: [PATCH 03/21] Enable Typescript `strictFunctionTypes` (#32911) 1. Enable [strictFunctionTypes](https://www.typescriptlang.org/tsconfig/#strictFunctionTypes) 2. Introduce `DOMEvent` helper type which sets `e.target`. Surely not totally correct with that `Partial` but seems to work. 3. Various type-related refactors, change objects in `eventsource.sharedworker.ts` to `Map`. --- tsconfig.json | 1 + web_src/js/components/ContextPopup.vue | 5 +- web_src/js/features/clipboard.ts | 3 +- web_src/js/features/colorpicker.ts | 7 +-- web_src/js/features/common-form.ts | 4 +- web_src/js/features/comp/Cropper.ts | 4 +- web_src/js/features/comp/ReactionSelector.ts | 5 +- .../js/features/eventsource.sharedworker.ts | 49 ++++++++++--------- web_src/js/features/notification.ts | 6 +-- web_src/js/features/oauth2-settings.ts | 6 ++- web_src/js/features/repo-graph.ts | 12 ++--- web_src/js/features/repo-home.ts | 4 +- web_src/js/features/repo-issue.ts | 21 ++++---- web_src/js/features/repo-release.ts | 8 +-- web_src/js/features/repo-search.ts | 4 +- web_src/js/features/repo-settings.ts | 4 +- web_src/js/features/repo-wiki.ts | 2 +- web_src/js/htmx.ts | 4 +- web_src/js/markup/html2markdown.ts | 16 +++--- web_src/js/modules/tippy.ts | 10 ++-- web_src/js/utils/dom.ts | 3 +- 21 files changed, 94 insertions(+), 84 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 7d0316db29..d32cca0aaa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,7 @@ "verbatimModuleSyntax": true, "stripInternal": true, "strict": false, + "strictFunctionTypes": true, "noUnusedLocals": true, "noUnusedParameters": true, "noPropertyAccessFromIndexSignature": false, diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index b0e8447302..0aae202d42 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -25,10 +25,9 @@ const body = computed(() => { const root = ref(null); onMounted(() => { - root.value.addEventListener('ce-load-context-popup', (e: CustomEvent) => { - const data: IssuePathInfo = e.detail; + root.value.addEventListener('ce-load-context-popup', (e: CustomEventInit) => { if (!loading.value && issue.value === null) { - load(data); + load(e.detail); } }); }); diff --git a/web_src/js/features/clipboard.ts b/web_src/js/features/clipboard.ts index 8f40f34f74..22c264d774 100644 --- a/web_src/js/features/clipboard.ts +++ b/web_src/js/features/clipboard.ts @@ -1,6 +1,7 @@ import {showTemporaryTooltip} from '../modules/tippy.ts'; import {toAbsoluteUrl} from '../utils.ts'; import {clippie} from 'clippie'; +import type {DOMEvent} from '../utils/dom.ts'; const {copy_success, copy_error} = window.config.i18n; @@ -9,7 +10,7 @@ const {copy_success, copy_error} = window.config.i18n; // - data-clipboard-target: Holds a selector for a or