feat: several owners per organization, and handing ownership over
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
An organization may now have several owners; the unique index allowing only one is gone. Owners make members owners or take it back, their own included, through PUT /api/v1/org/members/:user/owner; handing an organization over is making someone else owner and stepping down. The last owner cannot step down, and changes serialize on a per-organization lock so two owners stepping down at once cannot leave none. A former owner without roles keeps working as Admin. Owners still cannot be removed while they are owners. Deleting an account now takes along only the organizations it is the last owner of, counted under the same lock; it just leaves those with further owners. The members page offers "Make owner", "Remove as owner" and "Step down as owner" to owners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
8d7c1f856c
commit
db3ff19983
23 files changed
+558
-115
No files matched your search
@@ -50,6 +50,11 @@ type MembersView struct {
|
||||
// Scopes are the resources an assignment can be limited to; values are
|
||||
// "<resource_type>:<id>".
|
||||
Scopes []ScopeOption
|
||||
// IsOwner is set when the viewer owns the organization and so decides
|
||||
// who else does; Self is the viewer, Owners counts the owners.
|
||||
IsOwner bool
|
||||
Self string
|
||||
Owners int
|
||||
}
|
||||
|
||||
// ScopeOption is a resource an assignment can be limited to.
|
||||
@@ -121,6 +126,7 @@ templ MembersPage(p Page, me Me, v MembersView) {
|
||||
</ul>
|
||||
</td>
|
||||
<td class="py-2.5 text-right">
|
||||
@ownerAction(v, m)
|
||||
if v.CanManage && !m.IsOwner {
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
@@ -488,3 +494,26 @@ templ tokenUsage() {
|
||||
<a href="/api/docs" class="text-ink underline underline-offset-2">{ i18n.T(ctx, "apidocs.title") }</a>
|
||||
</p>
|
||||
}
|
||||
|
||||
// ownerAction lets owners make a member an owner or take it back, their
|
||||
// own included, as long as another owner remains.
|
||||
templ ownerAction(v MembersView, m Member) {
|
||||
if v.IsOwner {
|
||||
switch {
|
||||
case !m.IsOwner:
|
||||
@ownerForm(m.UserID, true, i18n.T(ctx, "members.make_owner"), i18n.T(ctx, "members.make_owner_confirm", "Email", m.Email))
|
||||
case v.Owners > 1 && m.UserID == v.Self:
|
||||
@ownerForm(m.UserID, false, i18n.T(ctx, "members.step_down"), i18n.T(ctx, "members.step_down_confirm"))
|
||||
case v.Owners > 1:
|
||||
@ownerForm(m.UserID, false, i18n.T(ctx, "members.remove_owner"), i18n.T(ctx, "members.remove_owner_confirm", "Email", m.Email))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ ownerForm(user string, owner bool, label, confirm string) {
|
||||
<form data-api={ "/org/members/" + user + "/owner" } data-method="put" data-next="/settings/members" data-confirm={ confirm } class="mb-2 inline-block">
|
||||
<input type="checkbox" name="owner" checked?={ owner } hidden/>
|
||||
<button type="submit" class="text-sm text-muted underline-offset-2 hover:text-ink hover:underline">{ label }</button>
|
||||
<p data-error class="hidden text-xs text-down"></p>
|
||||
</form>
|
||||
}
|
||||
Reference in new issue
Block a user