Skip to content

Commit

Permalink
Merge branch 'cypress/upgrading-8.10-branch' of github.com:MadameShee…
Browse files Browse the repository at this point in the history
…ma/kibana into cypress/upgrading-8.10-branch
  • Loading branch information
patrykkopycinski committed Sep 27, 2023
2 parents 72f2165 + 8dd2e4b commit 1ec0ab6
Show file tree
Hide file tree
Showing 28 changed files with 382 additions and 91 deletions.
4 changes: 2 additions & 2 deletions fleet_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
[
{
"name": "apm",
"version": "8.10.2-preview-1695056404",
"version": "8.10.3-preview-1695284222",
"forceAlignStackVersion": true,
"allowSyncToPrerelease": true
},
{
"name": "elastic_agent",
"version": "1.13.0"
"version": "1.13.1"
},
{
"name": "endpoint",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"del": "^6.1.0",
"elastic-apm-node": "^3.49.1",
"email-addresses": "^5.0.0",
"execa": "^4.0.2",
"execa": "^5.1.1",
"expiry-js": "0.1.7",
"extract-zip": "^2.0.1",
"fast-deep-equal": "^3.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const mockKibanaValues = {
setDocTitle: jest.fn(),
share: sharePluginMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
userProfile: {},
};

jest.mock('../../shared/kibana', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useEffect, useState, ChangeEvent } from 'react';
import { useActions, useValues } from 'kea';

import {
EuiCallOut,
EuiFieldSearch,
EuiFlexGroup,
EuiFlexItem,
Expand Down Expand Up @@ -73,7 +74,7 @@ export const SearchIndexDocuments: React.FC = () => {

const { makeRequest: getDocuments } = useActions(documentLogic);
const { makeRequest: getMappings } = useActions(mappingLogic);
const { data, status } = useValues(documentLogic);
const { data, status, error } = useValues(documentLogic);
const { data: mappingData, status: mappingStatus } = useValues(mappingLogic);

const docs = data?.results?.hits.hits ?? [];
Expand All @@ -83,6 +84,8 @@ export const SearchIndexDocuments: React.FC = () => {

const shouldShowAccessControlSwitcher =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
const isAccessControlIndexNotFound =
shouldShowAccessControlSwitcher && error?.body?.statusCode === 404;

useEffect(() => {
getDocuments({
Expand Down Expand Up @@ -140,11 +143,29 @@ export const SearchIndexDocuments: React.FC = () => {
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
{docs.length === 0 &&
{isAccessControlIndexNotFound && (
<EuiCallOut
size="m"
title={i18n.translate(
'xpack.enterpriseSearch.content.searchIndex.documents.noIndex.title',
{ defaultMessage: 'Access Control Index not found' }
)}
iconType="iInCircle"
>
<p>
{i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noIndex', {
defaultMessage:
"An Access Control Index won't be created until you enable document-level security and run your first access control sync.",
})}
</p>
</EuiCallOut>
)}
{!isAccessControlIndexNotFound &&
docs.length === 0 &&
i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noMappings', {
defaultMessage: 'No documents found for index',
})}
{docs.length > 0 && (
{!isAccessControlIndexNotFound && docs.length > 0 && (
<DocumentList
docs={docs}
docsPerPage={pagination.pageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useEffect, useState } from 'react';
import { useActions, useValues } from 'kea';

import {
EuiCallOut,
EuiCode,
EuiCodeBlock,
EuiFlexGroup,
Expand Down Expand Up @@ -54,9 +55,12 @@ export const SearchIndexIndexMappings: React.FC = () => {
? indexName
: indexName.replace('search-', CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX);
const { makeRequest: makeMappingRequest } = useActions(mappingsWithPropsApiLogic(indexToShow));
const { data: mappingData } = useValues(mappingsWithPropsApiLogic(indexToShow));
const { data: mappingData, error } = useValues(mappingsWithPropsApiLogic(indexToShow));
const shouldShowAccessControlSwitch =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
const isAccessControlIndexNotFound =
shouldShowAccessControlSwitch && error?.body?.statusCode === 404;

useEffect(() => {
makeMappingRequest({ indexName: indexToShow });
}, [indexToShow, indexName]);
Expand All @@ -76,9 +80,27 @@ export const SearchIndexIndexMappings: React.FC = () => {
</EuiFlexItem>
)}
<EuiFlexItem grow>
<EuiCodeBlock language="json" isCopyable>
{JSON.stringify(mappingData, null, 2)}
</EuiCodeBlock>
{isAccessControlIndexNotFound ? (
<EuiCallOut
size="m"
title={i18n.translate(
'xpack.enterpriseSearch.content.searchIndex.mappings.noIndex.title',
{ defaultMessage: 'Access Control Index not found' }
)}
iconType="iInCircle"
>
<p>
{i18n.translate('xpack.enterpriseSearch.content.searchIndex.mappings.noIndex', {
defaultMessage:
"An Access Control Index won't be created until you enable document-level security and run your first access control sync.",
})}
</p>
</EuiCallOut>
) : (
<EuiCodeBlock language="json" isCopyable>
{JSON.stringify(mappingData, null, 2)}
</EuiCodeBlock>
)}
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useEffect, useState } from 'react';

import { useValues } from 'kea';

Expand All @@ -21,6 +21,8 @@ import { Chat } from '@kbn/cloud-chat-plugin/public';
import { i18n } from '@kbn/i18n';
import { WelcomeBanner } from '@kbn/search-api-panels';

import { AuthenticatedUser } from '@kbn/security-plugin/common';

import { ErrorStateCallout } from '../../../shared/error_state';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
Expand All @@ -40,9 +42,24 @@ import { IngestionSelector } from './ingestion_selector';
import './product_selector.scss';

export const ProductSelector: React.FC = () => {
const { config, userProfile } = useValues(KibanaLogic);
const { config, security } = useValues(KibanaLogic);
const { errorConnectingMessage } = useValues(HttpLogic);

const [user, setUser] = useState<AuthenticatedUser | {}>({});

useEffect(() => {
try {
security.authc
.getCurrentUser()
.then(setUser)
.catch(() => {
setUser({});
});
} catch {
setUser({});
}
}, [security.authc]);

const showErrorConnecting = !!(config.host && errorConnectingMessage);
// The create index flow does not work without ent-search, when content is updated
// to no longer rely on ent-search we can always show the Add Content component
Expand All @@ -53,7 +70,7 @@ export const ProductSelector: React.FC = () => {
<TrialCallout />
<EuiPageTemplate.Section alignment="top" className="entSearchProductSelectorHeader">
<EuiText color="ghost">
<WelcomeBanner userProfile={userProfile} image={headerImage} showDescription={false} />
<WelcomeBanner userProfile={{ user }} image={headerImage} showDescription={false} />
</EuiText>
</EuiPageTemplate.Section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const renderApp = (
const { history } = params;
const { application, chrome, http, uiSettings } = core;
const { capabilities, navigateToUrl } = application;
const { charts, cloud, guidedOnboarding, lens, security, share, userProfile } = plugins;
const { charts, cloud, guidedOnboarding, lens, security, share } = plugins;

const entCloudHost = getCloudEnterpriseSearchHost(plugins.cloud);
externalUrl.enterpriseSearchUrl = publicUrl || entCloudHost || config.host || '';
Expand Down Expand Up @@ -108,7 +108,6 @@ export const renderApp = (
setDocTitle: chrome.docTitle.change,
share,
uiSettings,
userProfile,
});
const unmountLicensingLogic = mountLicensingLogic({
canManageLicense: core.application.capabilities.management?.stack?.license_management,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { GetUserProfileResponse, UserProfileData } from '@kbn/security-plugin/common';
import { SecurityPluginStart } from '@kbn/security-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';

Expand Down Expand Up @@ -54,7 +53,6 @@ interface KibanaLogicProps {
setDocTitle(title: string): void;
share: SharePluginStart;
uiSettings: IUiSettingsClient;
userProfile: GetUserProfileResponse<UserProfileData>;
}

export interface KibanaValues extends Omit<KibanaLogicProps, 'cloud'> {
Expand Down Expand Up @@ -95,7 +93,6 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
setDocTitle: [props.setDocTitle, {}],
share: [props.share, {}],
uiSettings: [props.uiSettings, {}],
userProfile: [props.userProfile, {}],
}),
selectors: ({ selectors }) => ({
isCloud: [() => [selectors.cloud], (cloud?: Partial<CloudSetup>) => !!cloud?.isCloudEnabled],
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/publi
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import { GetUserProfileResponse, UserProfileData } from '@kbn/security-plugin/common';
import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';

Expand Down Expand Up @@ -66,7 +65,6 @@ export interface PluginsStart {
licensing: LicensingPluginStart;
security: SecurityPluginStart;
share: SharePluginStart;
userProfile: GetUserProfileResponse<UserProfileData>;
}

export class EnterpriseSearchPlugin implements Plugin {
Expand Down Expand Up @@ -102,8 +100,7 @@ export class EnterpriseSearchPlugin implements Plugin {
cloudSetup && (pluginsStart as PluginsStart).cloud
? { ...cloudSetup, ...(pluginsStart as PluginsStart).cloud }
: undefined;
const userProfile = await (pluginsStart as PluginsStart).security.userProfiles.getCurrent();
const plugins = { ...pluginsStart, cloud, userProfile } as PluginsStart;
const plugins = { ...pluginsStart, cloud } as PluginsStart;

coreStart.chrome
.getChromeStyle$()
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/constants/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElasticsearchAssetType, KibanaAssetType } from '../types/models';

export const PACKAGES_SAVED_OBJECT_TYPE = 'epm-packages';
export const ASSETS_SAVED_OBJECT_TYPE = 'epm-packages-assets';
export const MAX_TIME_COMPLETE_INSTALL = 60000;
export const MAX_TIME_COMPLETE_INSTALL = 30 * 60 * 1000; // 30 minutes

export const FLEET_SYSTEM_PACKAGE = 'system';
export const FLEET_ELASTIC_AGENT_PACKAGE = 'elastic_agent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
}

const onCreateOption = (searchValue: string) => {
const normalizedSearchValue = searchValue.trim().toLowerCase();
const normalizedSearchValue = searchValue.trim();

const newOption = {
label: normalizedSearchValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { getManifestDownloadLink } from './kubernetes_instructions';

describe('getManifestDownloadLink', () => {
it('should return the correct link', () => {
expect(getManifestDownloadLink('https://fleet.host', 'enrollmentToken')).toEqual(
'/api/fleet/kubernetes/download?fleetServer=https%3A%2F%2Ffleet.host&enrolToken=enrollmentToken'
);
expect(getManifestDownloadLink('https://fleet.host')).toEqual(
'/api/fleet/kubernetes/download?fleetServer=https%3A%2F%2Ffleet.host'
);
expect(getManifestDownloadLink(undefined, 'enrollmentToken')).toEqual(
'/api/fleet/kubernetes/download?enrolToken=enrollmentToken'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ interface Props {
fleetServerHost?: string;
}

export const getManifestDownloadLink = (fleetServerHost?: string, enrollmentAPIKey?: string) => {
const searchParams = new URLSearchParams({
...(fleetServerHost && { fleetServer: fleetServerHost }),
...(enrollmentAPIKey && { enrolToken: enrollmentAPIKey }),
});

return `${agentPolicyRouteService.getK8sFullDownloadPath()}?${searchParams.toString()}`;
};

export const KubernetesInstructions: React.FunctionComponent<Props> = ({
enrollmentAPIKey,
onCopy,
Expand Down Expand Up @@ -111,13 +120,8 @@ export const KubernetesInstructions: React.FunctionComponent<Props> = ({
</EuiCopy>
);

const searchParams = new URLSearchParams({
...(fleetServerHost && { fleetServer: fleetServerHost }),
...(enrollmentAPIKey && { enrolToken: enrollmentAPIKey }),
});

const downloadLink = core.http.basePath.prepend(
`${agentPolicyRouteService.getK8sFullDownloadPath()}${searchParams.toString()}`
getManifestDownloadLink(fleetServerHost, enrollmentAPIKey)
);

const k8sDownloadYaml = (
Expand Down
Loading

0 comments on commit 1ec0ab6

Please sign in to comment.