diff --git a/frontend/routes/@[scope]/(_islands)/ScopeInviteForm.tsx b/frontend/routes/@[scope]/(_islands)/ScopeInviteForm.tsx index ed5c07c5..1fb2d689 100644 --- a/frontend/routes/@[scope]/(_islands)/ScopeInviteForm.tsx +++ b/frontend/routes/@[scope]/(_islands)/ScopeInviteForm.tsx @@ -4,6 +4,7 @@ import { useCallback, useRef } from "preact/hooks"; import { JSX } from "preact/jsx-runtime"; import { ScopeInvite } from "../../../utils/api_types.ts"; import { api, path } from "../../../utils/api.ts"; +import TbUsersPlus from "@preact-icons/tb/TbUsersPlus"; interface ScopeInviteFormProps { scope: string; @@ -53,7 +54,7 @@ export function ScopeInviteForm(props: ScopeInviteFormProps) { class="contents" onSubmit={onSubmit} > -
+
+ {(isLastAdmin || isInvalidInput.value) && ( +
+ Warning +

+ {isLastAdmin && + "You are the last admin in this scope. You must promote another member to admin before leaving."} + {isInvalidInput.value && + "The scope name you entered does not match the scope name."} +

+
+ )} +
+ { + scopeInput.value = (e.target as HTMLInputElement).value; + }} + placeholder="Scope name" + disabled={isLastAdmin} + title={isLastAdmin + ? "This is the last admin in this scope. Promote another member to admin before demoting this one." + : undefined} + /> + +
+ + ); +} diff --git a/frontend/routes/@[scope]/~/members.tsx b/frontend/routes/@[scope]/~/members.tsx index 32f860b8..a9f235be 100644 --- a/frontend/routes/@[scope]/~/members.tsx +++ b/frontend/routes/@[scope]/~/members.tsx @@ -18,6 +18,7 @@ import { scopeData } from "../../../utils/data.ts"; import TbTrash from "@preact-icons/tb/TbTrash"; import { scopeIAM } from "../../../utils/iam.ts"; import { ScopeIAM } from "../../../utils/iam.ts"; +import { ScopeMemberLeave } from "../(_islands)/ScopeMemberLeave.tsx"; export default define.page(function ScopeMembersPage( { params, data, state, url }, @@ -70,10 +71,11 @@ export default define.page(function ScopeMembersPage( {iam.canAdmin && } {data.scopeMember && ( - )}
@@ -195,43 +197,6 @@ function MemberInvite({ scope }: { scope: string }) { ); } -function MemberLeave( - props: { userId: string; isAdmin: boolean; isLastAdmin: boolean }, -) { - return ( -
-

Leave scope

-

- Leaving this scope will revoke your access to all packages in this - scope. You will no longer be able to publish packages to this - scope{props.isAdmin && " or manage members"}. -

- - {props.isLastAdmin && ( -
- Warning -

- You are the last admin in this scope. You must promote another - member to admin before leaving. -

-
- )} - -
- ); -} - export const handler = define.handlers({ async GET(ctx) { let [user, data, membersResp, invitesResp] = await Promise.all([