Skip to content

Commit 33075e7

Browse files
committed
improvements
1 parent fe350ae commit 33075e7

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

options/locale/locale_en-US.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,11 +2843,11 @@ settings.visibility = Visibility
28432843
settings.change_visibility = Change Visibility
28442844
settings.invalid_visibility = The new visibility is not valid.
28452845
settings.change_visibility_notices_1 = This operation <strong>CANNOT</strong> be undone.
2846-
settings.change_visibility_notices_2 = Some users will no longer be able to access the organization’s repositories.
2847-
settings.change_visibility_no_change = There has been no change in visibility.
2846+
settings.change_visibility_notices_2 = Non-members will lose access to the organization’s repositories if visibility is changed to private.
2847+
settings.change_visibility_no_change = You did not make any changes to visibility.
28482848
settings.change_visibility_failed = Failed to change the visibility of %s due to an internal error.
28492849
settings.change_visibility_success = The visibility of organization %s has been successfully changed.
2850-
settings.visibility_desc = Change the organization visibility
2850+
settings.visibility_desc = Change who can view the organization and its repositories.
28512851
settings.visibility.public = Public
28522852
settings.visibility.limited = Limited (Visible to authenticated users only)
28532853
settings.visibility.limited_shortname = Limited

routers/web/org/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func SettingsRenamePost(ctx *context.Context) {
233233

234234
// SettingsChangeVisibilityPost response for change organization visibility
235235
func SettingsChangeVisibilityPost(ctx *context.Context) {
236-
visibility := structs.VisibleType(ctx.FormInt("visibility"))
236+
visibility := structs.VisibilityModes[ctx.FormString("visibility")]
237237
if !visibility.IsValid() {
238238
ctx.JSONError(ctx.Tr("org.settings.invalid_visibility"))
239239
return

templates/org/settings/options_dangerzone.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,26 @@
4848
</div>
4949
<form class="ui form form-fetch-action" action="{{.Link}}/visibility" method="post">
5050
{{.CsrfTokenHtml}}
51+
<input type="hidden" name="current_visibility" value="{{.CurrentVisibility}}">
5152
<div class="tw-flex tw-flex-col tw-gap-3">
5253
<label>{{ctx.Locale.Tr "org.settings.visibility"}}</label>
5354
<div class="ui radio checkbox">
54-
<input name="visibility" type="radio" value="0" {{if eq .CurrentVisibility 0}}checked{{end}}>
55+
<input name="visibility" type="radio" value="public" {{if .CurrentVisibility.IsPublic}}checked{{end}}>
5556
<label>{{ctx.Locale.Tr "org.settings.visibility.public"}}</label>
5657
</div>
5758
<div class="ui radio checkbox">
58-
<input name="visibility" type="radio" value="1" {{if eq .CurrentVisibility 1}}checked{{end}}>
59+
<input name="visibility" type="radio" value="limited" {{if .CurrentVisibility.IsLimited}}checked{{end}}>
5960
<label>{{ctx.Locale.Tr "org.settings.visibility.limited"}}</label>
6061
</div>
6162
<div class="ui radio checkbox">
62-
<input name="visibility" type="radio" value="2" {{if eq .CurrentVisibility 2}}checked{{end}}>
63+
<input name="visibility" type="radio" value="private" {{if .CurrentVisibility.IsPrivate}}checked{{end}}>
6364
<label>{{ctx.Locale.Tr "org.settings.visibility.private"}}</label>
6465
</div>
6566
</div>
6667

6768
<div class="actions">
6869
<button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button>
69-
<button class="ui red button">{{ctx.Locale.Tr "org.settings.change_visibility"}}</button>
70+
<button id="change-visibility-submit" class="ui red button" disabled>{{ctx.Locale.Tr "org.settings.change_visibility"}}</button>
7071
</div>
7172
</form>
7273
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function initOrgVisibilityChange() {
2+
const visibilityModal = document.querySelector('#change-visibility-org-modal');
3+
if (!visibilityModal) return;
4+
5+
const visibilitySelect = visibilityModal.querySelectorAll<HTMLInputElement>("input[name='visibility']");
6+
if (!visibilitySelect) return;
7+
8+
const currentValue = visibilityModal.querySelector<HTMLInputElement>('input[name="current_visibility"]').value;
9+
10+
for (const radio of visibilitySelect) {
11+
radio.addEventListener('change', () => {
12+
const selectedValue = visibilityModal.querySelector<HTMLInputElement>("input[name='visibility']:checked").value;
13+
const btn = visibilityModal.querySelector<HTMLButtonElement>('#change-visibility-submit');
14+
if (selectedValue === currentValue) {
15+
btn.setAttribute('disabled', '');
16+
} else {
17+
btn.removeAttribute('disabled');
18+
}
19+
});
20+
}
21+
}
22+
23+
export function initOrgSettings() {
24+
initOrgVisibilityChange();
25+
}

web_src/js/index-domready.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {initRepoActivityTopAuthorsChart, initRepoArchiveLinks} from './features/
3333
import {initRepoMigrationStatusChecker} from './features/repo-migrate.ts';
3434
import {initRepoDiffView} from './features/repo-diff.ts';
3535
import {initOrgTeam} from './features/org-team.ts';
36+
import {initOrgSettings} from './features/org-settings.ts';
3637
import {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.ts';
3738
import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.ts';
3839
import {initRepoEditor} from './features/repo-editor.ts';
@@ -120,6 +121,7 @@ const initPerformanceTracer = callInitFunctions([
120121
initNotificationsTable,
121122

122123
initOrgTeam,
124+
initOrgSettings,
123125

124126
initRepoActivityTopAuthorsChart,
125127
initRepoArchiveLinks,

0 commit comments

Comments
 (0)