[Enterprise Search] Add eslint import/order rules (#90530)

* Add import rules

- newlines between each group
- mocks in test files before everything else
- React before all other externals

* Run --fix on public/applications/workplace_search

* Manually fix errors still present in WS public files

- these appear to be mostly due to jest.mock() or const mixed in with imports, which confuses the autofixer

* Run --fix on public/applications/app_search

+ some manual fixes/tweaks along the way

* Run --fix on public/applications/shared

- some opinionated changes, particularly around IFlashMessages and grouping together types coming from Kibana (src->../../src)

* Run --fix on public/applications/enterprise_search

- mostly straightforward

* Run --fix on public/applications/__mocks__

* Fix remaining top-level public files

- Some opinionated changes (src/core -> ../../src/core) to keep types/mocks together

* Run --fix on server/ files

- same opinionated src->../src changes to keep deps grouped together

- opinionated require->import fetch change in enterprise_esarch_config_api.test.ts

- opinionated [] inclusion of builtins & external imports together (mostly for enterprise_search_request_handler.ts)
This commit is contained in:
Constance 2021-02-09 09:33:39 -08:00 committed by GitHub
parent 4b3d1bf83c
commit f3399620cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
489 changed files with 1424 additions and 1080 deletions

View file

@ -1119,6 +1119,39 @@ module.exports = {
// All files
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
rules: {
'import/order': [
'error',
{
groups: ['unknown', ['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'],
pathGroups: [
{
pattern:
'{../../../../../../,../../../../../,../../../../,../../../,../../,../}{common/,*}__mocks__{*,/**}',
group: 'unknown',
},
{
pattern: '{**,.}/*.mock',
group: 'unknown',
},
{
pattern: 'react*',
group: 'external',
position: 'before',
},
{
pattern: '{@elastic/**,@kbn/**,src/**}',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: [],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always-and-inside-groups',
},
],
'import/newline-after-import': 'error',
'react-hooks/exhaustive-deps': 'off',
'react/jsx-boolean-value': ['error', 'never'],
},

View file

@ -11,11 +11,11 @@
* NOTE: These variable names MUST start with 'mock*' in order for
* Jest to accept its use within a jest.mock()
*/
import { mockFlashMessagesValues, mockFlashMessagesActions } from './flash_messages_logic.mock';
import { mockHttpValues } from './http_logic.mock';
import { mockKibanaValues } from './kibana_logic.mock';
import { mockLicensingValues } from './licensing_logic.mock';
import { mockHttpValues } from './http_logic.mock';
import { mockTelemetryActions } from './telemetry_logic.mock';
import { mockFlashMessagesValues, mockFlashMessagesActions } from './flash_messages_logic.mock';
export const mockAllValues = {
...mockKibanaValues,

View file

@ -6,6 +6,7 @@
*/
import { chartPluginMock } from '../../../../../../src/plugins/charts/public/mocks';
import { mockHistory } from './';
export const mockKibanaValues = {

View file

@ -6,8 +6,9 @@
*/
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mount, ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from './';

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { mount } from 'enzyme';
import { I18nProvider } from '@kbn/i18n/react';
/**

View file

@ -8,6 +8,7 @@
import React from 'react';
import { shallow, mount, ReactWrapper } from 'enzyme';
import { I18nProvider, __IntlProvider } from '@kbn/i18n/react';
// Use fake component to extract `intl` property to use in tests.

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__';
import { LogicMounter } from '../__mocks__';
import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__';
import { AppLogic } from './app_logic';
describe('AppLogic', () => {

View file

@ -8,6 +8,7 @@
import { kea, MakeLogicType } from 'kea';
import { InitialAppData } from '../../../common/types';
import { ConfiguredLimits, Account, Role } from './types';
import { getRoleAbilities } from './utils/role';

View file

@ -11,14 +11,15 @@ import { mockKibanaValues, setMockValues, setMockActions, rerender } from '../..
import React from 'react';
import { useParams } from 'react-router-dom';
import { shallow } from 'enzyme';
import { Loading } from '../../../shared/loading';
import { FlashMessages } from '../../../shared/flash_messages';
import { Loading } from '../../../shared/loading';
import { LogRetentionCallout } from '../log_retention';
import { AnalyticsHeader, AnalyticsUnavailable } from './components';
import { AnalyticsLayout } from './analytics_layout';
import { AnalyticsHeader, AnalyticsUnavailable } from './components';
describe('AnalyticsLayout', () => {
const { history } = mockKibanaValues;

View file

@ -7,18 +7,21 @@
import React, { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useValues, useActions } from 'kea';
import { EuiSpacer } from '@elastic/eui';
import { KibanaLogic } from '../../../shared/kibana';
import { FlashMessages } from '../../../shared/flash_messages';
import { KibanaLogic } from '../../../shared/kibana';
import { Loading } from '../../../shared/loading';
import { LogRetentionCallout, LogRetentionOptions } from '../log_retention';
import { AnalyticsLogic } from './';
import { AnalyticsHeader, AnalyticsUnavailable } from './components';
import { AnalyticsLogic } from './';
interface Props {
title: string;
isQueryView?: boolean;

View file

@ -19,6 +19,7 @@ jest.mock('../engine', () => ({
import { nextTick } from '@kbn/test/jest';
import { DEFAULT_START_DATE, DEFAULT_END_DATE } from './constants';
import { AnalyticsLogic } from './';
describe('AnalyticsLogic', () => {

View file

@ -8,9 +8,9 @@
import { kea, MakeLogicType } from 'kea';
import queryString from 'query-string';
import { KibanaLogic } from '../../../shared/kibana';
import { HttpLogic } from '../../../shared/http';
import { flashAPIErrors } from '../../../shared/flash_messages';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { EngineLogic } from '../engine';
import { DEFAULT_START_DATE, DEFAULT_END_DATE } from './constants';

View file

@ -8,9 +8,11 @@
import '../../__mocks__/engine_logic.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { Route, Switch } from 'react-router-dom';
import { shallow } from 'enzyme';
import { AnalyticsRouter } from './';
describe('AnalyticsRouter', () => {

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiStat } from '@elastic/eui';
import { AnalyticsCards } from './';

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiStat } from '@elastic/eui';
interface Props {

View file

@ -8,7 +8,9 @@
import { mockKibanaValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { Chart, Settings, LineSeries, Axis } from '@elastic/charts';
import { AnalyticsChart } from './';

View file

@ -6,9 +6,11 @@
*/
import React from 'react';
import { useValues } from 'kea';
import moment from 'moment';
import { Chart, Settings, LineSeries, CurveType, Axis } from '@elastic/charts';
import { KibanaLogic } from '../../../../shared/kibana';

View file

@ -8,13 +8,16 @@
import { setMockValues, mockKibanaValues } from '../../../../__mocks__';
import React, { ReactElement } from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import moment, { Moment } from 'moment';
import { EuiPageHeader, EuiSelect, EuiDatePickerRange, EuiButton } from '@elastic/eui';
import { LogRetentionTooltip } from '../../log_retention';
import { DEFAULT_START_DATE, DEFAULT_END_DATE } from '../constants';
import { AnalyticsHeader } from './';
describe('AnalyticsHeader', () => {

View file

@ -6,12 +6,11 @@
*/
import React, { useState } from 'react';
import { useValues } from 'kea';
import queryString from 'query-string';
import moment from 'moment';
import queryString from 'query-string';
import { i18n } from '@kbn/i18n';
import {
EuiPageHeader,
EuiPageHeaderSection,
@ -23,11 +22,12 @@ import {
EuiDatePicker,
EuiButton,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AnalyticsLogic } from '../';
import { KibanaLogic } from '../../../../shared/kibana';
import { LogRetentionTooltip, LogRetentionOptions } from '../../log_retention';
import { AnalyticsLogic } from '../';
import { DEFAULT_START_DATE, DEFAULT_END_DATE, SERVER_DATE_FORMAT } from '../constants';
import { convertTagsToSelectOptions } from '../utils';

View file

@ -9,7 +9,9 @@ import { mockKibanaValues } from '../../../../__mocks__';
import '../../../__mocks__/engine_logic.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFieldSearch } from '@elastic/eui';
import { AnalyticsSearch } from './';

View file

@ -6,10 +6,11 @@
*/
import React, { useState } from 'react';
import { useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiButton, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { KibanaLogic } from '../../../../shared/kibana';
import { ENGINE_ANALYTICS_QUERY_DETAIL_PATH } from '../../../routes';

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsSection } from './';

View file

@ -9,6 +9,7 @@ import { mountWithIntl, mockKibanaValues } from '../../../../../__mocks__';
import '../../../../__mocks__/engine_logic.mock';
import React from 'react';
import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';
import { AnalyticsTable } from './';

View file

@ -6,10 +6,12 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiBasicTable, EuiBasicTableColumn, EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Query } from '../../types';
import {
TERM_COLUMN_PROPS,
TAGS_COLUMN,

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiBadge, EuiToolTip } from '@elastic/eui';
import { InlineTagsList } from './inline_tags_list';

View file

@ -6,8 +6,9 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiBadgeGroup, EuiBadge, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Query } from '../../types';

View file

@ -9,6 +9,7 @@ import { mountWithIntl } from '../../../../../__mocks__';
import '../../../../__mocks__/engine_logic.mock';
import React from 'react';
import { EuiBasicTable, EuiLink, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';
import { QueryClicksTable } from './';

View file

@ -7,15 +7,16 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiBasicTable, EuiBasicTableColumn, EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { EuiLinkTo } from '../../../../../shared/react_router_helpers';
import { ENGINE_DOCUMENT_DETAIL_PATH } from '../../../../routes';
import { generateEnginePath } from '../../../engine';
import { DOCUMENTS_TITLE } from '../../../documents';
import { generateEnginePath } from '../../../engine';
import { QueryClick } from '../../types';
import { FIRST_COLUMN_PROPS, TAGS_COLUMN, COUNT_COLUMN_PROPS } from './shared_columns';
interface Props {

View file

@ -9,6 +9,7 @@ import { mountWithIntl, mockKibanaValues } from '../../../../../__mocks__';
import '../../../../__mocks__/engine_logic.mock';
import React from 'react';
import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';
import { RecentQueriesTable } from './';

View file

@ -7,11 +7,12 @@
import React from 'react';
import { EuiBasicTable, EuiBasicTableColumn, EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedDate, FormattedTime } from '@kbn/i18n/react';
import { EuiBasicTable, EuiBasicTableColumn, EuiEmptyPrompt } from '@elastic/eui';
import { RecentQuery } from '../../types';
import {
TERM_COLUMN_PROPS,
TAGS_COLUMN,

View file

@ -6,14 +6,15 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiLinkTo } from '../../../../../shared/react_router_helpers';
import { KibanaLogic } from '../../../../../shared/kibana';
import { EuiLinkTo } from '../../../../../shared/react_router_helpers';
import { ENGINE_ANALYTICS_QUERY_DETAIL_PATH } from '../../../../routes';
import { generateEnginePath } from '../../../engine';
import { Query, RecentQuery } from '../../types';
import { InlineTagsList } from './inline_tags_list';
/**

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiEmptyPrompt } from '@elastic/eui';
import { FlashMessages } from '../../../../shared/flash_messages';

View file

@ -6,8 +6,9 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FlashMessages } from '../../../../shared/flash_messages';

View file

@ -6,6 +6,7 @@
*/
import moment from 'moment';
import { i18n } from '@kbn/i18n';
export const ANALYTICS_TITLE = i18n.translate(

View file

@ -6,11 +6,12 @@
*/
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { EuiSelectProps } from '@elastic/eui';
import { SERVER_DATE_FORMAT } from './constants';
import { EuiSelectProps } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ChartData } from './components/analytics_chart';
import { SERVER_DATE_FORMAT } from './constants';
interface ConvertToChartData {
data: number[];

View file

@ -9,6 +9,7 @@ import { setMockValues } from '../../../../__mocks__';
import '../../../__mocks__/engine_logic.mock';
import React from 'react';
import { shallow } from 'enzyme';
import {
@ -18,6 +19,7 @@ import {
AnalyticsTable,
RecentQueriesTable,
} from '../components';
import { Analytics, ViewAllButton } from './analytics';
describe('Analytics overview', () => {

View file

@ -6,10 +6,11 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { EuiSpacer, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { EuiButtonTo } from '../../../../shared/react_router_helpers';
import {
@ -21,6 +22,8 @@ import {
} from '../../../routes';
import { generateEnginePath } from '../../engine';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSection, AnalyticsTable, RecentQueriesTable } from '../components';
import {
ANALYTICS_TITLE,
TOTAL_QUERIES,
@ -32,9 +35,7 @@ import {
TOP_QUERIES_NO_CLICKS,
RECENT_QUERIES,
} from '../constants';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSection, AnalyticsTable, RecentQueriesTable } from '../components';
import { AnalyticsLogic, AnalyticsCards, AnalyticsChart, convertToChartData } from '../';
import { AnalyticsLogic, AnalyticsCards, AnalyticsChart, convertToChartData } from '../index';
export const Analytics: React.FC = () => {
const {

View file

@ -10,12 +10,14 @@ import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { useParams } from 'react-router-dom';
import { shallow } from 'enzyme';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsCards, AnalyticsChart, QueryClicksTable } from '../components';
import { QueryDetail } from './';
describe('QueryDetail', () => {

View file

@ -6,10 +6,11 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { BreadcrumbTrail } from '../../../../shared/kibana_chrome/generate_breadcrumbs';
@ -17,7 +18,7 @@ import { useDecodedParams } from '../../../utils/encode_path_params';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSection, QueryClicksTable } from '../components';
import { AnalyticsLogic, AnalyticsCards, AnalyticsChart, convertToChartData } from '../';
import { AnalyticsLogic, AnalyticsCards, AnalyticsChart, convertToChartData } from '../index';
const QUERY_DETAIL_TITLE = i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.analytics.queryDetail.title',

View file

@ -8,9 +8,11 @@
import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { RecentQueriesTable } from '../components';
import { RecentQueries } from './';
describe('RecentQueries', () => {

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { RECENT_QUERIES } from '../constants';
import { AnalyticsLogic } from '../';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSearch, RecentQueriesTable } from '../components';
import { AnalyticsLogic } from '../';
import { RECENT_QUERIES } from '../constants';
export const RecentQueries: React.FC = () => {
const { recentQueries } = useValues(AnalyticsLogic);

View file

@ -8,9 +8,11 @@
import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsTable } from '../components';
import { TopQueries } from './';
describe('TopQueries', () => {

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { TOP_QUERIES } from '../constants';
import { AnalyticsLogic } from '../';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSearch, AnalyticsTable } from '../components';
import { AnalyticsLogic } from '../';
import { TOP_QUERIES } from '../constants';
export const TopQueries: React.FC = () => {
const { topQueries } = useValues(AnalyticsLogic);

View file

@ -8,9 +8,11 @@
import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsTable } from '../components';
import { TopQueriesNoClicks } from './';
describe('TopQueriesNoClicks', () => {

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { TOP_QUERIES_NO_CLICKS } from '../constants';
import { AnalyticsLogic } from '../';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSearch, AnalyticsTable } from '../components';
import { AnalyticsLogic } from '../';
import { TOP_QUERIES_NO_CLICKS } from '../constants';
export const TopQueriesNoClicks: React.FC = () => {
const { topQueriesNoClicks } = useValues(AnalyticsLogic);

View file

@ -8,9 +8,11 @@
import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsTable } from '../components';
import { TopQueriesNoResults } from './';
describe('TopQueriesNoResults', () => {

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { TOP_QUERIES_NO_RESULTS } from '../constants';
import { AnalyticsLogic } from '../';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSearch, AnalyticsTable } from '../components';
import { AnalyticsLogic } from '../';
import { TOP_QUERIES_NO_RESULTS } from '../constants';
export const TopQueriesNoResults: React.FC = () => {
const { topQueriesNoResults } = useValues(AnalyticsLogic);

View file

@ -8,9 +8,11 @@
import { setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsTable } from '../components';
import { TopQueriesWithClicks } from './';
describe('TopQueriesWithClicks', () => {

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { TOP_QUERIES_WITH_CLICKS } from '../constants';
import { AnalyticsLogic } from '../';
import { AnalyticsLayout } from '../analytics_layout';
import { AnalyticsSearch, AnalyticsTable } from '../components';
import { AnalyticsLogic } from '../';
import { TOP_QUERIES_WITH_CLICKS } from '../constants';
export const TopQueriesWithClicks: React.FC = () => {
const { topQueriesWithClicks } = useValues(AnalyticsLogic);

View file

@ -6,6 +6,7 @@
*/
import { i18n } from '@kbn/i18n';
import { DOCS_PREFIX } from '../../routes';
export const CREDENTIALS_TITLE = i18n.translate(

View file

@ -9,12 +9,15 @@ import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock';
import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { Credentials } from './credentials';
import { EuiCopy, EuiLoadingContent, EuiPageContentBody } from '@elastic/eui';
import { externalUrl } from '../../../shared/enterprise_search_url';
import { Credentials } from './credentials';
import { CredentialsFlyout } from './credentials_flyout';
describe('Credentials', () => {

View file

@ -6,6 +6,7 @@
*/
import React, { useEffect } from 'react';
import { useActions, useValues } from 'kea';
import {
@ -24,14 +25,14 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { FlashMessages } from '../../../shared/flash_messages';
import { CredentialsLogic } from './credentials_logic';
import { externalUrl } from '../../../shared/enterprise_search_url/external_url';
import { FlashMessages } from '../../../shared/flash_messages';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { CREDENTIALS_TITLE } from './constants';
import { CredentialsList } from './credentials_list';
import { CredentialsFlyout } from './credentials_flyout';
import { CredentialsList } from './credentials_list';
import { CredentialsLogic } from './credentials_logic';
export const Credentials: React.FC = () => {
const { initializeCredentialsData, resetCredentials, showCredentialsForm } = useActions(

View file

@ -8,12 +8,15 @@
import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyoutBody, EuiForm } from '@elastic/eui';
import { ApiTokenTypes } from '../constants';
import { defaultApiToken } from '../credentials_logic';
import { CredentialsFlyoutBody } from './body';
import {
FormKeyName,
FormKeyType,
@ -21,7 +24,6 @@ import {
FormKeyEngineAccess,
FormKeyUpdateWarning,
} from './form_components';
import { CredentialsFlyoutBody } from './body';
describe('CredentialsFlyoutBody', () => {
const values = {

View file

@ -6,12 +6,14 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { EuiFlyoutBody, EuiForm } from '@elastic/eui';
import { FlashMessages } from '../../../../shared/flash_messages';
import { CredentialsLogic } from '../credentials_logic';
import { ApiTokenTypes } from '../constants';
import { CredentialsLogic } from '../credentials_logic';
import {
FormKeyName,

View file

@ -8,7 +8,9 @@
import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyoutFooter, EuiButtonEmpty } from '@elastic/eui';
import { CredentialsFlyoutFooter } from './footer';

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import {
EuiFlyoutFooter,
EuiFlexGroup,

View file

@ -8,7 +8,9 @@
import { setMockValues, setMockActions, rerender } from '../../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiRadio, EuiCheckbox } from '@elastic/eui';
import { FormKeyEngineAccess, EngineSelection } from './key_engine_access';

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import {
EuiFormRow,
EuiRadio,

View file

@ -8,7 +8,9 @@
import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFieldText, EuiFormRow } from '@elastic/eui';
import { FormKeyName } from './';

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { EuiFormRow, EuiFieldText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

View file

@ -8,7 +8,9 @@
import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiCheckbox } from '@elastic/eui';
import { FormKeyReadWriteAccess } from './';

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { EuiCheckbox, EuiText, EuiTitle, EuiSpacer, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

View file

@ -8,10 +8,13 @@
import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiSelect } from '@elastic/eui';
import { ApiTokenTypes, TOKEN_TYPE_INFO } from '../../constants';
import { FormKeyType } from './';
describe('FormKeyType', () => {

View file

@ -6,13 +6,15 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { EuiFormRow, EuiSelect, EuiText, EuiLink } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AppLogic } from '../../../../app_logic';
import { CredentialsLogic } from '../../credentials_logic';
import { TOKEN_TYPE_DESCRIPTION, TOKEN_TYPE_INFO, DOCS_HREF } from '../../constants';
import { CredentialsLogic } from '../../credentials_logic';
export const FormKeyType: React.FC = () => {
const { myRole } = useValues(AppLogic);

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiCallOut } from '@elastic/eui';
import { FormKeyUpdateWarning } from './';

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { EuiSpacer, EuiCallOut } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

View file

@ -8,7 +8,9 @@
import { setMockValues } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyoutHeader } from '@elastic/eui';
import { ApiTokenTypes } from '../constants';

View file

@ -6,12 +6,14 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { EuiFlyoutHeader, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { CredentialsLogic } from '../credentials_logic';
import { FLYOUT_ARIA_LABEL_ID } from '../constants';
import { CredentialsLogic } from '../credentials_logic';
export const CredentialsFlyoutHeader: React.FC = () => {
const { activeApiToken } = useValues(CredentialsLogic);

View file

@ -8,7 +8,9 @@
import { setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyout } from '@elastic/eui';
import { CredentialsFlyout } from './';

View file

@ -6,14 +6,17 @@
*/
import React from 'react';
import { useActions } from 'kea';
import { EuiPortal, EuiFlyout } from '@elastic/eui';
import { CredentialsLogic } from '../credentials_logic';
import { FLYOUT_ARIA_LABEL_ID } from '../constants';
import { CredentialsFlyoutHeader } from './header';
import { CredentialsLogic } from '../credentials_logic';
import { CredentialsFlyoutBody } from './body';
import { CredentialsFlyoutFooter } from './footer';
import { CredentialsFlyoutHeader } from './header';
export const CredentialsFlyout: React.FC = () => {
const { hideCredentialsForm } = useActions(CredentialsLogic);

View file

@ -8,15 +8,18 @@
import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiBasicTable, EuiCopy, EuiEmptyPrompt } from '@elastic/eui';
import { ApiToken } from '../types';
import { ApiTokenTypes } from '../constants';
import { HiddenText } from '../../../../shared/hidden_text';
import { ApiTokenTypes } from '../constants';
import { ApiToken } from '../types';
import { Key } from './key';
import { CredentialsList } from './credentials_list';
import { CredentialsList } from './';
describe('Credentials', () => {
const apiToken: ApiToken = {

View file

@ -6,19 +6,21 @@
*/
import React, { useMemo } from 'react';
import { EuiBasicTable, EuiBasicTableColumn, EuiCopy, EuiEmptyPrompt } from '@elastic/eui';
import { CriteriaWithPagination } from '@elastic/eui/src/components/basic_table/basic_table';
import { useActions, useValues } from 'kea';
import { EuiBasicTable, EuiBasicTableColumn, EuiCopy, EuiEmptyPrompt } from '@elastic/eui';
import { CriteriaWithPagination } from '@elastic/eui/src/components/basic_table/basic_table';
import { i18n } from '@kbn/i18n';
import { CredentialsLogic } from '../credentials_logic';
import { Key } from './key';
import { HiddenText } from '../../../../shared/hidden_text';
import { ApiToken } from '../types';
import { TOKEN_TYPE_DISPLAY_NAMES } from '../constants';
import { apiTokenSort } from '../utils/api_token_sort';
import { CredentialsLogic } from '../credentials_logic';
import { ApiToken } from '../types';
import { getModeDisplayText, getEnginesDisplayText } from '../utils';
import { apiTokenSort } from '../utils/api_token_sort';
import { Key } from './key';
export const CredentialsList: React.FC = () => {
const { deleteApiKey, fetchCredentials, showCredentialsForm } = useActions(CredentialsLogic);

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiButtonIcon } from '@elastic/eui';
import { Key } from './key';

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { EuiButtonIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

View file

@ -17,6 +17,7 @@ jest.mock('../../app_logic', () => ({
import { nextTick } from '@kbn/test/jest';
import { AppLogic } from '../../app_logic';
import { ApiTokenTypes } from './constants';
import { CredentialsLogic } from './credentials_logic';

View file

@ -7,19 +7,19 @@
import { kea, MakeLogicType } from 'kea';
import { formatApiName } from '../../utils/format_api_name';
import { ApiTokenTypes, CREATE_MESSAGE, UPDATE_MESSAGE, DELETE_MESSAGE } from './constants';
import { HttpLogic } from '../../../shared/http';
import { Meta } from '../../../../../common/types';
import {
clearFlashMessages,
setSuccessMessage,
flashAPIErrors,
} from '../../../shared/flash_messages';
import { HttpLogic } from '../../../shared/http';
import { AppLogic } from '../../app_logic';
import { Meta } from '../../../../../common/types';
import { Engine } from '../../types';
import { formatApiName } from '../../utils/format_api_name';
import { ApiTokenTypes, CREATE_MESSAGE, UPDATE_MESSAGE, DELETE_MESSAGE } from './constants';
import { ApiToken, CredentialsDetails, TokenReadWrite } from './types';
export const defaultApiToken: ApiToken = {

View file

@ -6,6 +6,7 @@
*/
import { Engine } from '../../types';
import { ApiTokenTypes } from './constants';
export interface CredentialsDetails {

View file

@ -5,11 +5,12 @@
* 2.0.
*/
import { apiTokenSort } from '.';
import { ApiTokenTypes } from '../constants';
import { ApiToken } from '../types';
import { apiTokenSort } from '.';
describe('apiTokenSort', () => {
const apiToken: ApiToken = {
name: '',

View file

@ -6,22 +6,24 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { getEnginesDisplayText } from './get_engines_display_text';
import { ApiToken } from '../types';
import { ApiTokenTypes } from '../constants';
import { ApiToken } from '../types';
const apiToken: ApiToken = {
name: '',
type: ApiTokenTypes.Private,
read: true,
write: true,
access_all_engines: true,
engines: ['engine1', 'engine2', 'engine3'],
};
import { getEnginesDisplayText } from './get_engines_display_text';
describe('getEnginesDisplayText', () => {
const apiToken: ApiToken = {
name: '',
type: ApiTokenTypes.Private,
read: true,
write: true,
access_all_engines: true,
engines: ['engine1', 'engine2', 'engine3'],
};
it('returns "--" when the token is an admin token', () => {
const wrapper = shallow(
<div>{getEnginesDisplayText({ ...apiToken, type: ApiTokenTypes.Admin })}</div>

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import { ApiTokenTypes, ALL } from '../constants';
import { ApiToken } from '../types';

View file

@ -9,7 +9,9 @@ import '../../../../__mocks__/enterprise_search_url.mock';
import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { EuiCode, EuiCodeBlock, EuiButtonEmpty } from '@elastic/eui';
import { ApiCodeExample, FlyoutHeader, FlyoutBody, FlyoutFooter } from './api_code_example';

View file

@ -5,12 +5,12 @@
* 2.0.
*/
import dedent from 'dedent';
import React from 'react';
import dedent from 'dedent';
import { useValues, useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiFlyoutHeader,
EuiTitle,
@ -27,18 +27,19 @@ import {
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { getEnterpriseSearchUrl } from '../../../../shared/enterprise_search_url';
import { DOCS_PREFIX } from '../../../routes';
import { EngineLogic } from '../../engine';
import { EngineDetails } from '../../engine/types';
import { DOCS_PREFIX } from '../../../routes';
import {
DOCUMENTS_API_JSON_EXAMPLE,
FLYOUT_ARIA_LABEL_ID,
FLYOUT_CANCEL_BUTTON,
} from '../constants';
import { DocumentCreationLogic } from '../';
import { DocumentCreationLogic } from '../index';
export const ApiCodeExample: React.FC = () => (
<>

View file

@ -8,10 +8,13 @@
import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiTextArea, EuiButtonEmpty, EuiButton } from '@elastic/eui';
import { Errors } from '../creation_response_components';
import { PasteJsonText, FlyoutHeader, FlyoutBody, FlyoutFooter } from './paste_json_text';
describe('PasteJsonText', () => {

View file

@ -6,9 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import {
EuiFlyoutHeader,
EuiTitle,
@ -22,12 +22,13 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AppLogic } from '../../../app_logic';
import { FLYOUT_ARIA_LABEL_ID, FLYOUT_CANCEL_BUTTON, FLYOUT_CONTINUE_BUTTON } from '../constants';
import { Errors } from '../creation_response_components';
import { DocumentCreationLogic } from '../';
import { DocumentCreationLogic } from '../index';
import './paste_json_text.scss';

View file

@ -8,10 +8,13 @@
import { setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { EuiButtonEmpty } from '@elastic/eui';
import { DocumentCreationButtons } from '../';
import { ShowCreationModes } from './';
describe('ShowCreationModes', () => {

View file

@ -6,9 +6,9 @@
*/
import React from 'react';
import { useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import {
EuiFlyoutHeader,
EuiTitle,
@ -16,9 +16,10 @@ import {
EuiFlyoutFooter,
EuiButtonEmpty,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FLYOUT_ARIA_LABEL_ID, FLYOUT_CANCEL_BUTTON } from '../constants';
import { DocumentCreationLogic, DocumentCreationButtons } from '../';
import { DocumentCreationLogic, DocumentCreationButtons } from '../index';
export const ShowCreationModes: React.FC = () => {
const { closeDocumentCreation } = useActions(DocumentCreationLogic);

View file

@ -8,10 +8,13 @@
import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFilePicker, EuiButtonEmpty, EuiButton } from '@elastic/eui';
import { Errors } from '../creation_response_components';
import { UploadJsonFile, FlyoutHeader, FlyoutBody, FlyoutFooter } from './upload_json_file';
describe('UploadJsonFile', () => {

View file

@ -6,9 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import {
EuiFlyoutHeader,
EuiTitle,
@ -22,12 +22,13 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AppLogic } from '../../../app_logic';
import { FLYOUT_ARIA_LABEL_ID, FLYOUT_CANCEL_BUTTON, FLYOUT_CONTINUE_BUTTON } from '../constants';
import { Errors } from '../creation_response_components';
import { DocumentCreationLogic } from '../';
import { DocumentCreationLogic } from '../index';
export const UploadJsonFile: React.FC = () => (
<>

View file

@ -8,7 +8,9 @@
import { setMockValues } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiCallOut } from '@elastic/eui';
import { Errors } from './';

View file

@ -6,12 +6,13 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { EuiCallOut } from '@elastic/eui';
import { DOCUMENT_CREATION_ERRORS, DOCUMENT_CREATION_WARNINGS } from '../constants';
import { DocumentCreationLogic } from '../';
import { DocumentCreationLogic } from '../index';
export const Errors: React.FC = () => {
const { errors, warnings } = useValues(DocumentCreationLogic);

View file

@ -8,15 +8,19 @@
import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyoutBody, EuiCallOut, EuiButton } from '@elastic/eui';
import { FlyoutHeader, FlyoutBody, FlyoutFooter } from './summary';
import {
InvalidDocumentsSummary,
ValidDocumentsSummary,
SchemaFieldsSummary,
} from './summary_sections';
import { Summary, FlyoutHeader, FlyoutBody, FlyoutFooter } from './summary';
import { Summary } from './';
describe('Summary', () => {
const values = {

View file

@ -6,9 +6,9 @@
*/
import React from 'react';
import { useValues, useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import {
EuiFlyoutHeader,
EuiTitle,
@ -19,10 +19,11 @@ import {
EuiFlexItem,
EuiButton,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { DocumentCreationLogic } from '../';
import { FLYOUT_ARIA_LABEL_ID, FLYOUT_CLOSE_BUTTON, DOCUMENT_CREATION_ERRORS } from '../constants';
import { DocumentCreationStep } from '../types';
import { DocumentCreationLogic } from '../';
import {
InvalidDocumentsSummary,

View file

@ -6,7 +6,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { EuiCodeBlock, EuiCallOut } from '@elastic/eui';
import { ExampleDocumentJson, MoreDocumentsText } from './summary_documents';

View file

@ -7,8 +7,8 @@
import React, { Fragment } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiCodeBlock, EuiCallOut, EuiTitle, EuiText, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
interface ExampleDocumentJsonProps {
document: object;

View file

@ -6,7 +6,9 @@
*/
import React, { ReactElement } from 'react';
import { shallow } from 'enzyme';
import { EuiAccordion, EuiIcon } from '@elastic/eui';
import { SummarySectionAccordion, SummarySectionEmpty } from './summary_section';

View file

@ -8,11 +8,13 @@
import { setMockValues } from '../../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiBadge } from '@elastic/eui';
import { SummarySectionAccordion, SummarySectionEmpty } from './summary_section';
import { ExampleDocumentJson, MoreDocumentsText } from './summary_documents';
import { SummarySectionAccordion, SummarySectionEmpty } from './summary_section';
import {
InvalidDocumentsSummary,

View file

@ -6,15 +6,16 @@
*/
import React from 'react';
import { useValues } from 'kea';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiBadge } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { DocumentCreationLogic } from '../';
import { SummarySectionAccordion, SummarySectionEmpty } from './summary_section';
import { ExampleDocumentJson, MoreDocumentsText } from './summary_documents';
import { SummarySectionAccordion, SummarySectionEmpty } from './summary_section';
export const InvalidDocumentsSummary: React.FC = () => {
const {

View file

@ -9,8 +9,11 @@ import { setMockActions } from '../../../__mocks__/kea.mock';
import '../../__mocks__/engine_logic.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiCard } from '@elastic/eui';
import { EuiCardTo } from '../../../shared/react_router_helpers';
import { DocumentCreationButtons } from './';

View file

@ -6,10 +6,9 @@
*/
import React from 'react';
import { useActions } from 'kea';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiText,
EuiCode,
@ -20,6 +19,8 @@ import {
EuiCard,
EuiIcon,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCardTo } from '../../../shared/react_router_helpers';
import { DOCS_PREFIX, ENGINE_CRAWLER_PATH } from '../../routes';

View file

@ -8,7 +8,9 @@
import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { EuiFlyout } from '@elastic/eui';
import {
@ -18,9 +20,8 @@ import {
UploadJsonFile,
} from './creation_mode_components';
import { Summary } from './creation_response_components';
import { DocumentCreationStep } from './types';
import { DocumentCreationFlyout, FlyoutContent } from './document_creation_flyout';
import { DocumentCreationStep } from './types';
describe('DocumentCreationFlyout', () => {
const values = {

Some files were not shown because too many files have changed in this diff Show more