@@ -25,44 +25,48 @@ import {
2525import {
2626 Textarea
2727} from "@/components/ui/textarea"
28- import type { TurIntegrationInstance } from "@/models/integration/integration-instance .model.ts "
29- import { TurIntegrationInstanceService } from "@/services/integration/integration.service"
28+ import type { TurIntegrationIndexingRule } from "@/models/integration/integration-indexing-rule .model"
29+ import { TurIntegrationIndexingRuleService } from "@/services/integration/integration-indexing-rule .service"
3030import { useEffect } from "react"
3131import {
3232 useForm
3333} from "react-hook-form"
3434import { useNavigate } from "react-router-dom"
3535import { toast } from "sonner"
36- const turIntegrationInstanceService = new TurIntegrationInstanceService ( ) ;
36+ import { DynamicIndexingRuleFields } from "./dynamic.indexing.rule.field"
37+
3738interface Props {
38- value : TurIntegrationInstance ;
39+ value : TurIntegrationIndexingRule ;
3940 isNew : boolean ;
4041}
4142
4243export const IntegrationIndexingRulesForm : React . FC < Props > = ( { value, isNew } ) => {
43- const form = useForm < TurIntegrationInstance > ( ) ;
44- const { setValue } = form ;
44+ const form = useForm < TurIntegrationIndexingRule > ( ) ;
45+ const { control , register , setValue } = form ;
4546 const navigate = useNavigate ( )
4647 useEffect ( ( ) => {
4748 setValue ( "id" , value . id )
48- setValue ( "title " , value . title ) ;
49+ setValue ( "name " , value . name ) ;
4950 setValue ( "description" , value . description ) ;
50- setValue ( "vendor" , value . vendor ) ;
51- setValue ( "endpoint" , value . endpoint ) ;
52- setValue ( "enabled" , value . enabled ) ;
51+ setValue ( "ruleType" , value . ruleType ) ;
52+ setValue ( "source" , value . source ) ;
53+ setValue ( "attribute" , value . attribute ) ;
54+ setValue ( "values" , value . values ) ;
5355 } , [ setValue , value ] ) ;
5456
5557
56- function onSubmit ( integrationInstance : TurIntegrationInstance ) {
58+ function onSubmit ( integrationIndexingRule : TurIntegrationIndexingRule ) {
5759 try {
5860 if ( isNew ) {
59- turIntegrationInstanceService . create ( integrationInstance ) ;
60- toast . success ( `The ${ integrationInstance . title } Integration Instance was saved` ) ;
61+ const turIntegrationIndexingRuleService = new TurIntegrationIndexingRuleService ( "" ) ;
62+ turIntegrationIndexingRuleService . create ( integrationIndexingRule ) ;
63+ toast . success ( `The ${ integrationIndexingRule . name } Integration Indexing Rule was saved` ) ;
6164 navigate ( ROUTES . INTEGRATION_INSTANCE ) ;
6265 }
6366 else {
64- turIntegrationInstanceService . update ( integrationInstance ) ;
65- toast . success ( `The ${ integrationInstance . title } Integration Instance was updated` ) ;
67+ const turIntegrationIndexingRuleService = new TurIntegrationIndexingRuleService ( "" ) ;
68+ turIntegrationIndexingRuleService . update ( integrationIndexingRule ) ;
69+ toast . success ( `The ${ integrationIndexingRule . name } Integration Indexing Rule was updated` ) ;
6670 }
6771 } catch ( error ) {
6872 console . error ( "Form submission error" , error ) ;
@@ -75,18 +79,18 @@ export const IntegrationIndexingRulesForm: React.FC<Props> = ({ value, isNew })
7579 < form onSubmit = { form . handleSubmit ( onSubmit ) } className = "space-y-8 py-8 pr-8" >
7680 < FormField
7781 control = { form . control }
78- name = "title "
82+ name = "name "
7983 render = { ( { field } ) => (
8084 < FormItem >
81- < FormLabel > Name</ FormLabel >
85+ < FormLabel > Rule Name</ FormLabel >
8286 < FormControl >
8387 < Input
8488 { ...field }
85- placeholder = "Title "
89+ placeholder = "e.g., Ignore Draft Pages "
8690 type = "text"
8791 />
8892 </ FormControl >
89- < FormDescription > Integration instance title will appear on list.</ FormDescription >
93+ < FormDescription > A unique, descriptive name to easily identify this rule in the list.</ FormDescription >
9094 < FormMessage />
9195 </ FormItem >
9296 ) }
@@ -97,60 +101,88 @@ export const IntegrationIndexingRulesForm: React.FC<Props> = ({ value, isNew })
97101 name = "description"
98102 render = { ( { field } ) => (
99103 < FormItem >
100- < FormLabel > Description</ FormLabel >
104+ < FormLabel > Rule Description</ FormLabel >
101105 < FormControl >
102106 < Textarea
103- placeholder = "Description "
107+ placeholder = "e.g., Excludes all draft pages from indexing "
104108 className = "resize-none"
105109 { ...field }
106110 />
107111 </ FormControl >
108- < FormDescription > Integration instance description will appear on list .</ FormDescription >
112+ < FormDescription > Provide details about what this rule does and when it should be applied .</ FormDescription >
109113 < FormMessage />
110114 </ FormItem >
111115 ) }
112116 />
113-
114117 < FormField
115118 control = { form . control }
116- name = "vendor "
119+ name = "source "
117120 render = { ( { field } ) => (
118121 < FormItem >
119- < FormLabel > Vendor</ FormLabel >
120- < Select onValueChange = { field . onChange } value = { field . value } >
121- < FormControl >
122- < SelectTrigger >
123- < SelectValue placeholder = "Choose..." />
124- </ SelectTrigger >
125- </ FormControl >
126- < SelectContent >
127- < SelectItem key = "AEM" value = "AEM" > AEM</ SelectItem >
128- < SelectItem key = "WEB_CRAWLER" value = "WEB_CRAWLER" > Web Crawler</ SelectItem >
129- </ SelectContent >
130- </ Select >
131- < FormDescription > Integration vendor that will be used.</ FormDescription >
122+ < FormLabel > Content Source</ FormLabel >
123+ < FormControl >
124+ < Input
125+ placeholder = "e.g., WKND"
126+ type = "text"
127+ { ...field } />
128+ </ FormControl >
129+ < FormDescription > The content path or source location where this rule will be applied.</ FormDescription >
132130 < FormMessage />
133131 </ FormItem >
134132 ) }
135133 />
136-
137134 < FormField
138135 control = { form . control }
139- name = "endpoint "
136+ name = "attribute "
140137 render = { ( { field } ) => (
141138 < FormItem >
142- < FormLabel > Endpoint </ FormLabel >
139+ < FormLabel > Target Attribute </ FormLabel >
143140 < FormControl >
144141 < Input
145- placeholder = "URL "
142+ placeholder = "e.g., title "
146143 type = "text"
147144 { ...field } />
148145 </ FormControl >
149- < FormDescription > Integration instance hostname will be connected .</ FormDescription >
146+ < FormDescription > The content attribute or property name used to match against the values below .</ FormDescription >
150147 < FormMessage />
151148 </ FormItem >
152149 ) }
153150 />
151+
152+ < FormField
153+ control = { form . control }
154+ name = "ruleType"
155+ render = { ( { field } ) => (
156+ < FormItem >
157+ < FormLabel > Action Type</ FormLabel >
158+ < Select onValueChange = { field . onChange } value = { field . value } >
159+ < FormControl >
160+ < SelectTrigger >
161+ < SelectValue placeholder = "Choose..." />
162+ </ SelectTrigger >
163+ </ FormControl >
164+ < SelectContent >
165+ < SelectItem key = "IGNORE" value = "IGNORE" > Ignore</ SelectItem >
166+ </ SelectContent >
167+ </ Select >
168+ < FormDescription > Defines the action to take when content matches this rule. "Ignore" will exclude matching content from indexing.</ FormDescription >
169+ < FormMessage />
170+ </ FormItem >
171+ ) }
172+ />
173+
174+ < FormItem >
175+ < FormLabel > Matching Values</ FormLabel >
176+ < FormDescription > Add the values that the attribute should match. Content with matching attribute values will have the rule applied.</ FormDescription >
177+ < FormControl >
178+ < DynamicIndexingRuleFields
179+ fieldName = "values"
180+ control = { control }
181+ register = { register }
182+ />
183+ </ FormControl >
184+ </ FormItem >
185+
154186 < Button type = "submit" > Save</ Button >
155187 </ form >
156188 </ Form >
0 commit comments