videogen/apps/mobile/components/team/PermissionsCard.tsx
caelum0x d56639a594
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
Menivor — open source release (MIT), free to use and fork
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.
2026-12-04 02:10:26 +03:00

105 lines
2.7 KiB
TypeScript

/**
* Presentational card for a caller's effective access in a workspace: their role
* badge plus a chip per granted permission. All data comes from
* {@link getMyPermissions}; a non-member (`role === null`) renders a clear
* "not a member" message with no permission chips (the tenant-isolation signal).
*/
import { StyleSheet, Text, View } from "react-native";
import type { Permissions } from "@/lib/types";
import { colors } from "@/components/me/theme";
import { roleLabel } from "./roles";
/** Friendly labels for the Enterprise permission catalog (falls back to the id). */
const PERMISSION_LABELS: Readonly<Record<string, string>> = {
"jobs.read": "View jobs",
"jobs.create": "Create jobs",
"members.manage": "Manage members",
"workspace.settings": "Workspace settings",
"billing.manage": "Manage billing",
"audit.read": "Read audit log",
"admin.access": "Full access",
};
function permissionLabel(permission: string): string {
return PERMISSION_LABELS[permission] ?? permission;
}
export function PermissionsCard({
permissions,
}: {
permissions: Readonly<Permissions>;
}) {
if (!permissions.role) {
return (
<Text style={styles.empty}>
You are not a member of this workspace.
</Text>
);
}
return (
<View style={styles.card}>
<View style={styles.roleRow}>
<Text style={styles.roleLabel}>Your role</Text>
<Text style={styles.roleBadge}>{roleLabel(permissions.role)}</Text>
</View>
{permissions.permissions.length > 0 ? (
<View style={styles.chips}>
{permissions.permissions.map((permission) => (
<Text key={permission} style={styles.chip}>
{permissionLabel(permission)}
</Text>
))}
</View>
) : (
<Text style={styles.empty}>No permissions granted.</Text>
)}
</View>
);
}
const styles = StyleSheet.create({
card: {
backgroundColor: colors.card,
borderColor: colors.border,
borderWidth: 1,
borderRadius: 12,
padding: 14,
gap: 12,
},
roleRow: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
gap: 12,
},
roleLabel: { color: colors.muted, fontSize: 13 },
roleBadge: {
color: colors.accent,
fontSize: 13,
fontWeight: "800",
letterSpacing: 0.5,
},
chips: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
chip: {
color: colors.textSecondary,
fontSize: 12,
backgroundColor: colors.cardAlt,
borderColor: colors.border,
borderWidth: 1,
borderRadius: 999,
paddingHorizontal: 12,
paddingVertical: 6,
overflow: "hidden",
},
empty: {
color: colors.muted,
fontSize: 13,
lineHeight: 18,
paddingVertical: 8,
},
});