diff --git a/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js b/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js index f74e145865475..47392c541890e 100644 --- a/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js +++ b/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js @@ -73,22 +73,7 @@ describe('discover field chooser directives', function() { beforeEach(() => pluginInstance.initializeServices()); beforeEach(() => pluginInstance.initializeInnerAngular()); - beforeEach( - ngMock.module('app/discover', $provide => { - $provide.decorator('config', $delegate => { - // disable shortDots for these tests - $delegate.get = _.wrap($delegate.get, function(origGet, name) { - if (name === 'shortDots:enable') { - return false; - } else { - return origGet.call(this, name); - } - }); - - return $delegate; - }); - }) - ); + beforeEach(ngMock.module('app/discover')); beforeEach( ngMock.inject(function(Private) { diff --git a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js index c19e033ccb72d..9b63b8cd18f3e 100644 --- a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js +++ b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js @@ -30,7 +30,6 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta describe('Doc Table', function() { let $parentScope; let $scope; - let config; // Stub out a minimal mapping of 4 fields let mapping; @@ -41,8 +40,7 @@ describe('Doc Table', function() { beforeEach(() => pluginInstance.initializeInnerAngular()); beforeEach(ngMock.module('app/discover')); beforeEach( - ngMock.inject(function(_config_, $rootScope, Private) { - config = _config_; + ngMock.inject(function($rootScope, Private) { $parentScope = $rootScope; $parentScope.indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); mapping = $parentScope.indexPattern.fields; @@ -144,12 +142,6 @@ describe('Doc Table', function() { filter: sinon.spy(), maxLength: 50, }); - - // Ignore the metaFields (_id, _type, etc) since we don't have a mapping for them - sinon - .stub(config, 'get') - .withArgs('metaFields') - .returns([]); }); afterEach(function() { destroy(); @@ -215,11 +207,6 @@ describe('Doc Table', function() { maxLength: 50, }); - sinon - .stub(config, 'get') - .withArgs('metaFields') - .returns(['_id']); - // Open the row $scope.toggleRow(); $scope.$digest(); diff --git a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts index 4d871bcb7a858..a19278911507c 100644 --- a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts +++ b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts @@ -23,9 +23,7 @@ import angular from 'angular'; import { EuiIcon } from '@elastic/eui'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; -import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; -// @ts-ignore -import { StateManagementConfigProvider } from 'ui/state_management/config_provider'; +import { CoreStart, LegacyCoreStart } from 'kibana/public'; // @ts-ignore import { KbnUrlProvider } from 'ui/url'; import { DataPublicPluginStart } from '../../../../../plugins/data/public'; @@ -108,7 +106,6 @@ export function initializeInnerAngularModule( createLocalI18nModule(); createLocalPrivateModule(); createLocalPromiseModule(); - createLocalConfigModule(core.uiSettings); createLocalKbnUrlModule(); createLocalTopNavModule(navigation); createLocalStorageModule(); @@ -143,7 +140,6 @@ export function initializeInnerAngularModule( 'ngRoute', 'react', 'ui.bootstrap', - 'discoverConfig', 'discoverI18n', 'discoverPrivate', 'discoverPromise', @@ -176,21 +172,6 @@ function createLocalKbnUrlModule() { .service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider)); } -function createLocalConfigModule(uiSettings: IUiSettingsClient) { - angular - .module('discoverConfig', ['discoverPrivate']) - .provider('stateManagementConfig', StateManagementConfigProvider) - .provider('config', () => { - return { - $get: () => ({ - get: (value: string) => { - return uiSettings ? uiSettings.get(value) : undefined; - }, - }), - }; - }); -} - function createLocalPromiseModule() { angular.module('discoverPromise', []).service('Promise', PromiseServiceCreator); } @@ -229,7 +210,7 @@ const createLocalStorageService = function(type: string) { function createElasticSearchModule(data: DataPublicPluginStart) { angular - .module('discoverEs', ['discoverConfig']) + .module('discoverEs', []) // Elasticsearch client used for requesting data. Connects to the /elasticsearch proxy .service('es', () => { return data.search.__LEGACY.esClient; @@ -242,12 +223,7 @@ function createPagerFactoryModule() { function createDocTableModule() { angular - .module('discoverDocTable', [ - 'discoverKbnUrl', - 'discoverConfig', - 'discoverPagerFactory', - 'react', - ]) + .module('discoverDocTable', ['discoverKbnUrl', 'discoverPagerFactory', 'react']) .directive('docTable', createDocTableDirective) .directive('kbnTableHeader', createTableHeaderDirective) .directive('toolBarPagerText', createToolBarPagerTextDirective) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js index 038f783a0daf1..f8e764cbcbebb 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js @@ -66,7 +66,7 @@ getAngularModule().config($routeProvider => { }); }); -function ContextAppRouteController($routeParams, $scope, config, $route) { +function ContextAppRouteController($routeParams, $scope, $route) { const filterManager = getServices().filterManager; const indexPattern = $route.current.locals.indexPattern.ip; const { @@ -77,9 +77,9 @@ function ContextAppRouteController($routeParams, $scope, config, $route) { setFilters, setAppState, } = getState({ - defaultStepSize: config.get('context:defaultSize'), + defaultStepSize: getServices().uiSettings.get('context:defaultSize'), timeFieldName: indexPattern.timeFieldName, - storeInSessionStorage: config.get('state:storeInSessionStorage'), + storeInSessionStorage: getServices().uiSettings.get('state:storeInSessionStorage'), }); this.state = { ...appState.getState() }; this.anchorId = $routeParams.id; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js index 345717cafee9a..a6a1de695156d 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js @@ -57,13 +57,13 @@ module.directive('contextApp', function ContextApp() { }; }); -function ContextAppController($scope, config, Private) { - const { filterManager, indexpatterns } = getServices(); +function ContextAppController($scope, Private) { + const { filterManager, indexpatterns, uiSettings } = getServices(); const queryParameterActions = getQueryParameterActions(filterManager, indexpatterns); const queryActions = Private(QueryActionsProvider); this.state = createInitialState( - parseInt(config.get('context:step'), 10), - getFirstSortableField(this.indexPattern, config.get('context:tieBreakerFields')), + parseInt(uiSettings.get('context:step'), 10), + getFirstSortableField(this.indexPattern, uiSettings.get('context:tieBreakerFields')), this.discoverUrl ); diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js index 4bc498928be52..b020113381992 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js @@ -17,9 +17,9 @@ * under the License. */ import { FieldName } from './field_name/field_name'; -import { wrapInI18nContext } from '../../../kibana_services'; +import { getServices, wrapInI18nContext } from '../../../kibana_services'; -export function FieldNameDirectiveProvider(config, reactDirective) { +export function FieldNameDirectiveProvider(reactDirective) { return reactDirective( wrapInI18nContext(FieldName), [ @@ -29,7 +29,7 @@ export function FieldNameDirectiveProvider(config, reactDirective) { ], { restrict: 'AE' }, { - useShortDots: config.get('shortDots:enable'), + useShortDots: getServices().uiSettings.get('shortDots:enable'), } ); } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index 9a383565f4f43..2857f8720d8dc 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -64,7 +64,7 @@ const { share, timefilter, toastNotifications, - uiSettings, + uiSettings: config, visualizations, } = getServices(); @@ -131,7 +131,7 @@ app.config($routeProvider => { * * @type {State} */ - const id = getIndexPatternId(index, indexPatternList, uiSettings.get('defaultIndex')); + const id = getIndexPatternId(index, indexPatternList, config.get('defaultIndex')); return Promise.props({ list: indexPatternList, loaded: indexPatterns.get(id), @@ -184,7 +184,6 @@ function discoverController( $timeout, $window, Promise, - config, kbnUrl, localStorage, uiCapabilities diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts index 32174984c1dfb..84d865fd22a9a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts @@ -16,11 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { IUiSettingsClient } from 'kibana/public'; import { TableHeader } from './table_header/table_header'; -import { wrapInI18nContext } from '../../../../kibana_services'; +import { wrapInI18nContext, getServices } from '../../../../kibana_services'; + +export function createTableHeaderDirective(reactDirective: any) { + const { uiSettings: config } = getServices(); -export function createTableHeaderDirective(reactDirective: any, config: IUiSettingsClient) { return reactDirective( wrapInI18nContext(TableHeader), [ diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts index 7a090d6b7820c..5d3f6ac199a46 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts @@ -19,7 +19,6 @@ import _ from 'lodash'; import $ from 'jquery'; -import { IUiSettingsClient } from 'kibana/public'; // @ts-ignore import rison from 'rison-node'; import '../../doc_viewer'; @@ -45,8 +44,7 @@ interface LazyScope extends ng.IScope { export function createTableRowDirective( $compile: ng.ICompileService, $httpParamSerializer: any, - kbnUrl: any, - config: IUiSettingsClient + kbnUrl: any ) { const cellTemplate = _.template(noWhiteSpace(cellTemplateHtml)); const truncateByHeightTemplate = _.template(noWhiteSpace(truncateByHeightTemplateHtml)); @@ -140,7 +138,7 @@ export function createTableRowDirective( const newHtmls = [openRowHtml]; const mapping = indexPattern.fields.getByName; - const hideTimeColumn = config.get('doc_table:hideTimeColumn'); + const hideTimeColumn = getServices().uiSettings.get('doc_table:hideTimeColumn'); if (indexPattern.timeFieldName && !hideTimeColumn) { newHtmls.push( cellTemplate({ diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts index 0ca8286c17081..3cb3a460af649 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts @@ -17,21 +17,17 @@ * under the License. */ -import { IUiSettingsClient } from 'kibana/public'; import html from './doc_table.html'; import { dispatchRenderComplete } from '../../../../../../../../plugins/kibana_utils/public'; // @ts-ignore import { getLimitedSearchResultsMessage } from './doc_table_strings'; +import { getServices } from '../../../kibana_services'; interface LazyScope extends ng.IScope { [key: string]: any; } -export function createDocTableDirective( - config: IUiSettingsClient, - pagerFactory: any, - $filter: any -) { +export function createDocTableDirective(pagerFactory: any, $filter: any) { return { restrict: 'E', template: html, @@ -68,7 +64,7 @@ export function createDocTableDirective( }; $scope.limitedResultsWarning = getLimitedSearchResultsMessage( - config.get('discover:sampleSize') + getServices().uiSettings.get('discover:sampleSize') ); $scope.addRows = function() { diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js index 4afaafd9bb1cf..398728e51862f 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js @@ -29,8 +29,9 @@ import { KBN_FIELD_TYPES, } from '../../../../../../../../plugins/data/public'; import { getMapsAppUrl, isFieldVisualizable, isMapsAppRegistered } from './lib/visualize_url_utils'; +import { getServices } from '../../../kibana_services'; -export function createFieldChooserDirective($location, config) { +export function createFieldChooserDirective($location) { return { restrict: 'E', scope: { @@ -49,6 +50,7 @@ export function createFieldChooserDirective($location, config) { $scope.showFilter = false; $scope.toggleShowFilter = () => ($scope.showFilter = !$scope.showFilter); $scope.indexPatternList = _.sortBy($scope.indexPatternList, o => o.get('title')); + const config = getServices().uiSettings; const filter = ($scope.filter = { props: ['type', 'aggregatable', 'searchable', 'missing', 'name'], diff --git a/x-pack/plugins/ml/common/constants/categorization_job.ts b/x-pack/plugins/ml/common/constants/categorization_job.ts new file mode 100644 index 0000000000000..c1c65e4bf15b8 --- /dev/null +++ b/x-pack/plugins/ml/common/constants/categorization_job.ts @@ -0,0 +1,80 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { VALIDATION_RESULT } from '../types/categories'; + +export const NUMBER_OF_CATEGORY_EXAMPLES = 5; +export const CATEGORY_EXAMPLES_SAMPLE_SIZE = 1000; +export const CATEGORY_EXAMPLES_WARNING_LIMIT = 0.75; +export const CATEGORY_EXAMPLES_ERROR_LIMIT = 0.02; + +export const VALID_TOKEN_COUNT = 3; +export const MEDIAN_LINE_LENGTH_LIMIT = 400; +export const NULL_COUNT_PERCENT_LIMIT = 0.75; + +export enum CATEGORY_EXAMPLES_VALIDATION_STATUS { + VALID = 'valid', + PARTIALLY_VALID = 'partially_valid', + INVALID = 'invalid', +} + +export const VALIDATION_CHECK_DESCRIPTION = { + [VALIDATION_RESULT.NO_EXAMPLES]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validNoDataFound', + { + defaultMessage: 'Examples were successfully loaded.', + } + ), + [VALIDATION_RESULT.FAILED_TO_TOKENIZE]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validFailureToGetTokens', + { + defaultMessage: 'The examples loaded were tokenized successfully.', + } + ), + [VALIDATION_RESULT.TOKEN_COUNT]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validTokenLength', + { + defaultMessage: + 'More than {tokenCount} tokens per example were found in over {percentage}% of the examples loaded.', + values: { + percentage: Math.floor(CATEGORY_EXAMPLES_WARNING_LIMIT * 100), + tokenCount: VALID_TOKEN_COUNT, + }, + } + ), + [VALIDATION_RESULT.MEDIAN_LINE_LENGTH]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validMedianLineLength', + { + defaultMessage: + 'The median line length of the examples loaded was less than {medianCharCount} characters.', + values: { + medianCharCount: MEDIAN_LINE_LENGTH_LIMIT, + }, + } + ), + [VALIDATION_RESULT.NULL_VALUES]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validNullValues', + { + defaultMessage: 'Less than {percentage}% of the examples loaded were null.', + values: { + percentage: Math.floor(100 - NULL_COUNT_PERCENT_LIMIT * 100), + }, + } + ), + [VALIDATION_RESULT.TOO_MANY_TOKENS]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validTooManyTokens', + { + defaultMessage: 'Less than 10000 tokens were found in total in the examples loaded.', + } + ), + [VALIDATION_RESULT.INSUFFICIENT_PRIVILEGES]: i18n.translate( + 'xpack.ml.models.jobService.categorization.messages.validUserPrivileges', + { + defaultMessage: 'The user has sufficient privileges to perform the checks.', + } + ), +}; diff --git a/x-pack/plugins/ml/common/constants/new_job.ts b/x-pack/plugins/ml/common/constants/new_job.ts index 862fa72d11fdb..751413bb6485a 100644 --- a/x-pack/plugins/ml/common/constants/new_job.ts +++ b/x-pack/plugins/ml/common/constants/new_job.ts @@ -25,15 +25,3 @@ export const DEFAULT_RARE_BUCKET_SPAN = '1h'; export const DEFAULT_QUERY_DELAY = '60s'; export const SHARED_RESULTS_INDEX_NAME = 'shared'; - -// Categorization -export const NUMBER_OF_CATEGORY_EXAMPLES = 5; -export const CATEGORY_EXAMPLES_SAMPLE_SIZE = 1000; -export const CATEGORY_EXAMPLES_WARNING_LIMIT = 0.75; -export const CATEGORY_EXAMPLES_ERROR_LIMIT = 0.02; - -export enum CATEGORY_EXAMPLES_VALIDATION_STATUS { - VALID = 'valid', - PARTIALLY_VALID = 'partially_valid', - INVALID = 'invalid', -} diff --git a/x-pack/plugins/ml/common/types/categories.ts b/x-pack/plugins/ml/common/types/categories.ts index 862ad8e194a0b..5d4c3eab53ee8 100644 --- a/x-pack/plugins/ml/common/types/categories.ts +++ b/x-pack/plugins/ml/common/types/categories.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../constants/categorization_job'; export type CategoryId = number; @@ -39,12 +39,12 @@ export interface CategoryFieldExample { } export enum VALIDATION_RESULT { + NO_EXAMPLES, + FAILED_TO_TOKENIZE, + TOO_MANY_TOKENS, TOKEN_COUNT, MEDIAN_LINE_LENGTH, NULL_VALUES, - NO_EXAMPLES, - TOO_MANY_TOKENS, - FAILED_TO_TOKENIZE, INSUFFICIENT_PRIVILEGES, } diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/categorization_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/categorization_job_creator.ts index 7407a43aa9d5e..95fd9df892cab 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/categorization_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/categorization_job_creator.ts @@ -16,8 +16,8 @@ import { CREATED_BY_LABEL, DEFAULT_BUCKET_SPAN, DEFAULT_RARE_BUCKET_SPAN, - CATEGORY_EXAMPLES_VALIDATION_STATUS, } from '../../../../../../common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../../common/constants/categorization_job'; import { ML_JOB_AGGREGATION } from '../../../../../../common/constants/aggregation_types'; import { CategorizationAnalyzer, diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_validator/job_validator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_validator/job_validator.ts index 8f6b16c407fb6..82e5e15a24d5c 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_validator/job_validator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_validator/job_validator.ts @@ -16,7 +16,7 @@ import { JobCreator, JobCreatorType, isCategorizationJobCreator } from '../job_c import { populateValidationMessages, checkForExistingJobAndGroupIds } from './util'; import { ExistingJobsAndGroups } from '../../../../services/job_service'; import { cardinalityValidator, CardinalityValidatorResult } from './validators'; -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../../common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../../common/constants/categorization_job'; // delay start of validation to allow the user to make changes // e.g. if they are typing in a new value, try not to validate diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/categorization_examples_loader.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/categorization_examples_loader.ts index 8f3a56b6b2b90..de550f61858e6 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/categorization_examples_loader.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/categorization_examples_loader.ts @@ -11,7 +11,7 @@ import { ml } from '../../../../services/ml_api_service'; import { NUMBER_OF_CATEGORY_EXAMPLES, CATEGORY_EXAMPLES_VALIDATION_STATUS, -} from '../../../../../../common/constants/new_job'; +} from '../../../../../../common/constants/categorization_job'; export class CategorizationExamplesLoader { private _jobCreator: CategorizationJobCreator; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/additional_section.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/additional_section.tsx index dd287d10ab2c8..75856d5276fdf 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/additional_section.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/additional_section.tsx @@ -5,11 +5,17 @@ */ import React, { FC, Fragment } from 'react'; +import { i18n } from '@kbn/i18n'; import { EuiAccordion, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import { CalendarsSelection } from './components/calendars'; import { CustomUrlsSelection } from './components/custom_urls'; -const ButtonContent = Additional settings; +const buttonContent = i18n.translate( + 'xpack.ml.newJob.wizard.jobDetailsStep.additionalSectionButton', + { + defaultMessage: 'Additional settings', + } +); interface Props { additionalExpanded: boolean; @@ -22,7 +28,7 @@ export const AdditionalSection: FC = ({ additionalExpanded, setAdditional = ({ advancedExpanded, setAdvancedExpand = ({ overallValidStatus, validationChecks, @@ -66,6 +84,10 @@ export const ExamplesValidCallout: FC = ({ ))} {analyzerUsed} + + + + ); }; @@ -96,3 +118,28 @@ const AnalyzerUsed: FC<{ categorizationAnalyzer: CategorizationAnalyzer }> = ({ ); }; + +const AllValidationChecks: FC<{ validationChecks: FieldExampleCheck[] }> = ({ + validationChecks, +}) => { + const list: EuiListGroupItemProps[] = Object.keys(VALIDATION_CHECK_DESCRIPTION).map((k, i) => { + const failedCheck = validationChecks.find(vc => vc.id === i); + if ( + failedCheck !== undefined && + failedCheck?.valid !== CATEGORY_EXAMPLES_VALIDATION_STATUS.VALID + ) { + return { + iconType: 'cross', + label: failedCheck.message, + size: 's', + }; + } + return { + iconType: 'check', + label: VALIDATION_CHECK_DESCRIPTION[i as VALIDATION_RESULT], + size: 's', + }; + }); + + return ; +}; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/metric_selection.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/metric_selection.tsx index 411f6e898bd48..f5c3e90d63418 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/metric_selection.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/metric_selection.tsx @@ -18,7 +18,7 @@ import { CategoryFieldExample, FieldExampleCheck, } from '../../../../../../../../../common/types/categories'; -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../../../../../common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../../../../../common/constants/categorization_job'; import { LoadingWrapper } from '../../../charts/loading_wrapper'; interface Props { diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/top_categories.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/top_categories.tsx index 3bade07250b46..227c93dc2d86b 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/top_categories.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/categorization_view/top_categories.tsx @@ -11,7 +11,7 @@ import { JobCreatorContext } from '../../../job_creator_context'; import { CategorizationJobCreator } from '../../../../../common/job_creator'; import { Results } from '../../../../../common/results_loader'; import { ml } from '../../../../../../../services/ml_api_service'; -import { NUMBER_OF_CATEGORY_EXAMPLES } from '../../../../../../../../../common/constants/new_job'; +import { NUMBER_OF_CATEGORY_EXAMPLES } from '../../../../../../../../../common/constants/categorization_job'; export const TopCategories: FC = () => { const { jobCreator: jc, resultsLoader } = useContext(JobCreatorContext); diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts index bcceffb14123e..16e25067fd91e 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts @@ -17,7 +17,7 @@ import { CategoryFieldExample, FieldExampleCheck, } from '../../../../common/types/categories'; -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../common/constants/categorization_job'; import { Category } from '../../../../common/types/categories'; export const jobs = { diff --git a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts index ea2c71b04f56d..b209dc5681563 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts @@ -6,7 +6,7 @@ import { chunk } from 'lodash'; import { SearchResponse } from 'elasticsearch'; -import { CATEGORY_EXAMPLES_SAMPLE_SIZE } from '../../../../../common/constants/new_job'; +import { CATEGORY_EXAMPLES_SAMPLE_SIZE } from '../../../../../common/constants/categorization_job'; import { Token, CategorizationAnalyzer, diff --git a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/validation_results.ts b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/validation_results.ts index 34e63eabb405e..e3b37fffa9c77 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/validation_results.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/validation_results.ts @@ -6,10 +6,13 @@ import { i18n } from '@kbn/i18n'; import { + VALID_TOKEN_COUNT, + MEDIAN_LINE_LENGTH_LIMIT, + NULL_COUNT_PERCENT_LIMIT, CATEGORY_EXAMPLES_VALIDATION_STATUS, CATEGORY_EXAMPLES_ERROR_LIMIT, CATEGORY_EXAMPLES_WARNING_LIMIT, -} from '../../../../../common/constants/new_job'; +} from '../../../../../common/constants/categorization_job'; import { FieldExampleCheck, CategoryFieldExample, @@ -17,10 +20,6 @@ import { } from '../../../../../common/types/categories'; import { getMedianStringLength } from '../../../../../common/util/string_utils'; -const VALID_TOKEN_COUNT = 3; -const MEDIAN_LINE_LENGTH_LIMIT = 400; -const NULL_COUNT_PERCENT_LIMIT = 0.75; - export class ValidationResults { private _results: FieldExampleCheck[] = []; @@ -187,7 +186,6 @@ export class ValidationResults { valid: CATEGORY_EXAMPLES_VALIDATION_STATUS.PARTIALLY_VALID, message, }); - return; } } diff --git a/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts b/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts index ba7b9c31ad64c..aab7a65a7c122 100644 --- a/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts +++ b/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts @@ -96,7 +96,7 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'valid', message: '1000 field values analyzed, 95% contain 3 or more tokens.', }, @@ -117,12 +117,12 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 1, + id: 4, valid: 'partially_valid', message: 'The median length for the field values analyzed is over 400 characters.', }, { - id: 4, + id: 2, valid: 'invalid', message: 'Tokenization of field value examples has failed due to more than 10000 tokens being found in a sample of 50 values.', @@ -144,12 +144,12 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'valid', message: '250 field values analyzed, 95% contain 3 or more tokens.', }, { - id: 2, + id: 5, valid: 'partially_valid', message: 'More than 75% of field values are null.', }, @@ -170,12 +170,12 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'valid', message: '500 field values analyzed, 100% contain 3 or more tokens.', }, { - id: 1, + id: 4, valid: 'partially_valid', message: 'The median length for the field values analyzed is over 400 characters.', }, @@ -196,7 +196,7 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 0, validationChecks: [ { - id: 3, + id: 0, valid: 'invalid', message: 'No examples for this field could be found. Please ensure the selected date range contains data.', @@ -218,7 +218,7 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'invalid', message: '1000 field values analyzed, 0% contain 3 or more tokens.', }, @@ -242,7 +242,7 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'valid', message: '1000 field values analyzed, 100% contain 3 or more tokens.', }, @@ -263,7 +263,7 @@ export default ({ getService }: FtrProviderContext) => { exampleLength: 5, validationChecks: [ { - id: 0, + id: 3, valid: 'partially_valid', message: '1000 field values analyzed, 50% contain 3 or more tokens.', }, diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts index 80f020f66c0ed..9fa53d6e546ba 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../plugins/ml/common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../../plugins/ml/common/constants/categorization_job'; // eslint-disable-next-line import/no-default-export export default function({ getService }: FtrProviderContext) { diff --git a/x-pack/test/functional/services/machine_learning/job_wizard_categorization.ts b/x-pack/test/functional/services/machine_learning/job_wizard_categorization.ts index 2f4162c0cb60a..97d45701a2685 100644 --- a/x-pack/test/functional/services/machine_learning/job_wizard_categorization.ts +++ b/x-pack/test/functional/services/machine_learning/job_wizard_categorization.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../plugins/ml/common/constants/new_job'; +import { CATEGORY_EXAMPLES_VALIDATION_STATUS } from '../../../../plugins/ml/common/constants/categorization_job'; export function MachineLearningJobWizardCategorizationProvider({ getService }: FtrProviderContext) { const comboBox = getService('comboBox');