Skip to content

Commit

Permalink
misc: updated secret path component
Browse files Browse the repository at this point in the history
  • Loading branch information
sheensantoscapadngan committed Jul 2, 2024
1 parent fe9af20 commit 776822d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend/src/services/webhook/webhook-fns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const getWebhookPayload = (
switch (type) {
case WebhookType.SLACK:
return {
text: "A secret value has been updated",
text: "A secret value has been added or modified.",
attachments: [
{
color: "#E7F256",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import z from "zod";

import GlobPatternExamples from "@app/components/basic/popups/GlobPatternExamples";
import {
Button,
FormControl,
Expand All @@ -14,6 +13,7 @@ import {
Select,
SelectItem
} from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";

enum WebhookType {
GENERAL = "general",
Expand Down Expand Up @@ -67,7 +67,8 @@ export const AddWebhookForm = ({
}
});

const webhookType = watch("type");
const selectedWebhookType = watch("type");
const selectedEnvironment = watch("environment");

const generalFormFields = (
<>
Expand Down Expand Up @@ -165,20 +166,22 @@ export const AddWebhookForm = ({
</FormControl>
)}
/>
<FormControl
label="Secret Path"
icon={<GlobPatternExamples />}
isRequired
isError={Boolean(errors?.secretPath)}
errorText={errors?.secretPath?.message}
helperText="Glob patterns are used to match multiple files or directories"
>
<Input
placeholder="glob pattern / or /**/* or /{dir1,dir2}"
{...register("secretPath")}
/>
</FormControl>
{webhookType === WebhookType.SLACK ? slackFormFields : generalFormFields}
<Controller
control={control}
defaultValue=""
name="secretPath"
render={({ field, fieldState: { error } }) => (
<FormControl
label="Secret Path"
isRequired
isError={Boolean(error)}
errorText={error?.message}
>
<SecretPathInput {...field} environment={selectedEnvironment} placeholder="/" />
</FormControl>
)}
/>
{selectedWebhookType === WebhookType.SLACK ? slackFormFields : generalFormFields}
</div>
<div className="mt-8 flex items-center">
<Button
Expand Down

0 comments on commit 776822d

Please sign in to comment.