0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-21 12:24:38 +02:00

revert the changes for the submit button to allow a common method to handle it

This commit is contained in:
Lunny Xiao 2025-07-08 16:04:58 -07:00
parent d6de7867d5
commit ecc5b72800
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
5 changed files with 5 additions and 31 deletions

View File

@ -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 <strong>CANNOT</strong> 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 organizations 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

View File

@ -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
}

View File

@ -67,7 +67,7 @@
<div class="actions">
<button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button>
<button id="change-visibility-submit" class="ui red button" disabled>{{ctx.Locale.Tr "org.settings.change_visibility"}}</button>
<button class="ui red button">{{ctx.Locale.Tr "org.settings.change_visibility"}}</button>
</div>
</form>
</div>

View File

@ -1,25 +0,0 @@
function initOrgVisibilityChange() {
const visibilityModal = document.querySelector('#change-visibility-org-modal');
if (!visibilityModal) return;
const visibilitySelect = visibilityModal.querySelectorAll<HTMLInputElement>("input[name='visibility']");
if (!visibilitySelect) return;
const currentValue = visibilityModal.querySelector<HTMLInputElement>('input[name="current_visibility"]').value;
for (const radio of visibilitySelect) {
radio.addEventListener('change', () => {
const selectedValue = visibilityModal.querySelector<HTMLInputElement>("input[name='visibility']:checked").value;
const btn = visibilityModal.querySelector<HTMLButtonElement>('#change-visibility-submit');
if (selectedValue === currentValue) {
btn.setAttribute('disabled', '');
} else {
btn.removeAttribute('disabled');
}
});
}
}
export function initOrgSettings() {
initOrgVisibilityChange();
}

View File

@ -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,