diff --git a/frontend/src/components/resources/alerter/config.tsx b/frontend/src/components/resources/alerter/config.tsx index 5080b7e2f..f92e86864 100644 --- a/frontend/src/components/resources/alerter/config.tsx +++ b/frontend/src/components/resources/alerter/config.tsx @@ -11,6 +11,9 @@ import { import { useEffect, useState } from "react"; export const AlerterConfig = ({ id }: { id: string }) => { + const perms = useRead("GetPermissionLevel", { + target: { type: "Alerter", id }, + }).data; const config = useRead("GetAlerter", { alerter: id }).data?.config; const [type, setType] = useState(); useEffect(() => config?.type && setType(config.type), [config?.type]); @@ -20,8 +23,11 @@ export const AlerterConfig = ({ id }: { id: string }) => { const { mutate } = useWrite("UpdateAlerter"); if (!config) return null; + const disabled = perms !== Types.PermissionLevel.Write; + return ( { + const perms = useRead("GetPermissionLevel", { + target: { type: "Build", id }, + }).data; const config = useRead("GetBuild", { build: id }).data?.config; const docker_organizations = useRead("ListDockerOrganizations", {}).data; const [update, set] = useState>({}); @@ -29,8 +32,11 @@ export const BuildConfig = ({ id }: { id: string }) => { if (!config) return null; + const disabled = perms !== Types.PermissionLevel.Write; + return ( { account_type="github" selected={account} onSelect={(github_account) => set({ github_account })} + disabled={disabled} /> ), }, @@ -107,6 +114,7 @@ export const BuildConfig = ({ id }: { id: string }) => { account_type="docker" selected={account} onSelect={(docker_account) => set({ docker_account })} + disabled={disabled} /> ), docker_organization: @@ -114,12 +122,16 @@ export const BuildConfig = ({ id }: { id: string }) => { docker_organizations.length === 0 ? undefined : (value, set) => ( - + ), use_buildx: true, - labels: (l, set) => , + labels: (l, set) => , extra_args: (value, set) => ( - + ), }, pre_build: { @@ -128,6 +140,7 @@ export const BuildConfig = ({ id }: { id: string }) => { label="Pre Build" value={value} set={(value) => set({ pre_build: value })} + disabled={disabled} /> ), }, @@ -135,7 +148,7 @@ export const BuildConfig = ({ id }: { id: string }) => { "Build Args": { "Build Args": { build_args: (vars, set) => ( - + ), skip_secret_interp: true, }, @@ -148,9 +161,11 @@ export const BuildConfig = ({ id }: { id: string }) => { const BuildArgs = ({ vars, set, + disabled, }: { vars: Types.EnvironmentVar[]; set: (input: Partial) => void; + disabled: boolean; }) => { const [args, setArgs] = useState(env_to_text(vars)); useEffect(() => { @@ -164,6 +179,7 @@ const BuildArgs = ({ placeholder="VARIABLE=value" value={args} onChange={(e) => setArgs(e.target.value)} + disabled={disabled} /> ); @@ -172,9 +188,11 @@ const BuildArgs = ({ const ExtraArgs = ({ args, set, + disabled, }: { args: string[]; set: (update: Partial) => void; + disabled: boolean; }) => { return ( @@ -188,15 +206,18 @@ const ExtraArgs = ({ args[i] = e.target.value; set({ extra_args: [...args] }); }} + disabled={disabled} /> - + {!disabled && ( + + )} ))} @@ -215,9 +236,11 @@ const ExtraArgs = ({ const DockerOrganizations = ({ value, set, + disabled, }: { value?: string; set: (input: Partial) => void; + disabled: boolean; }) => { const docker_organizations = useRead("ListDockerOrganizations", {}).data; return ( @@ -225,8 +248,12 @@ const DockerOrganizations = ({ set({ github_account: value })} + disabled={disabled} > - + diff --git a/frontend/src/components/resources/server/config.tsx b/frontend/src/components/resources/server/config.tsx index a4015614d..b63b06056 100644 --- a/frontend/src/components/resources/server/config.tsx +++ b/frontend/src/components/resources/server/config.tsx @@ -4,6 +4,9 @@ import { Types } from "@monitor/client"; import { useState } from "react"; export const ServerConfig = ({ id }: { id: string }) => { + const perms = useRead("GetPermissionLevel", { + target: { type: "Server", id }, + }).data; const invalidate = useInvalidate(); const config = useRead("GetServer", { server: id }).data?.config; const [update, set] = useState>({}); @@ -15,8 +18,11 @@ export const ServerConfig = ({ id }: { id: string }) => { }); if (!config) return null; + const disabled = perms !== Types.PermissionLevel.Write; + return (