misc: updated secret path component

This commit is contained in:
Sheen Capadngan
2024-07-02 20:54:27 +08:00
parent fe9af20d8c
commit 776822d7d5
2 changed files with 20 additions and 17 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ export const getWebhookPayload = (
switch (type) { switch (type) {
case WebhookType.SLACK: case WebhookType.SLACK:
return { return {
text: "A secret value has been updated", text: "A secret value has been added or modified.",
attachments: [ attachments: [
{ {
color: "#E7F256", color: "#E7F256",
@@ -3,7 +3,6 @@ import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import z from "zod"; import z from "zod";
import GlobPatternExamples from "@app/components/basic/popups/GlobPatternExamples";
import { import {
Button, Button,
FormControl, FormControl,
@@ -14,6 +13,7 @@ import {
Select, Select,
SelectItem SelectItem
} from "@app/components/v2"; } from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";
enum WebhookType { enum WebhookType {
GENERAL = "general", GENERAL = "general",
@@ -67,7 +67,8 @@ export const AddWebhookForm = ({
} }
}); });
const webhookType = watch("type"); const selectedWebhookType = watch("type");
const selectedEnvironment = watch("environment");
const generalFormFields = ( const generalFormFields = (
<> <>
@@ -165,20 +166,22 @@ export const AddWebhookForm = ({
</FormControl> </FormControl>
)} )}
/> />
<FormControl <Controller
label="Secret Path" control={control}
icon={<GlobPatternExamples />} defaultValue=""
isRequired name="secretPath"
isError={Boolean(errors?.secretPath)} render={({ field, fieldState: { error } }) => (
errorText={errors?.secretPath?.message} <FormControl
helperText="Glob patterns are used to match multiple files or directories" label="Secret Path"
> isRequired
<Input isError={Boolean(error)}
placeholder="glob pattern / or /**/* or /{dir1,dir2}" errorText={error?.message}
{...register("secretPath")} >
/> <SecretPathInput {...field} environment={selectedEnvironment} placeholder="/" />
</FormControl> </FormControl>
{webhookType === WebhookType.SLACK ? slackFormFields : generalFormFields} )}
/>
{selectedWebhookType === WebhookType.SLACK ? slackFormFields : generalFormFields}
</div> </div>
<div className="mt-8 flex items-center"> <div className="mt-8 flex items-center">
<Button <Button