From ecc5b7280041d9809645a192aa99f0afe59af488 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 8 Jul 2025 16:04:58 -0700 Subject: [PATCH] revert the changes for the submit button to allow a common method to handle it --- options/locale/locale_en-US.ini | 3 +-- routers/web/org/setting.go | 4 ++- .../org/settings/options_dangerzone.tmpl | 2 +- web_src/js/features/org-settings.ts | 25 ------------------- web_src/js/index-domready.ts | 2 -- 5 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 web_src/js/features/org-settings.ts diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0f1b894393..ed85778c2c 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2842,10 +2842,9 @@ settings.repoadminchangeteam = Repository admin can add and remove access for te settings.visibility = Visibility settings.change_visibility = Change Visibility settings.invalid_visibility = The new visibility is not valid. -settings.change_visibility_notices_1 = This operation CANNOT be undone. +settings.change_visibility_notices_1 = If the organization is converted to private, the repository stars will be removed and cannot be restored. settings.change_visibility_notices_2 = Non-members will lose access to the organization’s repositories if visibility is changed to private. settings.change_visibility_no_change = You did not make any changes to visibility. -settings.change_visibility_failed = Failed to change the visibility of %s due to an internal error. settings.change_visibility_success = The visibility of organization %s has been successfully changed. settings.visibility_desc = Change who can view the organization and its repositories. settings.visibility.public = Public diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index d2965c2c3e..bb100a7aef 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -246,7 +246,9 @@ func SettingsChangeVisibilityPost(ctx *context.Context) { if err := org_service.ChangeOrganizationVisibility(ctx, ctx.Org.Organization, visibility); err != nil { log.Error("ChangeOrganizationVisibility: %v", err) - ctx.JSONError(util.Iif(ctx.Doer.IsAdmin, err.Error(), string(ctx.Tr("org.settings.change_visibility_failed", ctx.Org.Organization.Name)))) + ctx.JSON(http.StatusInternalServerError, map[string]any{ + "err": http.StatusText(http.StatusInternalServerError), + }) return } diff --git a/templates/org/settings/options_dangerzone.tmpl b/templates/org/settings/options_dangerzone.tmpl index f761c4ea7e..d01252e3e1 100644 --- a/templates/org/settings/options_dangerzone.tmpl +++ b/templates/org/settings/options_dangerzone.tmpl @@ -67,7 +67,7 @@
- +
diff --git a/web_src/js/features/org-settings.ts b/web_src/js/features/org-settings.ts deleted file mode 100644 index 4d20f55021..0000000000 --- a/web_src/js/features/org-settings.ts +++ /dev/null @@ -1,25 +0,0 @@ -function initOrgVisibilityChange() { - const visibilityModal = document.querySelector('#change-visibility-org-modal'); - if (!visibilityModal) return; - - const visibilitySelect = visibilityModal.querySelectorAll("input[name='visibility']"); - if (!visibilitySelect) return; - - const currentValue = visibilityModal.querySelector('input[name="current_visibility"]').value; - - for (const radio of visibilitySelect) { - radio.addEventListener('change', () => { - const selectedValue = visibilityModal.querySelector("input[name='visibility']:checked").value; - const btn = visibilityModal.querySelector('#change-visibility-submit'); - if (selectedValue === currentValue) { - btn.setAttribute('disabled', ''); - } else { - btn.removeAttribute('disabled'); - } - }); - } -} - -export function initOrgSettings() { - initOrgVisibilityChange(); -} diff --git a/web_src/js/index-domready.ts b/web_src/js/index-domready.ts index 476ba8d50d..4d7ab98db0 100644 --- a/web_src/js/index-domready.ts +++ b/web_src/js/index-domready.ts @@ -33,7 +33,6 @@ import {initRepoActivityTopAuthorsChart, initRepoArchiveLinks} from './features/ import {initRepoMigrationStatusChecker} from './features/repo-migrate.ts'; import {initRepoDiffView} from './features/repo-diff.ts'; import {initOrgTeam} from './features/org-team.ts'; -import {initOrgSettings} from './features/org-settings.ts'; import {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.ts'; import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.ts'; import {initRepoEditor} from './features/repo-editor.ts'; @@ -121,7 +120,6 @@ const initPerformanceTracer = callInitFunctions([ initNotificationsTable, initOrgTeam, - initOrgSettings, initRepoActivityTopAuthorsChart, initRepoArchiveLinks,