Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
124 lines
3.8 KiB
TypeScript
124 lines
3.8 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import { Loader2, UserMinus } from "lucide-react";
|
|
import {
|
|
ASSIGNABLE_WORKSPACE_ROLES,
|
|
type AssignableWorkspaceRole,
|
|
type Member,
|
|
type WorkspaceRole,
|
|
} from "@/lib/types";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Select } from "@/components/ui/select";
|
|
import { roleBadgeVariant, roleLabel } from "@/components/team/roles";
|
|
|
|
export interface MemberRowProps {
|
|
member: Member;
|
|
/** Is this row the signed-in caller? */
|
|
isSelf: boolean;
|
|
/** May the caller manage members (owner/admin)? */
|
|
canManage: boolean;
|
|
/** True while this row's role change / removal is in flight. */
|
|
pending: boolean;
|
|
/** Per-row error (role change / removal), if any. */
|
|
rowError?: string;
|
|
onChangeRole: (userId: string, role: WorkspaceRole) => void;
|
|
onRemove: (userId: string) => void;
|
|
}
|
|
|
|
/**
|
|
* One member row: identity + role, with role-change and remove controls shown
|
|
* only when the caller can manage AND the target is neither the caller nor an
|
|
* owner (owners are not demoted/removed through this UI). Purely presentational.
|
|
*/
|
|
export function MemberRow({
|
|
member,
|
|
isSelf,
|
|
canManage,
|
|
pending,
|
|
rowError,
|
|
onChangeRole,
|
|
onRemove,
|
|
}: Readonly<MemberRowProps>) {
|
|
const isOwner = member.role === "owner";
|
|
// Owners and the caller's own row are never mutated here.
|
|
const showControls = canManage && !isSelf && !isOwner;
|
|
const displayName = member.name?.trim() || member.email;
|
|
|
|
return (
|
|
<li className="flex flex-col gap-2 border-b border-border px-1 py-3 last:border-b-0 sm:flex-row sm:items-center sm:justify-between">
|
|
<div className="min-w-0">
|
|
<div className="flex items-center gap-2">
|
|
<span className="truncate font-medium">{displayName}</span>
|
|
{isSelf && (
|
|
<Badge variant="outline" className="shrink-0">
|
|
You
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
{member.name?.trim() && (
|
|
<span className="block truncate text-sm text-muted-foreground">
|
|
{member.email}
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
{showControls ? (
|
|
<>
|
|
<Select
|
|
aria-label={`Role for ${displayName}`}
|
|
className="h-8 w-32 text-sm"
|
|
value={
|
|
(ASSIGNABLE_WORKSPACE_ROLES as readonly string[]).includes(
|
|
member.role,
|
|
)
|
|
? member.role
|
|
: "member"
|
|
}
|
|
disabled={pending}
|
|
onChange={(e) =>
|
|
onChangeRole(
|
|
member.user_id,
|
|
e.target.value as AssignableWorkspaceRole,
|
|
)
|
|
}
|
|
>
|
|
{ASSIGNABLE_WORKSPACE_ROLES.map((r) => (
|
|
<option key={r} value={r}>
|
|
{roleLabel(r)}
|
|
</option>
|
|
))}
|
|
</Select>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="size-8 text-muted-foreground hover:text-destructive"
|
|
aria-label={`Remove ${displayName}`}
|
|
disabled={pending}
|
|
onClick={() => onRemove(member.user_id)}
|
|
>
|
|
{pending ? (
|
|
<Loader2 className="size-4 animate-spin" aria-hidden />
|
|
) : (
|
|
<UserMinus className="size-4" aria-hidden />
|
|
)}
|
|
</Button>
|
|
</>
|
|
) : (
|
|
<Badge variant={roleBadgeVariant(member.role)}>
|
|
{roleLabel(member.role)}
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
|
|
{rowError && (
|
|
<p className="w-full text-sm text-destructive sm:text-right" role="alert">
|
|
{rowError}
|
|
</p>
|
|
)}
|
|
</li>
|
|
);
|
|
}
|