@@ -59,6 +59,10 @@ const PAGE_SIZE = 20;
5959const WEBAPP_TYPES = [ "card" , "changelog" ] as const ;
6060const CLI_TYPES = [ "info" , "warn" , "error" , "success" ] as const ;
6161
62+ /** Sentinel for the discovery "match behavior" select meaning "none / not configured". */
63+ const DISCOVERY_MATCH_NONE = "" ;
64+ const DISCOVERY_MATCH_LABEL = "— none —" ;
65+
6266const SearchParams = z . object ( {
6367 page : z . coerce . number ( ) . optional ( ) ,
6468 hideInactive : z . coerce . boolean ( ) . optional ( ) ,
@@ -143,10 +147,11 @@ function parseNotificationFormData(formData: FormData) {
143147
144148 const discoveryFilePatterns = ( formData . get ( "discoveryFilePatterns" ) as string ) || "" ;
145149 const discoveryContentPattern = ( formData . get ( "discoveryContentPattern" ) as string ) || undefined ;
146- const discoveryMatchBehavior = ( formData . get ( "discoveryMatchBehavior" ) as string ) || "" ;
150+ const discoveryMatchBehavior =
151+ ( formData . get ( "discoveryMatchBehavior" ) as string ) || DISCOVERY_MATCH_NONE ;
147152
148153 const discovery =
149- discoveryFilePatterns && discoveryMatchBehavior
154+ discoveryFilePatterns && discoveryMatchBehavior !== DISCOVERY_MATCH_NONE
150155 ? {
151156 filePatterns : discoveryFilePatterns
152157 . split ( "," )
@@ -693,7 +698,7 @@ function NotificationForm({
693698 const [ actionUrl , setActionUrl ] = useState ( n ?. payloadActionUrl ?? "" ) ;
694699 const [ image , setImage ] = useState ( n ?. payloadImage ?? "" ) ;
695700 const [ discoveryMatchBehavior , setDiscoveryMatchBehavior ] = useState < string > (
696- n ?. payloadDiscovery ?. matchBehavior ?? ""
701+ n ?. payloadDiscovery ?. matchBehavior ?? DISCOVERY_MATCH_NONE
697702 ) ;
698703
699704 const typeOptions = surface === "WEBAPP" ? WEBAPP_TYPES : CLI_TYPES ;
@@ -1099,15 +1104,18 @@ function NotificationForm({
10991104 value = { discoveryMatchBehavior }
11001105 setValue = { setDiscoveryMatchBehavior }
11011106 variant = "tertiary/medium"
1102- items = { [ "" , "show-if-found" , "show-if-not-found" ] }
1103- placeholder = "— none —"
1104- text = { ( v ) => v || "— none —" }
1107+ items = { [ DISCOVERY_MATCH_NONE , "show-if-found" , "show-if-not-found" ] }
1108+ placeholder = { DISCOVERY_MATCH_LABEL }
1109+ text = { ( v ) => ( v === DISCOVERY_MATCH_NONE ? DISCOVERY_MATCH_LABEL : v ) }
11051110 className = "mt-1 w-full"
11061111 >
11071112 { ( items ) =>
11081113 items . map ( ( item ) => (
1109- < SelectItem key = { item || "none" } value = { item } >
1110- { item || "— none —" }
1114+ < SelectItem
1115+ key = { item === DISCOVERY_MATCH_NONE ? "none" : item }
1116+ value = { item }
1117+ >
1118+ { item === DISCOVERY_MATCH_NONE ? DISCOVERY_MATCH_LABEL : item }
11111119 </ SelectItem >
11121120 ) )
11131121 }
0 commit comments