-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Improve job and datafeed config editors in the Advanced job wiza…
…rd (#146968) ## Summary Part of #66716 Updates the code editor for anomaly detection job and datafeed configurations. It uses the monaco editor instead of ace and passes the JSON schema definition extracted from the elasticsearch specification to provide suggestions for available properties and documentation on hover. - Properties autocompletion (ctrl + space) <img width="552" alt="image" src="https://user-images.githubusercontent.com/5236598/205601880-03d484b4-c007-4e1b-9325-a80ccdcd02b8.png"> - Documentation on mouse over <img width="512" alt="image" src="https://user-images.githubusercontent.com/5236598/205602042-53a600ee-8fb5-4c18-991d-ffc2f2cca7e8.png"> - Data types support <img width="336" alt="image" src="https://user-images.githubusercontent.com/5236598/205602158-1298a37b-7d8e-40f8-9f6b-bf3117d37c04.png"> ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- Loading branch information
Showing
16 changed files
with
2,248 additions
and
29 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/ml/common/api_schemas/json_schema_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { schema, type TypeOf } from '@kbn/config-schema'; | ||
|
||
export const getJsonSchemaQuerySchema = schema.object({ | ||
/** | ||
* ES API path | ||
*/ | ||
path: schema.oneOf([ | ||
schema.literal('/_ml/anomaly_detectors/{job_id}'), | ||
schema.literal('/_ml/datafeeds/{datafeed_id}'), | ||
]), | ||
/** | ||
* API Method | ||
*/ | ||
method: schema.string(), | ||
}); | ||
|
||
export type SupportedPath = TypeOf<typeof getJsonSchemaQuerySchema>['path']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
x-pack/plugins/ml/public/application/services/ml_api_service/json_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { omitBy } from 'lodash'; | ||
import { isDefined } from '@kbn/ml-is-defined'; | ||
import { type SupportedPath } from '../../../../common/api_schemas/json_schema_schema'; | ||
import { HttpService } from '../http_service'; | ||
import { basePath } from '.'; | ||
|
||
export interface GetSchemaDefinitionParams { | ||
path: SupportedPath; | ||
method: string; | ||
} | ||
|
||
export function jsonSchemaProvider(httpService: HttpService) { | ||
const apiBasePath = basePath(); | ||
|
||
return { | ||
getSchemaDefinition(params: GetSchemaDefinitionParams) { | ||
return httpService.http<object>({ | ||
path: `${apiBasePath}/json_schema`, | ||
method: 'GET', | ||
query: omitBy(params, (v) => !isDefined(v)), | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { JsonSchemaService } from './json_schema_service'; |
Oops, something went wrong.