mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 14:26:38 +00:00
misc: cleanup of form display structure
This commit is contained in:
+33
-26
@@ -69,6 +69,38 @@ export const AddWebhookForm = ({
|
|||||||
|
|
||||||
const webhookType = watch("type");
|
const webhookType = watch("type");
|
||||||
|
|
||||||
|
const generalFormFields = (
|
||||||
|
<>
|
||||||
|
<FormControl
|
||||||
|
label="Secret Key"
|
||||||
|
isError={Boolean(errors?.webhookSecretKey)}
|
||||||
|
errorText={errors?.webhookSecretKey?.message}
|
||||||
|
helperText="To generate webhook signature for verification"
|
||||||
|
>
|
||||||
|
<Input placeholder="Provided during webhook setup" {...register("webhookSecretKey")} />
|
||||||
|
</FormControl>
|
||||||
|
<FormControl
|
||||||
|
label="Webhook URL"
|
||||||
|
isRequired
|
||||||
|
isError={Boolean(errors?.webhookUrl)}
|
||||||
|
errorText={errors?.webhookUrl?.message}
|
||||||
|
>
|
||||||
|
<Input {...register("webhookUrl")} />
|
||||||
|
</FormControl>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const slackFormFields = (
|
||||||
|
<FormControl
|
||||||
|
label="Incoming Webhook URL"
|
||||||
|
isRequired
|
||||||
|
isError={Boolean(errors?.webhookUrl)}
|
||||||
|
errorText={errors?.webhookUrl?.message}
|
||||||
|
>
|
||||||
|
<Input placeholder="https://hooks.slack.com/services/..." {...register("webhookUrl")} />
|
||||||
|
</FormControl>
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
reset();
|
reset();
|
||||||
@@ -146,32 +178,7 @@ export const AddWebhookForm = ({
|
|||||||
{...register("secretPath")}
|
{...register("secretPath")}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{webhookType === WebhookType.GENERAL && (
|
{webhookType === WebhookType.SLACK ? slackFormFields : generalFormFields}
|
||||||
<FormControl
|
|
||||||
label="Secret Key"
|
|
||||||
isError={Boolean(errors?.webhookSecretKey)}
|
|
||||||
errorText={errors?.webhookSecretKey?.message}
|
|
||||||
helperText="To generate webhook signature for verification"
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
placeholder="Provided during webhook setup"
|
|
||||||
{...register("webhookSecretKey")}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
)}
|
|
||||||
<FormControl
|
|
||||||
label={webhookType === WebhookType.SLACK ? "Incoming Webhook URL" : "Webhook URL"}
|
|
||||||
isRequired
|
|
||||||
isError={Boolean(errors?.webhookUrl)}
|
|
||||||
errorText={errors?.webhookUrl?.message}
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
placeholder={
|
|
||||||
webhookType === WebhookType.SLACK ? "https://hooks.slack.com/services/..." : ""
|
|
||||||
}
|
|
||||||
{...register("webhookUrl")}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-8 flex items-center">
|
<div className="mt-8 flex items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user