refactor: Webhooks (#12487)
Closes #12303 ### What’s Changed - Replace auto‐save with explicit Save / Cancel Webhook forms now use manual “Save” and “Cancel” buttons instead of the old debounced auto‐save/update. - Separate “New” and “Detail” routes Two dedicated paths `/settings/webhooks/new` for creation and /`settings/webhooks/:webhookId` for editing, making the UX clearer. - URL hint & normalization If a user omits the http(s):// scheme, we display a “Will be saved as https://…” hint and automatically default to HTTPS. - Centralized validation with Zod Introduced a `webhookFormSchema` for client‐side URL, operations, and secret validation. - Storybook coverage Added stories for both “New Webhook” and “Webhook Detail” - Unit tests Added tests for the new `useWebhookForm` hook
This commit is contained in:
@ -18,6 +18,7 @@ export { parseJson } from './parseJson';
|
||||
export { capitalize } from './strings/capitalize';
|
||||
export { absoluteUrlSchema } from './url/absoluteUrlSchema';
|
||||
export { buildSignedPath } from './url/buildSignedPath';
|
||||
export { getAbsoluteUrl } from './url/getAbsoluteUrl';
|
||||
export { getAbsoluteUrlOrThrow } from './url/getAbsoluteUrlOrThrow';
|
||||
export { getUrlHostnameOrThrow } from './url/getUrlHostnameOrThrow';
|
||||
export { isValidHostname } from './url/isValidHostname';
|
||||
|
||||
@ -1,14 +1,7 @@
|
||||
import { getAbsoluteUrl } from '@/utils/url/getAbsoluteUrl';
|
||||
import { isValidHostname } from '@/utils/url/isValidHostname';
|
||||
import { z } from 'zod';
|
||||
|
||||
const getAbsoluteUrl = (value: string): string => {
|
||||
if (value.startsWith('http://') || value.startsWith('https://')) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return `https://${value}`;
|
||||
};
|
||||
|
||||
export const absoluteUrlSchema = z.string().transform((value, ctx) => {
|
||||
const trimmedValue = value.trim();
|
||||
const absoluteUrl = getAbsoluteUrl(trimmedValue);
|
||||
|
||||
7
packages/twenty-shared/src/utils/url/getAbsoluteUrl.ts
Normal file
7
packages/twenty-shared/src/utils/url/getAbsoluteUrl.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const getAbsoluteUrl = (value: string): string => {
|
||||
if (value.startsWith('http://') || value.startsWith('https://')) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return `https://${value}`;
|
||||
};
|
||||
Reference in New Issue
Block a user