Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Enterprise Search Kibana plugin #66922

Merged
merged 49 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c107ccb
Initial App Search in Kibana plugin work
cee-chen Mar 4, 2020
7f47c8a
Update URL casing to match Kibana best practices
cee-chen Mar 10, 2020
ad1f754
Register App Search plugin in Home Feature Catalogue
cee-chen Mar 11, 2020
852b9e6
Add custom App Search in Kibana logo
cee-chen Mar 11, 2020
68a4b10
Fix appSearch.host config setting to be optional
cee-chen Mar 11, 2020
fe6eac1
Rename plugin to Enterprise Search
cee-chen Apr 15, 2020
c79af1a
Set up React Router URL structure
cee-chen Apr 16, 2020
cbae563
Convert showSetupGuide action/flag to a React Router link
cee-chen Apr 16, 2020
0e7fd50
Implement Kibana Chrome breadcrumbs
cee-chen Apr 17, 2020
b3c564e
Added server unit tests (#2)
JasonStoltz Apr 21, 2020
0c083e1
Refactor top-level Kibana props to a global context state
cee-chen Apr 23, 2020
1719a9d
Added unit tests for public (#4)
JasonStoltz Apr 28, 2020
c6393ed
Add UI telemetry tracking to AS in Kibana (#5)
constancecchen Apr 28, 2020
c8e3d99
Implement remaining unit tests (#7)
constancecchen May 4, 2020
a45d65e
Address larger tech debt/TODOs (#8)
constancecchen May 5, 2020
8eee7fd
Per telemetry team feedback, rename usageCollection telemetry mapping…
cee-chen May 5, 2020
75cfd89
Update Setup Guide installation instructions (#9)
constancecchen May 5, 2020
90e8aae
[Refactor] DRY out route test helper
cee-chen May 6, 2020
f987781
[Refactor] Rename public/test_utils to public/__mocks__
cee-chen May 6, 2020
7883a23
Add platinum licensing check to Meta Engines table/call (#11)
constancecchen May 7, 2020
4f83c5c
Update plugin to use new Kibana nav + URL update (#12)
constancecchen May 8, 2020
6d9c1c4
Add create_first_engine_button telemetry tracking to EmptyState
cee-chen May 8, 2020
af15936
Switch plugin URLs back to /app/enterprise_search/app_search
cee-chen May 13, 2020
9f3645d
Add i18n formatted messages / translations (#13)
constancecchen May 18, 2020
7e886e0
Update EngineOverviewHeader to disable button on prop
cee-chen May 18, 2020
3454568
Address review feedback (#14)
constancecchen Jun 1, 2020
fc19404
E2E testing (#6)
JasonStoltz Jun 2, 2020
0cd9668
Add README and CODEOWNERS (#15)
constancecchen Jun 2, 2020
e366a4a
Fix Typescript errors (#16)
constancecchen Jun 4, 2020
fbdcc61
Fixed TS warnings in E2E tests (#17)
JasonStoltz Jun 9, 2020
931ed8d
Feedback: Convert static CSS values to EUI variables where possible
cee-chen Jun 16, 2020
520408b
Feedback: Flatten nested CSS where possible
cee-chen Jun 16, 2020
bef0ef5
Refactor out components shared with Workplace Search (#18)
constancecchen Jun 17, 2020
176313e
Update copy per feedback from copy team
cee-chen Jun 24, 2020
f920bd4
Address various telemetry issues
cee-chen Jul 2, 2020
2a14b5d
Disable plugin access if a normal user does not have access to App Se…
constancecchen Jul 6, 2020
b1bf08a
Public URL support for Elastic Cloud (#21)
constancecchen Jul 6, 2020
0d0ca9c
Fix failing feature control tests
cee-chen Jul 7, 2020
a74b5e6
Address PR feedback
cee-chen Jul 7, 2020
972adcf
Casing feedback: change all plugin registration IDs from snake_case t…
cee-chen Jul 8, 2020
9e52680
Misc security feedback
cee-chen Jul 8, 2020
15a8b15
Security feedback: add warn logging to telemetry collector
cee-chen Jul 8, 2020
9c6acdd
Address feedback from Pierre
cee-chen Jul 8, 2020
3b715b5
PR feedback
cee-chen Jul 8, 2020
d72e988
Fix telemetry API call returning 415 on Chrome
cee-chen Jul 8, 2020
d6740f2
Fix failing tests
scottybollinger Jul 8, 2020
f305f11
Update Enterprise Search functional tests (without host) to run on CI
cee-chen Jul 8, 2020
2fbde3a
Merge branch 'master' into feature/enterprise-search-plugin
elasticmachine Jul 8, 2020
8ce4486
Address PR feedback from Pierre
cee-chen Jul 9, 2020
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
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,18 @@ module.exports = {
},
},

/**
* Enterprise Search overrides
*/
{
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
excludedFiles: ['x-pack/plugins/enterprise_search/**/*.{test,mock}.{ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'@typescript-eslint/no-explicit-any': 'error',
},
},

/**
* disable jsx-a11y for kbn-ui-framework
*/
Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
# Design
**/*.scss @elastic/kibana-design

# Enterprise Search
/x-pack/plugins/enterprise_search/ @elastic/app-search-frontend @elastic/workplace-search-frontend
/x-pack/test/functional_enterprise_search/ @elastic/app-search-frontend @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/**/*.scss @elastic/ent-search-design

cee-chen marked this conversation as resolved.
Show resolved Hide resolved
# Elasticsearch UI
/src/plugins/dev_tools/ @elastic/es-ui
/src/plugins/console/ @elastic/es-ui
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ export const DEFAULT_APP_CATEGORIES: Readonly<{
euiIconType: string;
order: number;
};
enterpriseSearch: {
id: string;
label: string;
order: number;
euiIconType: string;
};
observability: {
id: string;
label: string;
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ export const DEFAULT_APP_CATEGORIES: Readonly<{
euiIconType: string;
order: number;
};
enterpriseSearch: {
id: string;
label: string;
order: number;
euiIconType: string;
};
observability: {
id: string;
label: string;
Expand Down
12 changes: 10 additions & 2 deletions src/core/utils/default_app_categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,28 @@ export const DEFAULT_APP_CATEGORIES = Object.freeze({
euiIconType: 'logoKibana',
order: 1000,
},
enterpriseSearch: {
id: 'enterpriseSearch',
label: i18n.translate('core.ui.enterpriseSearchNavList.label', {
JasonStoltz marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Enterprise Search',
}),
order: 2000,
euiIconType: 'logoEnterpriseSearch',
},
observability: {
id: 'observability',
label: i18n.translate('core.ui.observabilityNavList.label', {
defaultMessage: 'Observability',
}),
euiIconType: 'logoObservability',
order: 2000,
order: 3000,
},
security: {
id: 'security',
label: i18n.translate('core.ui.securityNavList.label', {
defaultMessage: 'Security',
}),
order: 3000,
order: 4000,
euiIconType: 'logoSecurity',
},
management: {
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"xpack.data": "plugins/data_enhanced",
"xpack.embeddableEnhanced": "plugins/embeddable_enhanced",
"xpack.endpoint": "plugins/endpoint",
"xpack.enterpriseSearch": "plugins/enterprise_search",
"xpack.features": "plugins/features",
"xpack.fileUpload": "plugins/file_upload",
"xpack.globalSearch": ["plugins/global_search"],
Expand Down
25 changes: 25 additions & 0 deletions x-pack/plugins/enterprise_search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Enterprise Search

## Overview

This plugin's goal is to provide a Kibana user interface to the Enterprise Search solution's products (App Search and Workplace Search). In its current MVP state, the plugin provides a basic engines overview from App Search with the goal of gathering user feedback and raising product awareness.

## Development

1. When developing locally, Enterprise Search should be running locally alongside Kibana on `localhost:3002`.
2. Update `config/kibana.dev.yml` with `enterpriseSearch.host: 'http://localhost:3002'`
3. For faster QA/development, run Enterprise Search on [elasticsearch-native auth](https://www.elastic.co/guide/en/app-search/current/security-and-users.html#app-search-self-managed-security-and-user-management-elasticsearch-native-realm) and log in as the `elastic` superuser on Kibana.

## Testing

### Unit tests

From `kibana-root-folder/x-pack`, run:

```bash
yarn test:jest plugins/enterprise_search
```

### E2E tests

See [our functional test runner README](../../test/functional_enterprise_search).
7 changes: 7 additions & 0 deletions x-pack/plugins/enterprise_search/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const ENGINES_PAGE_SIZE = 10;
10 changes: 10 additions & 0 deletions x-pack/plugins/enterprise_search/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "enterpriseSearch",
"version": "kibana",
"kibanaVersion": "kibana",
"requiredPlugins": ["home", "features", "licensing"],
"configPath": ["enterpriseSearch"],
"optionalPlugins": ["usageCollection", "security"],
"server": true,
"ui": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { mockHistory } from './react_router_history.mock';
export { mockKibanaContext } from './kibana_context.mock';
export { mockLicenseContext } from './license_context.mock';
export { mountWithContext, mountWithKibanaContext } from './mount_with_context.mock';
export { shallowWithIntl } from './shallow_with_i18n.mock';

// Note: shallow_usecontext must be imported directly as a file
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { httpServiceMock } from 'src/core/public/mocks';

/**
* A set of default Kibana context values to use across component tests.
* @see enterprise_search/public/index.tsx for the KibanaContext definition/import
*/
export const mockKibanaContext = {
http: httpServiceMock.createSetupContract(),
setBreadcrumbs: jest.fn(),
enterpriseSearchUrl: 'http://localhost:3002',
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { licensingMock } from '../../../../licensing/public/mocks';

export const mockLicenseContext = {
license: licensingMock.createLicense(),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { mount } from 'enzyme';

import { I18nProvider } from '@kbn/i18n/react';
import { KibanaContext } from '../';
import { mockKibanaContext } from './kibana_context.mock';
import { LicenseContext } from '../shared/licensing';
import { mockLicenseContext } from './license_context.mock';

/**
* This helper mounts a component with all the contexts/providers used
* by the production app, while allowing custom context to be
* passed in via a second arg
*
* Example usage:
*
* const wrapper = mountWithContext(<Component />, { enterpriseSearchUrl: 'someOverride', license: {} });
*/
export const mountWithContext = (children: React.ReactNode, context?: object) => {
return mount(
<I18nProvider>
<KibanaContext.Provider value={{ ...mockKibanaContext, ...context }}>
<LicenseContext.Provider value={{ ...mockLicenseContext, ...context }}>
{children}
</LicenseContext.Provider>
</KibanaContext.Provider>
</I18nProvider>
);
};

/**
* This helper mounts a component with just the default KibanaContext -
* useful for isolated / helper components that only need this context
*
* Same usage/override functionality as mountWithContext
*/
export const mountWithKibanaContext = (children: React.ReactNode, context?: object) => {
return mount(
<KibanaContext.Provider value={{ ...mockKibanaContext, ...context }}>
{children}
</KibanaContext.Provider>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/**
* NOTE: This variable name MUST start with 'mock*' in order for
* Jest to accept its use within a jest.mock()
*/
export const mockHistory = {
createHref: jest.fn(({ pathname }) => `/enterprise_search${pathname}`),
push: jest.fn(),
location: {
pathname: '/current-path',
},
};

jest.mock('react-router-dom', () => ({
useHistory: jest.fn(() => mockHistory),
}));

/**
* For example usage, @see public/applications/shared/react_router_helpers/eui_link.test.tsx
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

/**
* NOTE: These variable names MUST start with 'mock*' in order for
* Jest to accept its use within a jest.mock()
*/
import { mockKibanaContext } from './kibana_context.mock';
import { mockLicenseContext } from './license_context.mock';

jest.mock('react', () => ({
...(jest.requireActual('react') as object),
useContext: jest.fn(() => ({ ...mockKibanaContext, ...mockLicenseContext })),
}));

/**
* Example usage within a component test using shallow():
*
* import '../../../test_utils/mock_shallow_usecontext'; // Must come before React's import, adjust relative path as needed
*
* import React from 'react';
* import { shallow } from 'enzyme';
*
* // ... etc.
*/

/**
* If you need to override the default mock context values, you can do so via jest.mockImplementation:
*
* import React, { useContext } from 'react';
*
* // ... etc.
*
* it('some test', () => {
* useContext.mockImplementationOnce(() => ({ enterpriseSearchUrl: 'someOverride' }));
* });
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';
import { I18nProvider } from '@kbn/i18n/react';
import { IntlProvider } from 'react-intl';

const intlProvider = new IntlProvider({ locale: 'en', messages: {} }, {});
const { intl } = intlProvider.getChildContext();

/**
* This helper shallow wraps a component with react-intl's <I18nProvider> which
* fixes "Could not find required `intl` object" console errors when running tests
*
* Example usage (should be the same as shallow()):
*
* const wrapper = shallowWithIntl(<Component />);
*/
export const shallowWithIntl = (children: React.ReactNode) => {
const context = { context: { intl } };

return shallow(<I18nProvider>{children}</I18nProvider>, context)
.childAt(0)
.dive(context)
.shallow();
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading