MCPcopy Create free account
hub / github.com/FeatureProbe/FeatureProbe / RuleContent

Function RuleContent

ui/src/components/Rule/condition.tsx:42–629  ·  view source on GitHub ↗
(props: IProps)

Source from the content-addressed store, hash-verified

40const SPECIAL_PREDICATE = ['<', '<=', '>', '>='];
41
42const RuleContent = (props: IProps) => {
43 const {
44 rule,
45 disabled,
46 ruleIndex,
47 // useSegment,
48 subjectOptions,
49 conditionIndex,
50 condition,
51 ruleContainer,
52 segmentContainer,
53 hooksFormContainer,
54 } = props;
55
56 const intl = useIntl();
57 const [ options, setOption ] = useState<IOption[]>([]);
58 const [ popupOpen, setPopupOpen ] = useState<boolean>(false);
59 const segmentList: ISegmentList = segmentContainer?.useContainer().segmentList;
60
61 useEffect(() => {
62 const handler = () => {
63 if (popupOpen) {
64 setPopupOpen(false);
65 }
66 };
67 window.addEventListener('click', handler);
68
69 return () => window.removeEventListener('click', handler);
70 }, [popupOpen]);
71
72 const {
73 handleChangeAttr,
74 handleChangeOperator,
75 handleChangeDateTime,
76 handleChangeTimeZone,
77 handleChangeValue,
78 handleDeleteCondition,
79 handleChangeRightValue,
80 handleChangePredict,
81 handleChangeRightPredict,
82 } = ruleContainer.useContainer();
83
84 const {
85 formState: { errors },
86 register,
87 unregister,
88 setValue,
89 trigger,
90 getValues,
91 clearErrors,
92 setError,
93 } = hooksFormContainer.useContainer();
94
95 const handleDelete = useCallback(async (ruleIndex: number, conditionIndex: number, ruleId?: string) => {
96 for(const key in getValues()) {
97 if (key.startsWith(`rule_${ruleId}_condition`)) {
98 unregister(key);
99 clearErrors(key);

Callers

nothing calls this directly

Calls 13

getAttrOptionsFunction · 0.90
timezoneOptionsFunction · 0.90
setValueFunction · 0.85
handleDeleteConditionFunction · 0.50
handleChangeAttrFunction · 0.50
handleChangeValueFunction · 0.50
handleChangePredictFunction · 0.50
handleChangeRightPredictFunction · 0.50
handleChangeOperatorFunction · 0.50
handleChangeDateTimeFunction · 0.50
handleChangeTimeZoneFunction · 0.50
handleChangeRightValueFunction · 0.50

Tested by

no test coverage detected