Merge pull request 'Make the issue popup say useful stuff' (#7) from popup into forgejo
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

Reviewed-on: #7
This commit is contained in:
Minecon724 2025-06-08 15:23:51 +02:00
commit ca48758779
3 changed files with 20 additions and 4 deletions

View file

@ -96,5 +96,6 @@
"settings.theme_light": "Light",
"settings.theme_dark": "Dark",
"settings.theme_auto": "Auto (per your browser)",
"error.issue_not_found": "Issue not found",
"meta.last_line": "Thank you for translating Forgejo! This line isn't seen by the users but it serves other purposes in the translation management. You can place a fun fact in the translation instead of translating it."
}

View file

@ -38,6 +38,7 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
copy_error: {{ctx.Locale.Tr "copy_error"}},
error_occurred: {{ctx.Locale.Tr "error.occurred"}},
network_error: {{ctx.Locale.Tr "error.network_error"}},
issue_not_found: {{ctx.Locale.Tr "error.issue_not_found"}},
remove_label_str: {{ctx.Locale.Tr "remove_label_str"}},
modal_confirm: {{ctx.Locale.Tr "modal.confirm"}},
modal_cancel: {{ctx.Locale.Tr "modal.cancel"}},

View file

@ -95,14 +95,28 @@ export default {
try {
const response = await GET(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`);
const respJson = await response.json();
const respText = await response.text();
// Necesary to handle stuff like 404 that require other error messages
let respJson = {};
try {
respJson = JSON.parse(respText);
} catch {}
if (!response.ok) {
this.i18nErrorMessage = respJson.message ?? i18n.network_error;
if (respJson.message) {
this.i18nErrorMessage = respJson.message;
} else if (response.status === 404) {
this.i18nErrorMessage = i18n.issue_not_found;
} else {
this.i18nErrorMessage = i18n.error_occurred;
}
return;
}
this.issue = respJson;
} catch {
this.i18nErrorMessage = i18n.network_error;
} catch (e) {
console.error('Error loading issue info:', e);
this.i18nErrorMessage = i18n.error_occurred; // No it is not a network error
} finally {
this.loading = false;
}