11import Button from '@app/components/Common/Button' ;
22import LoadingSpinner from '@app/components/Common/LoadingSpinner' ;
33import NotificationTypeSelector from '@app/components/NotificationTypeSelector' ;
4+ import SettingsBadge from '@app/components/Settings/SettingsBadge' ;
45import globalMessages from '@app/i18n/globalMessages' ;
56import defineMessages from '@app/utils/defineMessages' ;
67import { isValidURL } from '@app/utils/urlValidationHelper' ;
@@ -73,6 +74,11 @@ const messages = defineMessages(
7374 {
7475 agentenabled : 'Enable Agent' ,
7576 webhookUrl : 'Webhook URL' ,
77+ webhookUrlTip :
78+ 'Test Notification URL is set to {testUrl} instead of the actual webhook URL.' ,
79+ supportVariables : 'Support URL Variables' ,
80+ supportVariablesTip :
81+ 'Available variables are documented in the webhook template variables section' ,
7682 authheader : 'Authorization Header' ,
7783 validationJsonPayloadRequired : 'You must provide a valid JSON payload' ,
7884 webhooksettingssaved : 'Webhook notification settings saved successfully!' ,
@@ -111,8 +117,14 @@ const NotificationsWebhook = () => {
111117 . test (
112118 'valid-url' ,
113119 intl . formatMessage ( messages . validationWebhookUrl ) ,
114- isValidURL
120+ function ( value ) {
121+ const { supportVariables } = this . parent ;
122+ return supportVariables || isValidURL ( value ) ;
123+ }
115124 ) ,
125+
126+ supportVariables : Yup . boolean ( ) ,
127+
116128 jsonPayload : Yup . string ( )
117129 . when ( 'enabled' , {
118130 is : true ,
@@ -147,6 +159,7 @@ const NotificationsWebhook = () => {
147159 webhookUrl : data . options . webhookUrl ,
148160 jsonPayload : data . options . jsonPayload ,
149161 authHeader : data . options . authHeader ,
162+ supportVariables : data . options . supportVariables ?? false ,
150163 } }
151164 validationSchema = { NotificationsWebhookSchema }
152165 onSubmit = { async ( values ) => {
@@ -158,6 +171,7 @@ const NotificationsWebhook = () => {
158171 webhookUrl : values . webhookUrl ,
159172 jsonPayload : JSON . stringify ( values . jsonPayload ) ,
160173 authHeader : values . authHeader ,
174+ supportVariables : values . supportVariables ,
161175 } ,
162176 } ) ;
163177 addToast ( intl . formatMessage ( messages . webhooksettingssaved ) , {
@@ -215,6 +229,7 @@ const NotificationsWebhook = () => {
215229 webhookUrl : values . webhookUrl ,
216230 jsonPayload : JSON . stringify ( values . jsonPayload ) ,
217231 authHeader : values . authHeader ,
232+ supportVariables : values . supportVariables ?? false ,
218233 } ,
219234 } ) ;
220235
@@ -249,10 +264,59 @@ const NotificationsWebhook = () => {
249264 < Field type = "checkbox" id = "enabled" name = "enabled" />
250265 </ div >
251266 </ div >
267+ < div className = "form-row" >
268+ < label htmlFor = "supportVariables" className = "checkbox-label" >
269+ < span className = "mr-2" >
270+ { intl . formatMessage ( messages . supportVariables ) }
271+ </ span >
272+ < SettingsBadge badgeType = "experimental" />
273+ < span className = "label-tip" >
274+ { intl . formatMessage ( messages . supportVariablesTip ) }
275+ </ span >
276+ </ label >
277+ < div className = "form-input-area" >
278+ < Field
279+ type = "checkbox"
280+ id = "supportVariables"
281+ name = "supportVariables"
282+ onChange = { ( e : React . ChangeEvent < HTMLInputElement > ) =>
283+ setFieldValue ( 'supportVariables' , e . target . checked )
284+ }
285+ />
286+ </ div >
287+ </ div >
288+ { values . supportVariables && (
289+ < div className = "mt-2" >
290+ < Link
291+ href = "https://docs.jellyseerr.dev/using-jellyseerr/notifications/webhook#template-variables"
292+ passHref
293+ legacyBehavior
294+ >
295+ < Button
296+ as = "a"
297+ buttonSize = "sm"
298+ target = "_blank"
299+ rel = "noreferrer"
300+ >
301+ < QuestionMarkCircleIcon />
302+ < span >
303+ { intl . formatMessage ( messages . templatevariablehelp ) }
304+ </ span >
305+ </ Button >
306+ </ Link >
307+ </ div >
308+ ) }
252309 < div className = "form-row" >
253310 < label htmlFor = "webhookUrl" className = "text-label" >
254311 { intl . formatMessage ( messages . webhookUrl ) }
255312 < span className = "label-required" > *</ span >
313+ { values . supportVariables && (
314+ < div className = "label-tip" >
315+ { intl . formatMessage ( messages . webhookUrlTip , {
316+ testUrl : '/test' ,
317+ } ) }
318+ </ div >
319+ ) }
256320 </ label >
257321 < div className = "form-input-area" >
258322 < div className = "form-input-field" >
@@ -312,7 +376,7 @@ const NotificationsWebhook = () => {
312376 < span > { intl . formatMessage ( messages . resetPayload ) } </ span >
313377 </ Button >
314378 < Link
315- href = "https://docs.overseerr .dev/using-overseerr /notifications/webhooks #template-variables"
379+ href = "https://docs.jellyseerr .dev/using-jellyseerr /notifications/webhook #template-variables"
316380 passHref
317381 legacyBehavior
318382 >
0 commit comments