Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Clean up staff status badges

Manav Rathifdf1d75b7afc
diff --git a/infra/staff/src/components/FamilyComponentTable.tsx b/infra/staff/src/components/FamilyComponentTable.tsx
index 4e0168288b..f251e0afbc 100644
--- a/infra/staff/src/components/FamilyComponentTable.tsx
+++ b/infra/staff/src/components/FamilyComponentTable.tsx
@@ -14,6 +14,7 @@ import React, { useEffect, useState } from "react";
import { useInitialStaffSession } from "../services/session";
import { getCurrentAdminUser } from "../services/support";
import { CloseFamily } from "./CloseFamily";
+import { StatusBadge } from "./StatusBadge";
interface FamilyMember {
id: string;
@@ -104,24 +105,14 @@ export const FamilyTableComponent: React.FC = () => {
<TableCell>{member.id}</TableCell>
<TableCell>{member.email}</TableCell>
<TableCell>
- <span
- style={{
- backgroundColor:
- member.status === "SELF"
- ? "#00B33C"
- : "transparent",
- color:
- member.status === "SELF"
- ? "white"
- : "inherit",
- padding: "4px 8px",
- borderRadius: "10px",
- }}
+ <StatusBadge
+ highlighted={member.status === "SELF"}
+ tone="success"
>
{member.status === "SELF"
? "ADMIN"
: member.status}
- </span>
+ </StatusBadge>
</TableCell>
<TableCell>
{formatUsageToGB(member.usage)}
diff --git a/infra/staff/src/components/StatusBadge.tsx b/infra/staff/src/components/StatusBadge.tsx
new file mode 100644
index 0000000000..5d758fcdef
--- /dev/null
+++ b/infra/staff/src/components/StatusBadge.tsx
@@ -0,0 +1,32 @@
+import { Box } from "@mui/material";
+import type { ReactNode } from "react";
+
+type StatusBadgeTone = "success" | "neutral";
+
+interface StatusBadgeProps {
+ children: ReactNode;
+ highlighted: boolean;
+ tone?: StatusBadgeTone;
+}
+
+export const StatusBadge = ({
+ children,
+ highlighted,
+ tone = "neutral",
+}: StatusBadgeProps) => (
+ <Box
+ component="span"
+ sx={{
+ bgcolor: highlighted ? statusBadgeColor(tone) : "transparent",
+ borderRadius: "10px",
+ color: highlighted ? "white" : "inherit",
+ px: 1,
+ py: 0.5,
+ }}
+ >
+ {children}
+ </Box>
+);
+
+const statusBadgeColor = (tone: StatusBadgeTone) =>
+ tone === "success" ? "#00B33C" : "#494949";
diff --git a/infra/staff/src/components/StorageBonusTableComponent.tsx b/infra/staff/src/components/StorageBonusTableComponent.tsx
index e6dcf1f7c6..aec2082806 100644
--- a/infra/staff/src/components/StorageBonusTableComponent.tsx
+++ b/infra/staff/src/components/StorageBonusTableComponent.tsx
@@ -10,6 +10,7 @@ import {
import React, { useEffect, useState } from "react";
import { useInitialStaffSession } from "../services/session";
import { getCurrentAdminUser } from "../services/support";
+import { StatusBadge } from "./StatusBadge";
interface BonusData {
storage: number;
@@ -98,20 +99,9 @@ export const StorageBonusTableComponent: React.FC = () => {
{formatValidTill(bonus.validTill)}
</TableCell>
<TableCell>
- <span
- style={{
- backgroundColor: bonus.isRevoked
- ? "#494949"
- : "transparent",
- color: bonus.isRevoked
- ? "white"
- : "inherit",
- padding: "4px 8px",
- borderRadius: "10px",
- }}
- >
+ <StatusBadge highlighted={bonus.isRevoked}>
{bonus.isRevoked ? "Yes" : "No"}
- </span>
+ </StatusBadge>
</TableCell>
</TableRow>
))}
diff --git a/infra/staff/src/components/TokenTableComponent.tsx b/infra/staff/src/components/TokenTableComponent.tsx
index a8ddcd1bdf..49b6a3a94c 100644
--- a/infra/staff/src/components/TokenTableComponent.tsx
+++ b/infra/staff/src/components/TokenTableComponent.tsx
@@ -11,6 +11,7 @@ import {
import React, { useEffect, useMemo, useState } from "react";
import { useInitialStaffSession } from "../services/session";
import { getCurrentAdminUser } from "../services/support";
+import { StatusBadge } from "./StatusBadge";
interface TokenData {
creationTime: number;
@@ -144,20 +145,9 @@ export const TokensTableComponent: React.FC = () => {
<TableCell>{token.ua || "-"}</TableCell>
<TableCell>{token.app}</TableCell>
<TableCell>
- <span
- style={{
- backgroundColor: token.isDeleted
- ? "#494949"
- : "transparent",
- color: token.isDeleted
- ? "white"
- : "inherit",
- padding: "4px 8px",
- borderRadius: "10px",
- }}
- >
+ <StatusBadge highlighted={token.isDeleted}>
{token.isDeleted ? "Yes" : "No"}
- </span>
+ </StatusBadge>
</TableCell>
</TableRow>
))}