Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into notes-management-table
Browse files Browse the repository at this point in the history
  • Loading branch information
kqualters-elastic committed Jul 1, 2024
2 parents a6fbb4e + 804478b commit bab95c1
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/developer/best-practices/stability.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ access.
*** We need to make sure security is set up in a specific way for
non-standard {kib} indices. (create their own custom roles)
* {kib} running behind a reverse proxy or load balancer, without sticky
sessions. (we have had many discuss/SDH tickets around this)
sessions.
* If a proxy/loadbalancer is running between ES and {kib}

[discrete]
Expand Down Expand Up @@ -78,4 +78,4 @@ Does the feature work efficiently on the list of supported browsers?
* Does the feature affect old indices or saved objects?
* Has the feature been tested with {kib} aliases?
* Read/Write privileges of the indices before and after the
upgrade?
upgrade?
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@
jest.mock('./nav', () => ({
useAppSearchNav: () => [],
}));
import '../../../__mocks__/shallow_useeffect.mock';
import { setMockValues } from '../../../__mocks__/kea_logic';

import React from 'react';

import { shallow } from 'enzyme';
import { of } from 'rxjs';

import { SetAppSearchChrome } from '../../../shared/kibana_chrome';
import { EnterpriseSearchPageTemplateWrapper } from '../../../shared/layout';
import { SendAppSearchTelemetry } from '../../../shared/telemetry';

import { AppSearchPageTemplate } from './page_template';

const mockValues = {
getChromeStyle$: () => of('classic'),
updateSideNavDefinition: jest.fn(),
};

describe('AppSearchPageTemplate', () => {
beforeEach(() => {
setMockValues({ ...mockValues });
});

it('renders', () => {
const wrapper = shallow(
<AppSearchPageTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import React from 'react';

import { useValues } from 'kea';
import useObservable from 'react-use/lib/useObservable';

import { APP_SEARCH_PLUGIN } from '../../../../../common/constants';
import { KibanaLogic } from '../../../shared/kibana';
import { SetAppSearchChrome } from '../../../shared/kibana_chrome';
import { EnterpriseSearchPageTemplateWrapper, PageTemplateProps } from '../../../shared/layout';
import { SendAppSearchTelemetry } from '../../../shared/telemetry';
Expand All @@ -17,12 +21,27 @@ import { useAppSearchNav } from './nav';
export const AppSearchPageTemplate: React.FC<
Omit<PageTemplateProps, 'useEndpointHeaderActions'>
> = ({ children, pageChrome, pageViewTelemetry, ...pageTemplateProps }) => {
const navItems = useAppSearchNav();
const { getChromeStyle$, updateSideNavDefinition } = useValues(KibanaLogic);
const chromeStyle = useObservable(getChromeStyle$(), 'classic');

React.useEffect(() => {
if (chromeStyle === 'classic') return;
// We update the new side nav definition with the selected app items
updateSideNavDefinition({ appSearch: navItems?.[0]?.items });
}, [chromeStyle, navItems, updateSideNavDefinition]);
React.useEffect(() => {
return () => {
updateSideNavDefinition({ appSearch: undefined });
};
}, [updateSideNavDefinition]);

return (
<EnterpriseSearchPageTemplateWrapper
{...pageTemplateProps}
solutionNav={{
name: APP_SEARCH_PLUGIN.NAME,
items: useAppSearchNav(),
items: chromeStyle === 'classic' ? navItems : undefined,
}}
setPageChrome={pageChrome && <SetAppSearchChrome trail={pageChrome} />}
useEndpointHeaderActions={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@
jest.mock('./nav', () => ({
useWorkplaceSearchNav: () => [],
}));
import '../../../__mocks__/shallow_useeffect.mock';
import { setMockValues } from '../../../__mocks__/kea_logic';

import React from 'react';

import { shallow } from 'enzyme';
import { of } from 'rxjs';

import { SetWorkplaceSearchChrome } from '../../../shared/kibana_chrome';
import { EnterpriseSearchPageTemplateWrapper } from '../../../shared/layout';
import { SendWorkplaceSearchTelemetry } from '../../../shared/telemetry';

import { WorkplaceSearchPageTemplate } from './page_template';

const mockValues = {
getChromeStyle$: () => of('classic'),
updateSideNavDefinition: jest.fn(),
};

describe('WorkplaceSearchPageTemplate', () => {
beforeEach(() => {
setMockValues({ ...mockValues });
});

it('renders', () => {
const wrapper = shallow(
<WorkplaceSearchPageTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import React from 'react';

import { useValues } from 'kea';
import useObservable from 'react-use/lib/useObservable';

import { WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants';
import { KibanaLogic } from '../../../shared/kibana';
import { SetWorkplaceSearchChrome } from '../../../shared/kibana_chrome';
import { EnterpriseSearchPageTemplateWrapper, PageTemplateProps } from '../../../shared/layout';
import { SendWorkplaceSearchTelemetry } from '../../../shared/telemetry';
Expand All @@ -20,13 +24,28 @@ export const WorkplaceSearchPageTemplate: React.FC<PageTemplateProps> = ({
pageViewTelemetry,
...pageTemplateProps
}) => {
const navItems = useWorkplaceSearchNav();
const { getChromeStyle$, updateSideNavDefinition } = useValues(KibanaLogic);
const chromeStyle = useObservable(getChromeStyle$(), 'classic');

React.useEffect(() => {
if (chromeStyle === 'classic') return;
// We update the new side nav definition with the selected app items
updateSideNavDefinition({ workplaceSearch: navItems?.[0]?.items });
}, [chromeStyle, navItems, updateSideNavDefinition]);
React.useEffect(() => {
return () => {
updateSideNavDefinition({ workplaceSearch: undefined });
};
}, [updateSideNavDefinition]);

return (
<EnterpriseSearchPageTemplateWrapper
restrictWidth
{...pageTemplateProps}
solutionNav={{
items: chromeStyle === 'classic' ? navItems : undefined,
name: WORKPLACE_SEARCH_PLUGIN.NAME,
items: useWorkplaceSearchNav(),
}}
setPageChrome={pageChrome && <SetWorkplaceSearchChrome trail={pageChrome} />}
useEndpointHeaderActions={false}
Expand Down
25 changes: 19 additions & 6 deletions x-pack/plugins/enterprise_search/public/navigation_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import { SEARCH_APPLICATIONS_PATH } from './applications/applications/routes';
import { SEARCH_INDICES_PATH } from './applications/enterprise_search_content/routes';

export interface DynamicSideNavItems {
appSearch?: Array<EuiSideNavItemType<unknown>>;
collections?: Array<EuiSideNavItemType<unknown>>;
indices?: Array<EuiSideNavItemType<unknown>>;
searchApps?: Array<EuiSideNavItemType<unknown>>;
workplaceSearch?: Array<EuiSideNavItemType<unknown>>;
}

const title = i18n.translate(
Expand Down Expand Up @@ -79,7 +81,7 @@ export const getNavigationTreeDefinition = ({
id: 'es',
navigationTree$: dynamicItems$.pipe(
debounceTime(10),
map(({ indices, searchApps, collections }) => {
map(({ appSearch, indices, searchApps, collections, workplaceSearch }) => {
const navTree: NavigationTreeDefinition = {
body: [
{
Expand Down Expand Up @@ -218,21 +220,32 @@ export const getNavigationTreeDefinition = ({
{
children: [
{
getIsActive: ({ pathNameSerialized, prepend }) => {
return pathNameSerialized.startsWith(
prepend('/app/enterprise_search/app_search')
);
},
getIsActive: () => false,
link: 'appSearch:engines',
title: i18n.translate(
'xpack.enterpriseSearch.searchNav.entsearch.appSearch',
{
defaultMessage: 'App Search',
}
),
...(appSearch
? {
children: appSearch.map(euiItemTypeToNodeDefinition),
isCollapsible: false,
renderAs: 'accordion',
}
: {}),
},
{
getIsActive: () => false,
link: 'workplaceSearch',
...(workplaceSearch
? {
children: workplaceSearch.map(euiItemTypeToNodeDefinition),
isCollapsible: false,
renderAs: 'accordion',
}
: {}),
},
],
id: 'entsearch',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import { cleanupPack, cleanupAgentPolicy } from '../../tasks/api_fixtures';
import { request } from '../../tasks/common';
import { ServerlessRoleName } from '../../support/roles';

// Failing: See https://github.com/elastic/kibana/issues/176543
describe.skip('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
const integration = 'Osquery Manager';

describe(
Expand Down Expand Up @@ -162,6 +161,7 @@ describe.skip('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
it('should be able to run live prebuilt pack', () => {
navigateTo('/app/osquery/live_queries');
cy.contains('New live query').click();
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.contains('Run a set of queries in a pack.').click();
cy.getBySel(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
Expand Down Expand Up @@ -189,8 +189,7 @@ describe.skip('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
navigateTo('/app/osquery/packs');
});

// FLAKY: https://github.com/elastic/kibana/issues/171279
describe.skip('add proper shard to policies packs config', () => {
describe('add proper shard to policies packs config', () => {
const globalPack = 'globalPack' + generateRandomStringName(1)[0];
const agentPolicy = 'testGlobal' + generateRandomStringName(1)[0];
let globalPackId: string;
Expand Down

0 comments on commit bab95c1

Please sign in to comment.