diff --git a/src/pages/admin/settings/(partials)/envs/env-row.tsx b/src/pages/admin/settings/(partials)/envs/env-row.tsx index 88b7f37..f7b8201 100644 --- a/src/pages/admin/settings/(partials)/envs/env-row.tsx +++ b/src/pages/admin/settings/(partials)/envs/env-row.tsx @@ -2,10 +2,16 @@ import { useState } from "react"; import Row from "@moduletrace/twui/layout/Row"; import Span from "@moduletrace/twui/layout/Span"; import Stack from "@moduletrace/twui/layout/Stack"; -import type { EnvScope, EnvsMutationResult, KnownEnvStatus, PublicEnv } from "@/src/types"; +import type { + EnvScope, + EnvsMutationResult, + KnownEnvStatus, + PublicEnv, +} from "@/src/types"; import postEnvApi from "../../(functions)/post-env-api"; import EnvForm from "./env-form"; import EnvRowActions from "./env-row-actions"; +import { twMerge } from "tailwind-merge"; type Props = { scope: EnvScope; @@ -27,14 +33,26 @@ type Props = { * One env: its key, description and value (or "secret"), with Edit and * Remove. Edit opens the form in place. */ -export default function EnvRow({ scope, env, known, scoped, onChanged, onError }: Props) { +export default function EnvRow({ + scope, + env, + known, + scoped, + onChanged, + onError, +}: Props) { const [editing, setEditing] = useState(false); const [busy, setBusy] = useState(false); const key = env?.key || known?.key || ""; const remove = async () => { if (!env || busy) return; - if (!window.confirm(`Remove ${key}? Computers drop it on their next run.`)) return; + if ( + !window.confirm( + `Remove ${key}? Computers drop it on their next run.`, + ) + ) + return; setBusy(true); const res = await postEnvApi({ @@ -43,7 +61,8 @@ export default function EnvRow({ scope, env, known, scoped, onChanged, onError } }); setBusy(false); - if (res.success && res.singleRes) onChanged(res.singleRes, res.msg || "Removed."); + if (res.success && res.singleRes) + onChanged(res.singleRes, res.msg || "Removed."); else onError(res.msg || "Couldn't remove the env."); }; @@ -72,12 +91,22 @@ export default function EnvRow({ scope, env, known, scoped, onChanged, onError } ? "From the server's environment" : "Not set"; - const flags = env && !env.known && !env.expose_to_computers ? " · not on computers" : ""; + const flags = + env && !env.known && !env.expose_to_computers + ? " · not on computers" + : ""; return ( - + - {key} + + {key} + {env?.description || known?.description ? ( {known?.description || env?.description} diff --git a/src/pages/admin/settings/(partials)/envs/envs-group.tsx b/src/pages/admin/settings/(partials)/envs/envs-group.tsx index 58948eb..233c256 100644 --- a/src/pages/admin/settings/(partials)/envs/envs-group.tsx +++ b/src/pages/admin/settings/(partials)/envs/envs-group.tsx @@ -34,20 +34,34 @@ type Props = { }; const Descriptions: Record = { - general: "Set everywhere. A workspace, a bot or a computer can set the same key to override it.", - workspace: "For every bot working here. Beats general, loses to the bot's own.", - computer: "For this computer only. Beats a workspace, loses to the bot's own.", + general: + "Set everywhere. A workspace, a bot or a computer can set the same key to override it.", + workspace: + "For every bot working here. Beats general, loses to the bot's own.", + computer: + "For this computer only. Beats a workspace, loses to the bot's own.", bot: "For this bot only, everywhere it works. Beats the workspace, the computer and general.", }; /** * The envs bots and computers use, in one scope, with an add form. */ -export default function EnvsGroup({ scope, envs, scoped, title, status, onChanged, onError }: Props) { +export default function EnvsGroup({ + scope, + envs, + scoped, + title, + status, + onChanged, + onError, +}: Props) { const [adding, setAdding] = useState(false); return ( - + {envs.map((env) => (