Skip to content

Commit

Permalink
Merge branch 'main' into security/siem-migrations/11387-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
e40pud authored Dec 17, 2024
2 parents bc2eaec + e529a89 commit 62c3bbd
Show file tree
Hide file tree
Showing 67 changed files with 1,157 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,9 @@ describe('versioned', () => {
).toThrow(/failed validation/);
});

it('defaults version resolution "none" when in dev', () => {
it('defaults version resolution "oldest" when in dev', () => {
expect(config.schema.validate({}, { dev: true })).toMatchObject({
versioned: { versionResolution: 'none' },
versioned: { versionResolution: 'oldest' },
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ const configSchema = schema.object(
* Which handler resolution algo to use for public routes: "newest" or "oldest".
*
* @note Internal routes always require a version to be specified.
* @note in development we have an additional option "none" which is also the default in dev.
* @note in development we have an additional option "none".
* This prevents any fallbacks and requires that a version specified.
* Useful for ensuring that a given client always specifies a version.
*/
versionResolution: schema.conditional(
schema.contextRef('dev'),
true,
schema.oneOf([schema.literal('newest'), schema.literal('oldest'), schema.literal('none')], {
defaultValue: 'none',
defaultValue: 'oldest',
}),
schema.oneOf([schema.literal('newest'), schema.literal('oldest')], {
defaultValue: 'oldest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,9 @@ export const runActionTestSuite = ({

// Reindex doesn't return any errors on its own, so we have to test
// together with waitForReindexTask
describe('reindex & waitForReindexTask', () => {
// Flaky: https://github.com/elastic/kibana/issues/166190
// Reported here: https://github.com/elastic/kibana/issues/167273
describe.skip('reindex & waitForReindexTask', () => {
it('resolves right when reindex succeeds without reindex script', async () => {
const res = (await reindex({
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ describe('Share modal embed content tab', () => {

beforeEach(() => {
component = mountWithIntl(
<EmbedContent
isDirty={false}
objectType="dashboard"
setIsNotSaved={() => jest.fn()}
shareableUrl="/home#/"
/>
<EmbedContent isDirty={false} objectType="dashboard" shareableUrl="/home#/" />
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type EmbedProps = Pick<
| 'objectType'
| 'isDirty'
> & {
setIsNotSaved: () => void;
objectConfig?: ShareContextObjectTypeConfig;
};

Expand All @@ -55,7 +54,6 @@ export const EmbedContent = ({
shareableUrl,
objectType,
objectConfig = {},
setIsNotSaved,
isDirty,
}: EmbedProps) => {
const isMounted = useMountedState();
Expand All @@ -67,10 +65,6 @@ export const EmbedContent = ({
const [anonymousAccessParameters] = useState<AnonymousAccessState['accessURLParameters']>(null);
const [usePublicUrl] = useState<boolean>(false);

useEffect(() => {
if (objectType !== 'dashboard') setIsNotSaved();
}, [url, setIsNotSaved, objectType]);

const makeUrlEmbeddable = useCallback((tempUrl: string): string => {
const embedParam = '?embed=true';
const urlHasQueryString = tempUrl.indexOf('?') !== -1;
Expand Down
34 changes: 1 addition & 33 deletions src/plugins/share/public/components/tabs/embed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,13 @@
*/

import { i18n } from '@kbn/i18n';
import React, { useCallback } from 'react';
import React from 'react';
import { type IModalTabDeclaration } from '@kbn/shared-ux-tabbed-modal';
import { EmbedContent } from './embed_content';
import { useShareTabsContext } from '../../context';

const EMBED_TAB_ACTIONS = {
SET_EMBED_URL: 'SET_EMBED_URL',
SET_IS_NOT_SAVED: 'SET_IS_NOT_SAVED',
};

type IEmbedTab = IModalTabDeclaration<{ url: string; isNotSaved: boolean }>;

const embedTabReducer: IEmbedTab['reducer'] = (state = { url: '', isNotSaved: false }, action) => {
switch (action.type) {
case EMBED_TAB_ACTIONS.SET_IS_NOT_SAVED:
return {
...state,
isNotSaved: action.payload,
};
case EMBED_TAB_ACTIONS.SET_IS_NOT_SAVED:
return {
...state,
isNotSaved: action.payload,
};
default:
return state;
}
};

const EmbedTabContent: NonNullable<IEmbedTab['content']> = ({ state, dispatch }) => {
const {
embedUrlParamExtensions,
Expand All @@ -47,13 +25,6 @@ const EmbedTabContent: NonNullable<IEmbedTab['content']> = ({ state, dispatch })
isDirty,
} = useShareTabsContext()!;

const setIsNotSaved = useCallback(() => {
dispatch({
type: EMBED_TAB_ACTIONS.SET_IS_NOT_SAVED,
payload: objectType === 'dashboard' ? isDirty : false,
});
}, [dispatch, objectType, isDirty]);

return (
<EmbedContent
{...{
Expand All @@ -62,8 +33,6 @@ const EmbedTabContent: NonNullable<IEmbedTab['content']> = ({ state, dispatch })
shareableUrl,
objectType,
objectConfig: objectTypeMeta?.config?.embed,
isNotSaved: state?.isNotSaved,
setIsNotSaved,
isDirty,
}}
/>
Expand All @@ -75,6 +44,5 @@ export const embedTab: IEmbedTab = {
name: i18n.translate('share.contextMenu.embedCodeTab', {
defaultMessage: 'Embed',
}),
reducer: embedTabReducer,
content: EmbedTabContent,
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useFlyoutA11y = ({ isXlScreen }: { isXlScreen: boolean }) => {
a11yProps: {
ref: setFlyoutEl,
role: isXlScreen ? 'dialog' : undefined,
tabindex: isXlScreen ? 0 : undefined,
tabIndex: isXlScreen ? 0 : undefined,
'aria-describedby': isXlScreen ? descriptionId : undefined,
'data-no-focus-lock': isXlScreen || undefined,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const graphRequestSchema = schema.object({
nodesLimit: schema.maybe(schema.number()),
showUnknownTarget: schema.maybe(schema.boolean()),
query: schema.object({
eventIds: schema.arrayOf(schema.string()),
originEventIds: schema.arrayOf(
schema.object({ id: schema.string(), isAlert: schema.boolean() })
),
// TODO: use zod for range validation instead of config schema
start: schema.oneOf([schema.number(), schema.string()]),
end: schema.oneOf([schema.number(), schema.string()]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function scoreSuggestions({
type: 'string',
},
},
required: ['score'],
required: ['scores'],
} as const,
};

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/fleet/common/experimental_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export type ExperimentalFeatures = typeof allowedExperimentalValues;
const _allowedExperimentalValues = {
createPackagePolicyMultiPageLayout: true,
packageVerification: true,
showDevtoolsRequest: true,
diagnosticFileUploadEnabled: true,
displayAgentMetrics: true,
showIntegrationsSubcategories: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { i18n } from '@kbn/i18n';
import { omit } from 'lodash';
import { set } from '@kbn/safer-lodash-set';

import { ExperimentalFeaturesService } from '../../../../../services';
import {
generateCreatePackagePolicyDevToolsRequest,
generateCreateAgentPolicyDevToolsRequest,
Expand Down Expand Up @@ -39,12 +38,7 @@ export function useDevToolsRequest({
packageInfo?: PackageInfo;
packagePolicyId?: string;
}) {
const { showDevtoolsRequest: isShowDevtoolRequestExperimentEnabled } =
ExperimentalFeaturesService.get();

const showDevtoolsRequest =
!HIDDEN_API_REFERENCE_PACKAGES.includes(packageInfo?.name ?? '') &&
isShowDevtoolRequestExperimentEnabled;
const showDevtoolsRequest = !HIDDEN_API_REFERENCE_PACKAGES.includes(packageInfo?.name ?? '');

const [devtoolRequest, devtoolRequestDescription] = useMemo(() => {
if (selectedPolicyTab === SelectedPolicyTab.NEW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
ConfirmDeployAgentPolicyModal,
} from '../../../components';
import { DevtoolsRequestFlyoutButton } from '../../../../../components';
import { ExperimentalFeaturesService } from '../../../../../services';
import { generateUpdateAgentPolicyDevToolsRequest } from '../../../services';
import { UNKNOWN_SPACE } from '../../../../../../../../common/constants';

Expand Down Expand Up @@ -155,7 +154,6 @@ export const SettingsView = memo<{ agentPolicy: AgentPolicy }>(
setIsLoading(false);
};

const { showDevtoolsRequest } = ExperimentalFeaturesService.get();
const devtoolRequest = useMemo(
() =>
generateUpdateAgentPolicyDevToolsRequest(
Expand Down Expand Up @@ -235,28 +233,26 @@ export const SettingsView = memo<{ agentPolicy: AgentPolicy }>(
/>
</EuiButtonEmpty>
</EuiFlexItem>
{showDevtoolsRequest ? (
<EuiFlexItem grow={false}>
<DevtoolsRequestFlyoutButton
isDisabled={
isLoading ||
Object.keys(validation).length > 0 ||
hasAdvancedSettingsErrors ||
hasInvalidSpaceError
<EuiFlexItem grow={false}>
<DevtoolsRequestFlyoutButton
isDisabled={
isLoading ||
Object.keys(validation).length > 0 ||
hasAdvancedSettingsErrors ||
hasInvalidSpaceError
}
btnProps={{
color: 'text',
}}
description={i18n.translate(
'xpack.fleet.editAgentPolicy.devtoolsRequestDescription',
{
defaultMessage: 'This Kibana request updates an agent policy.',
}
btnProps={{
color: 'text',
}}
description={i18n.translate(
'xpack.fleet.editAgentPolicy.devtoolsRequestDescription',
{
defaultMessage: 'This Kibana request updates an agent policy.',
}
)}
request={devtoolRequest}
/>
</EuiFlexItem>
) : null}
)}
request={devtoolRequest}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={onSubmit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { useAuthz, useStartServices, sendCreateAgentPolicy } from '../../../../h
import { AgentPolicyForm, agentPolicyFormValidation } from '../../components';
import { DevtoolsRequestFlyoutButton } from '../../../../components';
import { generateCreateAgentPolicyDevToolsRequest } from '../../services';
import { ExperimentalFeaturesService } from '../../../../services';
import { generateNewAgentPolicyWithDefaults } from '../../../../../../../common/services/generate_new_agent_policy';

const FlyoutWithHigherZIndex = styled(EuiFlyout)`
Expand Down Expand Up @@ -109,7 +108,6 @@ export const CreateAgentPolicyFlyout: React.FunctionComponent<Props> = ({
/>
</EuiFlyoutBody>
);
const { showDevtoolsRequest } = ExperimentalFeaturesService.get();
const agentPolicyContent = useMemo(
() => generateCreateAgentPolicyDevToolsRequest(agentPolicy, withSysMonitoring),
[agentPolicy, withSysMonitoring]
Expand All @@ -128,25 +126,23 @@ export const CreateAgentPolicyFlyout: React.FunctionComponent<Props> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="none">
{showDevtoolsRequest ? (
<EuiFlexItem grow={false}>
<DevtoolsRequestFlyoutButton
isDisabled={
isLoading ||
Object.keys(validation).length > 0 ||
hasAdvancedSettingsErrors ||
hasInvalidSpaceError
<EuiFlexItem grow={false}>
<DevtoolsRequestFlyoutButton
isDisabled={
isLoading ||
Object.keys(validation).length > 0 ||
hasAdvancedSettingsErrors ||
hasInvalidSpaceError
}
description={i18n.translate(
'xpack.fleet.createAgentPolicy.devtoolsRequestDescription',
{
defaultMessage: 'This Kibana request creates a new agent policy.',
}
description={i18n.translate(
'xpack.fleet.createAgentPolicy.devtoolsRequestDescription',
{
defaultMessage: 'This Kibana request creates a new agent policy.',
}
)}
request={agentPolicyContent}
/>
</EuiFlexItem>
) : null}
)}
request={agentPolicyContent}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
fill
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/constants/fleet_es_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getESAssetMetadata } from '../services/epm/elasticsearch/meta';

const meta = getESAssetMetadata();

export const FLEET_INSTALL_FORMAT_VERSION = '1.3.0';
export const FLEET_INSTALL_FORMAT_VERSION = '1.4.0';

export const FLEET_AGENT_POLICIES_SCHEMA_VERSION = '1.1.1';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import {
} from '@kbn/core/server/mocks';
import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants';

import { FLEET_INSTALL_FORMAT_VERSION } from '../../../../../constants';
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../../common/constants';

import { appContextService } from '../../../../app_context';
import { createAppContextStartContractMock } from '../../../../../mocks';

import { auditLoggingService } from '../../../../audit_logging';
import { packagePolicyService } from '../../../../package_policy';

import { createArchiveIteratorFromMap } from '../../../archive/archive_iterator';

import { stepSaveSystemObject } from './step_save_system_object';
Expand Down Expand Up @@ -94,7 +92,7 @@ describe('updateLatestExecutedState', () => {
'epm-packages',
'test-integration',
{
install_format_schema_version: '1.3.0',
install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION,
install_status: 'installed',
install_version: '1.0.0',
latest_install_failed_attempts: [],
Expand Down Expand Up @@ -161,7 +159,7 @@ describe('updateLatestExecutedState', () => {
'epm-packages',
'test-integration',
{
install_format_schema_version: '1.3.0',
install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION,
install_status: 'installed',
install_version: '1.0.0',
latest_install_failed_attempts: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useEntityCentricExperienceSetting() {

const isEntityCentricExperienceEnabled = core.uiSettings.get<boolean>(
entityCentricExperience,
true
false
);

return { isEntityCentricExperienceEnabled };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useKibanaContextForPlugin } from './use_kibana';
export function useEntityCentricExperienceSetting() {
const { uiSettings } = useKibanaContextForPlugin().services;

const isEntityCentricExperienceEnabled = uiSettings.get<boolean>(entityCentricExperience, true);
const isEntityCentricExperienceEnabled = uiSettings.get<boolean>(entityCentricExperience);

return { isEntityCentricExperienceEnabled };
}
Loading

0 comments on commit 62c3bbd

Please sign in to comment.