0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-19 19:18:43 +02:00

improvements

This commit is contained in:
Lunny Xiao 2025-07-07 17:03:35 -07:00
parent fe350ae4f0
commit 33075e7be5
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
5 changed files with 36 additions and 8 deletions

View File

@ -2843,11 +2843,11 @@ settings.visibility = Visibility
settings.change_visibility = Change Visibility settings.change_visibility = Change Visibility
settings.invalid_visibility = The new visibility is not valid. 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 = This operation <strong>CANNOT</strong> be undone.
settings.change_visibility_notices_2 = Some users will no longer be able to access the organizations repositories. 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 = There has been no change in visibility. 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_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.change_visibility_success = The visibility of organization %s has been successfully changed.
settings.visibility_desc = Change the organization visibility settings.visibility_desc = Change who can view the organization and its repositories.
settings.visibility.public = Public settings.visibility.public = Public
settings.visibility.limited = Limited (Visible to authenticated users only) settings.visibility.limited = Limited (Visible to authenticated users only)
settings.visibility.limited_shortname = Limited settings.visibility.limited_shortname = Limited

View File

@ -233,7 +233,7 @@ func SettingsRenamePost(ctx *context.Context) {
// SettingsChangeVisibilityPost response for change organization visibility // SettingsChangeVisibilityPost response for change organization visibility
func SettingsChangeVisibilityPost(ctx *context.Context) { func SettingsChangeVisibilityPost(ctx *context.Context) {
visibility := structs.VisibleType(ctx.FormInt("visibility")) visibility := structs.VisibilityModes[ctx.FormString("visibility")]
if !visibility.IsValid() { if !visibility.IsValid() {
ctx.JSONError(ctx.Tr("org.settings.invalid_visibility")) ctx.JSONError(ctx.Tr("org.settings.invalid_visibility"))
return return

View File

@ -48,25 +48,26 @@
</div> </div>
<form class="ui form form-fetch-action" action="{{.Link}}/visibility" method="post"> <form class="ui form form-fetch-action" action="{{.Link}}/visibility" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<input type="hidden" name="current_visibility" value="{{.CurrentVisibility}}">
<div class="tw-flex tw-flex-col tw-gap-3"> <div class="tw-flex tw-flex-col tw-gap-3">
<label>{{ctx.Locale.Tr "org.settings.visibility"}}</label> <label>{{ctx.Locale.Tr "org.settings.visibility"}}</label>
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input name="visibility" type="radio" value="0" {{if eq .CurrentVisibility 0}}checked{{end}}> <input name="visibility" type="radio" value="public" {{if .CurrentVisibility.IsPublic}}checked{{end}}>
<label>{{ctx.Locale.Tr "org.settings.visibility.public"}}</label> <label>{{ctx.Locale.Tr "org.settings.visibility.public"}}</label>
</div> </div>
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input name="visibility" type="radio" value="1" {{if eq .CurrentVisibility 1}}checked{{end}}> <input name="visibility" type="radio" value="limited" {{if .CurrentVisibility.IsLimited}}checked{{end}}>
<label>{{ctx.Locale.Tr "org.settings.visibility.limited"}}</label> <label>{{ctx.Locale.Tr "org.settings.visibility.limited"}}</label>
</div> </div>
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input name="visibility" type="radio" value="2" {{if eq .CurrentVisibility 2}}checked{{end}}> <input name="visibility" type="radio" value="private" {{if .CurrentVisibility.IsPrivate}}checked{{end}}>
<label>{{ctx.Locale.Tr "org.settings.visibility.private"}}</label> <label>{{ctx.Locale.Tr "org.settings.visibility.private"}}</label>
</div> </div>
</div> </div>
<div class="actions"> <div class="actions">
<button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button>
<button class="ui red button">{{ctx.Locale.Tr "org.settings.change_visibility"}}</button> <button id="change-visibility-submit" class="ui red button" disabled>{{ctx.Locale.Tr "org.settings.change_visibility"}}</button>
</div> </div>
</form> </form>
</div> </div>

View File

@ -0,0 +1,25 @@
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,6 +33,7 @@ import {initRepoActivityTopAuthorsChart, initRepoArchiveLinks} from './features/
import {initRepoMigrationStatusChecker} from './features/repo-migrate.ts'; import {initRepoMigrationStatusChecker} from './features/repo-migrate.ts';
import {initRepoDiffView} from './features/repo-diff.ts'; import {initRepoDiffView} from './features/repo-diff.ts';
import {initOrgTeam} from './features/org-team.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 {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.ts';
import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.ts'; import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.ts';
import {initRepoEditor} from './features/repo-editor.ts'; import {initRepoEditor} from './features/repo-editor.ts';
@ -120,6 +121,7 @@ const initPerformanceTracer = callInitFunctions([
initNotificationsTable, initNotificationsTable,
initOrgTeam, initOrgTeam,
initOrgSettings,
initRepoActivityTopAuthorsChart, initRepoActivityTopAuthorsChart,
initRepoArchiveLinks, initRepoArchiveLinks,