diff --git a/.eslintrc.js b/.eslintrc.js index a678243e4f07a..b730b88a1b9cf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -514,6 +514,16 @@ module.exports = { }, }, + /** + * Harden specific rules + */ + { + files: ['test/harden/*.js'], + rules: { + 'mocha/handle-done-callback': 'off', // TODO: Find a way to disable all mocha rules + }, + }, + /** * APM overrides */ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd7868adb511e..aec6d44ad4abf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -391,9 +391,9 @@ Note that for VSCode, to enable "live" linting of TypeScript (and other) file ty All user-facing labels and info texts in Kibana should be internationalized. Please take a look at the [readme](packages/kbn-i18n/README.md) and the [guideline](packages/kbn-i18n/GUIDELINE.md) of the i18n package on how to do so. -In order to enable translations in the React parts of the application, the top most component of every `ReactDOM.render` call should be an `I18nContext`: +In order to enable translations in the React parts of the application, the top most component of every `ReactDOM.render` call should be the `Context` component from the `i18n` core service: ```jsx -import { I18nContext } from 'ui/i18n'; +const I18nContext = coreStart.i18n.Context; ReactDOM.render( diff --git a/docs/apm/advanced-queries.asciidoc b/docs/apm/advanced-queries.asciidoc index 942882f8c4dfb..971d543bbb445 100644 --- a/docs/apm/advanced-queries.asciidoc +++ b/docs/apm/advanced-queries.asciidoc @@ -5,7 +5,7 @@ When querying in the APM app, you're simply searching and selecting data from fi Queries entered into the query bar are also added as parameters to the URL, so it's easy to share a specific query or view with others. -In the screenshot below, you can begin to see some of the transaction fields available for filtering on: +In the screenshot below, you can begin to see some of the transaction fields available for filtering on: [role="screenshot"] image::apm/images/apm-query-bar.png[Example of the Kibana Query bar in APM app in Kibana] @@ -25,7 +25,7 @@ TIP: Read the {kibana-ref}/kuery-query.html[Kibana Query Language Enhancements] It may also be helpful to view your APM data in the {kibana-ref}/discover.html[Discover app]. Querying documents in Discover works the same way as querying in the APM app, -and all of the example queries listed above can also be used in the Discover app. +and all of the example APM app queries can also be used in the Discover app. [float] ==== Example Discover app query diff --git a/docs/canvas/canvas-function-reference.asciidoc b/docs/canvas/canvas-function-reference.asciidoc index 85e9d22490497..16aaf55802b17 100644 --- a/docs/canvas/canvas-function-reference.asciidoc +++ b/docs/canvas/canvas-function-reference.asciidoc @@ -3,13 +3,13 @@ == Canvas function reference Behind the scenes, Canvas is driven by a powerful expression language, -with dozens of functions and other capabilities, including table transforms, +with dozens of functions and other capabilities, including table transforms, type casting, and sub-expressions. The Canvas expression language also supports <>, which perform complex math calculations. -A *** denotes a required argument. +A *** denotes a required argument. A † denotes an argument can be passed multiple times. @@ -184,7 +184,7 @@ filters ---- `as` casts any primitive value (`string`, `number`, `date`, `null`) into a `datatable` with a single row and a single column with the given name (or defaults to `"value"` if no name is provided). This is useful when piping a primitive value into a function that only takes `datatable` as an input. -In the example above, `ply` expects each `fn` subexpression to return a `datatable` in order to merge the results of each `fn` back into a `datatable`, but using a `math` aggregation in the subexpressions returns a single `math` value, which is then cast into a `datatable` using `as`. +In the example, `ply` expects each `fn` subexpression to return a `datatable` in order to merge the results of each `fn` back into a `datatable`, but using a `math` aggregation in the subexpressions returns a single `math` value, which is then cast into a `datatable` using `as`. *Accepts:* `string`, `boolean`, `number`, `null` @@ -496,14 +496,14 @@ containerStyle backgroundImage={asset id=asset-f40d2292-cf9e-4f2c-8c6f-a504a25e9 *Code example* [source,text] ---- -shape "star" fill="#E61D35" maintainAspect=true -| render containerStyle={ - containerStyle backgroundColor="#F8D546" - borderRadius="200px" - border="4px solid #05509F" - padding="0px" - opacity="0.9" - overflow="hidden" +shape "star" fill="#E61D35" maintainAspect=true +| render containerStyle={ + containerStyle backgroundColor="#F8D546" + borderRadius="200px" + border="4px solid #05509F" + padding="0px" + opacity="0.9" + overflow="hidden" } ---- @@ -1437,8 +1437,8 @@ Aliases: `dataurl`, `url` |`string`, `null` |The HTTP(S) URL or `base64` data URL of an image. -Example value for the _Unnamed_ argument, formatted as a `base64` data URL: -[source, url] +Example value for the _Unnamed_ argument, formatted as a `base64` data URL: +[source, url] ------------ data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgdmlld0JveD0iMCAwIDI3MC42MDAwMSAyNjkuNTQ2NjYiCiAgIGhlaWdodD0iMjY5LjU0NjY2IgogICB3aWR0aD0iMjcwLjYwMDAxIgogICB4bWw6c3BhY2U9InByZXNlcnZlIgogICBpZD0ic3ZnMiIKICAgdmVyc2lvbj0iMS4xIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGE4Ij48cmRmOlJERj48Y2M6V29yawogICAgICAgICByZGY6YWJvdXQ9IiI+PGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+PGRjOnR5cGUKICAgICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZGVmcwogICAgIGlkPSJkZWZzNiIgLz48ZwogICAgIHRyYW5zZm9ybT0ibWF0cml4KDEuMzMzMzMzMywwLDAsLTEuMzMzMzMzMywwLDI2OS41NDY2NykiCiAgICAgaWQ9ImcxMCI+PGcKICAgICAgIHRyYW5zZm9ybT0ic2NhbGUoMC4xKSIKICAgICAgIGlkPSJnMTIiPjxwYXRoCiAgICAgICAgIGlkPSJwYXRoMTQiCiAgICAgICAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgIGQ9Im0gMjAyOS40OCw5NjIuNDQxIGMgMCwxNzAuMDk5IC0xMDUuNDYsMzE4Ljc5OSAtMjY0LjE3LDM3Ni42NTkgNi45OCwzNS44NiAxMC42Miw3MS43MSAxMC42MiwxMDkuMDUgMCwzMTYuMTkgLTI1Ny4yNCw1NzMuNDMgLTU3My40Nyw1NzMuNDMgLTE4NC43MiwwIC0zNTYuNTU4LC04OC41OSAtNDY0LjUzLC0yMzcuODUgLTUzLjA5LDQxLjE4IC0xMTguMjg1LDYzLjc1IC0xODYuMzA1LDYzLjc1IC0xNjcuODM2LDAgLTMwNC4zODMsLTEzNi41NCAtMzA0LjM4MywtMzA0LjM4IDAsLTM3LjA4IDYuNjE3LC03Mi41OCAxOS4wMzEsLTEwNi4wOCBDIDEwOC40ODgsMTM4MC4wOSAwLDEyMjcuODkgMCwxMDU4Ljg4IDAsODg3LjkxIDEwNS45NzcsNzM4LjUzOSAyNjUuMzk4LDY4MS4wOSBjIC02Ljc2OSwtMzUuNDQyIC0xMC40NiwtNzIuMDIgLTEwLjQ2LC0xMDkgQyAyNTQuOTM4LDI1Ni42MjEgNTExLjU2NiwwIDgyNy4wMjcsMCAxMDEyLjIsMCAxMTgzLjk0LDg4Ljk0MTQgMTI5MS4zLDIzOC44MzIgYyA1My40NSwtNDEuOTYxIDExOC44LC02NC45OTIgMTg2LjU2LC02NC45OTIgMTY3LjgzLDAgMzA0LjM4LDEzNi40OTIgMzA0LjM4LDMwNC4zMzIgMCwzNy4wNzggLTYuNjIsNzIuNjI5IC0xOS4wMywxMDYuMTI5IDE1Ny43OCw1Ni44NzkgMjY2LjI3LDIwOS4xMjkgMjY2LjI3LDM3OC4xNCIgLz48cGF0aAogICAgICAgICBpZD0icGF0aDE2IgogICAgICAgICBzdHlsZT0iZmlsbDojZmFjZjA5O2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIgogICAgICAgICBkPSJtIDc5Ny44OTgsMTE1MC45MyA0NDQuMDcyLC0yMDIuNDUgNDQ4LjA1LDM5Mi41OCBjIDYuNDksMzIuMzkgOS42Niw2NC42NyA5LjY2LDk4LjQ2IDAsMjc2LjIzIC0yMjQuNjgsNTAwLjk1IC01MDAuOSw1MDAuOTUgLTE2NS4yNCwwIC0zMTkuMzcsLTgxLjM2IC00MTMuMDUzLC0yMTcuNzkgbCAtNzQuNTI0LC0zODYuNjQgODYuNjk1LC0xODUuMTEiIC8+PHBhdGgKICAgICAgICAgaWQ9InBhdGgxOCIKICAgICAgICAgc3R5bGU9ImZpbGw6IzQ5YzFhZTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIKICAgICAgICAgZD0ibSAzMzguMjIzLDY4MC42NzIgYyAtNi40ODksLTMyLjM4MyAtOS44MDksLTY1Ljk4MSAtOS44MDksLTk5Ljk3MyAwLC0yNzYuOTI5IDIyNS4zMzYsLTUwMi4yNTc2IDUwMi4zMTMsLTUwMi4yNTc2IDE2Ni41OTMsMCAzMjEuNDczLDgyLjExNzYgNDE1LjAxMywyMTkuOTQ5NiBsIDczLjk3LDM4NS4zNDcgLTk4LjcyLDE4OC42MjEgTCA3NzUuMTU2LDEwNzUuNTcgMzM4LjIyMyw2ODAuNjcyIiAvPjxwYXRoCiAgICAgICAgIGlkPSJwYXRoMjAiCiAgICAgICAgIHN0eWxlPSJmaWxsOiNlZjI5OWI7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgIGQ9Im0gMzM1LjQxLDE0NDkuMTggMzA0LjMzMiwtNzEuODYgNjYuNjgsMzQ2LjAyIGMgLTQxLjU4NiwzMS43OCAtOTIuOTMsNDkuMTggLTE0NS43MzEsNDkuMTggLTEzMi4yNSwwIC0yMzkuODEyLC0xMDcuNjEgLTIzOS44MTIsLTIzOS44NyAwLC0yOS4yMSA0Ljg3OSwtNTcuMjIgMTQuNTMxLC04My40NyIgLz48cGF0aAogICAgICAgICBpZD0icGF0aDIyIgogICAgICAgICBzdHlsZT0iZmlsbDojNGNhYmU0O2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIgogICAgICAgICBkPSJNIDMwOC45OTIsMTM3Ni43IEMgMTczLjAyLDEzMzEuNjQgNzguNDgwNSwxMjAxLjMgNzguNDgwNSwxMDU3LjkzIDc4LjQ4MDUsOTE4LjM0IDE2NC44Miw3OTMuNjggMjk0LjQwNiw3NDQuMzUyIGwgNDI2Ljk4MSwzODUuOTM4IC03OC4zOTUsMTY3LjUxIC0zMzQsNzguOSIgLz48cGF0aAogICAgICAgICBpZD0icGF0aDI0IgogICAgICAgICBzdHlsZT0iZmlsbDojODVjZTI2O2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIgogICAgICAgICBkPSJtIDEzMjMuOCwyOTguNDEgYyA0MS43NCwtMzIuMDkgOTIuODMsLTQ5LjU5IDE0NC45OCwtNDkuNTkgMTMyLjI1LDAgMjM5LjgxLDEwNy41NTkgMjM5LjgxLDIzOS44MjEgMCwyOS4xNiAtNC44OCw1Ny4xNjggLTE0LjUzLDgzLjQxOCBsIC0zMDQuMDgsNzEuMTYgLTY2LjE4LC0zNDQuODA5IiAvPjxwYXRoCiAgICAgICAgIGlkPSJwYXRoMjYiCiAgICAgICAgIHN0eWxlPSJmaWxsOiMzMTc3YTc7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgIGQ9Im0gMTM4NS42Nyw3MjIuOTMgMzM0Ljc2LC03OC4zMDEgYyAxMzYuMDIsNDQuOTYxIDIzMC41NiwxNzUuMzUxIDIzMC41NiwzMTguNzYyIDAsMTM5LjMzOSAtODYuNTQsMjYzLjg1OSAtMjE2LjM4LDMxMy4wMzkgbCAtNDM3Ljg0LC0zODMuNTkgODguOSwtMTY5LjkxIiAvPjwvZz48L2c+PC9zdmc+ ------------ @@ -2052,8 +2052,8 @@ Default: `null` |`string`, `null` |The image to repeat. Provide an image asset as a `base64` data URL, or pass in a sub-expression. -Example value for the `image` argument, formatted as a `base64` data URL: -[source, url] +Example value for the `image` argument, formatted as a `base64` data URL: +[source, url] ------------ data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3Csvg%20viewBox%3D%22-3.948730230331421%20-1.7549896240234375%20245.25946044921875%20241.40370178222656%22%20width%3D%22245.25946044921875%22%20height%3D%22241.40370178222656%22%20style%3D%22enable-background%3Anew%200%200%20686.2%20235.7%3B%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%3Cdefs%3E%0A%20%20%20%20%3Cstyle%20type%3D%22text%2Fcss%22%3E%0A%09.st0%7Bfill%3A%232D2D2D%3B%7D%0A%3C%2Fstyle%3E%0A%20%20%3C%2Fdefs%3E%0A%20%20%3Cg%20transform%3D%22matrix%281%2C%200%2C%200%2C%201%2C%200%2C%200%29%22%3E%0A%20%20%20%20%3Cg%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M329.4%2C160.3l4.7-0.5l0.3%2C9.6c-12.4%2C1.7-23%2C2.6-31.8%2C2.6c-11.7%2C0-20-3.4-24.9-10.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-4.9-6.8-7.3-17.4-7.3-31.7c0-28.6%2C11.4-42.9%2C34.1-42.9c11%2C0%2C19.2%2C3.1%2C24.6%2C9.2c5.4%2C6.1%2C8.1%2C15.8%2C8.1%2C28.9l-0.7%2C9.3h-53.8%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc0%2C9%2C1.6%2C15.7%2C4.9%2C20c3.3%2C4.3%2C8.9%2C6.5%2C17%2C6.5C312.8%2C161.2%2C321.1%2C160.9%2C329.4%2C160.3z%20M325%2C124.9c0-10-1.6-17.1-4.8-21.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-3.2-4.1-8.4-6.2-15.6-6.2c-7.2%2C0-12.7%2C2.2-16.3%2C6.5c-3.6%2C4.3-5.5%2C11.3-5.6%2C20.9H325z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M354.3%2C171.4V64h12.2v107.4H354.3z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M443.5%2C113.5v41.1c0%2C4.1%2C10.1%2C3.9%2C10.1%2C3.9l-0.6%2C10.8c-8.6%2C0-15.7%2C0.7-20-3.4c-9.8%2C4.3-19.5%2C6.1-29.3%2C6.1%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-7.5%2C0-13.2-2.1-17.1-6.4c-3.9-4.2-5.9-10.3-5.9-18.3c0-7.9%2C2-13.8%2C6-17.5c4-3.7%2C10.3-6.1%2C18.9-6.9l25.6-2.4v-7%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc0-5.5-1.2-9.5-3.6-11.9c-2.4-2.4-5.7-3.6-9.8-3.6l-32.1%2C0V87.2h31.3c9.2%2C0%2C15.9%2C2.1%2C20.1%2C6.4C441.4%2C97.8%2C443.5%2C104.5%2C443.5%2C113.5%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bz%20M393.3%2C146.7c0%2C10%2C4.1%2C15%2C12.4%2C15c7.4%2C0%2C14.7-1.2%2C21.8-3.7l3.7-1.3v-26.9l-24.1%2C2.3c-4.9%2C0.4-8.4%2C1.8-10.6%2C4.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3BC394.4%2C138.7%2C393.3%2C142.2%2C393.3%2C146.7z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M491.2%2C98.2c-11.8%2C0-17.8%2C4.1-17.8%2C12.4c0%2C3.8%2C1.4%2C6.5%2C4.1%2C8.1c2.7%2C1.6%2C8.9%2C3.2%2C18.6%2C4.9%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc9.7%2C1.7%2C16.5%2C4%2C20.5%2C7.1c4%2C3%2C6%2C8.7%2C6%2C17.1c0%2C8.4-2.7%2C14.5-8.1%2C18.4c-5.4%2C3.9-13.2%2C5.9-23.6%2C5.9c-6.7%2C0-29.2-2.5-29.2-2.5%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bl0.7-10.6c12.9%2C1.2%2C22.3%2C2.2%2C28.6%2C2.2c6.3%2C0%2C11.1-1%2C14.4-3c3.3-2%2C5-5.4%2C5-10.1c0-4.7-1.4-7.9-4.2-9.6c-2.8-1.7-9-3.3-18.6-4.8%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-9.6-1.5-16.4-3.7-20.4-6.7c-4-2.9-6-8.4-6-16.3c0-7.9%2C2.8-13.8%2C8.4-17.6c5.6-3.8%2C12.6-5.7%2C20.9-5.7c6.6%2C0%2C29.6%2C1.7%2C29.6%2C1.7%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bv10.7C508.1%2C99%2C498.2%2C98.2%2C491.2%2C98.2z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M581.7%2C99.5h-25.9v39c0%2C9.3%2C0.7%2C15.5%2C2%2C18.4c1.4%2C2.9%2C4.6%2C4.4%2C9.7%2C4.4l14.5-1l0.8%2C10.1%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-7.3%2C1.2-12.8%2C1.8-16.6%2C1.8c-8.5%2C0-14.3-2.1-17.6-6.2c-3.3-4.1-4.9-12-4.9-23.6V99.5h-11.6V88.9h11.6V63.9h12.1v24.9h25.9V99.5z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M598.7%2C78.4V64.3h12.2v14.2H598.7z%20M598.7%2C171.4V88.9h12.2v82.5H598.7z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M663.8%2C87.2c3.6%2C0%2C9.7%2C0.7%2C18.3%2C2l3.9%2C0.5l-0.5%2C9.9c-8.7-1-15.1-1.5-19.2-1.5c-9.2%2C0-15.5%2C2.2-18.8%2C6.6%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-3.3%2C4.4-5%2C12.6-5%2C24.5c0%2C11.9%2C1.5%2C20.2%2C4.6%2C24.9c3.1%2C4.7%2C9.5%2C7%2C19.3%2C7l19.2-1.5l0.5%2C10.1c-10.1%2C1.5-17.7%2C2.3-22.7%2C2.3%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-12.7%2C0-21.5-3.3-26.3-9.8c-4.8-6.5-7.3-17.5-7.3-33c0-15.5%2C2.6-26.4%2C7.8-32.6C643%2C90.4%2C651.7%2C87.2%2C663.8%2C87.2z%22%2F%3E%0A%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M236.6%2C123.5c0-19.8-12.3-37.2-30.8-43.9c0.8-4.2%2C1.2-8.4%2C1.2-12.7C207%2C30%2C177%2C0%2C140.2%2C0%26%2310%3B%26%239%3B%26%239%3BC118.6%2C0%2C98.6%2C10.3%2C86%2C27.7c-6.2-4.8-13.8-7.4-21.7-7.4c-19.6%2C0-35.5%2C15.9-35.5%2C35.5c0%2C4.3%2C0.8%2C8.5%2C2.2%2C12.4%26%2310%3B%26%239%3B%26%239%3BC12.6%2C74.8%2C0%2C92.5%2C0%2C112.2c0%2C19.9%2C12.4%2C37.3%2C30.9%2C44c-0.8%2C4.1-1.2%2C8.4-1.2%2C12.7c0%2C36.8%2C29.9%2C66.7%2C66.7%2C66.7%26%2310%3B%26%239%3B%26%239%3Bc21.6%2C0%2C41.6-10.4%2C54.1-27.8c6.2%2C4.9%2C13.8%2C7.6%2C21.7%2C7.6c19.6%2C0%2C35.5-15.9%2C35.5-35.5c0-4.3-0.8-8.5-2.2-12.4%26%2310%3B%26%239%3B%26%239%3BC223.9%2C160.9%2C236.6%2C143.2%2C236.6%2C123.5z%20M91.6%2C34.8c10.9-15.9%2C28.9-25.4%2C48.1-25.4c32.2%2C0%2C58.4%2C26.2%2C58.4%2C58.4%26%2310%3B%26%239%3B%26%239%3Bc0%2C3.9-0.4%2C7.7-1.1%2C11.5l-52.2%2C45.8L93%2C101.5L82.9%2C79.9L91.6%2C34.8z%20M65.4%2C29c6.2%2C0%2C12.1%2C2%2C17%2C5.7l-7.8%2C40.3l-35.5-8.4%26%2310%3B%26%239%3B%26%239%3Bc-1.1-3.1-1.7-6.3-1.7-9.7C37.4%2C41.6%2C49.9%2C29%2C65.4%2C29z%20M9.1%2C112.3c0-16.7%2C11-31.9%2C26.9-37.2L75%2C84.4l9.1%2C19.5l-49.8%2C45%26%2310%3B%26%239%3B%26%239%3BC19.2%2C143.1%2C9.1%2C128.6%2C9.1%2C112.3z%20M145.2%2C200.9c-10.9%2C16.1-29%2C25.6-48.4%2C25.6c-32.3%2C0-58.6-26.3-58.6-58.5c0-4%2C0.4-7.9%2C1.1-11.7%26%2310%3B%26%239%3B%26%239%3Bl50.9-46l52%2C23.7l11.5%2C22L145.2%2C200.9z%20M171.2%2C206.6c-6.1%2C0-12-2-16.9-5.8l7.7-40.2l35.4%2C8.3c1.1%2C3.1%2C1.7%2C6.3%2C1.7%2C9.7%26%2310%3B%26%239%3B%26%239%3BC199.2%2C194.1%2C186.6%2C206.6%2C171.2%2C206.6z%20M200.5%2C160.5l-39-9.1l-10.4-19.8l51-44.7c15.1%2C5.7%2C25.2%2C20.2%2C25.2%2C36.5%26%2310%3B%26%239%3B%26%239%3BC227.4%2C140.1%2C216.4%2C155.3%2C200.5%2C160.5z%22%2F%3E%0A%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E ------------ @@ -2132,8 +2132,8 @@ Default: `null` |`string`, `null` |The image to reveal. Provide an image asset as a `base64` data URL, or pass in a sub-expression. -Example value for the `image` argument, formatted as a `base64` data URL: -[source, url] +Example value for the `image` argument, formatted as a `base64` data URL: +[source, url] ------------ data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3Csvg%20viewBox%3D%22-3.948730230331421%20-1.7549896240234375%20245.25946044921875%20241.40370178222656%22%20width%3D%22245.25946044921875%22%20height%3D%22241.40370178222656%22%20style%3D%22enable-background%3Anew%200%200%20686.2%20235.7%3B%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%3Cdefs%3E%0A%20%20%20%20%3Cstyle%20type%3D%22text%2Fcss%22%3E%0A%09.st0%7Bfill%3A%232D2D2D%3B%7D%0A%3C%2Fstyle%3E%0A%20%20%3C%2Fdefs%3E%0A%20%20%3Cg%20transform%3D%22matrix%281%2C%200%2C%200%2C%201%2C%200%2C%200%29%22%3E%0A%20%20%20%20%3Cg%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M329.4%2C160.3l4.7-0.5l0.3%2C9.6c-12.4%2C1.7-23%2C2.6-31.8%2C2.6c-11.7%2C0-20-3.4-24.9-10.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-4.9-6.8-7.3-17.4-7.3-31.7c0-28.6%2C11.4-42.9%2C34.1-42.9c11%2C0%2C19.2%2C3.1%2C24.6%2C9.2c5.4%2C6.1%2C8.1%2C15.8%2C8.1%2C28.9l-0.7%2C9.3h-53.8%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc0%2C9%2C1.6%2C15.7%2C4.9%2C20c3.3%2C4.3%2C8.9%2C6.5%2C17%2C6.5C312.8%2C161.2%2C321.1%2C160.9%2C329.4%2C160.3z%20M325%2C124.9c0-10-1.6-17.1-4.8-21.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-3.2-4.1-8.4-6.2-15.6-6.2c-7.2%2C0-12.7%2C2.2-16.3%2C6.5c-3.6%2C4.3-5.5%2C11.3-5.6%2C20.9H325z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M354.3%2C171.4V64h12.2v107.4H354.3z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M443.5%2C113.5v41.1c0%2C4.1%2C10.1%2C3.9%2C10.1%2C3.9l-0.6%2C10.8c-8.6%2C0-15.7%2C0.7-20-3.4c-9.8%2C4.3-19.5%2C6.1-29.3%2C6.1%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-7.5%2C0-13.2-2.1-17.1-6.4c-3.9-4.2-5.9-10.3-5.9-18.3c0-7.9%2C2-13.8%2C6-17.5c4-3.7%2C10.3-6.1%2C18.9-6.9l25.6-2.4v-7%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc0-5.5-1.2-9.5-3.6-11.9c-2.4-2.4-5.7-3.6-9.8-3.6l-32.1%2C0V87.2h31.3c9.2%2C0%2C15.9%2C2.1%2C20.1%2C6.4C441.4%2C97.8%2C443.5%2C104.5%2C443.5%2C113.5%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bz%20M393.3%2C146.7c0%2C10%2C4.1%2C15%2C12.4%2C15c7.4%2C0%2C14.7-1.2%2C21.8-3.7l3.7-1.3v-26.9l-24.1%2C2.3c-4.9%2C0.4-8.4%2C1.8-10.6%2C4.2%26%2310%3B%26%239%3B%26%239%3B%26%239%3BC394.4%2C138.7%2C393.3%2C142.2%2C393.3%2C146.7z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M491.2%2C98.2c-11.8%2C0-17.8%2C4.1-17.8%2C12.4c0%2C3.8%2C1.4%2C6.5%2C4.1%2C8.1c2.7%2C1.6%2C8.9%2C3.2%2C18.6%2C4.9%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc9.7%2C1.7%2C16.5%2C4%2C20.5%2C7.1c4%2C3%2C6%2C8.7%2C6%2C17.1c0%2C8.4-2.7%2C14.5-8.1%2C18.4c-5.4%2C3.9-13.2%2C5.9-23.6%2C5.9c-6.7%2C0-29.2-2.5-29.2-2.5%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bl0.7-10.6c12.9%2C1.2%2C22.3%2C2.2%2C28.6%2C2.2c6.3%2C0%2C11.1-1%2C14.4-3c3.3-2%2C5-5.4%2C5-10.1c0-4.7-1.4-7.9-4.2-9.6c-2.8-1.7-9-3.3-18.6-4.8%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-9.6-1.5-16.4-3.7-20.4-6.7c-4-2.9-6-8.4-6-16.3c0-7.9%2C2.8-13.8%2C8.4-17.6c5.6-3.8%2C12.6-5.7%2C20.9-5.7c6.6%2C0%2C29.6%2C1.7%2C29.6%2C1.7%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bv10.7C508.1%2C99%2C498.2%2C98.2%2C491.2%2C98.2z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M581.7%2C99.5h-25.9v39c0%2C9.3%2C0.7%2C15.5%2C2%2C18.4c1.4%2C2.9%2C4.6%2C4.4%2C9.7%2C4.4l14.5-1l0.8%2C10.1%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-7.3%2C1.2-12.8%2C1.8-16.6%2C1.8c-8.5%2C0-14.3-2.1-17.6-6.2c-3.3-4.1-4.9-12-4.9-23.6V99.5h-11.6V88.9h11.6V63.9h12.1v24.9h25.9V99.5z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M598.7%2C78.4V64.3h12.2v14.2H598.7z%20M598.7%2C171.4V88.9h12.2v82.5H598.7z%22%2F%3E%0A%20%20%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M663.8%2C87.2c3.6%2C0%2C9.7%2C0.7%2C18.3%2C2l3.9%2C0.5l-0.5%2C9.9c-8.7-1-15.1-1.5-19.2-1.5c-9.2%2C0-15.5%2C2.2-18.8%2C6.6%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-3.3%2C4.4-5%2C12.6-5%2C24.5c0%2C11.9%2C1.5%2C20.2%2C4.6%2C24.9c3.1%2C4.7%2C9.5%2C7%2C19.3%2C7l19.2-1.5l0.5%2C10.1c-10.1%2C1.5-17.7%2C2.3-22.7%2C2.3%26%2310%3B%26%239%3B%26%239%3B%26%239%3Bc-12.7%2C0-21.5-3.3-26.3-9.8c-4.8-6.5-7.3-17.5-7.3-33c0-15.5%2C2.6-26.4%2C7.8-32.6C643%2C90.4%2C651.7%2C87.2%2C663.8%2C87.2z%22%2F%3E%0A%20%20%20%20%3C%2Fg%3E%0A%20%20%20%20%3Cpath%20class%3D%22st0%22%20d%3D%22M236.6%2C123.5c0-19.8-12.3-37.2-30.8-43.9c0.8-4.2%2C1.2-8.4%2C1.2-12.7C207%2C30%2C177%2C0%2C140.2%2C0%26%2310%3B%26%239%3B%26%239%3BC118.6%2C0%2C98.6%2C10.3%2C86%2C27.7c-6.2-4.8-13.8-7.4-21.7-7.4c-19.6%2C0-35.5%2C15.9-35.5%2C35.5c0%2C4.3%2C0.8%2C8.5%2C2.2%2C12.4%26%2310%3B%26%239%3B%26%239%3BC12.6%2C74.8%2C0%2C92.5%2C0%2C112.2c0%2C19.9%2C12.4%2C37.3%2C30.9%2C44c-0.8%2C4.1-1.2%2C8.4-1.2%2C12.7c0%2C36.8%2C29.9%2C66.7%2C66.7%2C66.7%26%2310%3B%26%239%3B%26%239%3Bc21.6%2C0%2C41.6-10.4%2C54.1-27.8c6.2%2C4.9%2C13.8%2C7.6%2C21.7%2C7.6c19.6%2C0%2C35.5-15.9%2C35.5-35.5c0-4.3-0.8-8.5-2.2-12.4%26%2310%3B%26%239%3B%26%239%3BC223.9%2C160.9%2C236.6%2C143.2%2C236.6%2C123.5z%20M91.6%2C34.8c10.9-15.9%2C28.9-25.4%2C48.1-25.4c32.2%2C0%2C58.4%2C26.2%2C58.4%2C58.4%26%2310%3B%26%239%3B%26%239%3Bc0%2C3.9-0.4%2C7.7-1.1%2C11.5l-52.2%2C45.8L93%2C101.5L82.9%2C79.9L91.6%2C34.8z%20M65.4%2C29c6.2%2C0%2C12.1%2C2%2C17%2C5.7l-7.8%2C40.3l-35.5-8.4%26%2310%3B%26%239%3B%26%239%3Bc-1.1-3.1-1.7-6.3-1.7-9.7C37.4%2C41.6%2C49.9%2C29%2C65.4%2C29z%20M9.1%2C112.3c0-16.7%2C11-31.9%2C26.9-37.2L75%2C84.4l9.1%2C19.5l-49.8%2C45%26%2310%3B%26%239%3B%26%239%3BC19.2%2C143.1%2C9.1%2C128.6%2C9.1%2C112.3z%20M145.2%2C200.9c-10.9%2C16.1-29%2C25.6-48.4%2C25.6c-32.3%2C0-58.6-26.3-58.6-58.5c0-4%2C0.4-7.9%2C1.1-11.7%26%2310%3B%26%239%3B%26%239%3Bl50.9-46l52%2C23.7l11.5%2C22L145.2%2C200.9z%20M171.2%2C206.6c-6.1%2C0-12-2-16.9-5.8l7.7-40.2l35.4%2C8.3c1.1%2C3.1%2C1.7%2C6.3%2C1.7%2C9.7%26%2310%3B%26%239%3B%26%239%3BC199.2%2C194.1%2C186.6%2C206.6%2C171.2%2C206.6z%20M200.5%2C160.5l-39-9.1l-10.4-19.8l51-44.7c15.1%2C5.7%2C25.2%2C20.2%2C25.2%2C36.5%26%2310%3B%26%239%3B%26%239%3BC227.4%2C140.1%2C216.4%2C155.3%2C200.5%2C160.5z%22%2F%3E%0A%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E ------------ diff --git a/docs/dev-tools/console/console.asciidoc b/docs/dev-tools/console/console.asciidoc index 26620688499af..caffef7995fbf 100644 --- a/docs/dev-tools/console/console.asciidoc +++ b/docs/dev-tools/console/console.asciidoc @@ -18,8 +18,8 @@ NOTE: You are unable to interact with the REST API of {kib} with the Console. [[console-api]] === Write requests -Console understands commands in a cURL-like syntax. -For example, the following is a `GET` request to the {es} `_search` API. +Console understands commands in a cURL-like syntax. +For example, the following is a `GET` request to the {es} `_search` API. [source,js] ---------------------------------- @@ -43,23 +43,23 @@ curl -XGET "http://localhost:9200/_search" -d' }' ---------------------------------- -If you paste the above command into Console, {kib} automatically converts it +When you paste the command into Console, {kib} automatically converts it to Console syntax. Alternatively, if you want to want to see Console syntax in cURL, -click the action icon (image:dev-tools/console/images/wrench.png[]) and select *Copy as cURL*. +click the action icon (image:dev-tools/console/images/wrench.png[]) and select *Copy as cURL*. [float] [[console-autocomplete]] ==== Autocomplete When you're typing a command, Console makes context-sensitive suggestions. -These suggestions show you the parameters for each API and speed up your typing. -To configure your preferences for autocomplete, go to -<>. +These suggestions show you the parameters for each API and speed up your typing. +To configure your preferences for autocomplete, go to +<>. [float] [[auto-formatting]] ==== Auto-formatting -The auto-formatting +The auto-formatting capability can help you format requests. Select one or more requests that you want to format, click the action icon (image:dev-tools/console/images/wrench.png[]), and then select *Auto indent*. @@ -69,27 +69,27 @@ For example, you might have a request formatted like this: [role="screenshot"] image::dev-tools/console/images/copy-curl.png["Console close-up"] -Console adjusts the JSON body of the request to apply the indents. +Console adjusts the JSON body of the request to apply the indents. [role="screenshot"] image::dev-tools/console/images/request.png["Console close-up"] -If you select *Auto indent* on a request that is already well formatted, -Console collapses the request body to a single line per document. +If you select *Auto indent* on a request that is already well formatted, +Console collapses the request body to a single line per document. This is helpful when working with the {es} {ref}/docs-bulk.html[bulk APIs]. [float] [[console-request]] -=== Submit requests +=== Submit requests -When you're ready to submit the request to {es}, click the +When you're ready to submit the request to {es}, click the green triangle. You can select multiple requests and submit them together. -Console sends the requests to {es} one by one and shows the output -in the response pane. Submitting multiple request is helpful when you're debugging an issue or trying query +Console sends the requests to {es} one by one and shows the output +in the response pane. Submitting multiple request is helpful when you're debugging an issue or trying query combinations in multiple scenarios. @@ -105,7 +105,7 @@ the action icon (image:dev-tools/console/images/wrench.png[]) and select [[console-history]] === Get your request history -Console maintains a list of the last 500 requests that {es} successfully executed. +Console maintains a list of the last 500 requests that {es} successfully executed. To view your most recent requests, click *History*. If you select a request and click *Apply*, {kib} adds it to the editor at the current cursor position. @@ -113,7 +113,7 @@ and click *Apply*, {kib} adds it to the editor at the current cursor position. [[configuring-console]] === Configure Console settings -You can configure the Console font size, JSON syntax, +You can configure the Console font size, JSON syntax, and autocomplete suggestions in *Settings*. [role="screenshot"] @@ -130,9 +130,7 @@ shortcuts, click *Help*. [[console-settings]] === Disable Console -If you don’t want to use Console, you can disable it by setting `console.enabled` -to `false` in your `kibana.yml` configuration file. Changing this setting -causes the server to regenerate assets on the next startup, +If you don’t want to use Console, you can disable it by setting `console.enabled` +to `false` in your `kibana.yml` configuration file. Changing this setting +causes the server to regenerate assets on the next startup, which might cause a delay before pages start being served. - - diff --git a/docs/dev-tools/searchprofiler/more-complicated.asciidoc b/docs/dev-tools/searchprofiler/more-complicated.asciidoc index bd74a1095083f..a0771f4a0f240 100644 --- a/docs/dev-tools/searchprofiler/more-complicated.asciidoc +++ b/docs/dev-tools/searchprofiler/more-complicated.asciidoc @@ -25,7 +25,7 @@ POST test/_bulk // CONSOLE -- -. From the {searchprofiler}, enter "test" in the Index field above the query editor to restrict profiled +. From the {searchprofiler}, enter "test" in the *Index* field to restrict profiled queries to the `test` index. . Replace the default `match_all` query in the query editor with a query that has two sub-query @@ -66,7 +66,7 @@ components and includes a simple aggregation, like the example below. // NOTCONSOLE -- -. Click *Profile* to profile the query and visualize the results. +. Click *Profile* to profile the query and visualize the results. . Select the shard to view the query details. + [role="screenshot"] @@ -100,5 +100,5 @@ Select the name of the shard to view the aggregation details and timing breakdow image::dev-tools/searchprofiler/images/gs10.png["Drilling into the first shard's details"] For more information about how the {searchprofiler} works, how timings are calculated, and -how to interpret various results, see +how to interpret various results, see {ref}/search-profile.html#profiling-queries[Profiling queries]. diff --git a/docs/developer/core/development-dependencies.asciidoc b/docs/developer/core/development-dependencies.asciidoc index d430667449afa..285d338a23a0d 100644 --- a/docs/developer/core/development-dependencies.asciidoc +++ b/docs/developer/core/development-dependencies.asciidoc @@ -96,8 +96,8 @@ module.exports = window.angular; What this shim does is fairly simple if you go line by line: -. makes sure that jQuery is loaded before angular (which actually runs the shim above) +. makes sure that jQuery is loaded before angular (which actually runs the shim) . load the angular.js file from the node_modules directory . load the angular-elastic plugin, a plugin we want to always be included whenever we import angular . use the `ui/modules` module to add the module exported by angular-elastic as a dependency to the `kibana` angular module -. finally, export the window.angular variable. This means that writing `import angular from 'angular';` will properly set the angular variable to the angular library, rather than undefined which is the default behavior. \ No newline at end of file +. finally, export the window.angular variable. This means that writing `import angular from 'angular';` will properly set the angular variable to the angular library, rather than undefined which is the default behavior. diff --git a/docs/developer/core/development-modules.asciidoc b/docs/developer/core/development-modules.asciidoc index b36be6bbb5d25..cc5cd69ed8cb9 100644 --- a/docs/developer/core/development-modules.asciidoc +++ b/docs/developer/core/development-modules.asciidoc @@ -20,7 +20,7 @@ certain components. Here is a breakdown of those modules: the required modules and import them were they are actually necessary. - *`import 'ui/autoload/all'`* - Imports all of the above modules + Imports all of the modules [float] ==== Resolving Require Paths @@ -60,4 +60,4 @@ Here is how import/require statements are resolved to a file: ** path/index + '.js' ** path/index + '.json' ** path/index - * if none of the above paths matches then an error is thrown \ No newline at end of file + * if none of the paths matches then an error is thrown diff --git a/docs/developer/plugin/development-plugin-feature-registration.asciidoc b/docs/developer/plugin/development-plugin-feature-registration.asciidoc index f9078440cff2b..2c686964d369a 100644 --- a/docs/developer/plugin/development-plugin-feature-registration.asciidoc +++ b/docs/developer/plugin/development-plugin-feature-registration.asciidoc @@ -175,7 +175,7 @@ init(server) { } ----------- -Unlike the Canvas example above, Dev Tools does not require access to any saved objects to function. Dev Tools does specify an API endpoint, however. When this is configured, the Security plugin will automatically authorize access to any server API route that is tagged with `access:console`, similar to the following: +Unlike the Canvas example, Dev Tools does not require access to any saved objects to function. Dev Tools does specify an API endpoint, however. When this is configured, the Security plugin will automatically authorize access to any server API route that is tagged with `access:console`, similar to the following: ["source","javascript"] ----------- diff --git a/docs/developer/plugin/development-plugin-localization.asciidoc b/docs/developer/plugin/development-plugin-localization.asciidoc index ff497ec40e30e..78ee933f681f4 100644 --- a/docs/developer/plugin/development-plugin-localization.asciidoc +++ b/docs/developer/plugin/development-plugin-localization.asciidoc @@ -68,7 +68,7 @@ This outputs a `en.json` file inside the `translations` directory. To localize o Checking i18n does the following: * Checks all existing labels for violations. -* Takes translations from `.i18nrc.json` and compares them to the messages extracted and validated at the step above and: +* Takes translations from `.i18nrc.json` and compares them to the messages extracted and validated. ** Checks for unused translations. If you remove a label that has a corresponding translation, you must also remove the label from the translations file. ** Checks for incompatible translations. If you add or remove a new parameter from an existing string, you must also remove the label from the translations file. @@ -86,7 +86,7 @@ node scripts/i18n_check --fix --include-config ../kibana-extra/myPlugin/.i18nrc. Kibana relies on several UI frameworks (ReactJS and AngularJS) and requires localization in different environments (browser and NodeJS). The internationalization engine is framework agnostic and consumable in -all parts of Kibana (ReactJS, AngularJS and NodeJS). +all parts of Kibana (ReactJS, AngularJS and NodeJS). To simplify internationalization in UI frameworks, additional abstractions are @@ -112,7 +112,7 @@ export const HELLO_WORLD = i18n.translate('hello.wonderful.world', { Full details are {repo}tree/master/packages/kbn-i18n#vanilla-js[here]. [float] -===== i18n for React +===== i18n for React To localize strings in React, use either `FormattedMessage` or `i18n.translate`. @@ -138,7 +138,7 @@ Full details are {repo}tree/master/packages/kbn-i18n#react[here]. [float] -===== i18n for Angular +===== i18n for Angular You are encouraged to use `i18n.translate()` by statically importing `i18n` from `@kbn/i18n` wherever possible in your Angular code. Angular wrappers use the translation `service` with the i18n engine under the hood. diff --git a/docs/developer/pr-review.asciidoc b/docs/developer/pr-review.asciidoc index dee40f5118672..304718e437dc5 100644 --- a/docs/developer/pr-review.asciidoc +++ b/docs/developer/pr-review.asciidoc @@ -67,7 +67,7 @@ Enhancements are pretty much always going to have extensive unit tests as a base [float] === Product level review -Reviewers are not simply evaluating the code itself, they are also evaluating the quality of the user-facing change in the product. This generally means they need to check out the branch locally and "play around" with it. In addition to the "do we want this change in the product" details from above, the reviewer should be looking for bugs and evaluating how approachable and useful the feature is as implemented. Special attention should be given to error scenarios and edge cases to ensure they are all handled well within the product. +Reviewers are not simply evaluating the code itself, they are also evaluating the quality of the user-facing change in the product. This generally means they need to check out the branch locally and "play around" with it. In addition to the "do we want this change in the product" details, the reviewer should be looking for bugs and evaluating how approachable and useful the feature is as implemented. Special attention should be given to error scenarios and edge cases to ensure they are all handled well within the product. [float] @@ -107,7 +107,7 @@ Conflicting opinions between reviewers and authors happen, and sometimes it is h Whether or not a bit of feedback is appropriate for a pull request is often dependent on the motivation for giving the feedback in the first place. -_Demanding_ an author make changes based primarily on the mindset of "how would I write this code?" isn't appropriate. The reviewer didn't write the code, and their critical purpose in the review process is not to craft the contribution into a form that is simply whatever they would have written if they had. If a reviewer wants to provide this type of feedback, they should qualify it as a "nit" as mentioned in the nitpicking section above to make it clear that the author can take it or leave it. +_Demanding_ an author make changes based primarily on the mindset of "how would I write this code?" isn't appropriate. The reviewer didn't write the code, and their critical purpose in the review process is not to craft the contribution into a form that is simply whatever they would have written if they had. If a reviewer wants to provide this type of feedback, they should qualify it as a "nit" as mentioned in the nitpicking section to make it clear that the author can take it or leave it. Inflammatory feedback such as "this is crap" isn't feedback at all. It's both mean and unhelpful, and it is never appropriate. diff --git a/docs/infrastructure/metrics-explorer.asciidoc b/docs/infrastructure/metrics-explorer.asciidoc index c20718dac1c7a..d47581ffe720a 100644 --- a/docs/infrastructure/metrics-explorer.asciidoc +++ b/docs/infrastructure/metrics-explorer.asciidoc @@ -44,7 +44,7 @@ In this step we'll leave the aggregation dropdown set to *Average* but you can t 4. In the *graph per* dropdown, enter `host.name` and select this field. You will see a separate graph for each host you are monitoring. -If you are collecting metrics for multiple hosts, you will see something like the screenshot above. +If you are collecting metrics for multiple hosts, multiple graphics are displayed. If you only have metrics for a single host, you will see a single graph. Congratulations! Either way, you've explored your first metric. diff --git a/docs/logs/using.asciidoc b/docs/logs/using.asciidoc index d84a9260521c7..8074cc4a8026d 100644 --- a/docs/logs/using.asciidoc +++ b/docs/logs/using.asciidoc @@ -31,9 +31,7 @@ If so, <> to change the Click image:images/time-filter-calendar.png[time filter calendar], then choose the time range for the logs. -Log entries for the specified time appear in the middle of the page, with the earlier entries above and the later entries below. - -To quickly jump to a nearby point in time, click the minimap timeline to the right. +Log entries for the specified time appear in the middle of the page. To quickly jump to a nearby point in time, click the minimap timeline to the right. // ++ what's this thing called? It's minimap in the UI. Would timeline be better? [float] diff --git a/docs/management/numeral.asciidoc b/docs/management/numeral.asciidoc index 861277fd18478..65dfdab3abd3c 100644 --- a/docs/management/numeral.asciidoc +++ b/docs/management/numeral.asciidoc @@ -145,7 +145,7 @@ with multiple forms, such as German. [float] === Complete number pattern reference -These number formats, combined with the patterns described above, +These number formats, combined with the previously described patterns, produce the complete set of options for numeral formatting. The output here is all for the `en` locale. @@ -180,5 +180,3 @@ The output here is all for the `en` locale. | 1e-27 | 000 | 1e-27 | -1e-27 | 000 | -1e-27 |=== - - diff --git a/docs/management/rollups/create_and_manage_rollups.asciidoc b/docs/management/rollups/create_and_manage_rollups.asciidoc index b07f075f88032..83e1b7c16f8b4 100644 --- a/docs/management/rollups/create_and_manage_rollups.asciidoc +++ b/docs/management/rollups/create_and_manage_rollups.asciidoc @@ -128,7 +128,7 @@ rollup index, or you can remove or archive it using <> file to proxy EMS requests through the Kibana server. -. Update your firewall rules to whitelist connections from your Kibana server to the EMS domains listed above. +. Update your firewall rules to whitelist connections from your Kibana server to the EMS domains. NOTE: Coordinate map and region map visualizations do not support `map.proxyElasticMapsServiceInMaps` and will not proxy EMS requests through the Kibana server. diff --git a/docs/maps/maps-aggregations.asciidoc b/docs/maps/maps-aggregations.asciidoc index 05d8c0c605e7f..692e30a6665ed 100644 --- a/docs/maps/maps-aggregations.asciidoc +++ b/docs/maps/maps-aggregations.asciidoc @@ -2,10 +2,25 @@ [[maps-aggregations]] == Plot big data without plotting too much data -Use {ref}/search-aggregations.html[aggregations] to plot large data sets without overwhemling your network or your browser. +Use {ref}/search-aggregations.html[aggregations] to plot large data sets without overwhelming your network or your browser. +When using aggregations, the documents stay in Elasticsearch and only the calculated values for each group are returned to your computer. Aggregations group your documents into buckets and calculate metrics for each bucket. -Your documents stay in Elasticsearch and only the metrics for each group are returned to your computer. +Use metric aggregations for <>. For example, use the count aggregation to shade world countries by web log traffic. + +You can add the following metric aggregations: + +* *Average.* The mean of the values. + +* *Count.* The number of documents. + +* *Max.* The highest value. + +* *Min.* The lowest value. + +* *Sum.* The total value. + +* *Unique count.* The number of distinct values. Use aggregated layers with document layers to show aggregated views when the map shows larger amounts of the globe and individual documents when the map shows smaller regions. diff --git a/docs/maps/vector-style.asciidoc b/docs/maps/vector-style.asciidoc index cd5b086508ae8..509b1fae4066a 100644 --- a/docs/maps/vector-style.asciidoc +++ b/docs/maps/vector-style.asciidoc @@ -45,11 +45,17 @@ image::maps/images/vector_style_dynamic.png[] Quantitative data driven styling symbolizes features from a range of numeric property values. -To ensure symbols are consistent as you pan, zoom, and filter the map, quantitative data driven styling uses {ref}/search-aggregations-metrics-extendedstats-aggregation.html[extended_stats aggregation] to retrieve statistical metadata. +Property values are fit from the domain range to the style range on a linear scale. +For example, let's symbolize <> documents by size. +The sample web logs `bytes` field ranges from 0 to 18,000. This is the domain range. +The smallest feature has a symbol radius of 1, and the largest feature has a symbol radius of 24. This is the style range. +The `bytes` property value for each feature will fit on a linear scale from the range of 0 to 18,000 to the style range of 1 to 24. -Click the gear icon image:maps/images/gear_icon.png[] to configure extended_stats. Set *Sigma* to a smaller value to minimize outliers by moving the range minimum and maximum closer to the average. Clear the *Calculate range from indices* checkbox to turn off the extended_stats aggregation request. +To ensure symbols are consistent as you pan, zoom, and filter the map, quantitative data driven styling uses {ref}/search-aggregations-metrics-extendedstats-aggregation.html[extended_stats aggregation] to retrieve statistical metadata. Extended_stats is not available for numeric property values from the <> count, sum, and unique count. -NOTE: When the *Calculate range from indices* checkbox is cleared, symbols might be inconsistent as users pan, zoom, and filter the map. Without extended_stats, the range is calulated with data from the local layer. The range is recalulcated when layer data changes. +To configure extended_stats,click the gear icon image:maps/images/gear_icon.png[] to configure extended_stats. Set *Sigma* to a smaller value to minimize outliers by moving the range minimum and maximum closer to the average. Clear the *Calculate range from indices* checkbox to turn off the extended_stats aggregation request. The gear icon is not available for numeric property values from the <> count, sum, and unique count. + +NOTE: When extended_stats is not used, symbols might be inconsistent as users pan, zoom, and filter the map. Without extended_stats, the range is calculated with data from the local layer. The range is re-calculated when layer data changes. [role="screenshot"] image::maps/images/extended_stats_config.png[] diff --git a/docs/setup/docker.asciidoc b/docs/setup/docker.asciidoc index 8fd7b0490e194..ddabce3d5b842 100644 --- a/docs/setup/docker.asciidoc +++ b/docs/setup/docker.asciidoc @@ -7,11 +7,11 @@ A list of all published Docker images and tags is available at https://www.docker.elastic.co[www.docker.elastic.co]. The source code is in https://github.com/elastic/dockerfiles/tree/{branch}/kibana[GitHub]. -These images are free to use under the Elastic license. They contain open source -and free commercial features and access to paid commercial features. -{stack-ov}/license-management.html[Start a 30-day trial] to try out all of the -paid commercial features. See the -https://www.elastic.co/subscriptions[Subscriptions] page for information about +These images are free to use under the Elastic license. They contain open source +and free commercial features and access to paid commercial features. +{stack-ov}/license-management.html[Start a 30-day trial] to try out all of the +paid commercial features. See the +https://www.elastic.co/subscriptions[Subscriptions] page for information about Elastic license levels. [float] @@ -35,8 +35,8 @@ ifeval::["{release-state}"!="unreleased"] docker pull {docker-repo}:{version} -------------------------------------------- -Alternatively, you can download other Docker images that contain only features -available under the Apache 2.0 license. To download the images, go to +Alternatively, you can download other Docker images that contain only features +available under the Apache 2.0 license. To download the images, go to https://www.docker.elastic.co[www.docker.elastic.co]. [float] @@ -96,7 +96,7 @@ Some example translations are shown here: `KIBANA_DEFAULTAPPID`:: `kibana.defaultAppId` `XPACK_MONITORING_ENABLED`:: `xpack.monitoring.enabled` -In general, any setting listed in <> can be +In general, any setting listed in <> can be configured with this technique. These variables can be set with +docker-compose+ like this: @@ -135,5 +135,5 @@ with a <> or via <>. IMPORTANT: If replacing `kibana.yml` with a custom version, be sure to copy the -above defaults to the custom file if you want to retain them. If not, they will +defaults to the custom file if you want to retain them. If not, they will be "masked" by the new file. diff --git a/docs/setup/settings.asciidoc b/docs/setup/settings.asciidoc index 3d99e7298755f..80d04c260e25f 100644 --- a/docs/setup/settings.asciidoc +++ b/docs/setup/settings.asciidoc @@ -234,7 +234,8 @@ FeatureCollection. The file must use the https://en.wikipedia.org/wiki/World_Geodetic_System[WGS84 coordinate reference system (ESPG:4326)] and only include polygons. If the file is hosted on a separate domain from Kibana, the server needs to be CORS-enabled so Kibana can download the file. -The following example shows a valid regionmap configuration. +[[region-map-configuration-example]] +The following example shows a valid region map configuration. + -- map @@ -262,7 +263,7 @@ References the originating source of the geojson file. Supported on {ece}. [[regionmap-fields]]`map.regionmap.layers[].fields[]:`:: Mandatory. Each layer can contain multiple fields to indicate what properties from the geojson -features you wish to expose. The example above shows how to define multiple +features you wish to expose. This <> shows how to define multiple properties. Supported on {ece}. [[regionmap-field-description]]`map.regionmap.layers[].fields[].description:`:: diff --git a/docs/siem/index.asciidoc b/docs/siem/index.asciidoc index a15d860d76775..9d17b5209304f 100644 --- a/docs/siem/index.asciidoc +++ b/docs/siem/index.asciidoc @@ -4,7 +4,6 @@ [partintro] -- -beta[] The SIEM app in Kibana provides an interactive workspace for security teams to triage events and perform initial investigations. It enables analysis of diff --git a/docs/siem/siem-ui.asciidoc b/docs/siem/siem-ui.asciidoc index f01575a21b9f6..85253daaf2933 100644 --- a/docs/siem/siem-ui.asciidoc +++ b/docs/siem/siem-ui.asciidoc @@ -35,7 +35,7 @@ image::siem/images/network-ui.png[] [float] [[detections-ui]] -=== Detections +=== Detections (Beta) The Detections feature automatically searches for threats and creates signals when they are detected. Signal detection rules define the conditions diff --git a/docs/user/introduction.asciidoc b/docs/user/introduction.asciidoc index bbaf22b497868..8b987f81779e3 100644 --- a/docs/user/introduction.asciidoc +++ b/docs/user/introduction.asciidoc @@ -85,7 +85,7 @@ image::images/intro-dashboard.png[] * <> allows you to display your data in line charts, bar graphs, pie charts, histograms, and tables -(just to name a few). It's also home to *Lens*, mentioned above. +(just to name a few). It's also home to *Lens*, the drag-and-drop interface. *Visualize* supports the ability to add interactive controls to your dashboard, and filter dashboard content in real time. diff --git a/docs/user/reporting/development/pdf-integration.asciidoc b/docs/user/reporting/development/pdf-integration.asciidoc index dc9e63f34b25e..af5ba5be1636e 100644 --- a/docs/user/reporting/development/pdf-integration.asciidoc +++ b/docs/user/reporting/development/pdf-integration.asciidoc @@ -51,8 +51,7 @@ should have their screenshot taken and when the Visualizations are done renderin The print layout takes a screenshot of every element with the `data-shared-item` attribute and includes the individual screenshots in the PDF. The print layout also uses the `data-title` and `data-description` -attributes on the same HTMLElement as the `data-shared-item` to specify the title and description -that appears right above the individual screenshots. +attributes on the same HTMLElement as the `data-shared-item` to specify the title and description. The preserve layout takes a screenshot of the element with the `data-shared-items-container` attribute. Additionally, reporting will resize the element with the `data-shared-items-container` to be the size specified in the layout dimensions. @@ -63,4 +62,4 @@ Reporting needs to determine when all of the visualizations have completed rende If there are multiple visualizations, the `data-shared-items-count` attribute should be specified to let Reporting know how many Visualizations to look for. Reporting will look at every element with the `data-shared-item` attribute and use the corresponding `data-render-complete` attribute and `renderComplete` events to listen for rendering to complete. When rendering is complete for a visualization -the `data-render-complete` attribute should be set to "true" and it should dispatch a custom DOM `renderComplete` event. \ No newline at end of file +the `data-render-complete` attribute should be set to "true" and it should dispatch a custom DOM `renderComplete` event. diff --git a/docs/user/security/securing-communications/elasticsearch-mutual-tls.asciidoc b/docs/user/security/securing-communications/elasticsearch-mutual-tls.asciidoc index 8d64a0e6e0c11..f5192f4641d4d 100644 --- a/docs/user/security/securing-communications/elasticsearch-mutual-tls.asciidoc +++ b/docs/user/security/securing-communications/elasticsearch-mutual-tls.asciidoc @@ -63,7 +63,7 @@ you have hostname verification enabled on {es}. -- {es} needs the appropriate CA certificate chain to properly establish trust when receiving connections from {kib}. -If you followed the instructions above to generate a client certificate, then you will have a PKCS#12 file for {kib}. You can extract the CA +If you followed the instructions to generate a client certificate, then you will have a PKCS#12 file for {kib}. You can extract the CA certificate chain from this file. For example: [source,sh] @@ -165,6 +165,6 @@ attempt to use them to authenticate to {es} via the native realm. . Restart {kib}. -NOTE: The steps above enable {kib} to authenticate to {es} using a certificate. However, end users will only be able to authenticate to +These steps enable {kib} to authenticate to {es} using a certificate. However, end users will only be able to authenticate to {kib} with a username and password. To allow end users to authenticate to {kib} using a client certificate, see <>. diff --git a/docs/user/security/securing-communications/index.asciidoc b/docs/user/security/securing-communications/index.asciidoc index 2ac08a4fab5ee..97313c19f44cb 100644 --- a/docs/user/security/securing-communications/index.asciidoc +++ b/docs/user/security/securing-communications/index.asciidoc @@ -150,7 +150,7 @@ elasticsearch.ssl.certificateAuthorities: ["/path/to/elasticsearch-ca.pem"] + -- WARNING: You should not use a PKCS#12 file that contains a private key. This is an unnecessary security risk. If you only have a PKCS#12 -file that contains a private key, a safer approach is to extract the CA certificate chain in PEM format as described above. +file that contains a private key, a safer approach is to extract the CA certificate chain in PEM format. Specify your PKCS#12 file in `kibana.yml`: @@ -188,5 +188,5 @@ verification. For more information about this setting, see <>. +. Optional: <>. . Optional: <>. @@ -103,8 +103,8 @@ You can manage privileges on the *Management / Security / Roles* page in {kib}. If you're using the native realm with Basic Authentication, you can assign roles using the *Management / Security / Users* page in {kib} or the -{ref}/security-api.html#security-user-apis[user management APIs]. For example, -the following creates a user named `jacknich` and assigns it the `kibana_admin` +{ref}/security-api.html#security-user-apis[user management APIs]. For example, +the following creates a user named `jacknich` and assigns it the `kibana_admin` role: [source,js] @@ -131,8 +131,8 @@ on specific index patterns. For more information, see . Verify that you can log in as a user. If you are running {kib} locally, go to `https://localhost:5601` and enter the credentials for a -user you've assigned a {kib} user role. For example, you could log in as the -`jacknich` user created above. +user you've assigned a {kib} user role. For example, you could log in as the user +`jacknich`. + -- diff --git a/docs/visualize/vega.asciidoc b/docs/visualize/vega.asciidoc index d5b7ccb12f48c..c9cf1e7aeb820 100644 --- a/docs/visualize/vega.asciidoc +++ b/docs/visualize/vega.asciidoc @@ -18,47 +18,47 @@ NOTE: In Vega it is possible to load data dynamically, e.g. by setting signals a * To experiment using sample data, first click the {kib} logo in the upper left hand corner and then click the link next to *Sample Data*. -* Once you have data loaded, go to *Visualize*, click *+*, and select *Vega* to see an example graph. -*Note*: The default graph is written in Vega-Lite, but you can build visualizations -in either language. See <> for more information. +* Once you have data loaded, go to *Visualize*, click *+*, and select *Vega* to see an example graph. +*Note*: The default graph is written in Vega-Lite, but you can build visualizations +in either language. See <> for more information. * Try changing `mark` from `line` to `point`, `area`, `bar`, `circle`, -or `square`. Check out the +or `square`. Check out the https://vega.github.io/vega-lite/docs/mark.html#mark-def[Vega-Lite docs] for more information. * Explore other available https://vega.github.io/vega/examples/[Vega] or -https://vega.github.io/vega-lite/examples/[Vega-Lite] visualizations. +https://vega.github.io/vega-lite/examples/[Vega-Lite] visualizations. *Note*: You might need to make URLs absolute, for example, replace `"url": "data/world-110m.json"` with -`"url": "https://vega.github.io/editor/data/world-110m.json"`. +`"url": "https://vega.github.io/editor/data/world-110m.json"`. See <>. -* For more information on getting started, check out this https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana[blog post]. +* For more information on getting started, check out this https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana[blog post]. [[vega-vs-vegalite]] === Vega vs Vega-Lite -The Vega visualization in {kib} supports both Vega and Vega-Lite. You can use the -`schema` value to define which language you would like to use and its minimum +The Vega visualization in {kib} supports both Vega and Vega-Lite. You can use the +`schema` value to define which language you would like to use and its minimum required version. - -For example: + +For example: * Vega-Lite v2: `$schema: https://vega.github.io/schema/vega-lite/v2.json` * Vega v4: `$schema: https://vega.github.io/schema/vega/v4.json` - + The `schema` URL is only used for identification, and does not need to be accessible by {kib}. -Vega-Lite is a simplified version of Vega; it automates some constructions and has -much shorter specifications than Vega. Vega-Lite is automatically converted into +Vega-Lite is a simplified version of Vega; it automates some constructions and has +much shorter specifications than Vega. Vega-Lite is automatically converted into Vega before rendering, but it has some limitations, and there are some visualizations that can be expressed in Vega that cannot be expressed in Vega-Lite. You can learn more in the https://vega.github.io/vega-lite/[Vega-Lite documentation]. You can use https://vega.github.io/editor/[this editor] to convert Vega-Lite into -Vega. +Vega. -When you create a Vega visualization in {kib}, you can edit the `schema` -value in the dev tools to the left of the graph to define which of the two expression -languages you would like to use (see examples above). +When you create a Vega visualization in {kib}, you can edit the `schema` +value in the dev tools to the left of the graph to define which of the two expression +languages you would like to use. [[vega-querying-elasticsearch]] @@ -176,7 +176,7 @@ except that the timerange is shifted back by 10 minutes: ---- The `"%timefilter%"` can also be used to specify a single min or max -value. As shown above, the date_histogram's `extended_bounds` can be set +value. The date_histogram's `extended_bounds` can be set with two values - min and max. Instead of hardcoding a value, you may use `"min": {"%timefilter%": "min"}`, which will be replaced with the beginning of the current time range. The `shift` and `unit` values are @@ -234,7 +234,7 @@ the graph must specify `type=map` in the host configuration: // defaults to true, shows +/- buttons to zoom in/out "zoomControl": false, - // Defaults to 'false', disables mouse wheel zoom. If set to + // Defaults to 'false', disables mouse wheel zoom. If set to // 'true', map may zoom unexpectedly while scrolling dashboard "scrollWheelZoom": false, @@ -295,7 +295,7 @@ to your kibana.yml file. === Useful Links ==== Vega Editor -The https://vega.github.io/editor/[Vega Editor] includes examples for Vega & Vega-Lite, but does not support any +The https://vega.github.io/editor/[Vega Editor] includes examples for Vega & Vega-Lite, but does not support any {kib}-specific features like {es} requests and interactive base maps. ==== Vega-Lite resources @@ -303,14 +303,14 @@ The https://vega.github.io/editor/[Vega Editor] includes examples for Vega & Veg * https://vega.github.io/vega-lite/docs/[Docs] * https://vega.github.io/vega-lite/examples/[Examples] -==== Vega resources +==== Vega resources * https://vega.github.io/vega/tutorials/[Tutorials] * https://vega.github.io/vega/docs/[Docs] * https://vega.github.io/vega/examples/[Examples] ==== Elastic blog posts * https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana[Getting Started with Vega Visualizations in Kibana] -* https://www.elastic.co/blog/custom-vega-visualizations-in-kibana[Custom Vega Visualizations in Kibana] +* https://www.elastic.co/blog/custom-vega-visualizations-in-kibana[Custom Vega Visualizations in Kibana] * https://www.elastic.co/blog/sankey-visualization-with-vega-in-kibana[Sankey Visualization with Vega in Kibana] diff --git a/package.json b/package.json index 9f12f04223103..7a815856c3d5c 100644 --- a/package.json +++ b/package.json @@ -246,6 +246,7 @@ "regenerator-runtime": "^0.13.3", "regression": "2.0.1", "request": "^2.88.0", + "require-in-the-middle": "^5.0.2", "reselect": "^4.0.0", "resize-observer-polyfill": "^1.5.0", "rison-node": "1.0.2", @@ -480,6 +481,7 @@ "strip-ansi": "^3.0.1", "supertest": "^3.1.0", "supertest-as-promised": "^4.0.2", + "tape": "^4.13.0", "tree-kill": "^1.2.2", "typescript": "3.7.2", "typings-tester": "^0.3.2", diff --git a/scripts/test_hardening.js b/scripts/test_hardening.js new file mode 100644 index 0000000000000..c0a20a9ff6cb4 --- /dev/null +++ b/scripts/test_hardening.js @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var execFileSync = require('child_process').execFileSync; +var path = require('path'); +var syncGlob = require('glob').sync; +var program = require('commander'); + +program + .name('node scripts/test_hardening.js') + .arguments('[file...]') + .description( + 'Run the tests in test/harden directory. If no files are provided, all files within the directory will be run.' + ) + .action(function(globs) { + if (globs.length === 0) globs.push(path.join('test', 'harden', '*')); + globs.forEach(function(glob) { + syncGlob(glob).forEach(function(filename) { + if (path.basename(filename)[0] === '_') return; + console.log(process.argv[0], filename); + execFileSync(process.argv[0], [filename], { stdio: 'inherit' }); + }); + }); + }) + .parse(process.argv); diff --git a/src/core/public/http/types.ts b/src/core/public/http/types.ts index 6370ae165282b..c40ad74893ead 100644 --- a/src/core/public/http/types.ts +++ b/src/core/public/http/types.ts @@ -205,7 +205,12 @@ export interface HttpRequestInit { /** @public */ export interface HttpFetchQuery { - [key: string]: string | number | boolean | undefined; + [key: string]: + | string + | number + | boolean + | undefined + | Array; } /** diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index cd956eb17531a..f71a50e2927d8 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -610,7 +610,7 @@ export interface HttpFetchOptionsWithPath extends HttpFetchOptions { // @public (undocumented) export interface HttpFetchQuery { // (undocumented) - [key: string]: string | number | boolean | undefined; + [key: string]: string | number | boolean | undefined | Array; } // @public 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 9c29e182c55d6..76d475c4f7f96 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 @@ -22,15 +22,9 @@ // They can stay even after NP cutover import angular from 'angular'; import { EuiIcon } from '@elastic/eui'; -// @ts-ignore -import { StateProvider } from 'ui/state_management/state'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; // @ts-ignore -import { AppStateProvider } from 'ui/state_management/app_state'; -// @ts-ignore -import { GlobalStateProvider } from 'ui/state_management/global_state'; -// @ts-ignore import { StateManagementConfigProvider } from 'ui/state_management/config_provider'; // @ts-ignore import { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url'; @@ -117,8 +111,6 @@ export function initializeInnerAngularModule( createLocalConfigModule(core.uiSettings); createLocalKbnUrlModule(); createLocalTopNavModule(navigation); - createLocalGlobalStateModule(); - createLocalAppStateModule(); createLocalStorageModule(); createElasticSearchModule(data); createPagerFactoryModule(); @@ -136,6 +128,7 @@ export function initializeInnerAngularModule( 'discoverPrivate', 'discoverDocTable', 'discoverPagerFactory', + 'discoverPromise', ]) .config(watchMultiDecorator) .directive('icon', reactDirective => reactDirective(EuiIcon)) @@ -153,9 +146,8 @@ export function initializeInnerAngularModule( 'discoverConfig', 'discoverI18n', 'discoverPrivate', + 'discoverPromise', 'discoverTopNav', - 'discoverGlobalState', - 'discoverAppState', 'discoverLocalStorageProvider', 'discoverEs', 'discoverDocTable', @@ -178,19 +170,6 @@ export function initializeInnerAngularModule( .service('debounce', ['$timeout', DebounceProviderTimeout]); } -export function createLocalGlobalStateModule() { - angular - .module('discoverGlobalState', [ - 'discoverPrivate', - 'discoverConfig', - 'discoverKbnUrl', - 'discoverPromise', - ]) - .service('globalState', function(Private: IPrivate) { - return Private(GlobalStateProvider); - }); -} - function createLocalKbnUrlModule() { angular .module('discoverKbnUrl', ['discoverPrivate', 'ngRoute']) @@ -236,26 +215,6 @@ function createLocalI18nModule() { .directive('i18nId', i18nDirective); } -function createLocalAppStateModule() { - angular - .module('discoverAppState', [ - 'discoverGlobalState', - 'discoverPrivate', - 'discoverConfig', - 'discoverKbnUrl', - 'discoverPromise', - ]) - .service('AppState', function(Private: IPrivate) { - return Private(AppStateProvider); - }) - .service('getAppState', function(Private: any) { - return Private(AppStateProvider).getAppState; - }) - .service('State', function(Private: any) { - return Private(StateProvider); - }); -} - function createLocalStorageModule() { angular .module('discoverLocalStorageProvider', ['discoverPrivate']) @@ -287,7 +246,6 @@ function createDocTableModule() { .module('discoverDocTable', [ 'discoverKbnUrl', 'discoverConfig', - 'discoverAppState', 'discoverPagerFactory', 'react', ]) diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index 7fa5183a4f54b..6947d985be436 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -53,14 +53,12 @@ export { wrapInI18nContext } from 'ui/i18n'; export { getRequestInspectorStats, getResponseInspectorStats } from '../../../data/public'; // @ts-ignore export { intervalOptions } from 'ui/agg_types'; -export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore export { timezoneProvider } from 'ui/vis/lib/timezone'; export { tabifyAggResponse } from '../../../data/public'; export { unhashUrl } from '../../../../../plugins/kibana_utils/public'; export { - migrateLegacyQuery, ensureDefaultIndexPattern, formatMsg, formatStack, @@ -80,7 +78,6 @@ export { SortDirection, } from '../../../../../plugins/data/public'; export { ElasticSearchHit } from './np_ready/doc_views/doc_views_types'; -export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; // @ts-ignore export { buildPointSeriesData } from 'ui/agg_response/point_series/point_series'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html index 18254aeca5094..2d44b12989228 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html @@ -5,18 +5,15 @@

{{screenTitle}}

@@ -186,7 +183,6 @@

{{screenTitle}}

columns="state.columns" infinite-scroll="true" filter="filterQuery" - filters="state.filters" data-shared-item data-title="{{opts.savedSearch.lastSavedTitle}}" data-description="{{opts.savedSearch.description}}" 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 81c10798936f5..cf237d8d79cc2 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 @@ -24,17 +24,14 @@ import { debounceTime } from 'rxjs/operators'; import moment from 'moment'; import dateMath from '@elastic/datemath'; import { i18n } from '@kbn/i18n'; -import '../components/field_chooser/field_chooser'; +import { getState, splitState } from './discover_state'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; import { SavedObjectSaveModal, showSaveModal, } from '../../../../../../../plugins/saved_objects/public'; -// doc table -import './doc_table'; -import { getSortArray } from './doc_table/lib/get_sort'; -import { getSortForSearchSource } from './doc_table/lib/get_sort_for_search_source'; +import { getSortArray, getSortForSearchSource } from './doc_table'; import * as columnActions from './doc_table/actions/columns'; import indexTemplate from './discover.html'; @@ -44,26 +41,24 @@ import '../components/fetch_error'; import { getPainlessError } from './get_painless_error'; import { discoverResponseHandler } from './response_handler'; import { - angular, getRequestInspectorStats, getResponseInspectorStats, getServices, hasSearchStategyForIndexPattern, intervalOptions, - migrateLegacyQuery, unhashUrl, - stateMonitorFactory, subscribeWithScope, tabifyAggResponse, getAngularModule, ensureDefaultIndexPattern, - registerTimefilterWithGlobalStateFactory, } from '../../kibana_services'; const { core, chrome, + data, docTitle, + indexPatterns, filterManager, share, timefilter, @@ -77,9 +72,11 @@ import { esFilters, fieldFormats, indexPatterns as indexPatternsUtils, + connectToQueryState, + syncQueryStateWithUrl, + getDefaultQuery, } from '../../../../../../../plugins/data/public'; import { getIndexPatternId } from '../helpers/get_index_pattern_id'; -import { FilterStateManager } from '../../../../../data/public'; const fetchStatuses = { UNINITIALIZED: 'uninitialized', @@ -88,9 +85,6 @@ const fetchStatuses = { }; const app = getAngularModule(); -app.run((globalState, $rootScope) => { - registerTimefilterWithGlobalStateFactory(timefilter, globalState, $rootScope); -}); app.config($routeProvider => { const defaults = { @@ -119,10 +113,11 @@ app.config($routeProvider => { template: indexTemplate, reloadOnSearch: false, resolve: { - savedObjects: function(redirectWhenMissing, $route, kbnUrl, Promise, $rootScope, State) { - const indexPatterns = getServices().indexPatterns; + savedObjects: function(redirectWhenMissing, $route, kbnUrl, Promise, $rootScope) { const savedSearchId = $route.current.params.id; - return ensureDefaultIndexPattern(core, getServices().data, $rootScope, kbnUrl).then(() => { + return ensureDefaultIndexPattern(core, data, $rootScope, kbnUrl).then(() => { + const { appStateContainer } = getState({}); + const { index } = appStateContainer.getState(); return Promise.props({ ip: indexPatterns.getCache().then(indexPatternList => { /** @@ -134,22 +129,16 @@ app.config($routeProvider => { * * @type {State} */ - const state = new State('_a', {}); - const id = getIndexPatternId( - state.index, - indexPatternList, - uiSettings.get('defaultIndex') - ); - state.destroy(); + const id = getIndexPatternId(index, indexPatternList, uiSettings.get('defaultIndex')); return Promise.props({ list: indexPatternList, loaded: indexPatterns.get(id), - stateVal: state.index, - stateValFound: !!state.index && id === state.index, + stateVal: index, + stateValFound: !!index && id === index, }); }), savedSearch: getServices() - .getSavedSearchById(savedSearchId, kbnUrl) + .getSavedSearchById(savedSearchId) .then(savedSearch => { if (savedSearchId) { chrome.recentlyAccessed.add( @@ -188,23 +177,114 @@ function discoverController( $scope, $timeout, $window, - AppState, Promise, config, kbnUrl, localStorage, - uiCapabilities, - getAppState, - globalState + uiCapabilities ) { - const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager); + const { isDefault: isDefaultType } = indexPatternsUtils; + const subscriptions = new Subscription(); + const $fetchObservable = new Subject(); + let inspectorRequest; + const savedSearch = $route.current.locals.savedObjects.savedSearch; + $scope.searchSource = savedSearch.searchSource; + $scope.indexPattern = resolveIndexPatternLoading(); + + const getTimeField = () => { + return isDefaultType($scope.indexPattern) ? $scope.indexPattern.timeFieldName : undefined; + }; + + const { + appStateContainer, + startSync: startStateSync, + stopSync: stopStateSync, + setAppState, + replaceUrlAppState, + isAppStateDirty, + kbnUrlStateStorage, + getPreviousAppState, + } = getState({ + defaultAppState: getStateDefaults(), + storeInSessionStorage: config.get('state:storeInSessionStorage'), + }); + if (appStateContainer.getState().index !== $scope.indexPattern.id) { + //used index pattern is different than the given by url/state which is invalid + setAppState({ index: $scope.indexPattern.id }); + } + $scope.state = { ...appStateContainer.getState() }; + + // syncs `_g` portion of url with query services + const { stop: stopSyncingGlobalStateWithUrl } = syncQueryStateWithUrl( + data.query, + kbnUrlStateStorage + ); + + // sync initial app filters from state to filterManager + filterManager.setAppFilters(_.cloneDeep(appStateContainer.getState().filters)); + + const stopSyncingQueryAppStateWithStateContainer = connectToQueryState( + data.query, + appStateContainer, + { filters: esFilters.FilterStateStore.APP_STATE } + ); + + const appStateUnsubscribe = appStateContainer.subscribe(async newState => { + const { state: newStatePartial } = splitState(newState); + const { state: oldStatePartial } = splitState(getPreviousAppState()); + + if (!_.isEqual(newStatePartial, oldStatePartial)) { + $scope.$evalAsync(async () => { + $scope.state = { ...newState }; + + // detect changes that should trigger fetching of new data + const changes = ['interval', 'sort', 'index', 'query'].filter( + prop => !_.isEqual(newStatePartial[prop], oldStatePartial[prop]) + ); + if (changes.indexOf('index') !== -1) { + try { + $scope.indexPattern = await indexPatterns.get(newStatePartial.index); + $scope.opts.timefield = getTimeField(); + $scope.enableTimeRangeSelector = !!$scope.opts.timefield; + // is needed to rerender the histogram + $scope.vis = undefined; + + // Taking care of sort when switching index pattern: + // Old indexPattern: sort by A + // If A is not available in the new index pattern, sort has to be adapted and propagated to URL + const sort = getSortArray(newStatePartial.sort, $scope.indexPattern); + if (newStatePartial.sort && !_.isEqual(sort, newStatePartial.sort)) { + return await replaceUrlAppState({ sort }); + } + } catch (e) { + toastNotifications.addWarning({ text: getIndexPatternWarning(newStatePartial.index) }); + } + } + + if (changes.length) { + $fetchObservable.next(); + } + }); + } + }); + + $scope.setIndexPattern = id => { + setAppState({ index: id }); + }; + + // update data source when filters update + subscriptions.add( + subscribeWithScope($scope, filterManager.getUpdates$(), { + next: () => { + $scope.updateDataSource(); + }, + }) + ); const inspectorAdapters = { requests: new RequestAdapter(), }; - const subscriptions = new Subscription(); - $scope.timefilterUpdateHandler = ranges => { timefilter.setTime({ from: moment(ranges.from).toISOString(), @@ -213,7 +293,6 @@ function discoverController( }); }; $scope.intervalOptions = intervalOptions; - $scope.showInterval = false; $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; @@ -229,19 +308,15 @@ function discoverController( return interval.val !== 'custom'; }; - // the saved savedSearch - const savedSearch = $route.current.locals.savedObjects.savedSearch; - let abortController; $scope.$on('$destroy', () => { if (abortController) abortController.abort(); savedSearch.destroy(); subscriptions.unsubscribe(); - filterStateManager.destroy(); - }); - - const $appStatus = ($scope.appStatus = this.appStatus = { - dirty: !savedSearch.id, + appStateUnsubscribe(); + stopStateSync(); + stopSyncingGlobalStateWithUrl(); + stopSyncingQueryAppStateWithStateContainer(); }); const getTopNavLinks = () => { @@ -299,7 +374,7 @@ function discoverController( onSave={onSave} onClose={() => {}} title={savedSearch.title} - showCopyOnSave={savedSearch.id ? true : false} + showCopyOnSave={!!savedSearch.id} objectType="search" description={i18n.translate('kbn.discover.localMenu.saveSaveSearchDescription', { defaultMessage: @@ -353,7 +428,7 @@ function discoverController( ...sharingData, title: savedSearch.title, }, - isDirty: $appStatus.dirty, + isDirty: !savedSearch.id || isAppStateDirty(), }); }, }; @@ -382,13 +457,8 @@ function discoverController( inspectSearch, ]; }; - $scope.topNavMenu = getTopNavLinks(); - // the actual courier.SearchSource - $scope.searchSource = savedSearch.searchSource; - $scope.indexPattern = resolveIndexPatternLoading(); - $scope.searchSource .setField('index', $scope.indexPattern) .setField('highlightAll', true) @@ -401,7 +471,7 @@ function discoverController( // searchSource which applies time range const timeRangeSearchSource = savedSearch.searchSource.create(); - if (indexPatternsUtils.isDefault($scope.indexPattern)) { + if (isDefaultType($scope.indexPattern)) { timeRangeSearchSource.setField('filter', () => { return timefilter.createFilter($scope.indexPattern); }); @@ -431,11 +501,6 @@ function discoverController( ]); } - let stateMonitor; - - const $state = ($scope.state = new AppState(getStateDefaults())); - const $fetchObservable = new Subject(); - $scope.screenTitle = savedSearch.title; const getFieldCounts = async () => { @@ -455,8 +520,7 @@ function discoverController( }); }; - const getSharingDataFields = async () => { - const selectedFields = $state.columns; + const getSharingDataFields = async (selectedFields, timeFieldName, hideTimeColumn) => { if (selectedFields.length === 1 && selectedFields[0] === '_source') { const fieldCounts = await getFieldCounts(); return { @@ -465,8 +529,6 @@ function discoverController( }; } - const timeFieldName = $scope.indexPattern.timeFieldName; - const hideTimeColumn = config.get('doc_table:hideTimeColumn'); const fields = timeFieldName && !hideTimeColumn ? [timeFieldName, ...selectedFields] : selectedFields; return { @@ -478,12 +540,16 @@ function discoverController( this.getSharingData = async () => { const searchSource = $scope.searchSource.createCopy(); - const { searchFields, selectFields } = await getSharingDataFields(); + const { searchFields, selectFields } = await getSharingDataFields( + $scope.state.columns, + $scope.indexPattern.timeFieldName, + config.get('doc_table:hideTimeColumn') + ); searchSource.setField('fields', searchFields); searchSource.setField( 'sort', getSortForSearchSource( - $state.sort, + $scope.state.sort, $scope.indexPattern, config.get('discover:sort:defaultOrder') ) @@ -508,29 +574,25 @@ function discoverController( }; }; - $scope.uiState = $state.makeStateful('uiState'); - function getStateDefaults() { + const query = + $scope.searchSource.getField('query') || + getDefaultQuery( + localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage') + ); return { - query: ($scope.savedQuery && $scope.savedQuery.attributes.query) || - $scope.searchSource.getField('query') || { - query: '', - language: - localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage'), - }, + query, sort: getSortArray(savedSearch.sort, $scope.indexPattern), columns: savedSearch.columns.length > 0 ? savedSearch.columns : config.get('defaultColumns').slice(), index: $scope.indexPattern.id, interval: 'auto', - filters: - ($scope.savedQuery && $scope.savedQuery.attributes.filters) || - _.cloneDeep($scope.searchSource.getOwnField('filter')), + filters: _.cloneDeep($scope.searchSource.getOwnField('filter')), }; } - $state.index = $scope.indexPattern.id; - $state.sort = getSortArray($state.sort, $scope.indexPattern); + $scope.state.index = $scope.indexPattern.id; + $scope.state.sort = getSortArray($scope.state.sort, $scope.indexPattern); $scope.getBucketIntervalToolTipText = () => { return i18n.translate('kbn.discover.bucketIntervalTooltip', { @@ -550,16 +612,10 @@ function discoverController( }); }; - $scope.$watchCollection('state.columns', function() { - $state.save(); - }); - $scope.opts = { // number of records to fetch, then paginate through sampleSize: config.get('discover:sampleSize'), - timefield: indexPatternsUtils.isDefault($scope.indexPattern) - ? $scope.indexPattern.timeFieldName - : undefined, + timefield: getTimeField(), savedSearch: savedSearch, indexPatternList: $route.current.locals.savedObjects.ip.list, }; @@ -574,14 +630,8 @@ function discoverController( ); }; - const init = _.once(function() { - stateMonitor = stateMonitorFactory.create($state, getStateDefaults()); - stateMonitor.onChange(status => { - $appStatus.dirty = status.dirty || !savedSearch.id; - }); - $scope.$on('$destroy', () => stateMonitor.destroy()); - - $scope.updateDataSource().then(function() { + const init = _.once(() => { + $scope.updateDataSource().then(async () => { const searchBarChanges = merge( timefilter.getAutoRefreshFetch$(), timefilter.getFetch$(), @@ -601,47 +651,16 @@ function discoverController( }, }) ); - - $scope.$watchCollection('state.sort', function(sort) { - if (!sort) return; - - // get the current sort from searchSource as array of arrays - const currentSort = getSortArray($scope.searchSource.getField('sort'), $scope.indexPattern); - - // if the searchSource doesn't know, tell it so - if (!angular.equals(sort, currentSort)) $fetchObservable.next(); - }); - - // update data source when filters update - - subscriptions.add( - subscribeWithScope($scope, filterManager.getUpdates$(), { - next: () => { - $scope.updateDataSource().then(function() { - $state.save(); - }); - }, - }) - ); - - // update data source when hitting forward/back and the query changes - $scope.$listen($state, 'fetch_with_changes', function(diff) { - if (diff.indexOf('query') >= 0) $fetchObservable.next(); - }); - - $scope.$watch('opts.timefield', function(timefield) { - $scope.enableTimeRangeSelector = !!timefield; - }); - + //Handling change oft the histogram interval $scope.$watch('state.interval', function(newInterval, oldInterval) { if (newInterval !== oldInterval) { - $fetchObservable.next(); + setAppState({ interval: newInterval }); } }); $scope.$watch('vis.aggs', function() { // no timefield, no vis, nothing to update - if (!$scope.opts.timefield) return; + if (!getTimeField() || !$scope.vis) return; const buckets = $scope.vis.getAggConfig().byTypeName('buckets'); @@ -650,15 +669,6 @@ function discoverController( } }); - $scope.$watch('state.query', (newQuery, oldQuery) => { - if (!_.isEqual(newQuery, oldQuery)) { - const query = migrateLegacyQuery(newQuery); - if (!_.isEqual(query, newQuery)) { - $scope.updateQuery({ query }); - } - } - }); - $scope.$watchMulti( ['rows', 'fetchStatus'], (function updateResultState() { @@ -705,14 +715,12 @@ function discoverController( })() ); - if ($scope.opts.timefield) { + if (getTimeField()) { setupVisualization(); $scope.updateTime(); } init.complete = true; - $state.replace(); - if (shouldSearchOnPageLoad()) { $fetchObservable.next(); } @@ -728,7 +736,6 @@ function discoverController( try { const id = await savedSearch.save(saveOptions); $scope.$evalAsync(() => { - stateMonitor.setInitialState($state.toJSON()); if (id) { toastNotifications.addSuccess({ title: i18n.translate('kbn.discover.notifications.savedSearchTitle', { @@ -744,7 +751,7 @@ function discoverController( kbnUrl.change('/discover/{{id}}', { id: savedSearch.id }); } else { // Update defaults so that "reload saved query" functions correctly - $state.setDefaults(getStateDefaults()); + setAppState(getStateDefaults()); docTitle.change(savedSearch.lastSavedTitle); } } @@ -770,8 +777,6 @@ function discoverController( $scope.fetchError = undefined; - $scope.updateTime(); - // Abort any in-progress requests before fetching again if (abortController) abortController.abort(); abortController = new AbortController(); @@ -780,7 +785,6 @@ function discoverController( .updateDataSource() .then(setupVisualization) .then(function() { - $state.save(); $scope.fetchStatus = fetchStatuses.LOADING; logInspectorRequest(); return $scope.searchSource.fetch({ @@ -808,10 +812,27 @@ function discoverController( }; $scope.updateQuery = function({ query }) { - $state.query = query; + setAppState({ query }); $fetchObservable.next(); }; + $scope.updateSavedQueryId = newSavedQueryId => { + if (newSavedQueryId) { + setAppState({ savedQuery: newSavedQueryId }); + } else { + //reset filters and query string, remove savedQuery from state + const state = { + ...appStateContainer.getState(), + query: getDefaultQuery( + localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage') + ), + filters: [], + }; + delete state.savedQuery; + appStateContainer.set(state); + } + }; + function getDimensions(aggs, timeRange) { const [metric, agg] = aggs; agg.params.timeRange = timeRange; @@ -842,9 +863,9 @@ function discoverController( } function onResults(resp) { - logInspectorResponse(resp); + inspectorRequest.stats(getResponseInspectorStats($scope.searchSource, resp)).ok({ json: resp }); - if ($scope.opts.timefield) { + if (getTimeField()) { const tabifiedData = tabifyAggResponse($scope.vis.aggs, resp); $scope.searchSource.rawResponse = resp; $scope.histogramData = discoverResponseHandler( @@ -869,8 +890,6 @@ function discoverController( $scope.fetchStatus = fetchStatuses.COMPLETE; } - let inspectorRequest; - function logInspectorRequest() { inspectorAdapters.requests.reset(); const title = i18n.translate('kbn.discover.inspectorRequestDataTitle', { @@ -886,11 +905,8 @@ function discoverController( }); } - function logInspectorResponse(resp) { - inspectorRequest.stats(getResponseInspectorStats($scope.searchSource, resp)).ok({ json: resp }); - } - $scope.updateTime = function() { + //this is the timerange for the histogram, should be refactored $scope.timeRange = { from: dateMath.parse(timefilter.getTime().from), to: dateMath.parse(timefilter.getTime().to, { roundUp: true }), @@ -909,20 +925,26 @@ function discoverController( kbnUrl.change('/discover'); }; - $scope.updateDataSource = Promise.method(function updateDataSource() { + $scope.updateDataSource = () => { const { indexPattern, searchSource } = $scope; searchSource + .setField('index', $scope.indexPattern) .setField('size', $scope.opts.sampleSize) .setField( 'sort', - getSortForSearchSource($state.sort, indexPattern, config.get('discover:sort:defaultOrder')) + getSortForSearchSource( + $scope.state.sort, + indexPattern, + config.get('discover:sort:defaultOrder') + ) ) - .setField('query', !$state.query ? null : $state.query) + .setField('query', $scope.state.query || null) .setField('filter', filterManager.getFilters()); - }); + return Promise.resolve(); + }; - $scope.setSortOrder = function setSortOrder(sortPair) { - $scope.state.sort = sortPair; + $scope.setSortOrder = function setSortOrder(sort) { + setAppState({ sort }); }; // TODO: On array fields, negating does not negate the combination, rather all terms @@ -940,16 +962,19 @@ function discoverController( $scope.addColumn = function addColumn(columnName) { $scope.indexPattern.popularizeField(columnName, 1); - columnActions.addColumn($scope.state.columns, columnName); + const columns = columnActions.addColumn($scope.state.columns, columnName); + setAppState({ columns }); }; $scope.removeColumn = function removeColumn(columnName) { $scope.indexPattern.popularizeField(columnName, 1); - columnActions.removeColumn($scope.state.columns, columnName); + const columns = columnActions.removeColumn($scope.state.columns, columnName); + setAppState({ columns }); }; $scope.moveColumn = function moveColumn(columnName, newIndex) { - columnActions.moveColumn($scope.state.columns, columnName, newIndex); + const columns = columnActions.moveColumn($scope.state.columns, columnName, newIndex); + setAppState({ columns }); }; $scope.scrollToTop = function() { @@ -967,18 +992,10 @@ function discoverController( $scope.minimumVisibleRows = $scope.hits; }; - $scope.updateSavedQueryId = newSavedQueryId => { - if (newSavedQueryId) { - $state.savedQuery = newSavedQueryId; - } else { - delete $state.savedQuery; - } - $state.save(); - }; - async function setupVisualization() { // If no timefield has been specified we don't create a histogram of messages - if (!$scope.opts.timefield) return; + if (!getTimeField()) return; + const { interval: histogramInterval } = $scope.state; const visStateAggs = [ { @@ -989,8 +1006,8 @@ function discoverController( type: 'date_histogram', schema: 'segment', params: { - field: $scope.opts.timefield, - interval: $state.interval, + field: getTimeField(), + interval: histogramInterval, timeRange: timefilter.getTime(), }, }, @@ -1024,14 +1041,25 @@ function discoverController( visSavedObject.vis = $scope.vis; $scope.searchSource.onRequestStart((searchSource, options) => { + if (!$scope.vis) return; return $scope.vis.getAggConfig().onSearchRequestStart(searchSource, options); }); $scope.searchSource.setField('aggs', function() { + if (!$scope.vis) return; return $scope.vis.getAggConfig().toDsl(); }); } + function getIndexPatternWarning(index) { + return i18n.translate('kbn.discover.valueIsNotConfiguredIndexPatternIDWarningTitle', { + defaultMessage: '{stateVal} is not a configured index pattern ID', + values: { + stateVal: `"${index}"`, + }, + }); + } + function resolveIndexPatternLoading() { const { loaded: loadedIndexPattern, @@ -1046,15 +1074,7 @@ function discoverController( } if (stateVal && !stateValFound) { - const warningTitle = i18n.translate( - 'kbn.discover.valueIsNotConfiguredIndexPatternIDWarningTitle', - { - defaultMessage: '{stateVal} is not a configured index pattern ID', - values: { - stateVal: `"${stateVal}"`, - }, - } - ); + const warningTitle = getIndexPatternWarning(); if (ownIndexPattern) { toastNotifications.addWarning({ @@ -1090,7 +1110,7 @@ function discoverController( // Block the UI from loading if the user has loaded a rollup index pattern but it isn't // supported. $scope.isUnsupportedIndexPattern = - !indexPatternsUtils.isDefault($route.current.locals.savedObjects.ip.loaded) && + !isDefaultType($route.current.locals.savedObjects.ip.loaded) && !hasSearchStategyForIndexPattern($route.current.locals.savedObjects.ip.loaded); if ($scope.isUnsupportedIndexPattern) { @@ -1101,4 +1121,6 @@ function discoverController( addHelpMenuToAppChrome(chrome); init(); + // Propagate current app state to url, then start syncing + replaceUrlAppState().then(() => startStateSync()); } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.test.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.test.ts new file mode 100644 index 0000000000000..af772cb5c76f1 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.test.ts @@ -0,0 +1,78 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { getState, GetStateReturn } from './discover_state'; +import { createBrowserHistory, History } from 'history'; + +let history: History; +let state: GetStateReturn; +const getCurrentUrl = () => history.createHref(history.location); + +describe('Test discover state', () => { + beforeEach(async () => { + history = createBrowserHistory(); + history.push('/'); + state = getState({ + defaultAppState: { index: 'test' }, + hashHistory: history, + }); + await state.replaceUrlAppState({}); + await state.startSync(); + }); + afterEach(() => { + state.stopSync(); + }); + test('setting app state and syncing to URL', async () => { + state.setAppState({ index: 'modified' }); + state.flushToUrl(); + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/#?_a=(index:modified)"`); + }); + + test('changing URL to be propagated to appState', async () => { + history.push('/#?_a=(index:modified)'); + expect(state.appStateContainer.getState()).toMatchInlineSnapshot(` + Object { + "index": "modified", + } + `); + }); + test('URL navigation to url without _a, state should not change', async () => { + history.push('/#?_a=(index:modified)'); + history.push('/'); + expect(state.appStateContainer.getState()).toMatchInlineSnapshot(` + Object { + "index": "modified", + } + `); + }); + + test('isAppStateDirty returns whether the current state has changed', async () => { + state.setAppState({ index: 'modified' }); + expect(state.isAppStateDirty()).toBeTruthy(); + state.resetInitialAppState(); + expect(state.isAppStateDirty()).toBeFalsy(); + }); + + test('getPreviousAppState returns the state before the current', async () => { + state.setAppState({ index: 'first' }); + const stateA = state.appStateContainer.getState(); + state.setAppState({ index: 'second' }); + expect(state.getPreviousAppState()).toEqual(stateA); + }); +}); diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.ts new file mode 100644 index 0000000000000..10e7cd1d0c49d --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover_state.ts @@ -0,0 +1,223 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { isEqual } from 'lodash'; +import { createHashHistory, History } from 'history'; +import { + createStateContainer, + createKbnUrlStateStorage, + syncState, + ReduxLikeStateContainer, + IKbnUrlStateStorage, +} from '../../../../../../../plugins/kibana_utils/public'; +import { esFilters, Filter, Query } from '../../../../../../../plugins/data/public'; +import { migrateLegacyQuery } from '../../../../../../../plugins/kibana_legacy/public'; + +interface AppState { + /** + * Columns displayed in the table + */ + columns?: string[]; + /** + * Array of applied filters + */ + filters?: Filter[]; + /** + * id of the used index pattern + */ + index?: string; + /** + * Used interval of the histogram + */ + interval?: string; + /** + * Lucence or KQL query + */ + query?: Query; + /** + * Array of the used sorting [[field,direction],...] + */ + sort?: string[][]; +} + +interface GetStateParams { + /** + * Default state used for merging with with URL state to get the initial state + */ + defaultAppState?: AppState; + /** + * Determins the use of long vs. short/hashed urls + */ + storeInSessionStorage?: boolean; + /** + * Browser history used for testing + */ + hashHistory?: History; +} + +export interface GetStateReturn { + /** + * kbnUrlStateStorage + */ + kbnUrlStateStorage: IKbnUrlStateStorage; + /** + * App state, the _a part of the URL + */ + appStateContainer: ReduxLikeStateContainer; + /** + * Start sync between state and URL + */ + startSync: () => void; + /** + * Stop sync between state and URL + */ + stopSync: () => void; + /** + * Set app state to with a partial new app state + */ + setAppState: (newState: Partial) => void; + /** + * Set state in Url using history.replace + */ + replaceUrlAppState: (newState: Partial) => Promise; + /** + * Sync state to URL, used for testing + */ + flushToUrl: () => void; + /** + * Reset initial state to the current app state + */ + resetInitialAppState: () => void; + /** + * Return the Appstate before the current app state, useful for diffing changes + */ + getPreviousAppState: () => AppState; + /** + * Returns whether the current app state is different to the initial state + */ + isAppStateDirty: () => void; +} +const APP_STATE_URL_KEY = '_a'; + +/** + * Builds and returns appState and globalState containers and helper functions + * Used to sync URL with UI state + */ +export function getState({ + defaultAppState = {}, + storeInSessionStorage = false, + hashHistory, +}: GetStateParams): GetStateReturn { + const stateStorage = createKbnUrlStateStorage({ + useHash: storeInSessionStorage, + history: hashHistory ? hashHistory : createHashHistory(), + }); + + const appStateFromUrl = stateStorage.get(APP_STATE_URL_KEY) as AppState; + let initialAppState = { + ...defaultAppState, + ...appStateFromUrl, + }; + let previousAppState: AppState; + const appStateContainer = createStateContainer(initialAppState); + + const appStateContainerModified = { + ...appStateContainer, + set: (value: AppState | null) => { + if (value) { + previousAppState = appStateContainer.getState(); + appStateContainer.set(value); + } + }, + }; + + const { start, stop } = syncState({ + storageKey: APP_STATE_URL_KEY, + stateContainer: appStateContainerModified, + stateStorage, + }); + + return { + kbnUrlStateStorage: stateStorage, + appStateContainer: appStateContainerModified, + startSync: start, + stopSync: stop, + setAppState: (newPartial: AppState) => setState(appStateContainerModified, newPartial), + replaceUrlAppState: async (newPartial: AppState = {}) => { + const state = { ...appStateContainer.getState(), ...newPartial }; + await stateStorage.set(APP_STATE_URL_KEY, state, { replace: true }); + }, + resetInitialAppState: () => { + initialAppState = appStateContainer.getState(); + }, + getPreviousAppState: () => previousAppState, + flushToUrl: () => stateStorage.flush(), + isAppStateDirty: () => !isEqualState(initialAppState, appStateContainer.getState()), + }; +} + +/** + * Helper function to merge a given new state with the existing state and to set the given state + * container + */ +export function setState(stateContainer: ReduxLikeStateContainer, newState: AppState) { + const oldState = stateContainer.getState(); + const mergedState = { ...oldState, ...newState }; + if (!isEqualState(oldState, mergedState)) { + if (mergedState.query) { + mergedState.query = migrateLegacyQuery(mergedState.query); + } + stateContainer.set(mergedState); + } +} + +/** + * Helper function to compare 2 different filter states + */ +export function isEqualFilters(filtersA: Filter[], filtersB: Filter[]) { + if (!filtersA && !filtersB) { + return true; + } else if (!filtersA || !filtersB) { + return false; + } + return esFilters.compareFilters(filtersA, filtersB, esFilters.COMPARE_ALL_OPTIONS); +} + +/** + * helper function to extract filters of the given state + * returns a state object without filters and an array of filters + */ +export function splitState(state: AppState = {}) { + const { filters = [], ...statePartial } = state; + return { filters, state: statePartial }; +} + +/** + * Helper function to compare 2 different state, is needed since comparing filters + * works differently + */ +export function isEqualState(stateA: AppState, stateB: AppState) { + if (!stateA && !stateB) { + return true; + } else if (!stateA || !stateB) { + return false; + } + const { filters: stateAFilters = [], ...stateAPartial } = stateA; + const { filters: stateBFilters = [], ...stateBPartial } = stateB; + return isEqual(stateAPartial, stateBPartial) && isEqualFilters(stateAFilters, stateBFilters); +} diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/actions/columns.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/actions/columns.ts index ec4fe8025a7c7..cec1a097da5bf 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/actions/columns.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/actions/columns.ts @@ -17,35 +17,40 @@ * under the License. */ +/** + * Helper function to provide a fallback to a single _source column if the given array of columns + * is empty, and removes _source if there are more than 1 columns given + * @param columns + */ +function buildColumns(columns: string[]) { + if (columns.length > 1 && columns.indexOf('_source') !== -1) { + return columns.filter(col => col !== '_source'); + } else if (columns.length !== 0) { + return columns; + } + return ['_source']; +} + export function addColumn(columns: string[], columnName: string) { if (columns.includes(columnName)) { - return; + return columns; } - - columns.push(columnName); + return buildColumns([...columns, columnName]); } export function removeColumn(columns: string[], columnName: string) { if (!columns.includes(columnName)) { - return; + return columns; } - - columns.splice(columns.indexOf(columnName), 1); + return buildColumns(columns.filter(col => col !== columnName)); } export function moveColumn(columns: string[], columnName: string, newIndex: number) { - if (newIndex < 0) { - return; + if (newIndex < 0 || newIndex >= columns.length || !columns.includes(columnName)) { + return columns; } - - if (newIndex >= columns.length) { - return; - } - - if (!columns.includes(columnName)) { - return; - } - - columns.splice(columns.indexOf(columnName), 1); // remove at old index - columns.splice(newIndex, 0, columnName); // insert before new index + const modifiedColumns = [...columns]; + modifiedColumns.splice(modifiedColumns.indexOf(columnName), 1); // remove at old index + modifiedColumns.splice(newIndex, 0, columnName); // insert before new index + return modifiedColumns; } 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 8df035d098469..7a090d6b7820c 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 @@ -33,6 +33,7 @@ import { dispatchRenderComplete } from '../../../../../../../../../plugins/kiban import cellTemplateHtml from '../components/table_row/cell.html'; import truncateByHeightTemplateHtml from '../components/table_row/truncate_by_height.html'; import { esFilters } from '../../../../../../../../../plugins/data/public'; +import { getServices } from '../../../../kibana_services'; // guesstimate at the minimum number of chars wide cells in the table should be const MIN_LINE_LENGTH = 20; @@ -55,7 +56,6 @@ export function createTableRowDirective( scope: { columns: '=', filter: '=', - filters: '=?', indexPattern: '=', row: '=kbnTableRow', onAddColumn: '=?', @@ -116,12 +116,18 @@ export function createTableRowDirective( anchorId: $scope.row._id, indexPattern: $scope.indexPattern.id, }); + const globalFilters: any = getServices().filterManager.getGlobalFilters(); + const appFilters: any = getServices().filterManager.getAppFilters(); const hash = $httpParamSerializer({ + _g: rison.encode({ + filters: globalFilters || [], + }), _a: rison.encode({ columns: $scope.columns, - filters: ($scope.filters || []).map(esFilters.disableFilter), + filters: (appFilters || []).map(esFilters.disableFilter), }), }); + return `${path}?${hash}`; }; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.html index 61bb5cbf39cbe..3ce43426caf44 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.html @@ -43,7 +43,6 @@ sorting="sorting" index-pattern="indexPattern" filter="filter" - filters="filters" class="kbnDocTable__row" on-add-column="onAddColumn" on-remove-column="onRemoveColumn" @@ -93,7 +92,6 @@ sorting="sorting" index-pattern="indexPattern" filter="filter" - filters="filters" class="kbnDocTable__row" ng-class="{'kbnDocTable__row--highlight': row['$$_isAnchor']}" data-test-subj="docTableRow{{ row['$$_isAnchor'] ? ' docTableAnchorRow' : ''}}" 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 3329ffc7cd102..0ca8286c17081 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,15 +17,9 @@ * under the License. */ -import _ from 'lodash'; import { IUiSettingsClient } from 'kibana/public'; import html from './doc_table.html'; -import './infinite_scroll'; -import './components/table_header'; -import './components/table_row'; import { dispatchRenderComplete } from '../../../../../../../../plugins/kibana_utils/public'; -import './components/pager'; -import './lib/pager'; // @ts-ignore import { getLimitedSearchResultsMessage } from './doc_table_strings'; @@ -35,7 +29,6 @@ interface LazyScope extends ng.IScope { export function createDocTableDirective( config: IUiSettingsClient, - getAppState: any, pagerFactory: any, $filter: any ) { @@ -51,7 +44,6 @@ export function createDocTableDirective( isLoading: '=?', infiniteScroll: '=?', filter: '=?', - filters: '=?', minimumVisibleRows: '=?', onAddColumn: '=?', onChangeSortOrder: '=?', @@ -83,23 +75,6 @@ export function createDocTableDirective( $scope.limit += 50; }; - // This exists to fix the problem of an empty initial column list not playing nice with watchCollection. - $scope.$watch('columns', function(columns: string[]) { - if (columns.length !== 0) return; - - const $state = getAppState(); - $scope.columns.push('_source'); - if ($state) $state.replace(); - }); - - $scope.$watchCollection('columns', function(columns: string[], oldColumns: string[]) { - if (oldColumns.length === 1 && oldColumns[0] === '_source' && $scope.columns.length > 1) { - _.pull($scope.columns, '_source'); - } - - if ($scope.columns.length === 0) $scope.columns.push('_source'); - }); - $scope.$watch('hits', (hits: any) => { if (!hits) return; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/index.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/index.ts index 1eb1f10114d53..a7e3bdfd57f3b 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/index.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/index.ts @@ -17,4 +17,6 @@ * under the License. */ -import './doc_table'; +export { createDocTableDirective } from './doc_table'; +export { getSort, getSortArray } from './lib/get_sort'; +export { getSortForSearchSource } from './lib/get_sort_for_search_source'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/application.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/application.ts index 83f4a5962e3cd..7a4819bb0f2d1 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/application.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/application.ts @@ -36,8 +36,6 @@ function mountDiscoverApp(moduleName: string, element: HTMLElement) { // bootstrap angular into detached element and attach it later to // make angular-within-angular possible const $injector = angular.bootstrap(mountpoint, [moduleName]); - // initialize global state handler - $injector.get('globalState'); element.appendChild(mountpoint); return $injector; } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.test.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.test.tsx index b6fd5ee60b8e2..79417c07501a3 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.test.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.test.tsx @@ -25,6 +25,12 @@ import { ChangeIndexPattern } from './change_indexpattern'; import { SavedObject } from 'kibana/server'; import { DiscoverIndexPattern } from './discover_index_pattern'; import { EuiSelectable, EuiSelectableList } from '@elastic/eui'; +import { IIndexPattern } from 'src/plugins/data/public'; + +const indexPattern = { + id: 'test1', + title: 'test1 title', +} as IIndexPattern; const indexPattern1 = { id: 'test1', @@ -42,7 +48,7 @@ const indexPattern2 = { const defaultProps = { indexPatternList: [indexPattern1, indexPattern2], - selectedIndexPattern: indexPattern1, + selectedIndexPattern: indexPattern, setIndexPattern: jest.fn(async () => {}), }; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx index cca523ee2c1bd..fd2f96ca83a2f 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/discover_index_pattern.tsx @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { SavedObject } from 'kibana/server'; -import { IndexPatternAttributes } from 'src/plugins/data/public'; +import { IIndexPattern, IndexPatternAttributes } from 'src/plugins/data/public'; import { I18nProvider } from '@kbn/i18n/react'; import { IndexPatternRef } from './types'; @@ -31,7 +31,7 @@ export interface DiscoverIndexPatternProps { /** * currently selected index pattern, due to angular issues it's undefined at first rendering */ - selectedIndexPattern: SavedObject; + selectedIndexPattern: IIndexPattern; /** * triggered when user selects a new index pattern */ @@ -50,12 +50,16 @@ export function DiscoverIndexPattern({ id: entity.id, title: entity.attributes!.title, })); - const { id: selectedId, attributes } = selectedIndexPattern || {}; + const { id: selectedId, title: selectedTitle } = selectedIndexPattern || {}; const [selected, setSelected] = useState({ id: selectedId, - title: attributes?.title || '', + title: selectedTitle || '', }); + useEffect(() => { + const { id, title } = selectedIndexPattern; + setSelected({ id, title }); + }, [selectedIndexPattern]); if (!selectedId) { return null; } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.html index 1587c2af79752..fd63c26aa2bb3 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.html @@ -1,7 +1,7 @@