Skip to content

Commit

Permalink
Merge branch '8.x' into markjhoy/fix-ent-search-dep-banner-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
markjhoy authored Oct 15, 2024
2 parents c7e8550 + db2adf7 commit 38d0f22
Show file tree
Hide file tree
Showing 205 changed files with 5,122 additions and 2,645 deletions.
2 changes: 2 additions & 0 deletions .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ disabled:

# Cypress configs, for now these are still run manually
- x-pack/test/fleet_cypress/cli_config.ts
- x-pack/test/fleet_cypress/cli_config.space_awareness.ts
- x-pack/test/fleet_cypress/config.ts
- x-pack/test/fleet_cypress/config.space_awareness.ts
- x-pack/test/fleet_cypress/visual_config.ts

defaultQueue: 'n2-4-spot'
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/functional/fleet_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ echo "--- Fleet Cypress tests (Chrome)"
cd x-pack/plugins/fleet

set +e
yarn cypress:run:reporter; status=$?; yarn junit:merge || :; exit $status
yarn cypress:run:reporter; status=$?; yarn cypress_space_awareness:run:reporter; space_status=$?; yarn junit:merge || :; [ "$status" -ne 0 ] && exit $status || [ "$space_status" -ne 0 ] && exit $space_status || exit 0
5 changes: 5 additions & 0 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ xpack.ml.compatibleModuleType: 'security'

# Disable the embedded Dev Console
console.ui.embeddedEnabled: false

# Experimental Security Solution features

# This feature is disabled in Serverless until fully performance tested within a Serverless environment
xpack.securitySolution.enableExperimental: ['entityStoreDisabled']
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ export const transformUpdateRuleBody: RewriteResponseCase<UpdateRuleBody> = ({
...(uuid && { uuid }),
};
}),
...(alertDelay ? { alert_delay: alertDelay } : {}),
...(alertDelay !== undefined ? { alert_delay: alertDelay } : {}),
...(flapping !== undefined ? { flapping: transformUpdateRuleFlapping(flapping) } : {}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

// Feature flag for frontend rule specific flapping in rule flyout
export const IS_RULE_SPECIFIC_FLAPPING_ENABLED = false;
export const IS_RULE_SPECIFIC_FLAPPING_ENABLED = true;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import { useMutation } from '@tanstack/react-query';
import type { HttpStart, IHttpFetchError } from '@kbn/core-http-browser';
import { createRule, CreateRuleBody } from '../apis/create_rule';
import { Rule } from '../types';

export interface UseCreateRuleProps {
http: HttpStart;
onSuccess?: (formData: CreateRuleBody) => void;
onSuccess?: (rule: Rule) => void;
onError?: (error: IHttpFetchError<{ message: string }>) => void;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export interface UseLoadConnectorsProps {
http: HttpStart;
includeSystemActions?: boolean;
enabled?: boolean;
cacheTime?: number;
}

export const useLoadConnectors = (props: UseLoadConnectorsProps) => {
const { http, includeSystemActions = false, enabled = true } = props;
const { http, includeSystemActions = false, enabled = true, cacheTime } = props;

const queryFn = () => {
return fetchConnectors({ http, includeSystemActions });
Expand All @@ -27,6 +28,7 @@ export const useLoadConnectors = (props: UseLoadConnectorsProps) => {
const { data, isLoading, isFetching, isInitialLoading } = useQuery({
queryKey: ['useLoadConnectors', includeSystemActions],
queryFn,
cacheTime,
refetchOnWindowFocus: false,
enabled,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export interface UseLoadRuleTypeAadTemplateFieldProps {
http: HttpStart;
ruleTypeId?: string;
enabled: boolean;
cacheTime?: number;
}

export const useLoadRuleTypeAadTemplateField = (props: UseLoadRuleTypeAadTemplateFieldProps) => {
const { http, ruleTypeId, enabled } = props;
const { http, ruleTypeId, enabled, cacheTime } = props;

const queryFn = () => {
if (!ruleTypeId) {
Expand All @@ -43,6 +44,7 @@ export const useLoadRuleTypeAadTemplateField = (props: UseLoadRuleTypeAadTemplat
description: getDescription(d.name, EcsFlat),
}));
},
cacheTime,
refetchOnWindowFocus: false,
enabled,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import { RuleFormData } from '../../rule_form';
export interface UseResolveProps {
http: HttpStart;
id?: string;
cacheTime?: number;
}

export const useResolveRule = (props: UseResolveProps) => {
const { id, http } = props;
const { id, http, cacheTime } = props;

const queryFn = () => {
if (id) {
Expand All @@ -30,6 +31,7 @@ export const useResolveRule = (props: UseResolveProps) => {
queryKey: ['useResolveRule', id],
queryFn,
enabled: !!id,
cacheTime,
select: (rule): RuleFormData | null => {
if (!rule) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import { useMutation } from '@tanstack/react-query';
import type { HttpStart, IHttpFetchError } from '@kbn/core-http-browser';
import { updateRule, UpdateRuleBody } from '../apis/update_rule';
import { Rule } from '../types';

export interface UseUpdateRuleProps {
http: HttpStart;
onSuccess?: (formData: UpdateRuleBody) => void;
onSuccess?: (rule: Rule) => void;
onError?: (error: IHttpFetchError<{ message: string }>) => void;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-alerts-ui-shared/src/common/types/rule_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { TypeRegistry } from '../type_registry';

export type { SanitizedRuleAction as RuleAction } from '@kbn/alerting-types';

export type { Flapping } from '@kbn/alerting-types';

export type RuleTypeWithDescription = RuleType<string, string> & { description?: string };

export type RuleTypeIndexWithDescriptions = Map<string, RuleTypeWithDescription>;
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-alerts-ui-shared/src/rule_form/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const DEFAULT_FREQUENCY = {
summary: false,
};

export const GET_DEFAULT_FORM_DATA = ({
export const getDefaultFormData = ({
ruleTypeId,
name,
consumer,
Expand All @@ -50,6 +50,7 @@ export const GET_DEFAULT_FORM_DATA = ({
ruleTypeId,
name,
actions,
alertDelay: { active: 1 },
};
};

Expand Down
22 changes: 16 additions & 6 deletions packages/kbn-alerts-ui-shared/src/rule_form/create_rule_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EuiLoadingElastic } from '@elastic/eui';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { type RuleCreationValidConsumer } from '@kbn/rule-data-utils';
import type { RuleFormData, RuleFormPlugins } from './types';
import { DEFAULT_VALID_CONSUMERS, GET_DEFAULT_FORM_DATA } from './constants';
import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';
import { RuleFormStateProvider } from './rule_form_state';
import { useCreateRule } from '../common/hooks';
import { RulePage } from './rule_page';
Expand All @@ -24,6 +24,7 @@ import {
} from './rule_form_errors';
import { useLoadDependencies } from './hooks/use_load_dependencies';
import {
getAvailableRuleTypes,
getInitialConsumer,
getInitialMultiConsumer,
getInitialSchedule,
Expand All @@ -42,7 +43,8 @@ export interface CreateRuleFormProps {
shouldUseRuleProducer?: boolean;
canShowConsumerSelection?: boolean;
showMustacheAutocompleteSwitch?: boolean;
returnUrl: string;
onCancel?: () => void;
onSubmit?: (ruleId: string) => void;
}

export const CreateRuleForm = (props: CreateRuleFormProps) => {
Expand All @@ -56,16 +58,18 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
shouldUseRuleProducer = false,
canShowConsumerSelection = true,
showMustacheAutocompleteSwitch = false,
returnUrl,
onCancel,
onSubmit,
} = props;

const { http, docLinks, notifications, ruleTypeRegistry, i18n, theme } = plugins;
const { toasts } = notifications;

const { mutate, isLoading: isSaving } = useCreateRule({
http,
onSuccess: ({ name }) => {
onSuccess: ({ name, id }) => {
toasts.addSuccess(RULE_CREATE_SUCCESS_TEXT(name));
onSubmit?.(id);
},
onError: (error) => {
const message = parseRuleCircuitBreakerErrorMessage(
Expand All @@ -86,6 +90,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
const {
isInitialLoading,
ruleType,
ruleTypes,
ruleTypeModel,
uiConfig,
healthCheckError,
Expand Down Expand Up @@ -153,7 +158,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
<div data-test-subj="createRuleForm">
<RuleFormStateProvider
initialRuleFormState={{
formData: GET_DEFAULT_FORM_DATA({
formData: getDefaultFormData({
ruleTypeId,
name: `${ruleType.name} rule`,
consumer: getInitialConsumer({
Expand All @@ -174,6 +179,11 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
minimumScheduleInterval: uiConfig?.minimumScheduleInterval,
selectedRuleTypeModel: ruleTypeModel,
selectedRuleType: ruleType,
availableRuleTypes: getAvailableRuleTypes({
consumer,
ruleTypes,
ruleTypeRegistry,
}).map(({ ruleType: rt }) => rt),
validConsumers,
flappingSettings,
canShowConsumerSelection,
Expand All @@ -185,7 +195,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
}),
}}
>
<RulePage isEdit={false} isSaving={isSaving} returnUrl={returnUrl} onSave={onSave} />
<RulePage isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
</RuleFormStateProvider>
</div>
);
Expand Down
28 changes: 23 additions & 5 deletions packages/kbn-alerts-ui-shared/src/rule_form/edit_rule_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,27 @@ import {
RuleFormRuleTypeError,
} from './rule_form_errors';
import { RULE_EDIT_ERROR_TEXT, RULE_EDIT_SUCCESS_TEXT } from './translations';
import { parseRuleCircuitBreakerErrorMessage } from './utils';
import { getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from './utils';
import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';

export interface EditRuleFormProps {
id: string;
plugins: RuleFormPlugins;
showMustacheAutocompleteSwitch?: boolean;
returnUrl: string;
onCancel?: () => void;
onSubmit?: (ruleId: string) => void;
}

export const EditRuleForm = (props: EditRuleFormProps) => {
const { id, plugins, returnUrl, showMustacheAutocompleteSwitch = false } = props;
const { id, plugins, showMustacheAutocompleteSwitch = false, onCancel, onSubmit } = props;
const { http, notifications, docLinks, ruleTypeRegistry, i18n, theme, application } = plugins;
const { toasts } = notifications;

const { mutate, isLoading: isSaving } = useUpdateRule({
http,
onSuccess: ({ name }) => {
toasts.addSuccess(RULE_EDIT_SUCCESS_TEXT(name));
onSubmit?.(id);
},
onError: (error) => {
const message = parseRuleCircuitBreakerErrorMessage(
Expand All @@ -62,6 +65,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
const {
isInitialLoading,
ruleType,
ruleTypes,
ruleTypeModel,
uiConfig,
healthCheckError,
Expand Down Expand Up @@ -156,17 +160,31 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
connectors,
connectorTypes,
aadTemplateFields,
formData: fetchedFormData,
formData: {
...getDefaultFormData({
ruleTypeId: fetchedFormData.ruleTypeId,
name: fetchedFormData.name,
consumer: fetchedFormData.consumer,
actions: fetchedFormData.actions,
}),
...fetchedFormData,
},
id,
plugins,
minimumScheduleInterval: uiConfig?.minimumScheduleInterval,
selectedRuleType: ruleType,
selectedRuleTypeModel: ruleTypeModel,
availableRuleTypes: getAvailableRuleTypes({
consumer: fetchedFormData.consumer,
ruleTypes,
ruleTypeRegistry,
}).map(({ ruleType: rt }) => rt),
flappingSettings,
validConsumers: DEFAULT_VALID_CONSUMERS,
showMustacheAutocompleteSwitch,
}}
>
<RulePage isEdit={true} isSaving={isSaving} returnUrl={returnUrl} onSave={onSave} />
<RulePage isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
</RuleFormStateProvider>
</div>
);
Expand Down
Loading

0 comments on commit 38d0f22

Please sign in to comment.