Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export interface DynamicRuleFormFlyoutProps {
* the loading state of its footer buttons. The time field is automatically
* derived from the query's available date fields.
*/
const DynamicRuleFormFlyoutInner: React.FC<DynamicRuleFormFlyoutProps> = ({
const DynamicRuleFormFlyoutInner = ({
push,
onClose,
query,
services,
}) => {
}: DynamicRuleFormFlyoutProps) => {
const { createRule, isLoading } = useCreateRule({
http: services.http,
notifications: services.notifications,
Expand All @@ -62,7 +62,7 @@ const DynamicRuleFormFlyoutInner: React.FC<DynamicRuleFormFlyoutProps> = ({
);
};

export const DynamicRuleFormFlyout: React.FC<DynamicRuleFormFlyoutProps> = (props) => {
export const DynamicRuleFormFlyout = (props: DynamicRuleFormFlyoutProps) => {
const queryClient = useMemo(() => new QueryClient(), []);
return (
<QueryClientProvider client={queryClient}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import type { FormValues } from '../form/types';
import { ErrorCallOut } from './error_callout';

// Wrapper component that provides form context with configurable state
const TestWrapper: React.FC<{
const TestWrapper = ({
errors = {},
isSubmitted = false,
children,
}: {
errors?: FieldErrors<FormValues>;
isSubmitted?: boolean;
children: React.ReactNode;
}> = ({ errors = {}, isSubmitted = false, children }) => {
}) => {
const methods = useForm<FormValues>({
defaultValues: {
kind: 'alert',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const extractErrorMessages = (errors: FieldErrors): string[] => {
return messages;
};

export const ErrorCallOut: React.FC = () => {
export const ErrorCallOut = () => {
const {
formState: { errors, isSubmitted },
} = useFormContext<FormValues>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ const LazyStandaloneRuleFormFlyout = React.lazy(() =>
export { LazyDynamicRuleFormFlyout, LazyStandaloneRuleFormFlyout, LazyRuleFormFlyout };

/** Base flyout wrapper - use with DynamicRuleForm or StandaloneRuleForm as children */
export const RuleFormFlyout: React.FC<RuleFormFlyoutProps> = (props) => (
export const RuleFormFlyout = (props: RuleFormFlyoutProps) => (
<Suspense fallback={<EuiLoadingSpinner size="m" />}>
<LazyRuleFormFlyout {...props} />
</Suspense>
);

/** Pre-composed flyout for Discover integration - syncs with external query changes */
export const DynamicRuleFormFlyout: React.FC<DynamicRuleFormFlyoutProps> = (props) => (
export const DynamicRuleFormFlyout = (props: DynamicRuleFormFlyoutProps) => (
<Suspense fallback={<EuiLoadingSpinner size="m" />}>
<LazyDynamicRuleFormFlyout {...props} />
</Suspense>
);

/** Pre-composed flyout for classic experience - static initialization */
export const StandaloneRuleFormFlyout: React.FC<StandaloneRuleFormFlyoutProps> = (props) => (
export const StandaloneRuleFormFlyout = (props: StandaloneRuleFormFlyoutProps) => (
<Suspense fallback={<EuiLoadingSpinner size="m" />}>
<LazyStandaloneRuleFormFlyout {...props} />
</Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export interface RuleFormFlyoutProps {
* Use DynamicRuleFormFlyout or StandaloneRuleFormFlyout for pre-composed
* flyouts that handle form submission and state management.
*/
export const RuleFormFlyout: React.FC<RuleFormFlyoutProps> = ({
export const RuleFormFlyout = ({
push = true,
onClose,
isLoading = false,
children,
}) => {
}: RuleFormFlyoutProps) => {
return (
<EuiFlyout
session="start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export interface StandaloneRuleFormFlyoutProps {
* the loading state of its footer buttons. Time field is auto-selected by
* TimeFieldSelect based on available date fields.
*/
const StandaloneRuleFormFlyoutInner: React.FC<StandaloneRuleFormFlyoutProps> = ({
const StandaloneRuleFormFlyoutInner = ({
push,
onClose,
query,
services,
}) => {
}: StandaloneRuleFormFlyoutProps) => {
const { createRule, isLoading } = useCreateRule({
http: services.http,
notifications: services.notifications,
Expand All @@ -62,7 +62,7 @@ const StandaloneRuleFormFlyoutInner: React.FC<StandaloneRuleFormFlyoutProps> = (
);
};

export const StandaloneRuleFormFlyout: React.FC<StandaloneRuleFormFlyoutProps> = (props) => {
export const StandaloneRuleFormFlyout = (props: StandaloneRuleFormFlyoutProps) => {
const queryClient = useMemo(() => new QueryClient(), []);
return (
<QueryClientProvider client={queryClient}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const toggleButtons = [
},
];

export const EditModeToggle: React.FC<EditModeToggleProps> = ({ editMode, onChange, disabled }) => {
export const EditModeToggle = ({ editMode, onChange, disabled }: EditModeToggleProps) => {
const handleChange = (optionId: string) => {
onChange(optionId as EditMode);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ const RuleFormContext = createContext<RuleFormContextValue | undefined>(undefine
*
* `meta` defaults to `{ layout: 'page' }` when omitted.
*/
export const RuleFormProvider: React.FC<
PropsWithChildren<{ services: RuleFormServices; meta?: RuleFormMeta }>
> = ({ children, services, meta = DEFAULT_META }) => {
export const RuleFormProvider = ({
children,
services,
meta = DEFAULT_META,
}: PropsWithChildren<{ services: RuleFormServices; meta?: RuleFormMeta }>) => {
const value = useMemo(() => ({ services, meta }), [services, meta]);
return <RuleFormContext.Provider value={value}>{children}</RuleFormContext.Provider>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface DynamicRuleFormProps {
* Uses react-hook-form's `values` prop to sync form state on each prop change,
* with `resetOptions: { keepDirtyValues: true }` to preserve user input.
*/
export const DynamicRuleForm: React.FC<DynamicRuleFormProps> = ({
export const DynamicRuleForm = ({
query,
services,
layout,
Expand All @@ -65,7 +65,7 @@ export const DynamicRuleForm: React.FC<DynamicRuleFormProps> = ({
onCancel,
submitLabel,
cancelLabel,
}) => {
}: DynamicRuleFormProps) => {
// Get default form values derived from the query
const formValues = useFormDefaults({ query });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { RecoveryDelayField } from '../fields/recovery_delay_field';
* uses RecoveryBaseQueryOnlyField (full ES|QL editor with "not same as eval" validation)
* - Recovery delay (recovering state transition: immediate / breaches / duration)
*/
export const AlertConditionsFieldGroup: React.FC = () => {
export const AlertConditionsFieldGroup = () => {
const { control } = useFormContext<FormValues>();
const { data } = useRuleFormServices();
const kind = useWatch({ control, name: 'kind' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ interface ConditionFieldGroupProps {
* The base query defines what data is being evaluated, while the
* condition field defines the threshold or filter that triggers alerts.
*/
export const ConditionFieldGroup: React.FC<ConditionFieldGroupProps> = ({
includeBase = false,
}) => {
export const ConditionFieldGroup = ({ includeBase = false }: ConditionFieldGroupProps) => {
const { control } = useFormContext<FormValues>();

// Read the base query from form state (initialized via useFormDefaults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface FieldGroupProps {
children: React.ReactNode;
}

export const FieldGroup: React.FC<FieldGroupProps> = ({ title, children }) => {
export const FieldGroup = ({ title, children }: FieldGroupProps) => {
return (
<EuiSplitPanel.Outer hasShadow={false} hasBorder={true}>
<EuiSplitPanel.Inner color="subdued" paddingSize="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { TagsField } from '../fields/tags_field';
import { DescriptionField } from '../fields/description_field';

export const RuleDetailsFieldGroup: React.FC = () => {
export const RuleDetailsFieldGroup = () => {
return (
<>
<TagsField />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FieldGroup } from './field_group';
import { ScheduleField } from '../fields/schedule_field';
import { LookbackWindowField } from '../fields/lookback_window_field';

export const RuleExecutionFieldGroup: React.FC = () => {
export const RuleExecutionFieldGroup = () => {
return (
<FieldGroup
title={i18n.translate('xpack.alertingV2.ruleForm.ruleExecution', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const deriveMode = (stateTransition?: {
return 'immediate';
};

export const AlertDelayField: React.FC = () => {
export const AlertDelayField = () => {
const { control, setValue } = useFormContext<FormValues>();
const stateTransition = useWatch({ control, name: 'stateTransition' });
const [selectedMode, setSelectedMode] = useState<DelayMode>(deriveMode(stateTransition));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { FormValues } from '../types';

const DESCRIPTION_ROW_ID = 'ruleV2FormDescriptionField';

export const DescriptionField: React.FC = () => {
export const DescriptionField = () => {
const { control, watch } = useFormContext<FormValues>();
const descriptionValue = watch('metadata.description');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EuiFormRow, EuiSwitch } from '@elastic/eui';
import { Controller, useFormContext } from 'react-hook-form';
import type { FormValues } from '../types';

export const EnabledField: React.FC = () => {
export const EnabledField = () => {
const { control } = useFormContext<FormValues>();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface EsqlEditorFieldProps {
* />
* ```
*/
export const EsqlEditorField: React.FC<EsqlEditorFieldProps> = ({
export const EsqlEditorField = ({
name,
label,
labelTooltip,
Expand All @@ -91,7 +91,7 @@ export const EsqlEditorField: React.FC<EsqlEditorFieldProps> = ({
rules,
errors: serverErrors,
warning: serverWarning,
}) => {
}: EsqlEditorFieldProps) => {
const { control } = useFormContext<FormValues>();

const labelElement = label ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('EvaluationQueryField', () => {
it('shows required error when submitted with empty value', async () => {
const queryClient = createTestQueryClient();

const WrapperWithSubmit: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const WrapperWithSubmit = ({ children }: { children: React.ReactNode }) => {
const form = useForm<FormValues>({
defaultValues: {
...defaultTestFormValues,
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('EvaluationQueryField', () => {
it('shows validation error for invalid ES|QL query syntax', async () => {
const queryClient = createTestQueryClient();

const WrapperWithSubmit: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const WrapperWithSubmit = ({ children }: { children: React.ReactNode }) => {
const form = useForm<FormValues>({
defaultValues: {
...defaultTestFormValues,
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('EvaluationQueryField', () => {
it('shows validation error for incomplete query', async () => {
const queryClient = createTestQueryClient();

const WrapperWithSubmit: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const WrapperWithSubmit = ({ children }: { children: React.ReactNode }) => {
const form = useForm<FormValues>({
defaultValues: {
...defaultTestFormValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ interface EvaluationQueryFieldProps {
height?: string | number;
}

export const EvaluationQueryField: React.FC<EvaluationQueryFieldProps> = ({
export const EvaluationQueryField = ({
height = EDITOR_HEIGHT_INLINE,
}) => {
}: EvaluationQueryFieldProps) => {
return (
<EsqlEditorField
name="evaluation.query.base"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { FormValues } from '../types';
import { useQueryColumns, type QueryColumn } from '../hooks/use_query_columns';
import { useRuleFormServices } from '../contexts';

export const GroupFieldSelect: React.FC = () => {
export const GroupFieldSelect = () => {
const { data } = useRuleFormServices();
const { control, setValue, getValues } = useFormContext<FormValues>();
const query = useWatch({ name: 'evaluation.query.base', control });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { FormValues } from '../types';

const CARD_ID = 'ruleV2KindField';

export const KindField: React.FC = () => {
export const KindField = () => {
const { control } = useFormContext<FormValues>();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { LookbackWindow } from './lookback_window';

const LOOKBACK_WINDOW_ROW_ID = 'ruleV2FormLookbackWindowField';

export const LookbackWindowField: React.FC = () => {
export const LookbackWindowField = () => {
const { control } = useFormContext<FormValues>();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('NameField', () => {
it('shows required error when submitted with empty value', async () => {
const queryClient = createTestQueryClient();

const WrapperWithSubmit: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const WrapperWithSubmit = ({ children }: { children: React.ReactNode }) => {
const form = useForm<FormValues>({
defaultValues: defaultTestFormValues,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DEFAULT_NAME = i18n.translate('xpack.alertingV2.ruleForm.defaultRuleName',
defaultMessage: 'Untitled rule',
});

export const NameField: React.FC = () => {
export const NameField = () => {
const { control } = useFormContext<FormValues>();
const { euiTheme } = useEuiTheme();
const editTitleId = useGeneratedHtmlId({ prefix: 'ruleNameInlineEdit' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface QueryResultsGridProps {
*
* Used by both the rule preview and recovery preview components.
*/
export const QueryResultsGrid: React.FC<QueryResultsGridProps> = ({
export const QueryResultsGrid = ({
title,
dataTestSubj,
emptyBody,
Expand All @@ -88,7 +88,7 @@ export const QueryResultsGrid: React.FC<QueryResultsGridProps> = ({
groupingFields = [],
uniqueGroupCount,
hasValidQuery = false,
}) => {
}: QueryResultsGridProps) => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: DEFAULT_PAGE_SIZE });

const onChangeItemsPerPage = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jest.mock('./recovery_base_query_field', () => ({
* Helper to capture the form instance so tests can call getValues() directly.
*/
let formRef: UseFormReturn<FormValues> | undefined;
const FormRefCapture: React.FC = () => {
const FormRefCapture = () => {
formRef = useFormContext<FormValues>();
return null;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ interface RecoveryBaseAndConditionFieldProps {
* Validation logic is provided by the `useRecoveryValidation` hook via the
* `validation` prop. Seeding and field management are handled locally.
*/
export const RecoveryBaseAndConditionField: React.FC<RecoveryBaseAndConditionFieldProps> = ({
export const RecoveryBaseAndConditionField = ({
validation,
}) => {
}: RecoveryBaseAndConditionFieldProps) => {
const { getValues, setValue } = useFormContext<FormValues>();
const {
recoveryBaseQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ interface RecoveryBaseQueryFieldProps {
* All validation logic (syntax, grouping, differs-from-evaluation) is provided
* externally via the `rules` and `errors` props from the `useRecoveryValidation` hook.
*/
export const RecoveryBaseQueryField: React.FC<RecoveryBaseQueryFieldProps> = ({
export const RecoveryBaseQueryField = ({
labelTooltip = DEFAULT_TOOLTIP,
dataTestSubj = 'recoveryQueryField',
rules,
errors,
}) => {
}: RecoveryBaseQueryFieldProps) => {
return (
<EsqlEditorField
name="recoveryPolicy.query.base"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jest.mock('./recovery_base_query_field', () => ({
* Helper to capture the form instance so tests can call getValues() directly.
*/
let formRef: UseFormReturn<FormValues> | undefined;
const FormRefCapture: React.FC = () => {
const FormRefCapture = () => {
formRef = useFormContext<FormValues>();
return null;
};
Expand Down
Loading
Loading