Skip to content

Commit ab60348

Browse files
committed
Allowing setting secret env vars
1 parent d930104 commit ab60348

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new/route.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { useList } from "~/hooks/useList";
4040
import { useOrganization } from "~/hooks/useOrganizations";
4141
import { useProject } from "~/hooks/useProject";
4242
import { EnvironmentVariablesPresenter } from "~/presenters/v3/EnvironmentVariablesPresenter.server";
43+
import { logger } from "~/services/logger.server";
4344
import { requireUserId } from "~/services/session.server";
4445
import { cn } from "~/utils/cn";
4546
import {
@@ -87,6 +88,10 @@ const schema = z.object({
8788
if (i === "false") return false;
8889
return;
8990
}, z.boolean()),
91+
isSecret: z.preprocess((i) => {
92+
if (i === "true") return true;
93+
return false;
94+
}, z.boolean()),
9095
environmentIds: z.preprocess((i) => {
9196
if (typeof i === "string") return [i];
9297

@@ -194,7 +199,7 @@ export default function Page() {
194199
shouldRevalidate: "onSubmit",
195200
});
196201

197-
const [revealAll, setRevealAll] = useState(false);
202+
const [revealAll, setRevealAll] = useState(true);
198203

199204
useEffect(() => {
200205
setIsOpen(true);
@@ -257,6 +262,15 @@ export default function Page() {
257262
file when running locally.
258263
</Hint>
259264
</InputGroup>
265+
<InputGroup className="w-auto">
266+
<Switch
267+
name="isSecret"
268+
variant="large"
269+
label="Secret?"
270+
defaultChecked={false}
271+
value="true"
272+
/>
273+
</InputGroup>
260274
<InputGroup fullWidth>
261275
<FieldLayout showDeleteButton={false}>
262276
<Label>Keys</Label>

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables/route.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,6 @@ function EditEnvironmentVariablePanel({
330330
variable: EnvironmentVariableWithSetValues;
331331
revealAll: boolean;
332332
}) {
333-
const [reveal, setReveal] = useState(revealAll);
334-
335333
const [isOpen, setIsOpen] = useState(false);
336334
const lastSubmission = useActionData();
337335
const navigation = useNavigation();
@@ -351,8 +349,6 @@ function EditEnvironmentVariablePanel({
351349
shouldRevalidate: "onSubmit",
352350
});
353351

354-
console.log("edit form", { form, variable, id, environmentId, value });
355-
356352
return (
357353
<Dialog open={isOpen} onOpenChange={setIsOpen}>
358354
<DialogTrigger asChild>
@@ -380,21 +376,13 @@ function EditEnvironmentVariablePanel({
380376
</InputGroup>
381377
<EnvironmentCombo environment={variable.environment} className="text-sm" />
382378

383-
<div className="flex justify-between gap-1">
384-
<Switch
385-
variant="small"
386-
label="Reveal"
387-
checked={reveal}
388-
onCheckedChange={(e) => setReveal(e.valueOf())}
389-
/>
390-
</div>
391379
<InputGroup fullWidth>
392380
<Label>Value</Label>
393381
<Input
394382
{...conform.input(value, { type: "text" })}
395383
placeholder={variable.isSecret ? "Set new secret value" : "Not set"}
396384
defaultValue={variable.value}
397-
type={reveal ? "text" : "password"}
385+
type={"text"}
398386
/>
399387
<FormError id={value.errorId}>{value.error}</FormError>
400388
</InputGroup>

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class EnvironmentVariablesRepository implements Repository {
5151
options: {
5252
override: boolean;
5353
environmentIds: string[];
54+
isSecret?: boolean;
5455
variables: {
5556
key: string;
5657
value: string;
@@ -187,8 +188,11 @@ export class EnvironmentVariablesRepository implements Repository {
187188
variableId: environmentVariable.id,
188189
environmentId: environmentId,
189190
valueReferenceId: secretReference.id,
191+
isSecret: options.isSecret,
192+
},
193+
update: {
194+
isSecret: options.isSecret,
190195
},
191-
update: {},
192196
});
193197

194198
await secretStore.setSecret<{ secret: string }>(key, {

0 commit comments

Comments
 (0)