diff --git a/.github/workflows/pr-project-assigner.yml b/.github/workflows/pr-project-assigner.yml index d8b25b980a478e..ca5d0b9864f993 100644 --- a/.github/workflows/pr-project-assigner.yml +++ b/.github/workflows/pr-project-assigner.yml @@ -13,9 +13,9 @@ jobs: with: issue-mappings: | [ - { "label": "Team:AppArch", "projectNumber": 37, "columnName": "Review in progress" }, - { "label": "Feature:Lens", "projectNumber": 32, "columnName": "In progress" }, - { "label": "Team:Canvas", "projectNumber": 38, "columnName": "Review in progress" } ] - ghToken: ${{ secrets.GITHUB_TOKEN }} + ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }} +# { "label": "Team:AppArch", "projectNumber": 37, "columnName": "Review in progress" }, +# { "label": "Feature:Lens", "projectNumber": 32, "columnName": "In progress" }, +# { "label": "Team:Canvas", "projectNumber": 38, "columnName": "Review in progress" } \ No newline at end of file diff --git a/.github/workflows/project-assigner.yml b/.github/workflows/project-assigner.yml index 30032c9a7f998b..eb5827e121c74b 100644 --- a/.github/workflows/project-assigner.yml +++ b/.github/workflows/project-assigner.yml @@ -12,6 +12,6 @@ jobs: id: project_assigner with: issue-mappings: '[{"label": "Team:AppArch", "projectNumber": 37, "columnName": "To triage"}, {"label": "Feature:Lens", "projectNumber": 32, "columnName": "Long-term goals"}, {"label": "Team:Canvas", "projectNumber": 38, "columnName": "Inbox"}]' - ghToken: ${{ secrets.GITHUB_TOKEN }} + ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }} diff --git a/.sass-lint.yml b/.sass-lint.yml index 9c64c1e5eea569..dd7bc0576692b5 100644 --- a/.sass-lint.yml +++ b/.sass-lint.yml @@ -7,6 +7,7 @@ files: - 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss' - 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss' - 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss' + - 'x-pack/plugins/triggers_actions_ui/**/*.s+(a|c)ss' ignore: - 'x-pack/legacy/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss' - 'x-pack/legacy/plugins/lens/**/*.s+(a|c)ss' diff --git a/docs/api/dashboard/export-dashboard.asciidoc b/docs/api/dashboard/export-dashboard.asciidoc index 7858b69d44c79d..36c551dee84fcc 100644 --- a/docs/api/dashboard/export-dashboard.asciidoc +++ b/docs/api/dashboard/export-dashboard.asciidoc @@ -9,7 +9,7 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-request]] ==== Request -`GET /api/kibana/dashboards/export` +`GET :/api/kibana/dashboards/export` [[dashboard-api-export-params]] ==== Query parameters @@ -20,9 +20,9 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-response-body]] ==== Response body -`objects`:: +`objects`:: (array) A top level property that includes the saved objects. The order of the objects is not guaranteed. Use the exact response body as the request body for the corresponding <>. - + [[dashboard-api-export-codes]] ==== Response code @@ -33,10 +33,10 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -GET api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c <1> +$ curl -X GET "localhost:5601/api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c" <1> -------------------------------------------------- // KIBANA -<1> The dashboard ID is `942dcef0-b2cd-11e8-ad8e-85441f0c2e5c`. \ No newline at end of file +<1> The dashboard ID is `942dcef0-b2cd-11e8-ad8e-85441f0c2e5c`. diff --git a/docs/api/dashboard/import-dashboard.asciidoc b/docs/api/dashboard/import-dashboard.asciidoc index 14817719ec7ee6..320859f78c617a 100644 --- a/docs/api/dashboard/import-dashboard.asciidoc +++ b/docs/api/dashboard/import-dashboard.asciidoc @@ -9,7 +9,7 @@ experimental[] Import dashboards and corresponding saved objects. [[dashboard-api-import-request]] ==== Request -`POST /api/kibana/dashboards/import` +`POST :/api/kibana/dashboards/import` [[dashboard-api-import-params]] ==== Query parameters @@ -40,9 +40,9 @@ Use the complete response body from the <:/api/features` [float] [[features-api-get-codes]] @@ -23,7 +23,7 @@ experimental[] Retrieves all {kib} features. Features are used by spaces and sec The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "discover", diff --git a/docs/api/logstash-configuration-management.asciidoc b/docs/api/logstash-configuration-management.asciidoc index fbb45095c214b6..621b6c61dad8a6 100644 --- a/docs/api/logstash-configuration-management.asciidoc +++ b/docs/api/logstash-configuration-management.asciidoc @@ -2,9 +2,9 @@ [[logstash-configuration-management-api]] == Logstash configuration management APIs -Programmatically integrate with the Logstash configuration management feature. +Programmatically integrate with Logstash configuration management. -WARNING: Do not directly access the `.logstash` index. The structure of the `.logstash` index is subject to change, which could cause your integration to break. Instead, use the Logstash configuration management APIs. +WARNING: Do not directly access the `.logstash` index. The structure of the `.logstash` index is subject to change, which could cause your integration to break. Instead, use the Logstash configuration management APIs. The following Logstash configuration management APIs are available: @@ -20,5 +20,3 @@ include::logstash-configuration-management/delete-pipeline.asciidoc[] include::logstash-configuration-management/list-pipeline.asciidoc[] include::logstash-configuration-management/create-logstash.asciidoc[] include::logstash-configuration-management/retrieve-pipeline.asciidoc[] - - diff --git a/docs/api/logstash-configuration-management/create-logstash.asciidoc b/docs/api/logstash-configuration-management/create-logstash.asciidoc index 38e0ee12a0ebff..d6ad27fe446030 100644 --- a/docs/api/logstash-configuration-management/create-logstash.asciidoc +++ b/docs/api/logstash-configuration-management/create-logstash.asciidoc @@ -9,7 +9,7 @@ experimental[] Create a centrally-managed Logstash pipeline, or update an existi [[logstash-configuration-management-api-create-request]] ==== Request -`PUT /api/logstash/pipeline/` +`PUT :/api/logstash/pipeline/` [[logstash-configuration-management-api-create-params]] ==== Path parameters @@ -39,9 +39,9 @@ experimental[] Create a centrally-managed Logstash pipeline, or update an existi [[logstash-configuration-management-api-create-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -PUT api/logstash/pipeline/hello-world +$ curl -X PUT "localhost:5601/api/logstash/pipeline/hello-world" { "pipeline": "input { stdin {} } output { stdout {} }", "settings": { diff --git a/docs/api/logstash-configuration-management/delete-pipeline.asciidoc b/docs/api/logstash-configuration-management/delete-pipeline.asciidoc index 15d44034b46fee..e982619ee17f47 100644 --- a/docs/api/logstash-configuration-management/delete-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/delete-pipeline.asciidoc @@ -9,7 +9,7 @@ experimental[] Delete a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-delete-request]] ==== Request -`DELETE /api/logstash/pipeline/` +`DELETE :/api/logstash/pipeline/` [[logstash-configuration-management-api-delete-params]] ==== Path parameters @@ -26,9 +26,8 @@ experimental[] Delete a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-delete-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -DELETE api/logstash/pipeline/hello-world +$ curl -X DELETE "localhost:5601/api/logstash/pipeline/hello-world" -------------------------------------------------- // KIBANA - diff --git a/docs/api/logstash-configuration-management/list-pipeline.asciidoc b/docs/api/logstash-configuration-management/list-pipeline.asciidoc index 7140c35d898537..d875ea3d95b784 100644 --- a/docs/api/logstash-configuration-management/list-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/list-pipeline.asciidoc @@ -9,14 +9,14 @@ experimental[] List all centrally-managed Logstash pipelines. [[logstash-configuration-management-api-list-request]] ==== Request -`GET /api/logstash/pipelines` +`GET :/api/logstash/pipelines` [[logstash-configuration-management-api-list-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "pipelines": [ @@ -35,4 +35,4 @@ The API returns the following: } -------------------------------------------------- -<1> The `username` property appears when security is enabled, and depends on when the pipeline was created or last updated. \ No newline at end of file +<1> The `username` property appears when security is enabled, and depends on when the pipeline was created or last updated. diff --git a/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc b/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc index 93a1ec3aa1da5b..1eb380b71c62ab 100644 --- a/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc @@ -9,20 +9,20 @@ experimental[] Retrieve a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-retrieve-request]] ==== Request -`GET /api/logstash/pipeline/` +`GET :/api/logstash/pipeline/` [[logstash-configuration-management-api-retrieve-path-params]] ==== Path parameters `id`:: (Required, string) The pipeline ID. - + [[logstash-configuration-management-api-retrieve-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "hello-world", @@ -33,4 +33,4 @@ The API returns the following: "queue.type": "persistent" } } --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/role-management.asciidoc b/docs/api/role-management.asciidoc index 482d1a9b3cdd30..4c4620a23943ac 100644 --- a/docs/api/role-management.asciidoc +++ b/docs/api/role-management.asciidoc @@ -2,9 +2,9 @@ [[role-management-api]] == {kib} role management APIs -Manage the roles that grant <>. +Manage the roles that grant <>. -WARNING: Do not use the {ref}/security-api.html#security-role-apis[{es} role management APIs] to manage {kib} roles. +WARNING: Do not use the {ref}/security-api.html#security-role-apis[{es} role management APIs] to manage {kib} roles. The following {kib} role management APIs are available: diff --git a/docs/api/role-management/delete.asciidoc b/docs/api/role-management/delete.asciidoc index acf2e4a3e3f1f3..530e1e252ef8fc 100644 --- a/docs/api/role-management/delete.asciidoc +++ b/docs/api/role-management/delete.asciidoc @@ -4,26 +4,23 @@ Delete role ++++ -Delete a {kib} role. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Delete a {kib} role. [[role-management-api-delete-prereqs]] -==== Prerequisite +==== Prerequisite To use the delete role API, you must have the `manage_security` cluster privilege. [[role-management-api-delete-request-body]] ==== Request -`DELETE /api/security/role/my_admin_role` +`DELETE :/api/security/role/my_admin_role` [[role-management-api-delete-response-codes]] ==== Response codes `204`:: Indicates a successful call. - + `404`:: - Indicates an unsuccessful call. - \ No newline at end of file + Indicates an unsuccessful call. diff --git a/docs/api/role-management/get-all.asciidoc b/docs/api/role-management/get-all.asciidoc index 4a3dbd7734d3ad..888bf0c8a137c6 100644 --- a/docs/api/role-management/get-all.asciidoc +++ b/docs/api/role-management/get-all.asciidoc @@ -4,32 +4,30 @@ Get all roles ++++ -Retrieve all {kib} roles. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Retrieve all {kib} roles. [[role-management-api-get-prereqs]] -==== Prerequisite +==== Prerequisite To use the get role API, you must have the `manage_security` cluster privilege. [[role-management-api-retrieve-all-request-body]] ==== Request -`GET /api/security/role` +`GET :/api/security/role` [[role-management-api-retrieve-all-response-codes]] ==== Response code -`200`:: +`200`:: Indicates a successful call. - + [[role-management-api-retrieve-all-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- [ { @@ -77,4 +75,4 @@ The API returns the following: "kibana": [ ] } ] --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/role-management/get.asciidoc b/docs/api/role-management/get.asciidoc index 44423b01abe5b6..d1e9d1e6afa831 100644 --- a/docs/api/role-management/get.asciidoc +++ b/docs/api/role-management/get.asciidoc @@ -4,32 +4,30 @@ Get specific role ++++ -Retrieve a specific role. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Retrieve a specific role. [[role-management-specific-api-get-prereqs]] -==== Prerequisite +==== Prerequisite To use the get specific role API, you must have the `manage_security` cluster privilege. [[role-management-specific-api-retrieve-all-request-body]] ===== Request -`GET /api/security/role/my_restricted_kibana_role` +`GET :/api/security/role/my_restricted_kibana_role` [[role-management-specific-api-retrieve-all-response-codes]] ==== Response code -`200`:: +`200`:: Indicates a successful call. - + [[role-management-specific-api-retrieve-all-example]] ===== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "name": "my_restricted_kibana_role", diff --git a/docs/api/role-management/put.asciidoc b/docs/api/role-management/put.asciidoc index a00fedf7e7ac4c..59e6bc8d37eec7 100644 --- a/docs/api/role-management/put.asciidoc +++ b/docs/api/role-management/put.asciidoc @@ -4,15 +4,13 @@ Create or update role ++++ -Create a new {kib} role, or update the attributes of an existing role. {kib} roles are stored in the +experimental[] Create a new {kib} role, or update the attributes of an existing role. {kib} roles are stored in the {es} native realm. -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] - [[role-management-api-put-request]] ==== Request -`PUT /api/security/role/my_kibana_role` +`PUT :/api/security/role/my_kibana_role` [[role-management-api-put-prereqs]] ==== Prerequisite @@ -22,45 +20,45 @@ To use the create or update role API, you must have the `manage_security` cluste [[role-management-api-response-body]] ==== Request body -`metadata`:: +`metadata`:: (Optional, object) In the `metadata` object, keys that begin with `_` are reserved for system usage. -`elasticsearch`:: - (Optional, object) {es} cluster and index privileges. Valid keys include +`elasticsearch`:: + (Optional, object) {es} cluster and index privileges. Valid keys include `cluster`, `indices`, and `run_as`. For more information, see {ref}/defining-roles.html[Defining roles]. -`kibana`:: +`kibana`:: (list) Objects that specify the <> for the role: -`base` ::: +`base` ::: (Optional, list) A base privilege. When specified, the base must be `["all"]` or `["read"]`. When the `base` privilege is specified, you are unable to use the `feature` section. "all" grants read/write access to all {kib} features for the specified spaces. "read" grants read-only access to all {kib} features for the specified spaces. -`feature` ::: +`feature` ::: (object) Contains privileges for specific features. When the `feature` privileges are specified, you are unable to use the `base` section. To retrieve a list of available features, use the <>. -`spaces` ::: +`spaces` ::: (list) The spaces to apply the privileges to. To grant access to all spaces, set to `["*"]`, or omit the value. [[role-management-api-put-response-codes]] ==== Response code -`204`:: +`204`:: Indicates a successful call. ===== Examples Grant access to various features in all spaces: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -127,9 +125,9 @@ PUT /api/security/role/my_kibana_role Grant dashboard-only access to only the Marketing space: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -155,9 +153,9 @@ PUT /api/security/role/my_kibana_role Grant full access to all features in the Default space: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -182,9 +180,9 @@ PUT /api/security/role/my_kibana_role Grant different access to different spaces: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -216,11 +214,11 @@ PUT /api/security/role/my_kibana_role -------------------------------------------------- // KIBANA -Grant access to {kib} and Elasticsearch: +Grant access to {kib} and {es}: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 diff --git a/docs/api/saved-objects/bulk_create.asciidoc b/docs/api/saved-objects/bulk_create.asciidoc index d649684bc30f26..9daba224b317c3 100644 --- a/docs/api/saved-objects/bulk_create.asciidoc +++ b/docs/api/saved-objects/bulk_create.asciidoc @@ -9,9 +9,9 @@ experimental[] Create multiple {kib} saved objects. [[saved-objects-api-bulk-create-request]] ==== Request -`POST /api/saved_objects/_bulk_create` +`POST :/api/saved_objects/_bulk_create` -`POST /s//api/saved_objects/_bulk_create` +`POST :/s//api/saved_objects/_bulk_create` [[saved-objects-api-bulk-create-path-params]] @@ -63,9 +63,9 @@ Saved objects that are unable to persist are replaced with an error object. Create an index pattern with the `my-pattern` ID, and a dashboard with the `my-dashboard` ID: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_bulk_create +$ curl -X POST "localhost:5601/api/saved_objects/_bulk_create" [ { "type": "index-pattern", @@ -87,7 +87,7 @@ POST api/saved_objects/_bulk_create The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "saved_objects": [ diff --git a/docs/api/saved-objects/bulk_get.asciidoc b/docs/api/saved-objects/bulk_get.asciidoc index 3ef5823716d799..a6fdeb69ba9253 100644 --- a/docs/api/saved-objects/bulk_get.asciidoc +++ b/docs/api/saved-objects/bulk_get.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve multiple {kib} saved objects by ID. [[saved-objects-api-bulk-get-request]] ==== Request -`POST /api/saved_objects/_bulk_get` +`POST :/api/saved_objects/_bulk_get` -`POST /s//api/saved_objects/_bulk_get` +`POST :/s//api/saved_objects/_bulk_get` [[saved-objects-api-bulk-get-path-params]] ==== Path parameters @@ -50,9 +50,9 @@ Saved objects that are unable to persist are replaced with an error object. Retrieve an index pattern with the `my-pattern` ID, and a dashboard with the `my-dashboard` ID: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_bulk_get +$ curl -X POST "localhost:5601/api/saved_objects/_bulk_get" [ { "type": "index-pattern", @@ -68,7 +68,7 @@ POST api/saved_objects/_bulk_get The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "saved_objects": [ diff --git a/docs/api/saved-objects/create.asciidoc b/docs/api/saved-objects/create.asciidoc index 634c71bb4eefeb..dc010c80fd0121 100644 --- a/docs/api/saved-objects/create.asciidoc +++ b/docs/api/saved-objects/create.asciidoc @@ -9,11 +9,11 @@ experimental[] Create {kib} saved objects. [[saved-objects-api-create-request]] ==== Request -`POST /api/saved_objects/` + +`POST :/api/saved_objects/` + -`POST /api/saved_objects//` +`POST :/api/saved_objects//` -`POST /s//saved_objects/` +`POST :/s//saved_objects/` [[saved-objects-api-create-path-params]] ==== Path parameters @@ -55,9 +55,9 @@ any data that you send to the API is properly formed. [[saved-objects-api-create-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/index-pattern/my-pattern +$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern" { "attributes": { "title": "my-pattern-*" @@ -68,7 +68,7 @@ POST api/saved_objects/index-pattern/my-pattern The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", <1> diff --git a/docs/api/saved-objects/delete.asciidoc b/docs/api/saved-objects/delete.asciidoc index c34f9b67dfd22d..65c955e15d360d 100644 --- a/docs/api/saved-objects/delete.asciidoc +++ b/docs/api/saved-objects/delete.asciidoc @@ -4,16 +4,16 @@ Delete object ++++ -experimental[] Remove {kib} saved objects. +experimental[] Remove {kib} saved objects. WARNING: Once you delete a saved object, _it cannot be recovered_. [[saved-objects-api-delete-request]] ==== Request -`DELETE /api/saved_objects//` +`DELETE :/api/saved_objects//` -`DELETE /s//api/saved_objects//` +`DELETE :/s//api/saved_objects//` [[saved-objects-api-delete-path-params]] ==== Path parameters @@ -33,12 +33,12 @@ WARNING: Once you delete a saved object, _it cannot be recovered_. `200`:: Indicates a successful call. -==== Examples +==== Example Delete an index pattern object with the `my-pattern` ID: -[source,js] +[source,sh] -------------------------------------------------- -DELETE api/saved_objects/index-pattern/my-pattern +$ curl -X DELETE "localhost:5601/api/saved_objects/index-pattern/my-pattern" -------------------------------------------------- // KIBANA diff --git a/docs/api/saved-objects/export.asciidoc b/docs/api/saved-objects/export.asciidoc index 1b4f50dda2ddb5..e8c762b9543a18 100644 --- a/docs/api/saved-objects/export.asciidoc +++ b/docs/api/saved-objects/export.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve sets of saved objects that you want to import into {kib} [[saved-objects-api-export-request]] ==== Request -`POST /api/saved_objects/_export` +`POST :/api/saved_objects/_export` -`POST /s//api/saved_objects/_export` +`POST :/s//api/saved_objects/_export` [[saved-objects-api-export-path-params]] ==== Path parameters @@ -39,7 +39,7 @@ TIP: You must include `type` or `objects` in the request body. [[saved-objects-api-export-request-response-body]] ==== Response body -The format of the response body is newline delimited JSON. Each exported object is exported as a valid JSON record and separated by the newline character '\n'. +The format of the response body is newline delimited JSON. Each exported object is exported as a valid JSON record and separated by the newline character '\n'. When `excludeExportDetails=false` (the default) we append an export result details record at the end of the file after all the saved object records. The export result details object has the following format: @@ -66,9 +66,9 @@ When `excludeExportDetails=false` (the default) we append an export result detai Export all index pattern saved objects: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "type": "index-pattern" } @@ -77,9 +77,9 @@ POST api/saved_objects/_export Export all index pattern saved objects and exclude the export summary from the stream: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "type": "index-pattern", "excludeExportDetails": true @@ -89,9 +89,9 @@ POST api/saved_objects/_export Export a specific saved object: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "objects": [ { @@ -105,9 +105,9 @@ POST api/saved_objects/_export Export a specific saved object and it's related objects : -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "objects": [ { diff --git a/docs/api/saved-objects/find.asciidoc b/docs/api/saved-objects/find.asciidoc index 955c50922fde76..93e60be5d49239 100644 --- a/docs/api/saved-objects/find.asciidoc +++ b/docs/api/saved-objects/find.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit [[saved-objects-api-find-request]] ==== Request -`GET /api/saved_objects/_find` +`GET :/api/saved_objects/_find` -`GET /s//api/saved_objects/_find` +`GET :/s//api/saved_objects/_find` [[saved-objects-api-find-path-params]] ==== Path parameters @@ -67,15 +67,15 @@ change. Use the find API for traditional paginated results, but avoid using it t Find index patterns with titles that start with `my`: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/_find?type=index-pattern&search_fields=title&search=my* +$ curl -X GET "localhost:5601/api/saved_objects/_find?type=index-pattern&search_fields=title&search=my*" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "total": 1, @@ -95,8 +95,8 @@ The API returns the following: For parameters that accept multiple values (e.g. `fields`), repeat the query parameter for each value: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/_find?fields=id&fields=title +$ curl -X GET "localhost:5601/api/saved_objects/_find?fields=id&fields=title" -------------------------------------------------- // KIBANA diff --git a/docs/api/saved-objects/get.asciidoc b/docs/api/saved-objects/get.asciidoc index 29f8ef67e0a833..86b86795b534f1 100644 --- a/docs/api/saved-objects/get.asciidoc +++ b/docs/api/saved-objects/get.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve a single {kib} saved object by ID. [[saved-objects-api-get-request]] ==== Request -`GET /api/saved_objects//` +`GET :/api/saved_objects//` -`GET /s//api/saved_objects//` +`GET :/s//api/saved_objects//` [[saved-objects-api-get-params]] ==== Path parameters @@ -37,15 +37,15 @@ experimental[] Retrieve a single {kib} saved object by ID. Retrieve the index pattern object with the `my-pattern` ID: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/index-pattern/my-pattern +$ curl -X GET "localhost:5601/api/saved_objects/index-pattern/my-pattern" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", @@ -57,17 +57,17 @@ The API returns the following: } -------------------------------------------------- -The following example retrieves a dashboard object in the `testspace` by id. +Retrieve a dashboard object in the `testspace` by ID: -[source,js] +[source,sh] -------------------------------------------------- -GET /s/testspace/api/saved_objects/dashboard/7adfa750-4c81-11e8-b3d7-01146121b73d +$ curl -X GET "localhost:5601/s/testspace/api/saved_objects/dashboard/7adfa750-4c81-11e8-b3d7-01146121b73d" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "7adfa750-4c81-11e8-b3d7-01146121b73d", diff --git a/docs/api/saved-objects/import.asciidoc b/docs/api/saved-objects/import.asciidoc index 1a380830ed21a6..b3e4c48696a176 100644 --- a/docs/api/saved-objects/import.asciidoc +++ b/docs/api/saved-objects/import.asciidoc @@ -9,9 +9,9 @@ experimental[] Create sets of {kib} saved objects from a file created by the exp [[saved-objects-api-import-request]] ==== Request -`POST /api/saved_objects/_import` +`POST :/api/saved_objects/_import` -`POST /s//api/saved_objects/_import` +`POST :/s//api/saved_objects/_import` [[saved-objects-api-import-path-params]] ==== Path parameters @@ -55,14 +55,15 @@ The request body must include the multipart/form-data type. Import an index pattern and dashboard: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -70,7 +71,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -80,14 +81,15 @@ The API returns the following: Import an index pattern and dashboard that includes a conflict on the index pattern: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -95,7 +97,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": false, @@ -115,14 +117,15 @@ The API returns the following: Import a visualization and dashboard with an index pattern for the visualization reference that doesn't exist: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"visualization","id":"my-vis","attributes":{"title":"my-vis"},"references":[{"name":"ref_0","type":"index-pattern","id":"my-pattern-*"}]} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"},"references":[{"name":"ref_0","type":"visualization","id":"my-vis"}]} @@ -130,7 +133,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- "success": false, "successCount": 0, diff --git a/docs/api/saved-objects/resolve_import_errors.asciidoc b/docs/api/saved-objects/resolve_import_errors.asciidoc index b64e5deb361b20..ec03917390d36d 100644 --- a/docs/api/saved-objects/resolve_import_errors.asciidoc +++ b/docs/api/saved-objects/resolve_import_errors.asciidoc @@ -17,9 +17,9 @@ To resolve errors, you can: [[saved-objects-api-resolve-import-errors-request]] ==== Request -`POST /api/saved_objects/_resolve_import_errors` +`POST :/api/saved_objects/_resolve_import_errors` -`POST /s//api/saved_objects/_resolve_import_errors` +`POST :/s//api/saved_objects/_resolve_import_errors` [[saved-objects-api-resolve-import-errors-path-params]] ==== Path parameters @@ -61,21 +61,22 @@ The request body must include the multipart/form-data type. Retry a dashboard import: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard"}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} -------------------------------------------------- The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -85,14 +86,15 @@ The API returns the following: Resolve errors for a dashboard and overwrite the existing saved object: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard","overwrite":true}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -100,7 +102,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -110,21 +112,22 @@ The API returns the following: Resolve errors for a visualization by replacing the index pattern with another: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"visualization","id":"my-vis","replaceReferences":[{"type":"index-pattern","from":"missing","to":"existing"}]}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"visualization","id":"my-vis","attributes":{"title":"Look at my visualization"},"references":[{"name":"ref_0","type":"index-pattern","id":"missing"}]} -------------------------------------------------- The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, diff --git a/docs/api/saved-objects/update.asciidoc b/docs/api/saved-objects/update.asciidoc index 99a9bd4ad15bbd..62f4104debc777 100644 --- a/docs/api/saved-objects/update.asciidoc +++ b/docs/api/saved-objects/update.asciidoc @@ -9,9 +9,9 @@ experimental[] Update the attributes for existing {kib} saved objects. [[saved-objects-api-update-request]] ==== Request -`PUT /api/saved_objects//` +`PUT :/api/saved_objects//` -`PUT /s//api/saved_objects//` +`PUT :/s//api/saved_objects//` [[saved-objects-api-update-path-params]] ==== Path parameters @@ -47,9 +47,9 @@ WARNING: When you update, attributes are not validated, which allows you to pass Update an existing index pattern object,`my-pattern`, with a different title: -[source,js] +[source,sh] -------------------------------------------------- -PUT api/saved_objects/index-pattern/my-pattern +$ curl -X PUT "localhost:5601/api/saved_objects/index-pattern/my-pattern" { "attributes": { "title": "some-other-pattern-*" @@ -60,7 +60,7 @@ PUT api/saved_objects/index-pattern/my-pattern The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", diff --git a/docs/api/spaces-management/copy_saved_objects.asciidoc b/docs/api/spaces-management/copy_saved_objects.asciidoc index c07b5f35efe093..e23a137485b2d5 100644 --- a/docs/api/spaces-management/copy_saved_objects.asciidoc +++ b/docs/api/spaces-management/copy_saved_objects.asciidoc @@ -5,225 +5,75 @@ Copy saved objects to space ++++ -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -//// -Use the appropriate heading levels for your book. -Add anchors for each section. -FYI: The section titles use attributes in case those terms change. -//// - -[[spaces-api-copy-saved-objects-request]] -==== {api-request-title} -//// -This section show the basic endpoint, without the body or optional parameters. -Variables should use <...> syntax. -If an API supports both PUT and POST, include both here. -//// - -`POST /api/spaces/_copy_saved_objects` - -`POST /s//api/spaces/_copy_saved_objects` - - -//// -[[spaces-api-copy-saved-objects-prereqs]] -==== {api-prereq-title} -//// -//// -Optional list of prerequisites. - -For example: - -* A snapshot of an index created in 5.x can be restored to 6.x. You must... -* If the {es} {security-features} are enabled, you must have `write`, `monitor`, -and `manage_follow_index` index privileges... -//// - - -[[spaces-api-copy-saved-objects-desc]] -==== {api-description-title} - -Copy saved objects between spaces. +experimental[] Copy saved objects between spaces. It also allows you to automatically copy related objects, so when you copy a `dashboard`, this can automatically copy over the associated visualizations, index patterns, and saved searches, as required. -You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the +You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the <> to do this on a per-object basis. -//// -Add a more detailed description the context. -Link to related APIs if appropriate. +[[spaces-api-copy-saved-objects-request]] +==== {api-request-title} -Guidelines for parameter documentation -*************************************** -* Use a definition list. -* End each definition with a period. -* Include whether the parameter is Optional or Required and the data type. -* Include default values as the last sentence of the first paragraph. -* Include a range of valid values, if applicable. -* If the parameter requires a specific delimiter for multiple values, say so. -* If the parameter supports wildcards, ditto. -* For large or nested objects, consider linking to a separate definition list. -*************************************** -//// +`POST :/api/spaces/_copy_saved_objects` +`POST :/s//api/spaces/_copy_saved_objects` [[spaces-api-copy-saved-objects-path-params]] ==== {api-path-parms-title} -//// -A list of all the parameters within the path of the endpoint (before the query string (?)). -For example: -``:: -(Required, string) Name of the follower index -//// `space_id`:: -(Optional, string) Identifies the source space from which saved objects will be copied. If `space_id` is not specified in the URL, the default space is used. - -//// -[[spaces-api-copy-saved-objects-params]] -==== {api-query-parms-title} -//// -//// -A list of the parameters in the query string of the endpoint (after the ?). - -For example: -`wait_for_active_shards`:: -(Optional, integer) Specifies the number of shards to wait on being active before -responding. A shard must be restored from the leader index being active. -Restoring a follower shard requires transferring all the remote Lucene segment -files to the follower index. The default is `0`, which means waiting on none of -the shards to be active. -//// +(Optional, string) The ID of the space that contains the saved objects you want to copy. When `space_id` is unspecified in the URL, the default space is used. [[spaces-api-copy-saved-objects-request-body]] ==== {api-request-body-title} -//// -A list of the properties you can specify in the body of the request. -For example: -`remote_cluster`:: -(Required, string) The <> that contains -the leader index. +`spaces`:: + (Required, string array) The IDs of the spaces where you want to copy the specified objects. -`leader_index`:: -(Required, string) The name of the index in the leader cluster to follow. -//// -`spaces` :: - (Required, string array) The ids of the spaces the specified object(s) will be copied into. - -`objects` :: +`objects`:: (Required, object array) The saved objects to copy. - `type` ::: + `type`::: (Required, string) The saved object type. - `id` ::: - (Required, string) The saved object id. + `id`::: + (Required, string) The saved object ID. -`includeReferences` :: +`includeReferences`:: (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target spaces. The default value is `false`. -`overwrite` :: - (Optional, boolean) When set to `true`, all conflicts will be automatically overidden. If a saved object with a matching `type` and `id` exists in the target space, then that version will be replaced with the version from the source space. The default value is `false`. +`overwrite`:: + (Optional, boolean) When set to `true`, all conflicts are automatically overidden. When a saved object with a matching `type` and `id` exists in the target space, that version is replaced with the version from the source space. The default value is `false`. [[spaces-api-copy-saved-objects-response-body]] ==== {api-response-body-title} -//// -Response body is only required for detailed responses. - -For example: -`auto_follow_stats`:: - (object) An object representing stats for the auto-follow coordinator. This - object consists of the following fields: - -`auto_follow_stats.number_of_successful_follow_indices`::: - (long) the number of indices that the auto-follow coordinator successfully - followed -... - -//// ``:: - (object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space. + (object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response. `success`::: - (boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to `false`. Consult the `successCount` and `errors` properties of the response for additional information. + (boolean) The copy operation was successful. When set to `false`, some objects may have been copied. For additional information, refer to the `successCount` and `errors` properties. `successCount`::: - (number) The number of objects that were successfully copied. + (number) The number of objects that successfully copied. `errors`::: - (Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the `success` flag will be set to `false`. + (Optional, array) The errors that occurred during the copy operation. When errors are reported, the `success` flag is set to `false`.v `id`:::: - (string) The saved object id which failed to copy. + (string) The saved object ID that failed to copy. `type`:::: - (string) The type of saved object which failed to copy. + (string) The type of saved object that failed to copy. `error`:::: - (object) The error which caused the copy operation to fail. + (object) The error that caused the copy operation to fail. `type`::::: - (string) Indicates the type of error. May be one of: `conflict`, `unsupported_type`, `missing_references`, `unknown`. Errors marked as `conflict` may be resolved by using the <>. - -//// -[[spaces-api-copy-saved-objects-response-codes]] -==== {api-response-codes-title} -//// -//// -Response codes are only required when needed to understand the response body. - -For example: -`200`:: -Indicates all listed indices or index aliases exist. - - `404`:: -Indicates one or more listed indices or index aliases **do not** exist. -//// - + (string) The type of error. For example, `unsupported_type`, `missing_references`, or `unknown`. Errors marked as `conflict` may be resolved by using the <>. [[spaces-api-copy-saved-objects-example]] ==== {api-examples-title} -//// -Optional brief example. -Use an 'Examples' heading if you include multiple examples. +Copy a dashboard with the `my-dashboard` ID, including all references from the `default` space to the `marketing` and `sales` spaces: -[source,js] +[source,sh] ---- -PUT /follower_index/_ccr/follow?wait_for_active_shards=1 -{ - "remote_cluster" : "remote_cluster", - "leader_index" : "leader_index", - "max_read_request_operation_count" : 1024, - "max_outstanding_read_requests" : 16, - "max_read_request_size" : "1024k", - "max_write_request_operation_count" : 32768, - "max_write_request_size" : "16k", - "max_outstanding_write_requests" : 8, - "max_write_buffer_count" : 512, - "max_write_buffer_size" : "512k", - "max_retry_delay" : "10s", - "read_poll_timeout" : "30s" -} ----- -// CONSOLE -// TEST[setup:remote_cluster_and_leader_index] - -The API returns the following result: - -[source,js] ----- -{ - "follow_index_created" : true, - "follow_index_shards_acked" : true, - "index_following_started" : true -} ----- -// TESTRESPONSE -//// - -The following example attempts to copy a dashboard with id `my-dashboard`, including all references from the `default` space to the `marketing` and `sales` spaces. The `marketing` space succeeds, while the `sales` space fails due to a conflict on the underlying index pattern: - -[source,js] ----- -POST /api/spaces/_copy_saved_objects +$ curl -X POST "localhost:5601/api/spaces/_copy_saved_objects" { "objects": [{ "type": "dashboard", @@ -235,9 +85,9 @@ POST /api/spaces/_copy_saved_objects ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "marketing": { @@ -258,11 +108,13 @@ The API returns the following result: } ---- -The following example successfully copies a visualization with id `my-viz` from the `marketing` space to the `default` space: +The `marketing` space succeeds, but the `sales` space fails due to a conflict in the index pattern. + +Copy a visualization with the `my-viz` ID from the `marketing` space to the `default` space: -[source,js] +[source,sh] ---- -POST /s/marketing/api/spaces/_copy_saved_objects +$ curl -X POST "localhost:5601/s/marketing/api/spaces/_copy_saved_objects" { "objects": [{ "type": "visualization", @@ -273,9 +125,9 @@ POST /s/marketing/api/spaces/_copy_saved_objects ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "default": { diff --git a/docs/api/spaces-management/delete.asciidoc b/docs/api/spaces-management/delete.asciidoc index c66307ea3070f4..5b4db78c056dd3 100644 --- a/docs/api/spaces-management/delete.asciidoc +++ b/docs/api/spaces-management/delete.asciidoc @@ -4,22 +4,20 @@ Delete space ++++ -Delete a {kib} space. +experimental[] Delete a {kib} space. -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -WARNING: When you delete a space, all saved objects that belong to the space are automatically deleted, which is permanent and cannot be undone. +WARNING: When you delete a space, all saved objects that belong to the space are automatically deleted, which is permanent and cannot be undone. [[spaces-api-delete-request]] ==== Request -`DELETE /api/spaces/space/marketing` +`DELETE :/api/spaces/space/marketing` [[spaces-api-delete-errors-codes]] ==== Response codes -`204`:: +`204`:: Indicates a successful call. - + `404`:: Indicates that the request failed. diff --git a/docs/api/spaces-management/get.asciidoc b/docs/api/spaces-management/get.asciidoc index 49119d7602b201..48245b77866040 100644 --- a/docs/api/spaces-management/get.asciidoc +++ b/docs/api/spaces-management/get.asciidoc @@ -4,14 +4,12 @@ Get space ++++ -Retrieve a specified {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Retrieve a specified {kib} space. [[spaces-api-get-request]] ==== Request -`GET /api/spaces/space/marketing` +`GET :/api/spaces/space/marketing` [[spaces-api-get-response-codes]] ==== Response code @@ -24,7 +22,7 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "marketing", @@ -35,4 +33,4 @@ The API returns the following: "disabledFeatures": [], "imageUrl": "" } --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/spaces-management/get_all.asciidoc b/docs/api/spaces-management/get_all.asciidoc index f7fb92baa165f2..8f7ba86f332de3 100644 --- a/docs/api/spaces-management/get_all.asciidoc +++ b/docs/api/spaces-management/get_all.asciidoc @@ -4,14 +4,12 @@ Get all spaces ++++ -Retrieve all {kib} spaces. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Retrieve all {kib} spaces. [[spaces-api-get-all-request]] ==== Request -`GET /api/spaces/space` +`GET :/api/spaces/space` [[spaces-api-get-all-response-codes]] ==== Response code @@ -24,7 +22,7 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- [ { diff --git a/docs/api/spaces-management/post.asciidoc b/docs/api/spaces-management/post.asciidoc index 4d4627e98899ee..b96fbe6364c34e 100644 --- a/docs/api/spaces-management/post.asciidoc +++ b/docs/api/spaces-management/post.asciidoc @@ -4,14 +4,12 @@ Create space ++++ -Create a {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Create a {kib} space. [[spaces-api-post-request]] ==== Request -`POST /api/spaces/space` +`POST :/api/spaces/space` [[spaces-api-post-request-body]] ==== Request body @@ -29,13 +27,13 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi (Optional, string array) The list of disabled features for the space. To get a list of available feature IDs, use the <>. `initials`:: - (Optional, string) Specifies the initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. + (Optional, string) The initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. `color`:: - (Optional, string) Specifies the hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. + (Optional, string) The hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. `imageUrl`:: - (Optional, string) Specifies the data-url encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. + (Optional, string) The data-URL encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. For best results, your image should be 64x64. Images will not be optimized by this API call, so care should be taken when using custom images. [[spaces-api-post-response-codes]] @@ -47,9 +45,9 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi [[spaces-api-post-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST /api/spaces/space +$ curl -X POST "localhost:5601/api/spaces/space" { "id": "marketing", "name": "Marketing", diff --git a/docs/api/spaces-management/put.asciidoc b/docs/api/spaces-management/put.asciidoc index 586818707c76f7..f405d57975a702 100644 --- a/docs/api/spaces-management/put.asciidoc +++ b/docs/api/spaces-management/put.asciidoc @@ -4,37 +4,35 @@ Update space ++++ -Update an existing {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Update an existing {kib} space. [[spaces-api-put-api-request]] ==== Request -`PUT /api/spaces/space/` +`PUT :/api/spaces/space/` [[spaces-api-put-request-body]] ==== Request body -`id`:: +`id`:: (Required, string) The space ID that is part of the {kib} URL when inside the space. You are unable to change the ID with the update operation. -`name`:: +`name`:: (Required, string) The display name for the space. -`description`:: +`description`:: (Optional, string) The description for the space. -`disabledFeatures`:: +`disabledFeatures`:: (Optional, string array) The list of disabled features for the space. To get a list of available feature IDs, use the <>. -`initials`:: +`initials`:: (Optional, string) Specifies the initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. -`color`:: +`color`:: (Optional, string) Specifies the hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. -`imageUrl`:: +`imageUrl`:: (Optional, string) Specifies the data-url encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. For best results, your image should be 64x64. Images will not be optimized by this API call, so care should be taken when using custom images. @@ -43,13 +41,13 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi `200`:: Indicates a successful call. - + [[sample-api-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/spaces/space/marketing +$ curl -X PUT "localhost:5601/api/spaces/space/marketing" { "id": "marketing", "name": "Marketing", diff --git a/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc b/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc index 7b52125599c052..8e874bb9f94e5d 100644 --- a/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc +++ b/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc @@ -5,227 +5,80 @@ Resolve copy to space conflicts ++++ -Overwrite specific saved objects that were returned as errors from the <>. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -//// -Use the appropriate heading levels for your book. -Add anchors for each section. -FYI: The section titles use attributes in case those terms change. -//// +experimental[] Overwrite saved objects that are returned as errors from the <>. [[spaces-api-resolve-copy-saved-objects-conflicts-request]] ==== {api-request-title} -//// -This section show the basic endpoint, without the body or optional parameters. -Variables should use <...> syntax. -If an API supports both PUT and POST, include both here. -//// - -`POST /api/spaces/_resolve_copy_saved_objects_errors` - -`POST /s//api/spaces/_resolve_copy_saved_objects_errors` +`POST :/api/spaces/_resolve_copy_saved_objects_errors` +`POST :/s//api/spaces/_resolve_copy_saved_objects_errors` [[spaces-api-resolve-copy-saved-objects-conflicts-prereqs]] ==== {api-prereq-title} -//// -Optional list of prerequisites. - -For example: - -* A snapshot of an index created in 5.x can be restored to 6.x. You must... -* If the {es} {security-features} are enabled, you must have `write`, `monitor`, -and `manage_follow_index` index privileges... -//// -* Executed the <>, which returned one or more `conflict` errors that you wish to resolve. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-desc]] -==== {api-description-title} - -Allows saved objects to be selectively overridden in the target spaces. -//// - -//// -Add a more detailed description the context. -Link to related APIs if appropriate. - -Guidelines for parameter documentation -*************************************** -* Use a definition list. -* End each definition with a period. -* Include whether the parameter is Optional or Required and the data type. -* Include default values as the last sentence of the first paragraph. -* Include a range of valid values, if applicable. -* If the parameter requires a specific delimiter for multiple values, say so. -* If the parameter supports wildcards, ditto. -* For large or nested objects, consider linking to a separate definition list. -*************************************** -//// +Execute the <>, which returns the errors for you to resolve. [[spaces-api-resolve-copy-saved-objects-conflicts-path-params]] ==== {api-path-parms-title} -//// -A list of all the parameters within the path of the endpoint (before the query string (?)). -For example: -``:: -(Required, string) Name of the follower index -//// `space_id`:: -(Optional, string) Identifies the source space from which saved objects will be copied. If `space_id` is not specified in the URL, the default space is used. Must be the same value that was used during the failed <> operation. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-request-params]] -==== {api-query-parms-title} -//// -//// -A list of the parameters in the query string of the endpoint (after the ?). - -For example: -`wait_for_active_shards`:: -(Optional, integer) Specifies the number of shards to wait on being active before -responding. A shard must be restored from the leader index being active. -Restoring a follower shard requires transferring all the remote Lucene segment -files to the follower index. The default is `0`, which means waiting on none of -the shards to be active. -//// +(Optional, string) The ID of the space that contains the saved objects you want to copy. When `space_id` is unspecified in the URL, the default space is used. The `space_id` must be the same value used during the failed <> operation. [[spaces-api-resolve-copy-saved-objects-conflicts-request-body]] ==== {api-request-body-title} -//// -A list of the properties you can specify in the body of the request. - -For example: -`remote_cluster`:: -(Required, string) The <> that contains -the leader index. -`leader_index`:: -(Required, string) The name of the index in the leader cluster to follow. -//// -`objects` :: - (Required, object array) The saved objects to copy. Must be the same value that was used during the failed <> operation. - `type` ::: +`objects`:: + (Required, object array) The saved objects to copy. The `objects` must be the same values used during the failed <> operation. + `type`::: (Required, string) The saved object type. - `id` ::: - (Required, string) The saved object id. + `id`::: + (Required, string) The saved object ID. -`includeReferences` :: - (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target spaces. You must set this to the same value that you used when executing the <>. The default value is `false`. +`includeReferences`:: + (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects are copied into the target spaces. The `includeReferences` must be the same values used during the failed <> operation. The default value is `false`. `retries`:: - (Required, object) The retry operations to attempt. Object keys represent the target space ids. - `` ::: - (Required, array) The the conflicts to resolve for the indicated ``. - `type` :::: + (Required, object) The retry operations to attempt. Object keys represent the target space IDs. + ``::: + (Required, array) The errors to resolve for the specified ``. + `type`:::: (Required, string) The saved object type. - `id` :::: - (Required, string) The saved object id. - `overwrite` :::: - (Required, boolean) when set to `true`, the saved object from the source space (desigated by the <>) will overwrite the the conflicting object in the destination space. When `false`, this does nothing. + `id`:::: + (Required, string) The saved object ID. + `overwrite`:::: + (Required, boolean) When set to `true`, the saved object from the source space (desigated by the <>) overwrites the conflicting object in the destination space. When set to `false`, this does nothing. [[spaces-api-resolve-copy-saved-objects-conflicts-response-body]] ==== {api-response-body-title} -//// -Response body is only required for detailed responses. - -For example: -`auto_follow_stats`:: - (object) An object representing stats for the auto-follow coordinator. This - object consists of the following fields: - -`auto_follow_stats.number_of_successful_follow_indices`::: - (long) the number of indices that the auto-follow coordinator successfully - followed -... - -//// ``:: - (object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space. + (object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response. `success`::: - (boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to `false`. Consult the `successCount` and `errors` properties of the response for additional information. + (boolean) The copy operation was successful. When set to `false`, some objects may have been copied. For additional information, refer to the `successCount` and `errors` properties. `successCount`::: - (number) The number of objects that were successfully copied. + (number) The number of objects that successfully copied. `errors`::: - (Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the `success` flag will be set to `false`. + (Optional, array) The errors that occurred during the copy operation. When errors are reported, the `success` flag is set to `false`. `id`:::: - (string) The saved object id which failed to copy. + (string) The saved object ID that failed to copy. `type`:::: - (string) The type of saved object which failed to copy. + (string) The type of saved object that failed to copy. `error`:::: - (object) The error which caused the copy operation to fail. + (object) The error that caused the copy operation to fail. `type`::::: - (string) Indicates the type of error. May be one of: `unsupported_type`, `missing_references`, `unknown`. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-response-codes]] -==== {api-response-codes-title} -//// -//// -Response codes are only required when needed to understand the response body. - -For example: -`200`:: -Indicates all listed indices or index aliases exist. - - `404`:: -Indicates one or more listed indices or index aliases **do not** exist. -//// + (string) The type of error. For example, `unsupported_type`, `missing_references`, or `unknown`. [[spaces-api-resolve-copy-saved-objects-conflicts-example]] ==== {api-examples-title} -//// -Optional brief example. -Use an 'Examples' heading if you include multiple examples. - - -[source,js] ----- -PUT /follower_index/_ccr/follow?wait_for_active_shards=1 -{ - "remote_cluster" : "remote_cluster", - "leader_index" : "leader_index", - "max_read_request_operation_count" : 1024, - "max_outstanding_read_requests" : 16, - "max_read_request_size" : "1024k", - "max_write_request_operation_count" : 32768, - "max_write_request_size" : "16k", - "max_outstanding_write_requests" : 8, - "max_write_buffer_count" : 512, - "max_write_buffer_size" : "512k", - "max_retry_delay" : "10s", - "read_poll_timeout" : "30s" -} ----- -// CONSOLE -// TEST[setup:remote_cluster_and_leader_index] - -The API returns the following result: - -[source,js] ----- -{ - "follow_index_created" : true, - "follow_index_shards_acked" : true, - "index_following_started" : true -} ----- -// TESTRESPONSE -//// -The following example overwrites an index pattern in the marketing space, and a visualization in the sales space. +Overwrite an index pattern in the `marketing` space, and a visualization in the `sales` space: -[source,js] +[source,sh] ---- -POST api/spaces/_resolve_copy_saved_objects_errors +$ curl -X POST "localhost:5601/api/spaces/_resolve_copy_saved_objects_errors" { "objects": [{ "type": "dashboard", @@ -248,9 +101,9 @@ POST api/spaces/_resolve_copy_saved_objects_errors ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "marketing": { diff --git a/docs/api/upgrade-assistant.asciidoc b/docs/api/upgrade-assistant.asciidoc index b524307c0f273e..15d87fbd0dc9d3 100644 --- a/docs/api/upgrade-assistant.asciidoc +++ b/docs/api/upgrade-assistant.asciidoc @@ -2,7 +2,7 @@ [[upgrade-assistant-api]] == Upgrade assistant APIs -Check the upgrade status of your Elasticsearch cluster and reindex indices that were created in the previous major version. The assistant helps you prepare for the next major version of Elasticsearch. +Check the upgrade status of your {es} cluster and reindex indices that were created in the previous major version. The assistant helps you prepare for the next major version of {es}. The following upgrade assistant APIs are available: @@ -10,11 +10,17 @@ The following upgrade assistant APIs are available: * <> to start a new reindex or resume a paused reindex +* <> to start or resume multiple reindex tasks + +* <> to check the current reindex batch queue + * <> to check the status of the reindex operation -* <> to cancel reindexes that are waiting for the Elasticsearch reindex task to complete +* <> to cancel reindexes that are waiting for the {es} reindex task to complete include::upgrade-assistant/status.asciidoc[] include::upgrade-assistant/reindexing.asciidoc[] +include::upgrade-assistant/batch_reindexing.asciidoc[] +include::upgrade-assistant/batch_queue.asciidoc[] include::upgrade-assistant/check_reindex_status.asciidoc[] include::upgrade-assistant/cancel_reindex.asciidoc[] diff --git a/docs/api/upgrade-assistant/batch_queue.asciidoc b/docs/api/upgrade-assistant/batch_queue.asciidoc new file mode 100644 index 00000000000000..dcb9b465e4ddc5 --- /dev/null +++ b/docs/api/upgrade-assistant/batch_queue.asciidoc @@ -0,0 +1,68 @@ +[[batch-reindex-queue]] +=== Batch reindex queue API +++++ +Batch reindex queue +++++ + +experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] + +Check the current reindex batch queue. + +[[batch-reindex-queue-request]] +==== Request + +`GET /api/upgrade_assistant/reindex/batch/queue` + +[[batch-reindex-queue-request-codes]] +==== Response code + +`200`:: + Indicates a successful call. + +[[batch-reindex-queue-example]] +==== Example + +The API returns the following: + +[source,js] +-------------------------------------------------- +{ + "queue": [ <1> + { + "indexName": "index1", + "newIndexName": "reindexed-v8-index2", + "status": 3, + "lastCompletedStep": 0, + "locked": null, + "reindexTaskId": null, + "reindexTaskPercComplete": null, + "errorMessage": null, + "runningReindexCount": null, + "reindexOptions": { + "queueSettings": { + "queuedAt": 1583406985489 + } + } + }, + { + "indexName": "index2", + "newIndexName": "reindexed-v8-index2", + "status": 3, + "lastCompletedStep": 0, + "locked": null, + "reindexTaskId": null, + "reindexTaskPercComplete": null, + "errorMessage": null, + "runningReindexCount": null, + "reindexOptions": { + "queueSettings": { + "queuedAt": 1583406987334 + } + } + } + ] +} +-------------------------------------------------- + +<1> Items in this array indicate reindex tasks at a given point in time and the order in which they will be executed. + diff --git a/docs/api/upgrade-assistant/batch_reindexing.asciidoc b/docs/api/upgrade-assistant/batch_reindexing.asciidoc new file mode 100644 index 00000000000000..40b6d9c816d5c3 --- /dev/null +++ b/docs/api/upgrade-assistant/batch_reindexing.asciidoc @@ -0,0 +1,81 @@ +[[batch-start-resume-reindex]] +=== Batch start or resume reindex API +++++ +Batch start or resume reindex +++++ + +experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] + +Start or resume multiple reindexing tasks in one request. Additionally, reindexing tasks started or resumed +via the batch endpoint will be placed on a queue and executed one-by-one, which ensures that minimal cluster resources +are consumed over time. + +[[batch-start-resume-reindex-request]] +==== Request + +`POST /api/upgrade_assistant/reindex/batch` + +[[batch-start-resume-reindex-request-body]] +==== Request body + +`indexNames`:: + (Required, array) The list of index names to be reindexed. + +[[batch-start-resume-reindex-codes]] +==== Response code + +`200`:: + Indicates a successful call. + +[[batch-start-resume-example]] +==== Example + +[source,js] +-------------------------------------------------- +POST /api/upgrade_assistant/reindex/batch +{ + "indexNames": [ <1> + "index1", + "index2" + ] +} +-------------------------------------------------- +<1> The order in which the indices are provided here determines the order in which the reindex tasks will be executed. + +Similar to the <>, the API returns the following: + +[source,js] +-------------------------------------------------- +{ + "enqueued": [ <1> + { + "indexName": "index1", + "newIndexName": "reindexed-v8-index1", + "status": 3, + "lastCompletedStep": 0, + "locked": null, + "reindexTaskId": null, + "reindexTaskPercComplete": null, + "errorMessage": null, + "runningReindexCount": null, + "reindexOptions": { <2> + "queueSettings": { + "queuedAt": 1583406985489 <3> + } + } + } + ], + "errors": [ <4> + { + "indexName": "index2", + "message": "Something went wrong!" + } + ] +} +-------------------------------------------------- + +<1> A list of reindex operations created, the order in the array indicates the order in which tasks will be executed. +<2> Presence of this key indicates that the reindex job will occur in the batch. +<3> A Unix timestamp of when the reindex task was placed in the queue. +<4> A list of errors that may have occurred preventing the reindex task from being created. + diff --git a/docs/api/upgrade-assistant/cancel_reindex.asciidoc b/docs/api/upgrade-assistant/cancel_reindex.asciidoc index 8951f235c9265f..04ab3bdde35fc8 100644 --- a/docs/api/upgrade-assistant/cancel_reindex.asciidoc +++ b/docs/api/upgrade-assistant/cancel_reindex.asciidoc @@ -4,14 +4,14 @@ Cancel reindex ++++ -Cancel reindexes that are waiting for the Elasticsearch reindex task to complete. For example, `lastCompletedStep` set to `40`. +experimental[] Cancel reindexes that are waiting for the {es} reindex task to complete. For example, `lastCompletedStep` set to `40`. -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +Cancel reindexes that are waiting for the Elasticsearch reindex task to complete. For example, `lastCompletedStep` set to `40`. [[cancel-reindex-request]] ==== Request -`POST /api/upgrade_assistant/reindex/myIndex/cancel` +`POST :/api/upgrade_assistant/reindex/myIndex/cancel` [[cancel-reindex-response-codes]] ==== Response codes @@ -24,7 +24,7 @@ experimental["The underlying Upgrade Assistant concepts are stable, but the APIs The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "acknowledged": true diff --git a/docs/api/upgrade-assistant/check_reindex_status.asciidoc b/docs/api/upgrade-assistant/check_reindex_status.asciidoc index cb4664baf96b29..00801f201d1e14 100644 --- a/docs/api/upgrade-assistant/check_reindex_status.asciidoc +++ b/docs/api/upgrade-assistant/check_reindex_status.asciidoc @@ -4,27 +4,27 @@ Check reindex status ++++ -Check the status of the reindex operation. +experimental[] Check the status of the reindex operation. -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +Check the status of the reindex operation. [[check-reindex-status-request]] ==== Request -`GET /api/upgrade_assistant/reindex/myIndex` +`GET :/api/upgrade_assistant/reindex/myIndex` [[check-reindex-status-response-codes]] ==== Response codes `200`:: Indicates a successful call. - + [[check-reindex-status-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "reindexOp": { @@ -53,59 +53,58 @@ The API returns the following: [[status-code]] ==== Status codes -`0`:: +`0`:: In progress -`1`:: +`1`:: Completed -`2`:: +`2`:: Failed - -`3`:: + +`3`:: Paused NOTE: If the {kib} node that started the reindex is shutdown or restarted, the reindex goes into a paused state after some time. To resume the reindex, you must submit a new POST request to the `/api/upgrade_assistant/reindex/` endpoint. -`4`:: +`4`:: Cancelled [[step-code]] ==== Step codes -`0`:: +`0`:: The reindex operation has been created in Kibana. - -`10`:: + +`10`:: The index group services stopped. Only applies to some system indices. - -`20`:: - The index is set to `readonly`. - -`30`:: + +`20`:: + The index is set to `readonly`. + +`30`:: The new destination index has been created. - -`40`:: + +`40`:: The reindex task in Elasticsearch has started. - -`50`:: + +`50`:: The reindex task in Elasticsearch has completed. - -`60`:: + +`60`:: Aliases were created to point to the new index, and the old index has been deleted. - -`70`:: + +`70`:: The index group services have resumed. Only applies to some system indices. [[warning-code]] ==== Warning codes -`0`:: +`0`:: Specifies to remove the `_all` meta field. - -`1`:: + +`1`:: Specifies to convert any coerced boolean values in the source document. For example, `yes`, `1`, and `off`. - -`2`:: - Specifies to convert documents to support Elastic Common Schema. Only applies to APM indices created in 6.x. +`2`:: + Specifies to convert documents to support Elastic Common Schema. Only applies to APM indices created in 6.x. diff --git a/docs/api/upgrade-assistant/reindexing.asciidoc b/docs/api/upgrade-assistant/reindexing.asciidoc index a6d5d9d0c16acc..ce5670822e5adc 100644 --- a/docs/api/upgrade-assistant/reindexing.asciidoc +++ b/docs/api/upgrade-assistant/reindexing.asciidoc @@ -4,14 +4,14 @@ Start or resume reindex ++++ -Start a new reindex or resume a paused reindex. +experimental[] Start a new reindex or resume a paused reindex. -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +Start a new reindex or resume a paused reindex. [[start-resume-reindex-request]] ==== Request -`POST /api/upgrade_assistant/reindex/myIndex` +`POST :/api/upgrade_assistant/reindex/myIndex` [[start-resume-reindex-codes]] ==== Response code @@ -24,7 +24,7 @@ experimental["The underlying Upgrade Assistant concepts are stable, but the APIs The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "indexName": ".ml-state", @@ -37,9 +37,9 @@ The API returns the following: } -------------------------------------------------- -<1> Name of the new index that is being created. -<2> Current status of the reindex. For details, see <>. -<3> Last successfully completed step of the reindex. For details, see <> table. -<4> Task ID of the reindex task in Elasticsearch. Only present if reindexing has started. -<5> Percentage of how far the reindexing task in Elasticsearch has progressed, in decimal from from 0 to 1. -<6> Error that caused the reindex to fail, if it failed. +<1> The name of the new index. +<2> The reindex status. For more information, refer to <>. +<3> The last successfully completed step of the reindex. For more information, refer to <>. +<4> The task ID of the reindex task in {es}. Appears when the reindexing starts. +<5> The progress of the reindexing task in {es}. Appears in decimal form, from 0 to 1. +<6> The error that caused the reindex to fail, if it failed. diff --git a/docs/api/upgrade-assistant/status.asciidoc b/docs/api/upgrade-assistant/status.asciidoc index 9ad77bcabff735..42030061c42892 100644 --- a/docs/api/upgrade-assistant/status.asciidoc +++ b/docs/api/upgrade-assistant/status.asciidoc @@ -4,14 +4,14 @@ Upgrade readiness status ++++ -Check the status of your cluster. +experimental[] Check the status of your cluster. -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +Check the status of your cluster. [[upgrade-assistant-api-status-request]] ==== Request -`GET /api/upgrade_assistant/status` +`GET :/api/upgrade_assistant/status` [[upgrade-assistant-api-status-response-codes]] ==== Response codes @@ -24,7 +24,7 @@ experimental["The underlying Upgrade Assistant concepts are stable, but the APIs The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "readyForUpgrade": false, diff --git a/docs/api/url-shortening.asciidoc b/docs/api/url-shortening.asciidoc index 8bc701a3d5d123..a62529e11a9baa 100644 --- a/docs/api/url-shortening.asciidoc +++ b/docs/api/url-shortening.asciidoc @@ -12,18 +12,18 @@ Short URLs are designed to make sharing {kib} URLs easier. [[url-shortening-api-request]] ==== Request -`POST /api/shorten_url` +`POST :/api/shorten_url` [[url-shortening-api-request-body]] ==== Request body `url`:: - (Required, string) The {kib} URL that you want to shorten, Relative to `/app/kibana`. + (Required, string) The {kib} URL that you want to shorten, relative to `/app/kibana`. [[url-shortening-api-response-body]] ==== Response body -urlId:: A top level property that contains the shortened URL token for the provided request body. +urlId:: A top-level property that contains the shortened URL token for the provided request body. [[url-shortening-api-codes]] ==== Response code @@ -31,21 +31,21 @@ urlId:: A top level property that contains the shortened URL token for the provi `200`:: Indicates a successful call. -[[url-shortening-api-example]] +[[url-shortening-api-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST api/shorten_url +$ curl -X POST "localhost:5601/api/shorten_url" { "url": "/app/kibana#/dashboard?_g=()&_a=(description:'',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),panels:!((embeddableConfig:(),gridData:(h:15,i:'1',w:24,x:0,y:0),id:'8f4d0c00-4c86-11e8-b3d7-01146121b73d',panelIndex:'1',type:visualization,version:'7.0.0-alpha1')),query:(language:lucene,query:''),timeRestore:!f,title:'New%20Dashboard',viewMode:edit)" } -------------------------------------------------- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "urlId": "f73b295ff92718b26bc94edac766d8e3" diff --git a/docs/api/using-api.asciidoc b/docs/api/using-api.asciidoc index 37c5315025dc41..aba65f2e921c28 100644 --- a/docs/api/using-api.asciidoc +++ b/docs/api/using-api.asciidoc @@ -33,6 +33,7 @@ For example, the following `curl` command exports a dashboard: -- curl -X POST -u $USER:$PASSWORD "localhost:5601/api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c" -- +// KIBANA [float] [[api-request-headers]] @@ -43,14 +44,14 @@ For all APIs, you must use a request header. The {kib} APIs support the `kbn-xsr `kbn-xsrf: true`:: By default, you must use `kbn-xsrf` for all API calls, except in the following scenarios: -* The API endpoint uses the `GET` or `HEAD` methods +* The API endpoint uses the `GET` or `HEAD` operations * The path is whitelisted using the <> setting * XSRF protections are disabled using the `server.xsrf.disableProtection` setting `Content-Type: application/json`:: - Applicable only when you send a payload in the API request. {kib} API requests and responses use JSON. Typically, if you include the `kbn-xsrf` header, you must also include the `Content-Type` header. + Applicable only when you send a payload in the API request. {kib} API requests and responses use JSON. Typically, if you include the `kbn-xsrf` header, you must also include the `Content-Type` header. Request header example: diff --git a/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md b/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md index cda64018c3f690..dc256e6f5bc067 100644 --- a/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md +++ b/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md @@ -4,12 +4,12 @@ ## ErrorToastOptions interface -Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. +Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. Signature: ```typescript -export interface ErrorToastOptions +export interface ErrorToastOptions extends ToastOptions ``` ## Properties diff --git a/docs/development/core/public/kibana-plugin-core-public.itoasts.md b/docs/development/core/public/kibana-plugin-core-public.itoasts.md index 305ed82ea5693d..e009c77fe23bcd 100644 --- a/docs/development/core/public/kibana-plugin-core-public.itoasts.md +++ b/docs/development/core/public/kibana-plugin-core-public.itoasts.md @@ -9,5 +9,5 @@ Methods for adding and removing global toast messages. See [ToastsApi](./kibana- Signature: ```typescript -export declare type IToasts = Pick; +export declare type IToasts = Pick; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.md b/docs/development/core/public/kibana-plugin-core-public.md index a9fbaa25ea150a..b8aa56eb2941b5 100644 --- a/docs/development/core/public/kibana-plugin-core-public.md +++ b/docs/development/core/public/kibana-plugin-core-public.md @@ -57,7 +57,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [CoreStart](./kibana-plugin-core-public.corestart.md) | Core services exposed to the Plugin start lifecycle | | [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) | | | [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) | | -| [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. | +| [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. | | [FatalErrorInfo](./kibana-plugin-core-public.fatalerrorinfo.md) | Represents the message and stack of a fatal Error | | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | | [HttpFetchOptions](./kibana-plugin-core-public.httpfetchoptions.md) | All options that may be used with a [HttpHandler](./kibana-plugin-core-public.httphandler.md). | @@ -115,6 +115,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SavedObjectsUpdateOptions](./kibana-plugin-core-public.savedobjectsupdateoptions.md) | | | [StringValidationRegex](./kibana-plugin-core-public.stringvalidationregex.md) | StringValidation with regex object | | [StringValidationRegexString](./kibana-plugin-core-public.stringvalidationregexstring.md) | StringValidation as regex string | +| [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. | | [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) | UiSettings parameters defined by the plugins. | | [UiSettingsState](./kibana-plugin-core-public.uisettingsstate.md) | | | [UserProvidedValues](./kibana-plugin-core-public.userprovidedvalues.md) | Describes the values explicitly set by user. | diff --git a/docs/development/core/public/kibana-plugin-core-public.toastoptions.md b/docs/development/core/public/kibana-plugin-core-public.toastoptions.md new file mode 100644 index 00000000000000..0d85c482c2288c --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastoptions.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastOptions](./kibana-plugin-core-public.toastoptions.md) + +## ToastOptions interface + +Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. + +Signature: + +```typescript +export interface ToastOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [toastLifeTimeMs](./kibana-plugin-core-public.toastoptions.toastlifetimems.md) | number | How long should the toast remain on screen. | + diff --git a/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md b/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md new file mode 100644 index 00000000000000..bb0e2f9afc83b9 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastOptions](./kibana-plugin-core-public.toastoptions.md) > [toastLifeTimeMs](./kibana-plugin-core-public.toastoptions.toastlifetimems.md) + +## ToastOptions.toastLifeTimeMs property + +How long should the toast remain on screen. + +Signature: + +```typescript +toastLifeTimeMs?: number; +``` diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md index e8cc9ff74e0c47..420100a1209ab9 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the danger color and alert icon. Signature: ```typescript -addDanger(toastOrTitle: ToastInput): Toast; +addDanger(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addDanger(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md new file mode 100644 index 00000000000000..76508d26b4ae98 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md @@ -0,0 +1,27 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastsApi](./kibana-plugin-core-public.toastsapi.md) > [addInfo](./kibana-plugin-core-public.toastsapi.addinfo.md) + +## ToastsApi.addInfo() method + +Adds a new toast pre-configured with the info color and info icon. + +Signature: + +```typescript +addInfo(toastOrTitle: ToastInput, options?: ToastOptions): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | + +Returns: + +`Toast` + +a [Toast](./kibana-plugin-core-public.toast.md) + diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md index 160cbd4bf6b29d..c79f48042514ae 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the success color and check icon. Signature: ```typescript -addSuccess(toastOrTitle: ToastInput): Toast; +addSuccess(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addSuccess(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md index 17f94cc5b45537..6154af148332da 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the warning color and help icon. Signature: ```typescript -addWarning(toastOrTitle: ToastInput): Toast; +addWarning(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addWarning(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md index 4aa240fba0061c..ca4c08989128aa 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md @@ -23,10 +23,11 @@ export declare class ToastsApi implements IToasts | Method | Modifiers | Description | | --- | --- | --- | | [add(toastOrTitle)](./kibana-plugin-core-public.toastsapi.add.md) | | Adds a new toast to current array of toast. | -| [addDanger(toastOrTitle)](./kibana-plugin-core-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | +| [addDanger(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | | [addError(error, options)](./kibana-plugin-core-public.toastsapi.adderror.md) | | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | -| [addSuccess(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | -| [addWarning(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | +| [addInfo(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addinfo.md) | | Adds a new toast pre-configured with the info color and info icon. | +| [addSuccess(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | +| [addWarning(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | | [get$()](./kibana-plugin-core-public.toastsapi.get_.md) | | Observable of the toast messages to show to the user. | | [remove(toastOrId)](./kibana-plugin-core-public.toastsapi.remove.md) | | Removes a toast from the current array of toasts if present. | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterbar.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterbar.md index 016adffd0d7f41..6d8862323792aa 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterbar.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.filterbar.md @@ -7,7 +7,7 @@ Signature: ```typescript -FilterBar: React.ComponentClass, any> & { +FilterBar: React.ComponentClass, any> & { WrappedComponent: React.ComponentType; } ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md index 58690300b3bd62..d0d4cc491e1428 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md @@ -7,5 +7,5 @@ Signature: ```typescript -QueryStringInput: React.FC> +QueryStringInput: React.FC> ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md index 5cdf938a9e47f7..a0b879673e553c 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md @@ -7,7 +7,7 @@ Signature: ```typescript -SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "onQueryChange" | "customSubmitButton" | "screenTitle" | "dataTestSubj" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "refreshInterval" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "indexPatterns" | "refreshInterval" | "screenTitle" | "dataTestSubj" | "customSubmitButton" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; } ``` diff --git a/examples/alerting_example/public/components/view_alert.tsx b/examples/alerting_example/public/components/view_alert.tsx index c1b65eb92edc59..e418ed91096eb9 100644 --- a/examples/alerting_example/public/components/view_alert.tsx +++ b/examples/alerting_example/public/components/view_alert.tsx @@ -32,7 +32,11 @@ import { import { withRouter, RouteComponentProps } from 'react-router-dom'; import { CoreStart } from 'kibana/public'; import { isEmpty } from 'lodash'; -import { Alert, AlertTaskState } from '../../../../x-pack/plugins/alerting/common'; +import { + Alert, + AlertTaskState, + BASE_ALERT_API_PATH, +} from '../../../../x-pack/plugins/alerting/common'; import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants'; type Props = RouteComponentProps & { @@ -45,10 +49,10 @@ export const ViewAlertPage = withRouter(({ http, id }: Props) => { useEffect(() => { if (!alert) { - http.get(`/api/alert/${id}`).then(setAlert); + http.get(`${BASE_ALERT_API_PATH}/${id}`).then(setAlert); } if (!alertState) { - http.get(`/api/alert/${id}/state`).then(setAlertState); + http.get(`${BASE_ALERT_API_PATH}/${id}/state`).then(setAlertState); } }, [alert, alertState, http, id]); diff --git a/examples/alerting_example/public/components/view_astros_alert.tsx b/examples/alerting_example/public/components/view_astros_alert.tsx index db93d8f54924dc..296269180dd7b6 100644 --- a/examples/alerting_example/public/components/view_astros_alert.tsx +++ b/examples/alerting_example/public/components/view_astros_alert.tsx @@ -34,7 +34,11 @@ import { import { withRouter, RouteComponentProps } from 'react-router-dom'; import { CoreStart } from 'kibana/public'; import { isEmpty } from 'lodash'; -import { Alert, AlertTaskState } from '../../../../x-pack/plugins/alerting/common'; +import { + Alert, + AlertTaskState, + BASE_ALERT_API_PATH, +} from '../../../../x-pack/plugins/alerting/common'; import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants'; type Props = RouteComponentProps & { @@ -51,10 +55,10 @@ export const ViewPeopleInSpaceAlertPage = withRouter(({ http, id }: Props) => { useEffect(() => { if (!alert) { - http.get(`/api/alert/${id}`).then(setAlert); + http.get(`${BASE_ALERT_API_PATH}/${id}`).then(setAlert); } if (!alertState) { - http.get(`/api/alert/${id}/state`).then(setAlertState); + http.get(`${BASE_ALERT_API_PATH}/${id}/state`).then(setAlertState); } }, [alert, alertState, http, id]); diff --git a/package.json b/package.json index 70d064fa2a8eb7..3421bf938cd80d 100644 --- a/package.json +++ b/package.json @@ -118,10 +118,10 @@ "@babel/core": "^7.5.5", "@babel/register": "^7.7.0", "@elastic/apm-rum": "^4.6.0", - "@elastic/charts": "^17.1.1", + "@elastic/charts": "^18.1.0", "@elastic/datemath": "5.0.2", "@elastic/ems-client": "7.7.0", - "@elastic/eui": "20.0.2", + "@elastic/eui": "21.0.1", "@elastic/filesaver": "1.1.2", "@elastic/good": "8.1.1-kibana2", "@elastic/numeral": "2.4.0", diff --git a/packages/kbn-ui-shared-deps/package.json b/packages/kbn-ui-shared-deps/package.json index 65fd837ad17c23..1e9ceb42433f01 100644 --- a/packages/kbn-ui-shared-deps/package.json +++ b/packages/kbn-ui-shared-deps/package.json @@ -9,9 +9,9 @@ "kbn:watch": "node scripts/build --watch" }, "devDependencies": { - "@elastic/charts": "^17.1.1", + "@elastic/charts": "^18.1.0", "abortcontroller-polyfill": "^1.4.0", - "@elastic/eui": "20.0.2", + "@elastic/eui": "21.0.1", "@kbn/babel-preset": "1.0.0", "@kbn/dev-utils": "1.0.0", "@kbn/i18n": "1.0.0", diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 0ff044878afa9a..b91afa3ae7dc0c 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -168,6 +168,7 @@ export { ToastInputFields, ToastsSetup, ToastsStart, + ToastOptions, ErrorToastOptions, } from './notifications'; diff --git a/src/core/public/integrations/moment/moment_service.test.mocks.ts b/src/core/public/integrations/moment/moment_service.test.mocks.ts index 2fa013a6bf1321..bb13232157b785 100644 --- a/src/core/public/integrations/moment/moment_service.test.mocks.ts +++ b/src/core/public/integrations/moment/moment_service.test.mocks.ts @@ -21,6 +21,9 @@ export const momentMock = { locale: jest.fn(() => 'default-locale'), tz: { setDefault: jest.fn(), + zone: jest.fn( + z => [{ name: 'tz1' }, { name: 'tz2' }, { name: 'tz3' }].find(f => z === f.name) || null + ), }, weekdays: jest.fn(() => ['dow1', 'dow2', 'dow3']), updateLocale: jest.fn(), diff --git a/src/core/public/integrations/moment/moment_service.test.ts b/src/core/public/integrations/moment/moment_service.test.ts index c9b4479f2f1636..bc48ba2a85f635 100644 --- a/src/core/public/integrations/moment/moment_service.test.ts +++ b/src/core/public/integrations/moment/moment_service.test.ts @@ -47,6 +47,26 @@ describe('MomentService', () => { expect(momentMock.updateLocale).toHaveBeenCalledWith('default-locale', { week: { dow: 0 } }); }); + it('does not set unknkown zone', async () => { + const tz$ = new BehaviorSubject('timezone/undefined'); + const uiSettings = uiSettingsServiceMock.createSetupContract(); + uiSettings.get$.mockReturnValueOnce(tz$); + + service.start({ uiSettings }); + await flushPromises(); + expect(momentMock.tz.setDefault).not.toHaveBeenCalled(); + }); + + it('sets timezone when a zone is defined', async () => { + const tz$ = new BehaviorSubject('tz3'); + const uiSettings = uiSettingsServiceMock.createSetupContract(); + uiSettings.get$.mockReturnValueOnce(tz$); + + service.start({ uiSettings }); + await flushPromises(); + expect(momentMock.tz.setDefault).toHaveBeenCalledWith('tz3'); + }); + test('updates moment config', async () => { const tz$ = new BehaviorSubject('tz1'); const dow$ = new BehaviorSubject('dow1'); diff --git a/src/core/public/integrations/moment/moment_service.ts b/src/core/public/integrations/moment/moment_service.ts index 65f2bdea02933b..69cc29231d6e4b 100644 --- a/src/core/public/integrations/moment/moment_service.ts +++ b/src/core/public/integrations/moment/moment_service.ts @@ -35,7 +35,10 @@ export class MomentService implements CoreService { public async setup() {} public async start({ uiSettings }: StartDeps) { - const setDefaultTimezone = (tz: string) => moment.tz.setDefault(tz); + const setDefaultTimezone = (tz: string) => { + const zone = moment.tz.zone(tz); + if (zone) moment.tz.setDefault(zone.name); + }; const setStartDayOfWeek = (day: string) => { const dow = moment.weekdays().indexOf(day); moment.updateLocale(moment.locale(), { week: { dow } } as any); diff --git a/src/core/public/notifications/index.ts b/src/core/public/notifications/index.ts index 55b64ac375f087..1a5c2cee7ced60 100644 --- a/src/core/public/notifications/index.ts +++ b/src/core/public/notifications/index.ts @@ -19,6 +19,7 @@ export { ErrorToastOptions, + ToastOptions, Toast, ToastInput, IToasts, diff --git a/src/core/public/notifications/toasts/index.ts b/src/core/public/notifications/toasts/index.ts index 6e9de116833646..b259258b8a335b 100644 --- a/src/core/public/notifications/toasts/index.ts +++ b/src/core/public/notifications/toasts/index.ts @@ -20,6 +20,7 @@ export { ToastsService, ToastsSetup, ToastsStart } from './toasts_service'; export { ErrorToastOptions, + ToastOptions, ToastsApi, ToastInput, IToasts, diff --git a/src/core/public/notifications/toasts/toasts_api.test.ts b/src/core/public/notifications/toasts/toasts_api.test.ts index a0e419e9896578..7c0ef5576256a2 100644 --- a/src/core/public/notifications/toasts/toasts_api.test.ts +++ b/src/core/public/notifications/toasts/toasts_api.test.ts @@ -146,6 +146,21 @@ describe('#remove()', () => { }); }); +describe('#addInfo()', () => { + it('adds a info toast', async () => { + const toasts = new ToastsApi(toastDeps()); + expect(toasts.addInfo({})).toHaveProperty('color', 'primary'); + }); + + it('returns the created toast', async () => { + const toasts = new ToastsApi(toastDeps()); + const toast = toasts.addInfo({}, { toastLifeTimeMs: 1 }); + const currentToasts = await getCurrentToasts(toasts); + expect(currentToasts[0].toastLifeTimeMs).toBe(1); + expect(currentToasts[0]).toBe(toast); + }); +}); + describe('#addSuccess()', () => { it('adds a success toast', async () => { const toasts = new ToastsApi(toastDeps()); diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 8b1850ff9508f9..53717b9c2e1748 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -55,7 +55,18 @@ export type ToastInput = string | ToastInputFields; * Options available for {@link IToasts} APIs. * @public */ -export interface ErrorToastOptions { +export interface ToastOptions { + /** + * How long should the toast remain on screen. + */ + toastLifeTimeMs?: number; +} + +/** + * Options available for {@link IToasts} error APIs. + * @public + */ +export interface ErrorToastOptions extends ToastOptions { /** * The title of the toast and the dialog when expanding the message. */ @@ -84,7 +95,7 @@ const normalizeToast = (toastOrTitle: ToastInput): ToastInputFields => { */ export type IToasts = Pick< ToastsApi, - 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' + 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' | 'addInfo' >; /** @@ -145,17 +156,35 @@ export class ToastsApi implements IToasts { } } + /** + * Adds a new toast pre-configured with the info color and info icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} + * @returns a {@link Toast} + */ + public addInfo(toastOrTitle: ToastInput, options?: ToastOptions) { + return this.add({ + color: 'primary', + iconType: 'iInCircle', + ...normalizeToast(toastOrTitle), + ...options, + }); + } + /** * Adds a new toast pre-configured with the success color and check icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addSuccess(toastOrTitle: ToastInput) { + public addSuccess(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'success', iconType: 'check', ...normalizeToast(toastOrTitle), + ...options, }); } @@ -163,14 +192,16 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the warning color and help icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addWarning(toastOrTitle: ToastInput) { + public addWarning(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'warning', iconType: 'help', toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:warning'), ...normalizeToast(toastOrTitle), + ...options, }); } @@ -178,14 +209,16 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the danger color and alert icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addDanger(toastOrTitle: ToastInput) { + public addDanger(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'danger', iconType: 'alert', toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:warning'), ...normalizeToast(toastOrTitle), + ...options, }); } @@ -201,7 +234,6 @@ export class ToastsApi implements IToasts { return this.add({ color: 'danger', iconType: 'alert', - title: options.title, toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:error'), text: mountReactNode( this.i18n!.Context} /> ), + ...options, }); } diff --git a/src/core/public/notifications/toasts/toasts_service.mock.ts b/src/core/public/notifications/toasts/toasts_service.mock.ts index f44bd3253048db..2eb9cea7eb5c3d 100644 --- a/src/core/public/notifications/toasts/toasts_service.mock.ts +++ b/src/core/public/notifications/toasts/toasts_service.mock.ts @@ -25,6 +25,7 @@ const createToastsApiMock = () => { get$: jest.fn(() => new Observable()), add: jest.fn(), remove: jest.fn(), + addInfo: jest.fn(), addSuccess: jest.fn(), addWarning: jest.fn(), addDanger: jest.fn(), diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 7428280b2dccbb..37212a07ee6315 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -561,7 +561,7 @@ export interface EnvironmentMode { } // @public -export interface ErrorToastOptions { +export interface ErrorToastOptions extends ToastOptions { title: string; toastMessage?: string; } @@ -778,7 +778,7 @@ export interface ImageValidation { } // @public -export type IToasts = Pick; +export type IToasts = Pick; // @public export interface IUiSettingsClient { @@ -1270,16 +1270,22 @@ export type ToastInputFields = Pick; remove(toastOrId: Toast | string): void; // @internal (undocumented) diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 8078c32b10646f..a941735c7840e9 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -49,8 +49,6 @@ export default { '!packages/kbn-ui-framework/src/services/**/*/index.js', 'src/legacy/core_plugins/**/*.{js,jsx,ts,tsx}', '!src/legacy/core_plugins/**/{__test__,__snapshots__}/**/*', - 'src/legacy/ui/public/{agg_types,vis}/**/*.{ts,tsx}', - '!src/legacy/ui/public/{agg_types,vis}/**/*.d.ts', ], moduleNameMapper: { '@elastic/eui$': '/node_modules/@elastic/eui/test-env', diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index 3f81bfe5aadf26..55e1475fcb03a2 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -25,17 +25,9 @@ */ export { npSetup, npStart } from 'ui/new_platform'; - -export { KbnUrl } from 'ui/url/kbn_url'; -// @ts-ignore -export { KbnUrlProvider } from 'ui/url/index'; -export { IInjector } from 'ui/chrome'; export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url'; export { configureAppAngularModule, - IPrivate, migrateLegacyQuery, - PrivateProvider, - PromiseServiceCreator, subscribeWithScope, } from '../../../../../plugins/kibana_legacy/public'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts index 9447b5384d1721..877ccab99171d7 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts @@ -29,13 +29,7 @@ import { PluginInitializerContext, } from 'kibana/public'; import { Storage } from '../../../../../../plugins/kibana_utils/public'; -import { - configureAppAngularModule, - IPrivate, - KbnUrlProvider, - PrivateProvider, - PromiseServiceCreator, -} from '../legacy_imports'; +import { configureAppAngularModule } from '../legacy_imports'; // @ts-ignore import { initDashboardApp } from './legacy_app'; import { EmbeddableStart } from '../../../../../../plugins/embeddable/public'; @@ -116,10 +110,7 @@ function mountDashboardApp(appBasePath: string, element: HTMLElement) { function createLocalAngularModule(core: AppMountContext['core'], navigation: NavigationStart) { createLocalI18nModule(); - createLocalPrivateModule(); - createLocalPromiseModule(); createLocalConfigModule(core); - createLocalKbnUrlModule(); createLocalTopNavModule(navigation); createLocalIconModule(); @@ -127,10 +118,7 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav ...thirdPartyAngularDependencies, 'app/dashboard/Config', 'app/dashboard/I18n', - 'app/dashboard/Private', 'app/dashboard/TopNav', - 'app/dashboard/KbnUrl', - 'app/dashboard/Promise', 'app/dashboard/icon', ]); return dashboardAngularModule; @@ -142,14 +130,8 @@ function createLocalIconModule() { .directive('icon', reactDirective => reactDirective(EuiIcon)); } -function createLocalKbnUrlModule() { - angular - .module('app/dashboard/KbnUrl', ['app/dashboard/Private', 'ngRoute']) - .service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider)); -} - function createLocalConfigModule(core: AppMountContext['core']) { - angular.module('app/dashboard/Config', ['app/dashboard/Private']).provider('config', () => { + angular.module('app/dashboard/Config', []).provider('config', () => { return { $get: () => ({ get: core.uiSettings.get.bind(core.uiSettings), @@ -158,14 +140,6 @@ function createLocalConfigModule(core: AppMountContext['core']) { }); } -function createLocalPromiseModule() { - angular.module('app/dashboard/Promise', []).service('Promise', PromiseServiceCreator); -} - -function createLocalPrivateModule() { - angular.module('app/dashboard/Private', []).provider('Private', PrivateProvider); -} - function createLocalTopNavModule(navigation: NavigationStart) { angular .module('app/dashboard/TopNav', ['react']) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx index c0a0693431295b..4e9942767186e5 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx @@ -21,8 +21,6 @@ import moment from 'moment'; import { Subscription } from 'rxjs'; import { History } from 'history'; -import { IInjector } from '../legacy_imports'; - import { ViewMode } from '../../../../embeddable_api/public/np_ready/public'; import { SavedObjectDashboard } from '../saved_dashboard/saved_dashboard'; import { DashboardAppState, SavedDashboardPanel } from './types'; @@ -86,28 +84,26 @@ export interface DashboardAppScope extends ng.IScope { } export function initDashboardAppDirective(app: any, deps: RenderDeps) { - app.directive('dashboardApp', function($injector: IInjector) { - return { - restrict: 'E', - controllerAs: 'dashboardApp', - controller: ( - $scope: DashboardAppScope, - $route: any, - $routeParams: { - id?: string; - }, - kbnUrlStateStorage: IKbnUrlStateStorage, - history: History - ) => - new DashboardAppController({ - $route, - $scope, - $routeParams, - indexPatterns: deps.data.indexPatterns, - kbnUrlStateStorage, - history, - ...deps, - }), - }; - }); + app.directive('dashboardApp', () => ({ + restrict: 'E', + controllerAs: 'dashboardApp', + controller: ( + $scope: DashboardAppScope, + $route: any, + $routeParams: { + id?: string; + }, + kbnUrlStateStorage: IKbnUrlStateStorage, + history: History + ) => + new DashboardAppController({ + $route, + $scope, + $routeParams, + indexPatterns: deps.data.indexPatterns, + kbnUrlStateStorage, + history, + ...deps, + }), + })); } diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts index 60ea14dad19e17..08ccc1e0d1e89d 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts @@ -25,13 +25,6 @@ import { InputTimeRange, TimefilterContract, TimeRange } from 'src/plugins/data/ import { ViewMode } from 'src/plugins/embeddable/public'; import { createKbnUrlStateStorage } from 'src/plugins/kibana_utils/public'; -jest.mock('ui/agg_types', () => ({ - aggTypes: { - metrics: [], - buckets: [], - }, -})); - describe('DashboardState', function() { let dashboardState: DashboardStateManager; const savedDashboard = getSavedDashboardMock(); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js index 64abbdfb87d583..dbeaf8a98b461e 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js @@ -18,6 +18,7 @@ */ import { i18n } from '@kbn/i18n'; +import { parse } from 'query-string'; import dashboardTemplate from './dashboard_app.html'; import dashboardListingTemplate from './listing/dashboard_listing_ng_wrapper.html'; @@ -93,9 +94,8 @@ export function initDashboardApp(app, deps) { .when(DashboardConstants.LANDING_PAGE_PATH, { ...defaults, template: dashboardListingTemplate, - controller($injector, $location, $scope, kbnUrlStateStorage) { + controller($scope, kbnUrlStateStorage, history) { const service = deps.savedDashboards; - const kbnUrl = $injector.get('kbnUrl'); const dashboardConfig = deps.dashboardConfig; // syncs `_g` portion of url with query services @@ -106,13 +106,13 @@ export function initDashboardApp(app, deps) { $scope.listingLimit = deps.uiSettings.get('savedObjects:listingLimit'); $scope.create = () => { - kbnUrl.redirect(DashboardConstants.CREATE_NEW_DASHBOARD_URL); + history.push(DashboardConstants.CREATE_NEW_DASHBOARD_URL); }; $scope.find = search => { return service.find(search, $scope.listingLimit); }; $scope.editItem = ({ id }) => { - kbnUrl.redirect(`${createDashboardEditUrl(id)}?_a=(viewMode:edit)`); + history.push(`${createDashboardEditUrl(id)}?_a=(viewMode:edit)`); }; $scope.getViewUrl = ({ id }) => { return deps.addBasePath(`#${createDashboardEditUrl(id)}`); @@ -121,7 +121,7 @@ export function initDashboardApp(app, deps) { return service.delete(dashboards.map(d => d.id)); }; $scope.hideWriteControls = dashboardConfig.getHideWriteControls(); - $scope.initialFilter = $location.search().filter || EMPTY_FILTER; + $scope.initialFilter = parse(history.location.search).filter || EMPTY_FILTER; deps.chrome.setBreadcrumbs([ { text: i18n.translate('kbn.dashboard.dashboardBreadcrumbsTitle', { @@ -191,7 +191,7 @@ export function initDashboardApp(app, deps) { template: dashboardTemplate, controller: createNewDashboardCtrl, resolve: { - dash: function($route, kbnUrl, history) { + dash: function($route, history) { const id = $route.current.params.id; return ensureDefaultIndexPattern(deps.core, deps.data, history) @@ -208,7 +208,7 @@ export function initDashboardApp(app, deps) { // A corrupt dashboard was detected (e.g. with invalid JSON properties) if (error instanceof InvalidJSONProperty) { deps.core.notifications.toasts.addDanger(error.message); - kbnUrl.redirect(DashboardConstants.LANDING_PAGE_PATH); + history.push(DashboardConstants.LANDING_PAGE_PATH); return; } diff --git a/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js b/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js index f74e145865475d..47392c541890eb 100644 --- a/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js +++ b/src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js @@ -73,22 +73,7 @@ describe('discover field chooser directives', function() { beforeEach(() => pluginInstance.initializeServices()); beforeEach(() => pluginInstance.initializeInnerAngular()); - beforeEach( - ngMock.module('app/discover', $provide => { - $provide.decorator('config', $delegate => { - // disable shortDots for these tests - $delegate.get = _.wrap($delegate.get, function(origGet, name) { - if (name === 'shortDots:enable') { - return false; - } else { - return origGet.call(this, name); - } - }); - - return $delegate; - }); - }) - ); + beforeEach(ngMock.module('app/discover')); beforeEach( ngMock.inject(function(Private) { diff --git a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js index c19e033ccb72df..9b63b8cd18f3e9 100644 --- a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js +++ b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/rows_headers.js @@ -30,7 +30,6 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta describe('Doc Table', function() { let $parentScope; let $scope; - let config; // Stub out a minimal mapping of 4 fields let mapping; @@ -41,8 +40,7 @@ describe('Doc Table', function() { beforeEach(() => pluginInstance.initializeInnerAngular()); beforeEach(ngMock.module('app/discover')); beforeEach( - ngMock.inject(function(_config_, $rootScope, Private) { - config = _config_; + ngMock.inject(function($rootScope, Private) { $parentScope = $rootScope; $parentScope.indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); mapping = $parentScope.indexPattern.fields; @@ -144,12 +142,6 @@ describe('Doc Table', function() { filter: sinon.spy(), maxLength: 50, }); - - // Ignore the metaFields (_id, _type, etc) since we don't have a mapping for them - sinon - .stub(config, 'get') - .withArgs('metaFields') - .returns([]); }); afterEach(function() { destroy(); @@ -215,11 +207,6 @@ describe('Doc Table', function() { maxLength: 50, }); - sinon - .stub(config, 'get') - .withArgs('metaFields') - .returns(['_id']); - // Open the row $scope.toggleRow(); $scope.$digest(); diff --git a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts index 4d871bcb7a8585..031e10e99289f6 100644 --- a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts +++ b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts @@ -23,11 +23,7 @@ import angular from 'angular'; import { EuiIcon } from '@elastic/eui'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; -import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; -// @ts-ignore -import { StateManagementConfigProvider } from 'ui/state_management/config_provider'; -// @ts-ignore -import { KbnUrlProvider } from 'ui/url'; +import { CoreStart, LegacyCoreStart } from 'kibana/public'; import { DataPublicPluginStart } from '../../../../../plugins/data/public'; import { Storage } from '../../../../../plugins/kibana_utils/public'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; @@ -61,7 +57,6 @@ import { createRenderCompleteDirective } from './np_ready/angular/directives/ren import { initAngularBootstrap, configureAppAngularModule, - IPrivate, KbnAccessibleClickProvider, PrivateProvider, PromiseServiceCreator, @@ -108,8 +103,6 @@ export function initializeInnerAngularModule( createLocalI18nModule(); createLocalPrivateModule(); createLocalPromiseModule(); - createLocalConfigModule(core.uiSettings); - createLocalKbnUrlModule(); createLocalTopNavModule(navigation); createLocalStorageModule(); createElasticSearchModule(data); @@ -143,7 +136,6 @@ export function initializeInnerAngularModule( 'ngRoute', 'react', 'ui.bootstrap', - 'discoverConfig', 'discoverI18n', 'discoverPrivate', 'discoverPromise', @@ -170,27 +162,6 @@ export function initializeInnerAngularModule( .service('debounce', ['$timeout', DebounceProviderTimeout]); } -function createLocalKbnUrlModule() { - angular - .module('discoverKbnUrl', ['discoverPrivate', 'ngRoute']) - .service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider)); -} - -function createLocalConfigModule(uiSettings: IUiSettingsClient) { - angular - .module('discoverConfig', ['discoverPrivate']) - .provider('stateManagementConfig', StateManagementConfigProvider) - .provider('config', () => { - return { - $get: () => ({ - get: (value: string) => { - return uiSettings ? uiSettings.get(value) : undefined; - }, - }), - }; - }); -} - function createLocalPromiseModule() { angular.module('discoverPromise', []).service('Promise', PromiseServiceCreator); } @@ -229,7 +200,7 @@ const createLocalStorageService = function(type: string) { function createElasticSearchModule(data: DataPublicPluginStart) { angular - .module('discoverEs', ['discoverConfig']) + .module('discoverEs', []) // Elasticsearch client used for requesting data. Connects to the /elasticsearch proxy .service('es', () => { return data.search.__LEGACY.esClient; @@ -242,12 +213,7 @@ function createPagerFactoryModule() { function createDocTableModule() { angular - .module('discoverDocTable', [ - 'discoverKbnUrl', - 'discoverConfig', - 'discoverPagerFactory', - 'react', - ]) + .module('discoverDocTable', ['discoverPagerFactory', 'react']) .directive('docTable', createDocTableDirective) .directive('kbnTableHeader', createTableHeaderDirective) .directive('toolBarPagerText', createToolBarPagerTextDirective) 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 725e94f16e2e82..cf76a9355e384e 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -53,7 +53,6 @@ export { wrapInI18nContext } from 'ui/i18n'; import { search } from '../../../../../plugins/data/public'; export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search; // @ts-ignore -export { intervalOptions } from 'ui/agg_types'; // @ts-ignore export { timezoneProvider } from 'ui/vis/lib/timezone'; export { diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js index 038f783a0daf14..f8e764cbcbebb4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js @@ -66,7 +66,7 @@ getAngularModule().config($routeProvider => { }); }); -function ContextAppRouteController($routeParams, $scope, config, $route) { +function ContextAppRouteController($routeParams, $scope, $route) { const filterManager = getServices().filterManager; const indexPattern = $route.current.locals.indexPattern.ip; const { @@ -77,9 +77,9 @@ function ContextAppRouteController($routeParams, $scope, config, $route) { setFilters, setAppState, } = getState({ - defaultStepSize: config.get('context:defaultSize'), + defaultStepSize: getServices().uiSettings.get('context:defaultSize'), timeFieldName: indexPattern.timeFieldName, - storeInSessionStorage: config.get('state:storeInSessionStorage'), + storeInSessionStorage: getServices().uiSettings.get('state:storeInSessionStorage'), }); this.state = { ...appState.getState() }; this.anchorId = $routeParams.id; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js index 345717cafee9af..a6a1de695156d4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_app.js @@ -57,13 +57,13 @@ module.directive('contextApp', function ContextApp() { }; }); -function ContextAppController($scope, config, Private) { - const { filterManager, indexpatterns } = getServices(); +function ContextAppController($scope, Private) { + const { filterManager, indexpatterns, uiSettings } = getServices(); const queryParameterActions = getQueryParameterActions(filterManager, indexpatterns); const queryActions = Private(QueryActionsProvider); this.state = createInitialState( - parseInt(config.get('context:step'), 10), - getFirstSortableField(this.indexPattern, config.get('context:tieBreakerFields')), + parseInt(uiSettings.get('context:step'), 10), + getFirstSortableField(this.indexPattern, uiSettings.get('context:tieBreakerFields')), this.discoverUrl ); diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js index 4bc498928be52a..b020113381992a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name.js @@ -17,9 +17,9 @@ * under the License. */ import { FieldName } from './field_name/field_name'; -import { wrapInI18nContext } from '../../../kibana_services'; +import { getServices, wrapInI18nContext } from '../../../kibana_services'; -export function FieldNameDirectiveProvider(config, reactDirective) { +export function FieldNameDirectiveProvider(reactDirective) { return reactDirective( wrapInI18nContext(FieldName), [ @@ -29,7 +29,7 @@ export function FieldNameDirectiveProvider(config, reactDirective) { ], { restrict: 'AE' }, { - useShortDots: config.get('shortDots:enable'), + useShortDots: getServices().uiSettings.get('shortDots:enable'), } ); } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/histogram.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/histogram.tsx index 8db3c77ba0f472..107c30ec5e6883 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/histogram.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/histogram.tsx @@ -38,6 +38,7 @@ import { TooltipValue, TooltipType, ElementClickListener, + XYChartElementEvent, } from '@elastic/charts'; import { i18n } from '@kbn/i18n'; @@ -140,7 +141,7 @@ export class DiscoverHistogram extends Component ([elementData]) => { - const startRange = elementData[0].x; + const startRange = (elementData as XYChartElementEvent)[0].x; const range = { from: startRange, 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 9a383565f4f430..278317ec2e87bf 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 @@ -44,7 +44,6 @@ import { getRequestInspectorStats, getResponseInspectorStats, getServices, - intervalOptions, unhashUrl, subscribeWithScope, tabifyAggResponse, @@ -64,7 +63,7 @@ const { share, timefilter, toastNotifications, - uiSettings, + uiSettings: config, visualizations, } = getServices(); @@ -76,6 +75,7 @@ import { connectToQueryState, syncQueryStateWithUrl, getDefaultQuery, + search, } from '../../../../../../../plugins/data/public'; import { getIndexPatternId } from '../helpers/get_index_pattern_id'; import { addFatalError } from '../../../../../../../plugins/kibana_legacy/public'; @@ -131,7 +131,7 @@ app.config($routeProvider => { * * @type {State} */ - const id = getIndexPatternId(index, indexPatternList, uiSettings.get('defaultIndex')); + const id = getIndexPatternId(index, indexPatternList, config.get('defaultIndex')); return Promise.props({ list: indexPatternList, loaded: indexPatterns.get(id), @@ -184,8 +184,6 @@ function discoverController( $timeout, $window, Promise, - config, - kbnUrl, localStorage, uiCapabilities ) { @@ -256,6 +254,15 @@ function discoverController( } }); + // this listener is waiting for such a path http://localhost:5601/app/kibana#/discover + // which could be set through pressing "New" button in top nav or go to "Discover" plugin from the sidebar + // to reload the page in a right way + const unlistenHistoryBasePath = history.listen(({ pathname, search, hash }) => { + if (!search && !hash && pathname === '/discover') { + $route.reload(); + } + }); + $scope.setIndexPattern = async id => { await replaceUrlAppState({ index: id }); $route.reload(); @@ -286,7 +293,7 @@ function discoverController( mode: 'absolute', }); }; - $scope.intervalOptions = intervalOptions; + $scope.intervalOptions = search.aggs.intervalOptions; $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; @@ -311,6 +318,7 @@ function discoverController( stopStateSync(); stopSyncingGlobalStateWithUrl(); stopSyncingQueryAppStateWithStateContainer(); + unlistenHistoryBasePath(); }); const getTopNavLinks = () => { @@ -324,7 +332,7 @@ function discoverController( }), run: function() { $scope.$evalAsync(() => { - kbnUrl.change('/discover'); + history.push('/discover'); }); }, testId: 'discoverNewButton', @@ -392,9 +400,7 @@ function discoverController( testId: 'discoverOpenButton', run: () => { showOpenSearchPanel({ - makeUrl: searchId => { - return kbnUrl.eval('#/discover/{{id}}', { id: searchId }); - }, + makeUrl: searchId => `#/discover/${encodeURIComponent(searchId)}`, I18nContext: core.i18n.Context, }); }, @@ -752,7 +758,7 @@ function discoverController( }); if (savedSearch.id !== $route.current.params.id) { - kbnUrl.change('/discover/{{id}}', { id: savedSearch.id }); + history.push(`/discover/${encodeURIComponent(savedSearch.id)}`); } else { // Update defaults so that "reload saved query" functions correctly setAppState(getStateDefaults()); @@ -922,11 +928,11 @@ function discoverController( }; $scope.resetQuery = function() { - kbnUrl.change('/discover/{{id}}', { id: $route.current.params.id }); + history.push(`/discover/${encodeURIComponent($route.current.params.id)}`); }; $scope.newQuery = function() { - kbnUrl.change('/discover'); + history.push('/discover'); }; $scope.updateDataSource = () => { diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts index 32174984c1dfb4..84d865fd22a9a3 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header.ts @@ -16,11 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { IUiSettingsClient } from 'kibana/public'; import { TableHeader } from './table_header/table_header'; -import { wrapInI18nContext } from '../../../../kibana_services'; +import { wrapInI18nContext, getServices } from '../../../../kibana_services'; + +export function createTableHeaderDirective(reactDirective: any) { + const { uiSettings: config } = getServices(); -export function createTableHeaderDirective(reactDirective: any, config: IUiSettingsClient) { return reactDirective( wrapInI18nContext(TableHeader), [ diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts index 7a090d6b7820c4..698bfe7416d420 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_row.ts @@ -19,7 +19,6 @@ import _ from 'lodash'; import $ from 'jquery'; -import { IUiSettingsClient } from 'kibana/public'; // @ts-ignore import rison from 'rison-node'; import '../../doc_viewer'; @@ -42,12 +41,7 @@ interface LazyScope extends ng.IScope { [key: string]: any; } -export function createTableRowDirective( - $compile: ng.ICompileService, - $httpParamSerializer: any, - kbnUrl: any, - config: IUiSettingsClient -) { +export function createTableRowDirective($compile: ng.ICompileService, $httpParamSerializer: any) { const cellTemplate = _.template(noWhiteSpace(cellTemplateHtml)); const truncateByHeightTemplate = _.template(noWhiteSpace(truncateByHeightTemplateHtml)); @@ -112,10 +106,9 @@ export function createTableRowDirective( }; $scope.getContextAppHref = () => { - const path = kbnUrl.eval('#/discover/context/{{ indexPattern }}/{{ anchorId }}', { - anchorId: $scope.row._id, - indexPattern: $scope.indexPattern.id, - }); + const path = `#/discover/context/${encodeURIComponent( + $scope.indexPattern.id + )}/${encodeURIComponent($scope.row._id)}`; const globalFilters: any = getServices().filterManager.getGlobalFilters(); const appFilters: any = getServices().filterManager.getAppFilters(); const hash = $httpParamSerializer({ @@ -140,7 +133,7 @@ export function createTableRowDirective( const newHtmls = [openRowHtml]; const mapping = indexPattern.fields.getByName; - const hideTimeColumn = config.get('doc_table:hideTimeColumn'); + const hideTimeColumn = getServices().uiSettings.get('doc_table:hideTimeColumn'); if (indexPattern.timeFieldName && !hideTimeColumn) { newHtmls.push( cellTemplate({ diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts index 0ca8286c17081f..3cb3a460af6495 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts @@ -17,21 +17,17 @@ * under the License. */ -import { IUiSettingsClient } from 'kibana/public'; import html from './doc_table.html'; import { dispatchRenderComplete } from '../../../../../../../../plugins/kibana_utils/public'; // @ts-ignore import { getLimitedSearchResultsMessage } from './doc_table_strings'; +import { getServices } from '../../../kibana_services'; interface LazyScope extends ng.IScope { [key: string]: any; } -export function createDocTableDirective( - config: IUiSettingsClient, - pagerFactory: any, - $filter: any -) { +export function createDocTableDirective(pagerFactory: any, $filter: any) { return { restrict: 'E', template: html, @@ -68,7 +64,7 @@ export function createDocTableDirective( }; $scope.limitedResultsWarning = getLimitedSearchResultsMessage( - config.get('discover:sampleSize') + getServices().uiSettings.get('discover:sampleSize') ); $scope.addRows = function() { diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js index 4afaafd9bb1cf5..398728e51862ff 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/field_chooser/field_chooser.js @@ -29,8 +29,9 @@ import { KBN_FIELD_TYPES, } from '../../../../../../../../plugins/data/public'; import { getMapsAppUrl, isFieldVisualizable, isMapsAppRegistered } from './lib/visualize_url_utils'; +import { getServices } from '../../../kibana_services'; -export function createFieldChooserDirective($location, config) { +export function createFieldChooserDirective($location) { return { restrict: 'E', scope: { @@ -49,6 +50,7 @@ export function createFieldChooserDirective($location, config) { $scope.showFilter = false; $scope.toggleShowFilter = () => ($scope.showFilter = !$scope.showFilter); $scope.indexPatternList = _.sortBy($scope.indexPatternList, o => o.get('title')); + const config = getServices().uiSettings; const filter = ($scope.filter = { props: ['type', 'aggregatable', 'searchable', 'missing', 'name'], diff --git a/src/legacy/core_plugins/kibana/public/kibana.js b/src/legacy/core_plugins/kibana/public/kibana.js index 04eaf2cbe26790..df6b08ef765569 100644 --- a/src/legacy/core_plugins/kibana/public/kibana.js +++ b/src/legacy/core_plugins/kibana/public/kibana.js @@ -48,7 +48,6 @@ import './dashboard/legacy'; import './management'; import './dev_tools'; import 'ui/agg_response'; -import 'ui/agg_types'; import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/public'; import 'leaflet'; import { localApplicationService } from './local_application_service'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index e6b7a29e28d897..a2e2ba3543104d 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts @@ -24,8 +24,6 @@ * directly where they are needed. */ -// @ts-ignore -export { KbnUrlProvider } from 'ui/url'; export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url'; export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url'; export { wrapInI18nContext } from 'ui/i18n'; @@ -33,9 +31,6 @@ export { DashboardConstants } from '../dashboard/np_ready/dashboard_constants'; export { VisSavedObject, VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/'; export { configureAppAngularModule, - IPrivate, migrateLegacyQuery, - PrivateProvider, - PromiseServiceCreator, subscribeWithScope, } from '../../../../../plugins/kibana_legacy/public'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/application.ts b/src/legacy/core_plugins/kibana/public/visualize/np_ready/application.ts index c7c3286bb5c71a..241397884c8fe5 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/application.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/application.ts @@ -21,13 +21,7 @@ import angular, { IModule } from 'angular'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; import { AppMountContext } from 'kibana/public'; -import { - configureAppAngularModule, - KbnUrlProvider, - IPrivate, - PrivateProvider, - PromiseServiceCreator, -} from '../legacy_imports'; +import { configureAppAngularModule } from '../legacy_imports'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../../../plugins/navigation/public'; import { createTopNavDirective, @@ -82,36 +76,16 @@ function mountVisualizeApp(appBasePath: string, element: HTMLElement) { function createLocalAngularModule(core: AppMountContext['core'], navigation: NavigationStart) { createLocalI18nModule(); - createLocalPrivateModule(); - createLocalPromiseModule(); - createLocalKbnUrlModule(); createLocalTopNavModule(navigation); const visualizeAngularModule: IModule = angular.module(moduleName, [ ...thirdPartyAngularDependencies, 'app/visualize/I18n', - 'app/visualize/Private', 'app/visualize/TopNav', - 'app/visualize/KbnUrl', - 'app/visualize/Promise', ]); return visualizeAngularModule; } -function createLocalKbnUrlModule() { - angular - .module('app/visualize/KbnUrl', ['app/visualize/Private', 'ngRoute']) - .service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider)); -} - -function createLocalPromiseModule() { - angular.module('app/visualize/Promise', []).service('Promise', PromiseServiceCreator); -} - -function createLocalPrivateModule() { - angular.module('app/visualize/Private', []).provider('Private', PrivateProvider); -} - function createLocalTopNavModule(navigation: NavigationStart) { angular .module('app/visualize/TopNav', ['react']) diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index 1fab38027f65b4..7d1c29fbf48da8 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -30,7 +30,7 @@ import { VisualizeConstants } from '../visualize_constants'; import { getEditBreadcrumbs } from '../breadcrumbs'; import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util'; -import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public'; +import { unhashUrl, removeQueryParam } from '../../../../../../../plugins/kibana_utils/public'; import { MarkdownSimple, toMountPoint } from '../../../../../../../plugins/kibana_react/public'; import { addFatalError, kbnBaseUrl } from '../../../../../../../plugins/kibana_legacy/public'; import { @@ -69,16 +69,7 @@ export function initEditorDirective(app, deps) { initVisualizationDirective(app, deps); } -function VisualizeAppController( - $scope, - $route, - $window, - $injector, - $timeout, - kbnUrl, - kbnUrlStateStorage, - history -) { +function VisualizeAppController($scope, $route, $injector, $timeout, kbnUrlStateStorage, history) { const { indexPatterns, localStorage, @@ -421,7 +412,7 @@ function VisualizeAppController( const addToDashMode = $route.current.params[DashboardConstants.ADD_VISUALIZATION_TO_DASHBOARD_MODE_PARAM]; - kbnUrl.removeParam(DashboardConstants.ADD_VISUALIZATION_TO_DASHBOARD_MODE_PARAM); + removeQueryParam(history, DashboardConstants.ADD_VISUALIZATION_TO_DASHBOARD_MODE_PARAM); $scope.isAddToDashMode = () => addToDashMode; @@ -639,10 +630,10 @@ function VisualizeAppController( const savedVisualizationParsedUrl = new KibanaParsedUrl({ basePath: getBasePath(), appId: kbnBaseUrl.slice('/app/'.length), - appPath: kbnUrl.eval(`${VisualizeConstants.EDIT_PATH}/{{id}}`, { id: savedVis.id }), + appPath: `${VisualizeConstants.EDIT_PATH}/${encodeURIComponent(savedVis.id)}`, }); // Manually insert a new url so the back button will open the saved visualization. - $window.history.pushState({}, '', savedVisualizationParsedUrl.getRootRelativePath()); + history.replace(savedVisualizationParsedUrl.appPath); setActiveUrl(savedVisualizationParsedUrl.appPath); const lastDashboardAbsoluteUrl = chrome.navLinks.get('kibana:dashboard').url; @@ -658,7 +649,7 @@ function VisualizeAppController( DashboardConstants.ADD_EMBEDDABLE_ID, savedVis.id ); - kbnUrl.change(dashboardParsedUrl.appPath); + history.push(dashboardParsedUrl.appPath); } else if (savedVis.id === $route.current.params.id) { chrome.docTitle.change(savedVis.lastSavedTitle); chrome.setBreadcrumbs($injector.invoke(getEditBreadcrumbs)); diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/listing/visualize_listing.js index 5a479a491395ae..6c02afb672e4c5 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/listing/visualize_listing.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/listing/visualize_listing.js @@ -34,7 +34,7 @@ export function initListingDirective(app) { ); } -export function VisualizeListingController($injector, $scope, createNewVis, kbnUrlStateStorage) { +export function VisualizeListingController($scope, createNewVis, kbnUrlStateStorage, history) { const { addBasePath, chrome, @@ -46,7 +46,6 @@ export function VisualizeListingController($injector, $scope, createNewVis, kbnU visualizations, core: { docLinks, savedObjects }, } = getServices(); - const kbnUrl = $injector.get('kbnUrl'); // syncs `_g` portion of url with query services const { stop: stopSyncingQueryServiceStateWithUrl } = syncQueryStateWithUrl( @@ -83,7 +82,11 @@ export function VisualizeListingController($injector, $scope, createNewVis, kbnU this.closeNewVisModal = visualizations.showNewVisModal({ onClose: () => { // In case the user came via a URL to this page, change the URL to the regular landing page URL after closing the modal - kbnUrl.changePath(VisualizeConstants.LANDING_PAGE_PATH); + history.push({ + // Should preserve querystring part so the global state is preserved. + ...history.location, + pathname: VisualizeConstants.LANDING_PAGE_PATH, + }); }, }); } diff --git a/src/legacy/core_plugins/region_map/public/region_map_type.js b/src/legacy/core_plugins/region_map/public/region_map_type.js index a03fbe4b291e20..9a1a76362e094b 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_type.js +++ b/src/legacy/core_plugins/region_map/public/region_map_type.js @@ -18,12 +18,12 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { Schemas } from 'ui/agg_types'; import { mapToLayerWithId } from './util'; import { createRegionMapVisualization } from './region_map_visualization'; import { Status } from '../../visualizations/public'; import { RegionMapOptions } from './components/region_map_options'; import { truncatedColorSchemas } from '../../../../plugins/charts/public'; +import { Schemas } from '../../vis_default_editor/public'; // TODO: reference to TILE_MAP plugin should be removed import { ORIGIN } from '../../tile_map/common/origin'; diff --git a/src/legacy/core_plugins/telemetry/server/collection_manager.ts b/src/legacy/core_plugins/telemetry/server/collection_manager.ts index 715ca56e290a25..ebac4bede85bb6 100644 --- a/src/legacy/core_plugins/telemetry/server/collection_manager.ts +++ b/src/legacy/core_plugins/telemetry/server/collection_manager.ts @@ -20,6 +20,7 @@ import { encryptTelemetry } from './collectors'; import { CallCluster } from '../../elasticsearch'; import { UsageCollectionSetup } from '../../../../plugins/usage_collection/server'; +import { Cluster } from '../../elasticsearch'; import { ESLicense } from './telemetry_collection/get_local_license'; export type EncryptedStatsGetterConfig = { unencrypted: false } & { @@ -70,7 +71,7 @@ export type LicenseGetter = ( interface CollectionConfig { title: string; priority: number; - esCluster: string; + esCluster: string | Cluster; statsGetter: StatsGetter; clusterDetailsGetter: ClusterDetailsGetter; licenseGetter: LicenseGetter; @@ -79,7 +80,7 @@ interface Collection { statsGetter: StatsGetter; licenseGetter: LicenseGetter; clusterDetailsGetter: ClusterDetailsGetter; - esCluster: string; + esCluster: string | Cluster; title: string; } @@ -135,9 +136,10 @@ export class TelemetryCollectionManager { ): Promise => { const { start, end } = config; const server = config.unencrypted ? config.req.server : config.server; - const { callWithRequest, callWithInternalUser } = server.plugins.elasticsearch.getCluster( - collection.esCluster - ); + const { callWithRequest, callWithInternalUser } = + typeof collection.esCluster === 'string' + ? server.plugins.elasticsearch.getCluster(collection.esCluster) + : collection.esCluster; const callCluster = config.unencrypted ? (...args: any[]) => callWithRequest(config.req, ...args) : callWithInternalUser; diff --git a/src/legacy/core_plugins/tile_map/public/tile_map_type.js b/src/legacy/core_plugins/tile_map/public/tile_map_type.js index 544b63abe82c7c..0809bf6ecbab6c 100644 --- a/src/legacy/core_plugins/tile_map/public/tile_map_type.js +++ b/src/legacy/core_plugins/tile_map/public/tile_map_type.js @@ -21,8 +21,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { convertToGeoJson } from 'ui/vis/map/convert_to_geojson'; -import { Schemas } from 'ui/agg_types'; +import { Schemas } from '../../vis_default_editor/public'; import { Status } from '../../visualizations/public'; import { createTileMapVisualization } from './tile_map_visualization'; import { TileMapOptions } from './components/tile_map_options'; diff --git a/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js index 111db0a83ffc41..fb54c36df27d71 100644 --- a/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js +++ b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js @@ -21,287 +21,295 @@ import _ from 'lodash'; import rison from 'rison-node'; import { uiModules } from 'ui/modules'; import 'ui/directives/input_focus'; -import 'ui/directives/paginate'; import savedObjectFinderTemplate from './saved_object_finder.html'; import { savedSheetLoader } from '../services/saved_sheets'; import { keyMap } from 'ui/directives/key_map'; +import { + PaginateControlsDirectiveProvider, + PaginateDirectiveProvider, +} from '../../../../../plugins/kibana_legacy/public'; const module = uiModules.get('kibana'); -module.directive('savedObjectFinder', function($location, kbnUrl, Private, config) { - return { - restrict: 'E', - scope: { - type: '@', - // optional make-url attr, sets the userMakeUrl in our scope - userMakeUrl: '=?makeUrl', - // optional on-choose attr, sets the userOnChoose in our scope - userOnChoose: '=?onChoose', - // optional useLocalManagement attr, removes link to management section - useLocalManagement: '=?useLocalManagement', - /** - * @type {function} - an optional function. If supplied an `Add new X` button is shown - * and this function is called when clicked. - */ - onAddNew: '=', - /** - * @{type} boolean - set this to true, if you don't want the search box above the - * table to automatically gain focus once loaded - */ - disableAutoFocus: '=', - }, - template: savedObjectFinderTemplate, - controllerAs: 'finder', - controller: function($scope, $element) { - const self = this; - - // the text input element - const $input = $element.find('input[ng-model=filter]'); - - // The number of items to show in the list - $scope.perPage = config.get('savedObjects:perPage'); - - // the list that will hold the suggestions - const $list = $element.find('ul'); - - // the current filter string, used to check that returned results are still useful - let currentFilter = $scope.filter; - - // the most recently entered search/filter - let prevSearch; - - // the list of hits, used to render display - self.hits = []; - - self.service = savedSheetLoader; - self.properties = self.service.loaderProperties; - - filterResults(); - - /** - * Boolean that keeps track of whether hits are sorted ascending (true) - * or descending (false) by title - * @type {Boolean} - */ - self.isAscending = true; - - /** - * Sorts saved object finder hits either ascending or descending - * @param {Array} hits Array of saved finder object hits - * @return {Array} Array sorted either ascending or descending - */ - self.sortHits = function(hits) { - self.isAscending = !self.isAscending; - self.hits = self.isAscending ? _.sortBy(hits, 'title') : _.sortBy(hits, 'title').reverse(); - }; - - /** - * Passed the hit objects and will determine if the - * hit should have a url in the UI, returns it if so - * @return {string|null} - the url or nothing - */ - self.makeUrl = function(hit) { - if ($scope.userMakeUrl) { - return $scope.userMakeUrl(hit); - } - - if (!$scope.userOnChoose) { - return hit.url; - } +module + .directive('paginate', PaginateDirectiveProvider) + .directive('paginateControls', PaginateControlsDirectiveProvider) + .directive('savedObjectFinder', function($location, kbnUrl, Private, config) { + return { + restrict: 'E', + scope: { + type: '@', + // optional make-url attr, sets the userMakeUrl in our scope + userMakeUrl: '=?makeUrl', + // optional on-choose attr, sets the userOnChoose in our scope + userOnChoose: '=?onChoose', + // optional useLocalManagement attr, removes link to management section + useLocalManagement: '=?useLocalManagement', + /** + * @type {function} - an optional function. If supplied an `Add new X` button is shown + * and this function is called when clicked. + */ + onAddNew: '=', + /** + * @{type} boolean - set this to true, if you don't want the search box above the + * table to automatically gain focus once loaded + */ + disableAutoFocus: '=', + }, + template: savedObjectFinderTemplate, + controllerAs: 'finder', + controller: function($scope, $element) { + const self = this; + + // the text input element + const $input = $element.find('input[ng-model=filter]'); + + // The number of items to show in the list + $scope.perPage = config.get('savedObjects:perPage'); + + // the list that will hold the suggestions + const $list = $element.find('ul'); + + // the current filter string, used to check that returned results are still useful + let currentFilter = $scope.filter; + + // the most recently entered search/filter + let prevSearch; + + // the list of hits, used to render display + self.hits = []; + + self.service = savedSheetLoader; + self.properties = self.service.loaderProperties; - return '#'; - }; + filterResults(); - self.preventClick = function($event) { - $event.preventDefault(); - }; + /** + * Boolean that keeps track of whether hits are sorted ascending (true) + * or descending (false) by title + * @type {Boolean} + */ + self.isAscending = true; + + /** + * Sorts saved object finder hits either ascending or descending + * @param {Array} hits Array of saved finder object hits + * @return {Array} Array sorted either ascending or descending + */ + self.sortHits = function(hits) { + self.isAscending = !self.isAscending; + self.hits = self.isAscending + ? _.sortBy(hits, 'title') + : _.sortBy(hits, 'title').reverse(); + }; + + /** + * Passed the hit objects and will determine if the + * hit should have a url in the UI, returns it if so + * @return {string|null} - the url or nothing + */ + self.makeUrl = function(hit) { + if ($scope.userMakeUrl) { + return $scope.userMakeUrl(hit); + } - /** - * Called when a hit object is clicked, can override the - * url behavior if necessary. - */ - self.onChoose = function(hit, $event) { - if ($scope.userOnChoose) { - $scope.userOnChoose(hit, $event); - } + if (!$scope.userOnChoose) { + return hit.url; + } - const url = self.makeUrl(hit); - if (!url || url === '#' || url.charAt(0) !== '#') return; + return '#'; + }; - $event.preventDefault(); + self.preventClick = function($event) { + $event.preventDefault(); + }; - // we want the '/path', not '#/path' - kbnUrl.change(url.substr(1)); - }; + /** + * Called when a hit object is clicked, can override the + * url behavior if necessary. + */ + self.onChoose = function(hit, $event) { + if ($scope.userOnChoose) { + $scope.userOnChoose(hit, $event); + } - $scope.$watch('filter', function(newFilter) { - // ensure that the currentFilter changes from undefined to '' - // which triggers - currentFilter = newFilter || ''; - filterResults(); - }); - - $scope.pageFirstItem = 0; - $scope.pageLastItem = 0; - $scope.onPageChanged = page => { - $scope.pageFirstItem = page.firstItem; - $scope.pageLastItem = page.lastItem; - }; - - //manages the state of the keyboard selector - self.selector = { - enabled: false, - index: -1, - }; - - self.getLabel = function() { - return _.words(self.properties.nouns) - .map(_.capitalize) - .join(' '); - }; - - //key handler for the filter text box - self.filterKeyDown = function($event) { - switch (keyMap[$event.keyCode]) { - case 'enter': - if (self.hitCount !== 1) return; - - const hit = self.hits[0]; - if (!hit) return; - - self.onChoose(hit, $event); - $event.preventDefault(); - break; - } - }; + const url = self.makeUrl(hit); + if (!url || url === '#' || url.charAt(0) !== '#') return; - //key handler for the list items - self.hitKeyDown = function($event, page, paginate) { - switch (keyMap[$event.keyCode]) { - case 'tab': - if (!self.selector.enabled) break; + $event.preventDefault(); - self.selector.index = -1; - self.selector.enabled = false; + // we want the '/path', not '#/path' + kbnUrl.change(url.substr(1)); + }; - //if the user types shift-tab return to the textbox - //if the user types tab, set the focus to the currently selected hit. - if ($event.shiftKey) { - $input.focus(); - } else { - $list.find('li.active a').focus(); - } + $scope.$watch('filter', function(newFilter) { + // ensure that the currentFilter changes from undefined to '' + // which triggers + currentFilter = newFilter || ''; + filterResults(); + }); - $event.preventDefault(); - break; - case 'down': - if (!self.selector.enabled) break; + $scope.pageFirstItem = 0; + $scope.pageLastItem = 0; + $scope.onPageChanged = page => { + $scope.pageFirstItem = page.firstItem; + $scope.pageLastItem = page.lastItem; + }; + + //manages the state of the keyboard selector + self.selector = { + enabled: false, + index: -1, + }; + + self.getLabel = function() { + return _.words(self.properties.nouns) + .map(_.capitalize) + .join(' '); + }; + + //key handler for the filter text box + self.filterKeyDown = function($event) { + switch (keyMap[$event.keyCode]) { + case 'enter': + if (self.hitCount !== 1) return; + + const hit = self.hits[0]; + if (!hit) return; + + self.onChoose(hit, $event); + $event.preventDefault(); + break; + } + }; + + //key handler for the list items + self.hitKeyDown = function($event, page, paginate) { + switch (keyMap[$event.keyCode]) { + case 'tab': + if (!self.selector.enabled) break; + + self.selector.index = -1; + self.selector.enabled = false; + + //if the user types shift-tab return to the textbox + //if the user types tab, set the focus to the currently selected hit. + if ($event.shiftKey) { + $input.focus(); + } else { + $list.find('li.active a').focus(); + } + + $event.preventDefault(); + break; + case 'down': + if (!self.selector.enabled) break; + + if (self.selector.index + 1 < page.length) { + self.selector.index += 1; + } + $event.preventDefault(); + break; + case 'up': + if (!self.selector.enabled) break; + + if (self.selector.index > 0) { + self.selector.index -= 1; + } + $event.preventDefault(); + break; + case 'right': + if (!self.selector.enabled) break; + + if (page.number < page.count) { + paginate.goToPage(page.number + 1); + self.selector.index = 0; + selectTopHit(); + } + $event.preventDefault(); + break; + case 'left': + if (!self.selector.enabled) break; + + if (page.number > 1) { + paginate.goToPage(page.number - 1); + self.selector.index = 0; + selectTopHit(); + } + $event.preventDefault(); + break; + case 'escape': + if (!self.selector.enabled) break; - if (self.selector.index + 1 < page.length) { - self.selector.index += 1; - } - $event.preventDefault(); - break; - case 'up': - if (!self.selector.enabled) break; + $input.focus(); + $event.preventDefault(); + break; + case 'enter': + if (!self.selector.enabled) break; + + const hitIndex = (page.number - 1) * paginate.perPage + self.selector.index; + const hit = self.hits[hitIndex]; + if (!hit) break; + + self.onChoose(hit, $event); + $event.preventDefault(); + break; + case 'shift': + break; + default: + $input.focus(); + break; + } + }; + + self.hitBlur = function() { + self.selector.index = -1; + self.selector.enabled = false; + }; + + self.manageObjects = function(type) { + $location.url('/management/kibana/objects?_a=' + rison.encode({ tab: type })); + }; + + self.hitCountNoun = function() { + return (self.hitCount === 1 ? self.properties.noun : self.properties.nouns).toLowerCase(); + }; + + function selectTopHit() { + setTimeout(function() { + //triggering a focus event kicks off a new angular digest cycle. + $list.find('a:first').focus(); + }, 0); + } - if (self.selector.index > 0) { - self.selector.index -= 1; - } - $event.preventDefault(); - break; - case 'right': - if (!self.selector.enabled) break; - - if (page.number < page.count) { - paginate.goToPage(page.number + 1); - self.selector.index = 0; - selectTopHit(); - } - $event.preventDefault(); - break; - case 'left': - if (!self.selector.enabled) break; - - if (page.number > 1) { - paginate.goToPage(page.number - 1); - self.selector.index = 0; - selectTopHit(); + function filterResults() { + if (!self.service) return; + if (!self.properties) return; + + // track the filter that we use for this search, + // but ensure that we don't search for the same + // thing twice. This is called from multiple places + // and needs to be smart about when it actually searches + const filter = currentFilter; + if (prevSearch === filter) return; + + prevSearch = filter; + + const isLabsEnabled = config.get('visualize:enableLabs'); + self.service.find(filter).then(function(hits) { + hits.hits = hits.hits.filter( + hit => isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental' + ); + hits.total = hits.hits.length; + + // ensure that we don't display old results + // as we can't really cancel requests + if (currentFilter === filter) { + self.hitCount = hits.total; + self.hits = _.sortBy(hits.hits, 'title'); } - $event.preventDefault(); - break; - case 'escape': - if (!self.selector.enabled) break; - - $input.focus(); - $event.preventDefault(); - break; - case 'enter': - if (!self.selector.enabled) break; - - const hitIndex = (page.number - 1) * paginate.perPage + self.selector.index; - const hit = self.hits[hitIndex]; - if (!hit) break; - - self.onChoose(hit, $event); - $event.preventDefault(); - break; - case 'shift': - break; - default: - $input.focus(); - break; + }); } - }; - - self.hitBlur = function() { - self.selector.index = -1; - self.selector.enabled = false; - }; - - self.manageObjects = function(type) { - $location.url('/management/kibana/objects?_a=' + rison.encode({ tab: type })); - }; - - self.hitCountNoun = function() { - return (self.hitCount === 1 ? self.properties.noun : self.properties.nouns).toLowerCase(); - }; - - function selectTopHit() { - setTimeout(function() { - //triggering a focus event kicks off a new angular digest cycle. - $list.find('a:first').focus(); - }, 0); - } - - function filterResults() { - if (!self.service) return; - if (!self.properties) return; - - // track the filter that we use for this search, - // but ensure that we don't search for the same - // thing twice. This is called from multiple places - // and needs to be smart about when it actually searches - const filter = currentFilter; - if (prevSearch === filter) return; - - prevSearch = filter; - - const isLabsEnabled = config.get('visualize:enableLabs'); - self.service.find(filter).then(function(hits) { - hits.hits = hits.hits.filter( - hit => isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental' - ); - hits.total = hits.hits.length; - - // ensure that we don't display old results - // as we can't really cancel requests - if (currentFilter === filter) { - self.hitCount = hits.total; - self.hits = _.sortBy(hits.hits, 'title'); - } - }); - } - }, - }; -}); + }, + }; + }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg.test.tsx.snap b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg.test.tsx.snap index ba5f2ae975cbee..5200fee45d6b34 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg.test.tsx.snap +++ b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg.test.tsx.snap @@ -3,6 +3,7 @@ exports[`DefaultEditorAgg component should init with the default set of props 1`] = ` diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap deleted file mode 100644 index 028d0b80166930..00000000000000 --- a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap +++ /dev/null @@ -1,70 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DefaultEditorAggParams component should init with the default set of params 1`] = ` - - - - - - - - - -`; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx index 22e0ebb3d30dc4..7e715be25bff3c 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx @@ -21,17 +21,14 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { IndexPattern } from 'src/plugins/data/public'; +import { IndexPattern, IAggType, AggGroupNames } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggType, AggGroupNames } from '../legacy_imports'; import { DefaultEditorAgg, DefaultEditorAggProps } from './agg'; import { DefaultEditorAggParams } from './agg_params'; import { AGGS_ACTION_KEYS } from './agg_group_state'; import { Schema } from '../schemas'; -jest.mock('ui/new_platform'); - jest.mock('./agg_params', () => ({ DefaultEditorAggParams: () => null, })); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx index 30ccd4f0b6cae0..2a452732076233 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx @@ -28,7 +28,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggParams } from './agg_params'; import { DefaultEditorAggCommonProps } from './agg_common_props'; import { AGGS_ACTION_KEYS, AggsAction } from './agg_group_state'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx index 24cb83498d4d09..9df4ea58e0f075 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx @@ -29,7 +29,7 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IAggConfig, AggGroupNames } from '../../../../../plugins/data/public'; import { Schema } from '../schemas'; interface DefaultEditorAggAddProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts index 1a97cc5c4d967f..ec92f511b6eee2 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts @@ -18,7 +18,7 @@ */ import { VisState, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggType, IAggConfig, IAggGroupNames } from '../legacy_imports'; +import { IAggType, IAggConfig, IAggGroupNames } from 'src/plugins/data/public'; import { Schema } from '../schemas'; type AggId = IAggConfig['id']; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx index ec467480539abd..63f5e696c99f48 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfigs, IAggConfig } from '../legacy_imports'; +import { IAggConfigs, IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggGroup, DefaultEditorAggGroupProps } from './agg_group'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; @@ -36,17 +36,6 @@ jest.mock('@elastic/eui', () => ({ EuiPanel: 'eui-panel', })); -jest.mock('../legacy_imports', () => ({ - aggGroupNamesMap: () => ({ - metrics: 'Metrics', - buckets: 'Buckets', - }), - AggGroupNames: { - Metrics: 'metrics', - Buckets: 'buckets', - }, -})); - jest.mock('./agg', () => ({ DefaultEditorAgg: () =>
, })); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx index a15a98d4983ced..600612f2cf9d86 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx @@ -30,7 +30,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IAggConfig, aggGroupNamesMap, AggGroupNames } from '../legacy_imports'; +import { AggGroupNames, search, IAggConfig } from '../../../../../plugins/data/public'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props'; @@ -68,7 +68,7 @@ function DefaultEditorAggGroup({ setTouched, setValidity, }: DefaultEditorAggGroupProps) { - const groupNameLabel = (aggGroupNamesMap() as any)[groupName]; + const groupNameLabel = (search.aggs.aggGroupNamesMap() as any)[groupName]; // e.g. buckets can have no aggs const schemaNames = getSchemasByGroup(schemas, groupName).map(s => s.name); const group: IAggConfig[] = useMemo( diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts index aebece29e7ae67..3693f1b1e30918 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { isAggRemovable, calcAggIsTooLow, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx index 0a8c5c3077ada0..9a4cca940baeac 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx @@ -18,7 +18,7 @@ */ import { findIndex, isEmpty } from 'lodash'; -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { AggsState } from './agg_group_state'; import { Schema, getSchemaByName } from '../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx index d022297ae72b39..bfd5bec339b1f0 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; export enum AGGS_ACTION_KEYS { TOUCHED = 'aggsTouched', diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts index cdc5a4c8f8a773..7c2852798b4032 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts @@ -17,9 +17,8 @@ * under the License. */ -import { IndexPatternField } from 'src/plugins/data/public'; +import { IAggConfig, AggParam, IndexPatternField } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, AggParam } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; import { EditorConfig } from './utils'; import { Schema } from '../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx index d2821566fcb372..cd6486b6a15321 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx @@ -18,12 +18,16 @@ */ import React from 'react'; -import { mount, shallow } from 'enzyme'; +import { mount } from 'enzyme'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IndexPattern } from 'src/plugins/data/public'; -import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IndexPattern, IAggConfig, AggGroupNames } from 'src/plugins/data/public'; +import { + DefaultEditorAggParams as PureDefaultEditorAggParams, + DefaultEditorAggParamsProps, +} from './agg_params'; +import { KibanaContextProvider } from '../../../../../plugins/kibana_react/public'; +import { dataPluginMock } from '../../../../../plugins/data/public/mocks'; const mockEditorConfig = { useNormalizedEsInterval: { hidden: false, fixedValue: false }, @@ -34,8 +38,12 @@ const mockEditorConfig = { timeBase: '1m', }, }; +const DefaultEditorAggParams = (props: DefaultEditorAggParamsProps) => ( + + + +); -jest.mock('ui/new_platform'); jest.mock('./utils', () => ({ getEditorConfig: jest.fn(() => mockEditorConfig), })); @@ -109,12 +117,6 @@ describe('DefaultEditorAggParams component', () => { }; }); - it('should init with the default set of params', () => { - const comp = shallow(); - - expect(comp).toMatchSnapshot(); - }); - it('should reset the validity to true when destroyed', () => { const comp = mount(); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx index 510c21af95da1a..b1555b76500d0a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx @@ -22,8 +22,7 @@ import { EuiForm, EuiAccordion, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import useUnmount from 'react-use/lib/useUnmount'; -import { IndexPattern } from 'src/plugins/data/public'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IAggConfig, IndexPattern, AggGroupNames } from '../../../../../plugins/data/public'; import { DefaultEditorAggSelect } from './agg_select'; import { DefaultEditorAggParam } from './agg_param'; @@ -41,6 +40,8 @@ import { import { DefaultEditorCommonProps } from './agg_common_props'; import { EditorParamConfig, TimeIntervalParam, FixedParam, getEditorConfig } from './utils'; import { Schema, getSchemaByName } from '../schemas'; +import { useKibana } from '../../../../../plugins/kibana_react/public'; +import { VisDefaultEditorKibanaServices } from '../types'; const FIXED_VALUE_PROP = 'fixedValue'; const DEFAULT_PROP = 'default'; @@ -83,18 +84,24 @@ function DefaultEditorAggParams({ allowedAggs = [], hideCustomLabel = false, }: DefaultEditorAggParamsProps) { - const schema = getSchemaByName(schemas, agg.schema); - const { title } = schema; - const aggFilter = [...allowedAggs, ...(schema.aggFilter || [])]; + const schema = useMemo(() => getSchemaByName(schemas, agg.schema), [agg.schema, schemas]); + const aggFilter = useMemo(() => [...allowedAggs, ...(schema.aggFilter || [])], [ + allowedAggs, + schema.aggFilter, + ]); + const { services } = useKibana(); + const aggTypes = useMemo(() => services.data.search.aggs.types.getAll(), [ + services.data.search.aggs.types, + ]); const groupedAggTypeOptions = useMemo( - () => getAggTypeOptions(agg, indexPattern, groupName, aggFilter), - [agg, indexPattern, groupName, aggFilter] + () => getAggTypeOptions(aggTypes, agg, indexPattern, groupName, aggFilter), + [aggTypes, agg, indexPattern, groupName, aggFilter] ); const error = aggIsTooLow ? i18n.translate('visDefaultEditor.aggParams.errors.aggWrongRunOrderErrorMessage', { defaultMessage: '"{schema}" aggs must run before all other buckets!', - values: { schema: title }, + values: { schema: schema.title }, }) : ''; const aggTypeName = agg.type?.name; @@ -105,8 +112,20 @@ function DefaultEditorAggParams({ fieldName, ]); const params = useMemo( - () => getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }), - [agg, editorConfig, metricAggs, state, schemas, hideCustomLabel] + () => + getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }, + services.data.search.__LEGACY.aggTypeFieldFilters + ), + [ + agg, + editorConfig, + metricAggs, + state, + schemas, + hideCustomLabel, + services.data.search.__LEGACY.aggTypeFieldFilters, + ] ); const allParams = [...params.basic, ...params.advanced]; const [paramsState, onChangeParamsState] = useReducer( diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts index 047467750794bf..f2ebbdc87a60a4 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts @@ -17,9 +17,15 @@ * under the License. */ -import { IndexPattern } from 'src/plugins/data/public'; +import { + AggGroupNames, + BUCKET_TYPES, + IAggConfig, + IAggType, + IndexPattern, + IndexPatternField, +} from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, IAggType, AggGroupNames, BUCKET_TYPES } from '../legacy_imports'; import { getAggParamsToRender, getAggTypeOptions, @@ -33,7 +39,11 @@ jest.mock('../utils', () => ({ groupAndSortBy: jest.fn(() => ['indexedFields']), })); -jest.mock('ui/new_platform'); +const mockFilter: any = { + filter(fields: IndexPatternField[]): IndexPatternField[] { + return fields; + }, +}; describe('DefaultEditorAggParams helpers', () => { describe('getAggParamsToRender', () => { @@ -62,14 +72,20 @@ describe('DefaultEditorAggParams helpers', () => { }, schema: 'metric', } as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); it('should not create any param if there is no agg type', () => { agg = { schema: 'metric' } as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -85,7 +101,10 @@ describe('DefaultEditorAggParams helpers', () => { hidden: true, }, }; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -97,7 +116,10 @@ describe('DefaultEditorAggParams helpers', () => { }, schema: 'metric2', } as any) as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -136,7 +158,10 @@ describe('DefaultEditorAggParams helpers', () => { field: 'field', }, } as any) as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual({ basic: [ @@ -172,7 +197,13 @@ describe('DefaultEditorAggParams helpers', () => { describe('getAggTypeOptions', () => { it('should return agg type options grouped by subtype', () => { const indexPattern = {} as IndexPattern; - const aggs = getAggTypeOptions({} as IAggConfig, indexPattern, 'metrics', []); + const aggs = getAggTypeOptions( + { metrics: [] }, + {} as IAggConfig, + indexPattern, + 'metrics', + [] + ); expect(aggs).toEqual(['indexedFields']); }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts index 520ff6ffc5ff5c..e07bf816975791 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts @@ -19,23 +19,23 @@ import { get, isEmpty } from 'lodash'; -import { IndexPattern, IndexPatternField } from 'src/plugins/data/public'; -import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils'; -import { AggTypeState, AggParamsState } from './agg_params_state'; -import { AggParamEditorProps } from './agg_param_props'; -import { aggParamsMap } from './agg_params_map'; import { - aggTypeFilters, - aggTypeFieldFilters, - aggTypes, + AggTypeFieldFilters, IAggConfig, AggParam, IFieldParamType, IAggType, -} from '../legacy_imports'; + IndexPattern, + IndexPatternField, +} from 'src/plugins/data/public'; +import { VisState } from 'src/legacy/core_plugins/visualizations/public'; +import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils'; +import { AggTypeState, AggParamsState } from './agg_params_state'; +import { AggParamEditorProps } from './agg_param_props'; +import { aggParamsMap } from './agg_params_map'; import { EditorConfig } from './utils'; import { Schema, getSchemaByName } from '../schemas'; +import { search } from '../../../../../plugins/data/public'; interface ParamInstanceBase { agg: IAggConfig; @@ -53,14 +53,10 @@ export interface ParamInstance extends ParamInstanceBase { value: unknown; } -function getAggParamsToRender({ - agg, - editorConfig, - metricAggs, - state, - schemas, - hideCustomLabel, -}: ParamInstanceBase) { +function getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }: ParamInstanceBase, + aggTypeFieldFilters: AggTypeFieldFilters +) { const params = { basic: [] as ParamInstance[], advanced: [] as ParamInstance[], @@ -136,13 +132,14 @@ function getAggParamsToRender({ } function getAggTypeOptions( + aggTypes: any, agg: IAggConfig, indexPattern: IndexPattern, groupName: string, allowedAggs: string[] ): ComboBoxGroupedOptions { - const aggTypeOptions = aggTypeFilters.filter( - (aggTypes as any)[groupName], + const aggTypeOptions = search.aggs.aggTypeFilters.filter( + aggTypes[groupName], indexPattern, agg, allowedAggs diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts index 7caa775dd4fa49..4517313b6fd6e8 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts @@ -22,11 +22,12 @@ import { AggGroupNames, BUCKET_TYPES, METRIC_TYPES, - siblingPipelineType, - parentPipelineType, -} from '../legacy_imports'; + search, +} from '../../../../../plugins/data/public'; import { wrapWithInlineComp } from './controls/utils'; +const { siblingPipelineType, parentPipelineType } = search.aggs; + const buckets = { [BUCKET_TYPES.DATE_HISTOGRAM]: { scaleMetricValues: controls.ScaleMetricsParamEditor, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx index 4d969a2d8ec6c7..7ee432946f3c87 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx @@ -23,9 +23,8 @@ import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow, EuiLink, EuiText } fr import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { IndexPattern } from 'src/plugins/data/public'; +import { IAggType, IndexPattern } from 'src/plugins/data/public'; import { useKibana } from '../../../../../plugins/kibana_react/public'; -import { IAggType } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; import { AGG_TYPE_ACTION_KEYS, AggTypeAction } from './agg_params_state'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx index 7f04b851902de1..98540d3414f2d4 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx @@ -18,7 +18,7 @@ */ import { VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggCommonProps } from '../agg_common_props'; export interface AggControlProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx index 0b847e3747b301..0c1e93bc1e6462 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx @@ -20,7 +20,7 @@ import React, { FunctionComponent } from 'react'; import { mount, ReactWrapper } from 'enzyme'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { safeMakeLabel, useAvailableOptions, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx index 625b09b05d28f7..f6edecbbcbd701 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx @@ -22,7 +22,7 @@ import { EuiFieldText, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { InputList, InputListConfig, InputObject, InputModel, InputItem } from './input_list'; -import { CidrMask } from '../../../legacy_imports'; +import { search } from '../../../../../../../plugins/data/public'; const EMPTY_STRING = ''; @@ -47,7 +47,7 @@ function MaskList({ showValidation, onBlur, ...rest }: MaskListProps) { defaultValue: { mask: { model: '0.0.0.0/1', value: '0.0.0.0/1', isInvalid: false }, }, - validateClass: CidrMask, + validateClass: search.aggs.CidrMask, getModelValue: (item: MaskObject = {}) => ({ mask: { model: item.mask || EMPTY_STRING, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx index 186738d0f551c1..1043431475494e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx @@ -22,11 +22,10 @@ import { act } from 'react-dom/test-utils'; import { mount, shallow, ReactWrapper } from 'enzyme'; import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui'; -import { IndexPatternField } from 'src/plugins/data/public'; +import { IAggConfig, IndexPatternField } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { ComboBoxGroupedOptions } from '../../utils'; import { FieldParamEditor, FieldParamEditorProps } from './field'; -import { IAggConfig } from '../../legacy_imports'; function callComboBoxOnChange(comp: ReactWrapper, value: any = []) { const comboBoxProps = comp.find(EuiComboBox).props() as EuiComboBoxProps; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx index 0ec00ab6f20f08..59642ae4c25f78 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx @@ -23,8 +23,7 @@ import React, { useEffect, useState, useCallback } from 'react'; import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IndexPatternField } from 'src/plugins/data/public'; -import { AggParam, IAggConfig, IFieldParamType } from '../../legacy_imports'; +import { AggParam, IAggConfig, IFieldParamType, IndexPatternField } from 'src/plugins/data/public'; import { formatListAsProse, parseCommaSeparatedList, useValidation } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { ComboBoxGroupedOptions } from '../../utils'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx index 3622b27bad4036..e2e7c2895093e7 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx @@ -21,8 +21,7 @@ import React, { useState } from 'react'; import { EuiForm, EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Query, QueryStringInput } from '../../../../../../plugins/data/public'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig, Query, QueryStringInput } from '../../../../../../plugins/data/public'; interface FilterRowProps { id: string; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx index 416f925da8c1eb..90b7cb03b7a5b3 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx @@ -20,10 +20,12 @@ import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; +import { search } from '../../../../../../plugins/data/public'; import { SwitchParamEditor } from './switch'; -import { isType } from '../../legacy_imports'; import { AggParamEditorProps } from '../agg_param_props'; +const { isType } = search.aggs; + function HasExtendedBoundsParamEditor(props: AggParamEditorProps) { useEffect(() => { props.setValue(props.value && props.agg.params.min_doc_count); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx index cf7af1aa5cb3a7..c53e7a8beb8316 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DEFAULT_OPTIONS, aggFilter, MetricAggParamEditor } from './metric_agg'; jest.mock('./utils', () => ({ diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx index 8d22ab283f3a1e..7010f0d53e569e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx @@ -21,11 +21,11 @@ import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { SwitchParamEditor } from './switch'; -import { isStringType } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; function MissingBucketParamEditor(props: AggParamEditorProps) { - const fieldTypeIsNotString = !isStringType(props.agg); + const fieldTypeIsNotString = !search.aggs.isStringType(props.agg); useEffect(() => { if (fieldTypeIsNotString) { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx index f40143251e46a1..8f63662d928c1a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx @@ -21,7 +21,7 @@ import React, { useEffect } from 'react'; import { EuiFormRow, EuiSelect } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { OptionedValueProp, OptionedParamEditorProps } from '../../legacy_imports'; +import { OptionedValueProp, OptionedParamEditorProps } from 'src/plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; function OrderParamEditor({ diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx index 01f5ed9b6a2f1c..4c843791153b08 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx @@ -21,8 +21,6 @@ import React from 'react'; import { mount } from 'enzyme'; import { OrderByParamEditor } from './order_by'; -jest.mock('ui/new_platform'); - describe('OrderAggParamEditor component', () => { let setValue: jest.Mock; let setValidity: jest.Mock; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx index 8c020c668b3c63..41672bc192fabe 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx @@ -20,7 +20,7 @@ import React, { useEffect } from 'react'; import { EuiSpacer } from '@elastic/eui'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx index c0391358ec6e20..9f1aaa54a8ca3e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx @@ -28,8 +28,9 @@ import { useValidation, } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; -import { termsAggFilter } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; +const { termsAggFilter } = search.aggs; const DEFAULT_VALUE = '_key'; const DEFAULT_OPTIONS = [ { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx index 0eaf9bcc987c16..76eb12af8c4e24 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { AggParamEditorProps } from '../agg_param_props'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { mount } from 'enzyme'; import { PercentilesEditor } from './percentiles'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx index 5bc94bd4af2260..c9f53a68b3e83e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx @@ -20,7 +20,7 @@ import React, { useEffect } from 'react'; import { EuiSpacer } from '@elastic/eui'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx index 9d48b1c964a272..ead3f8bb006231 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx @@ -21,7 +21,7 @@ import React, { useEffect } from 'react'; import { EuiFormLabel, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts index 8a21114999cd67..b816e61cce355f 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts @@ -18,7 +18,7 @@ */ import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, AggParam } from '../../legacy_imports'; +import { IAggConfig, AggParam } from 'src/plugins/data/public'; import { EditorConfig } from '../utils'; export const aggParamCommonPropsMock = { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx index ee3666b2ed441b..de0059f5467ad7 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx @@ -23,7 +23,7 @@ import { EuiFormRow, EuiIconTip, EuiComboBox, EuiComboBoxOptionOption } from '@e import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { isValidInterval, AggParamOption } from '../../legacy_imports'; +import { search, AggParamOption } from '../../../../../../plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; interface ComboBoxOption extends EuiComboBoxOptionOption { @@ -59,7 +59,7 @@ function TimeIntervalParamEditor({ if (value) { definedOption = find(options, { key: value }); selectedOptions = definedOption ? [definedOption] : [{ label: value, key: 'custom' }]; - isValid = !!(definedOption || isValidInterval(value, timeBase)); + isValid = !!(definedOption || search.aggs.isValidInterval(value, timeBase)); } const interval = get(agg, 'buckets.getInterval') && (agg as any).buckets.getInterval(); @@ -100,7 +100,7 @@ function TimeIntervalParamEditor({ const normalizedCustomValue = customValue.trim(); setValue(normalizedCustomValue); - if (normalizedCustomValue && isValidInterval(normalizedCustomValue, timeBase)) { + if (normalizedCustomValue && search.aggs.isValidInterval(normalizedCustomValue, timeBase)) { agg.write(); } }; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx index 4ce0712040bd5f..74dab1a3b551ab 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx @@ -25,7 +25,7 @@ import { TopAggregateParamEditorProps, } from './top_aggregate'; import { aggParamCommonPropsMock } from './test_utils'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; describe('TopAggregateParamEditor', () => { let agg: IAggConfig; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx index 346dfc0156f070..bab20d18c8fc05 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx @@ -28,7 +28,7 @@ import { OptionedValueProp, OptionedParamEditorProps, OptionedParamType, -} from '../../legacy_imports'; +} from 'src/plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; export interface AggregateValueProp extends OptionedValueProp { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts index 8aeae488942cd5..f4c0814748ebca 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts @@ -20,7 +20,7 @@ import { useEffect, useCallback, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; type AggFilter = string[]; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts index c7816d5a9d3056..4dadef79b12047 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts @@ -19,7 +19,7 @@ import { useCallback } from 'react'; -import { IAggConfig, AggParamType } from '../../../legacy_imports'; +import { IAggConfig, AggParamType } from 'src/plugins/data/public'; type SetValue = (value?: IAggConfig) => void; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx index 1c1f9d57d8b907..6f92c27e90ec1c 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx @@ -23,11 +23,11 @@ import { EuiSpacer } from '@elastic/eui'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { - IAggConfig, AggGroupNames, - parentPipelineType, + IAggConfig, IMetricAggType, -} from '../../legacy_imports'; + search, +} from '../../../../../../plugins/data/public'; import { DefaultEditorAggGroup } from '../agg_group'; import { EditorAction, @@ -67,7 +67,7 @@ function DefaultEditorDataTab({ () => findLast( metricAggs, - ({ type }: { type: IMetricAggType }) => type.subtype === parentPipelineType + ({ type }: { type: IMetricAggType }) => type.subtype === search.aggs.parentPipelineType ), [metricAggs] ); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx index 1efd8dae8178b3..2508ef3a555375 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx @@ -23,7 +23,6 @@ import { i18n } from '@kbn/i18n'; import { keyCodes, EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { Vis } from 'src/legacy/core_plugins/visualizations/public'; -import { AggGroupNames } from '../../legacy_imports'; import { DefaultEditorNavBar, OptionTab } from './navbar'; import { DefaultEditorControls } from './controls'; import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state'; @@ -31,6 +30,7 @@ import { DefaultEditorAggCommonProps } from '../agg_common_props'; import { SidebarTitle } from './sidebar_title'; import { PersistedState } from '../../../../../../plugins/visualizations/public'; import { SavedSearch } from '../../../../../../plugins/discover/public'; +import { AggGroupNames } from '../../../../../../plugins/data/public'; import { getSchemasByGroup } from '../../schemas'; interface DefaultEditorSideBarProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts index f9915bedc8878d..e3577218b7e255 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts @@ -18,7 +18,7 @@ */ import { Vis, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { EditorStateActionTypes } from './constants'; import { Schema } from '../../../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts index df5ba3f6121c77..6383ac866dcfcd 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts @@ -21,15 +21,22 @@ import { useEffect, useReducer, useCallback } from 'react'; import { isEqual } from 'lodash'; import { Vis, VisState, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { editorStateReducer, initEditorState } from './reducers'; +import { createEditorStateReducer, initEditorState } from './reducers'; import { EditorStateActionTypes } from './constants'; import { EditorAction, updateStateParams } from './actions'; +import { useKibana } from '../../../../../../../plugins/kibana_react/public'; +import { VisDefaultEditorKibanaServices } from '../../../types'; export * from './editor_form_state'; export * from './actions'; export function useEditorReducer(vis: Vis): [VisState, React.Dispatch] { - const [state, dispatch] = useReducer(editorStateReducer, vis, initEditorState); + const { services } = useKibana(); + const [state, dispatch] = useReducer( + createEditorStateReducer(services.data.search), + vis, + initEditorState + ); useEffect(() => { const handleVisUpdate = (params: VisParams) => { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts index 73675e75cbe362..67220fd9fd91bb 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts @@ -20,7 +20,7 @@ import { cloneDeep } from 'lodash'; import { Vis, VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { createAggConfigs, AggGroupNames } from '../../../legacy_imports'; +import { AggGroupNames, DataPublicPluginStart } from '../../../../../../../plugins/data/public'; import { EditorStateActionTypes } from './constants'; import { getEnabledMetricAggsCount } from '../../agg_group_helper'; import { EditorAction } from './actions'; @@ -29,7 +29,9 @@ function initEditorState(vis: Vis) { return vis.copyCurrentState(true); } -function editorStateReducer(state: VisState, action: EditorAction): VisState { +const createEditorStateReducer = ({ + aggs: { createAggConfigs }, +}: DataPublicPluginStart['search']) => (state: VisState, action: EditorAction): VisState => { switch (action.type) { case EditorStateActionTypes.ADD_NEW_AGG: { const { schema } = action.payload; @@ -181,6 +183,6 @@ function editorStateReducer(state: VisState, action: EditorAction): VisState { }; } } -} +}; -export { editorStateReducer, initEditorState }; +export { createEditorStateReducer, initEditorState }; diff --git a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts b/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts deleted file mode 100644 index 50028d8c970f45..00000000000000 --- a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -/* `ui/agg_types` dependencies */ -export { BUCKET_TYPES, METRIC_TYPES } from '../../../../plugins/data/public'; -export { - AggGroupNames, - aggGroupNamesMap, - AggParam, - AggParamType, - AggType, - aggTypes, - createAggConfigs, - FieldParamType, - IAggConfig, - IAggConfigs, - IAggGroupNames, - IAggType, - IFieldParamType, - termsAggFilter, -} from 'ui/agg_types'; -export { aggTypeFilters, propFilter } from 'ui/agg_types'; -export { aggTypeFieldFilters } from 'ui/agg_types'; -export { MetricAggType, IMetricAggType } from 'ui/agg_types'; -export { parentPipelineType } from 'ui/agg_types'; -export { siblingPipelineType } from 'ui/agg_types'; -export { isType, isStringType } from 'ui/agg_types'; -export { OptionedValueProp, OptionedParamEditorProps, OptionedParamType } from 'ui/agg_types'; -export { isValidInterval } from 'ui/agg_types'; -export { AggParamOption } from 'ui/agg_types'; -export { CidrMask } from 'ui/agg_types'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/types.ts b/src/legacy/core_plugins/vis_default_editor/public/types.ts new file mode 100644 index 00000000000000..22fc24005994d6 --- /dev/null +++ b/src/legacy/core_plugins/vis_default_editor/public/types.ts @@ -0,0 +1,24 @@ +/* + * 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 { DataPublicPluginStart } from 'src/plugins/data/public'; + +export interface VisDefaultEditorKibanaServices { + data: DataPublicPluginStart; +} diff --git a/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts b/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts index b050979b7b3387..f3912450ba6704 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts @@ -18,9 +18,7 @@ */ import { groupAndSortBy } from './utils'; -import { AggGroupNames } from './legacy_imports'; - -jest.mock('ui/new_platform'); +import { AggGroupNames } from 'src/plugins/data/public'; const aggs = [ { diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx index 18fbba1b039b53..2e8f20946c73a4 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx @@ -17,8 +17,8 @@ * under the License. */ +import { IAggConfigs } from 'src/plugins/data/public'; import { PersistedState } from '../../../../plugins/visualizations/public'; -import { IAggConfigs } from './legacy_imports'; import { Vis } from '../../visualizations/public'; export interface VisOptionsProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts index fcb06f73513b04..3ff212c43e6e84 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { IndexPattern } from 'src/plugins/data/public'; -import { IAggType, IAggConfig, aggTypeFilters, propFilter } from './legacy_imports'; +import { IAggType, IAggConfig, IndexPattern, search } from '../../../../plugins/data/public'; +const { aggTypeFilters, propFilter } = search.aggs; const filterByName = propFilter('name'); /** diff --git a/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts index b769030a04fb11..cd7a8e740d85d8 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts @@ -18,4 +18,3 @@ */ export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -export { AggGroupNames, Schemas } from 'ui/agg_types'; diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts index 3bddc94929cf57..22c32895d68035 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts @@ -23,21 +23,8 @@ import { functionWrapper } from '../../../../plugins/expressions/common/expressi jest.mock('ui/new_platform'); -jest.mock('../../vis_default_editor/public/legacy_imports', () => ({ - propFilter: jest.fn(), - AggGroupNames: { - Buckets: 'buckets', - Metrics: 'metrics', - }, - aggTypeFilters: { - addFilter: jest.fn(), - }, - BUCKET_TYPES: { - DATE_HISTOGRAM: 'date_histogram', - }, - METRIC_TYPES: { - TOP_HITS: 'top_hits', - }, +jest.mock('../../vis_default_editor/public', () => ({ + Schemas: class {}, })); describe('interpreter/functions#metric', () => { diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts index 5813465cc3f00a..cce5864aa50a1f 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts @@ -36,21 +36,8 @@ import { createMetricVisTypeDefinition } from './metric_vis_type'; jest.mock('ui/new_platform'); -jest.mock('../../vis_default_editor/public/legacy_imports', () => ({ - propFilter: jest.fn(), - AggGroupNames: { - Buckets: 'buckets', - Metrics: 'metrics', - }, - aggTypeFilters: { - addFilter: jest.fn(), - }, - BUCKET_TYPES: { - DATE_HISTOGRAM: 'date_histogram', - }, - METRIC_TYPES: { - TOP_HITS: 'top_hits', - }, +jest.mock('../../vis_default_editor/public', () => ({ + Schemas: class {}, })); describe('metric_vis - createMetricVisTypeDefinition', () => { diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts index 0b8d9b17659f4b..f29164f7e540d1 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts @@ -22,8 +22,9 @@ import { i18n } from '@kbn/i18n'; import { MetricVisComponent } from './components/metric_vis_component'; import { MetricVisOptions } from './components/metric_vis_options'; import { ColorModes } from '../../vis_type_vislib/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; import { ColorSchemas, colorSchemas } from '../../../../plugins/charts/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; export const createMetricVisTypeDefinition = () => ({ name: 'metric', diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js index 91581923b05cb2..8edef2ea163537 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js @@ -27,7 +27,8 @@ import { oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative, } from 'fixtures/fake_hierarchical_data'; import sinon from 'sinon'; -import { tabifyAggResponse, npStart } from '../../legacy_imports'; +import { npStart } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { round } from 'lodash'; import { tableVisTypeDefinition } from '../../table_vis_type'; @@ -39,6 +40,8 @@ import { getAngularModule } from '../../get_inner_angular'; import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; import { tableVisResponseHandler } from '../../table_vis_response_handler'; +const { tabifyAggResponse } = search; + describe('Table Vis - AggTable Directive', function() { let $rootScope; let $compile; diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js index 4d62551dcf3961..89900d2144030c 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js @@ -21,13 +21,16 @@ import $ from 'jquery'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data'; -import { tabifyAggResponse, npStart } from '../../legacy_imports'; +import { npStart } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { getAngularModule } from '../../get_inner_angular'; import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; import { tableVisResponseHandler } from '../../table_vis_response_handler'; import { start as visualizationsStart } from '../../../../visualizations/public/np_ready/public/legacy'; +const { tabifyAggResponse } = search; + describe('Table Vis - AggTableGroup Directive', function() { let $rootScope; let $compile; diff --git a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx index 8cc0ca24568673..30a95262731668 100644 --- a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx +++ b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx @@ -24,11 +24,13 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { VisOptionsProps } from 'src/legacy/core_plugins/vis_default_editor/public'; -import { tabifyGetColumns } from '../legacy_imports'; +import { search } from '../../../../../plugins/data/public'; import { NumberInputOption, SwitchOption, SelectOption } from '../../../vis_type_vislib/public'; import { TableVisParams } from '../types'; import { totalAggregations } from './utils'; +const { tabifyGetColumns } = search; + function TableOptions({ aggs, stateParams, diff --git a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts b/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts index 6fb5658d8e8151..6208e358b4184f 100644 --- a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts +++ b/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts @@ -25,14 +25,14 @@ import 'angular-recursion'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; import { - PrivateProvider, + initAngularBootstrap, PaginateDirectiveProvider, PaginateControlsDirectiveProvider, + PrivateProvider, watchMultiDecorator, KbnAccessibleClickProvider, configureAppAngularModule, -} from './legacy_imports'; -import { initAngularBootstrap } from '../../../../plugins/kibana_legacy/public'; +} from '../../../../plugins/kibana_legacy/public'; initAngularBootstrap(); diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts index 7b584f8069338e..287b6c172ffd94 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts @@ -19,16 +19,3 @@ export { npSetup, npStart } from 'ui/new_platform'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -export { IAggConfig, AggGroupNames, Schemas } from 'ui/agg_types'; -// @ts-ignore -export { PaginateDirectiveProvider } from 'ui/directives/paginate'; -// @ts-ignore -export { PaginateControlsDirectiveProvider } from 'ui/directives/paginate'; -import { search } from '../../../../plugins/data/public'; -export const { tabifyAggResponse, tabifyGetColumns } = search; -export { - configureAppAngularModule, - KbnAccessibleClickProvider, - PrivateProvider, - watchMultiDecorator, -} from '../../../../plugins/kibana_legacy/public'; diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts index 6d4e94c6292a65..327a47093f535c 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts +++ b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts @@ -34,8 +34,13 @@ import { stubFields } from '../../../../plugins/data/public/stubs'; import { tableVisResponseHandler } from './table_vis_response_handler'; import { coreMock } from '../../../../core/public/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { createAggConfigs } from 'ui/agg_types'; -import { tabifyAggResponse, IAggConfig } from './legacy_imports'; +import { npStart } from './legacy_imports'; +import { IAggConfig, search } from '../../../../plugins/data/public'; + +// should be mocked once get rid of 'ui/new_platform' legacy imports +const { createAggConfigs } = npStart.plugins.data.search.aggs; + +const { tabifyAggResponse } = search; jest.mock('ui/new_platform'); jest.mock('../../../../plugins/kibana_legacy/public/angular/angular_config', () => ({ diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts index 970bf1ba7ce644..e70b09904253f2 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts +++ b/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts @@ -18,7 +18,8 @@ */ import { i18n } from '@kbn/i18n'; -import { AggGroupNames, Schemas } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Vis } from '../../visualizations/public'; import { tableVisResponseHandler } from './table_vis_response_handler'; // @ts-ignore diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts index 0d76bc5d8b68b0..cd7a8e740d85d8 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts @@ -17,5 +17,4 @@ * under the License. */ -export { Schemas } from 'ui/agg_types'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts b/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts index 34d15287169c0b..9a522fe6e648e0 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; -import { Schemas } from './legacy_imports'; +import { Schemas } from '../../vis_default_editor/public'; import { Status } from '../../visualizations/public'; import { TagCloudOptions } from './components/tag_cloud_options'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/area_decorator.test.js.snap b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/area_decorator.test.js.snap index 56504ca11ca397..6506b838ff2884 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/area_decorator.test.js.snap +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/area_decorator.test.js.snap @@ -22,12 +22,8 @@ exports[`src/legacy/core_plugins/metrics/public/visualizations/views/timeseries/ }, } } + color="rgb(0, 156, 224)" curve={9} - customSeriesColors={ - Array [ - "rgb(0, 156, 224)", - ] - } data={ Array [ Array [ diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/bar_decorator.test.js.snap b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/bar_decorator.test.js.snap index 6317973cef536f..c337c0dc77a2fe 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/bar_decorator.test.js.snap +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/__snapshots__/bar_decorator.test.js.snap @@ -15,11 +15,7 @@ exports[`src/legacy/core_plugins/metrics/public/visualizations/views/timeseries/ }, } } - customSeriesColors={ - Array [ - "rgb(0, 156, 224)", - ] - } + color="rgb(0, 156, 224)" data={ Array [ Array [ diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/area_decorator.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/area_decorator.js index 411c0813cad7ce..923024ff690a43 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/area_decorator.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/area_decorator.js @@ -43,7 +43,6 @@ export function AreaSeriesDecorator({ }) { const id = seriesId; const groupId = seriesGroupId; - const customSeriesColors = [color]; const areaSeriesStyle = getAreaStyles({ points, lines, color }); const seriesSettings = { @@ -51,7 +50,7 @@ export function AreaSeriesDecorator({ name, groupId, data, - customSeriesColors, + color, hideInLegend, xAccessor: X_ACCESSOR_INDEX, yAccessors: Y_ACCESSOR_INDEXES, diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/bar_decorator.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/bar_decorator.js index 9cc8931b48d9f1..6d2cd7b8dd9356 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/bar_decorator.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/decorators/bar_decorator.js @@ -42,7 +42,6 @@ export function BarSeriesDecorator({ }) { const id = seriesId; const groupId = seriesGroupId; - const customSeriesColors = [color]; const barSeriesStyle = getBarStyles(bars, color); const seriesSettings = { @@ -50,7 +49,7 @@ export function BarSeriesDecorator({ name, groupId, data, - customSeriesColors, + color, hideInLegend, xAccessor: X_ACCESSOR_INDEX, yAccessors: Y_ACCESSOR_INDEXES, diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/index.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/index.js index 75554a476bdea1..5673f560214c7d 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/index.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/index.js @@ -99,6 +99,7 @@ export const TimeSeries = ({ @@ -226,6 +227,7 @@ exports[`ValueAxesPanel component should init with the default set of props 1`] diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/__snapshots__/value_axis_options.test.tsx.snap b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/__snapshots__/value_axis_options.test.tsx.snap index 00e1b1cce5ea89..b89d193c7c751e 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/__snapshots__/value_axis_options.test.tsx.snap +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/__snapshots__/value_axis_options.test.tsx.snap @@ -118,6 +118,7 @@ exports[`ValueAxisOptions component should init with the default set of props 1` /> ({ SeriesPanel: () => 'SeriesPanel', })); diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx index 82b64e4185ed22..a6f4a967d9c760 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx @@ -21,7 +21,7 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { cloneDeep, uniq, get } from 'lodash'; import { EuiSpacer } from '@elastic/eui'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { BasicVislibParams, ValueAxis, SeriesParam, Axis } from '../../../types'; import { ValidationVisOptionsProps } from '../../common'; import { SeriesPanel } from './series_panel'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts b/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts index c78925d5316b0b..4610bd37db5f1a 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts @@ -19,8 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { RangeValues } from '../../vis_default_editor/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { RangeValues, Schemas } from '../../vis_default_editor/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; import { GaugeOptions } from './components/options'; import { getGaugeCollections, Alignments, ColorModes, GaugeTypes } from './utils/collections'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/goal.ts b/src/legacy/core_plugins/vis_type_vislib/public/goal.ts index d2fdb9543d8272..c918128d01f110 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/goal.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/goal.ts @@ -19,12 +19,13 @@ import { i18n } from '@kbn/i18n'; -import { Schemas, AggGroupNames } from './legacy_imports'; import { GaugeOptions } from './components/options'; import { getGaugeCollections, GaugeTypes, ColorModes } from './utils/collections'; import { createVislibVisController } from './vis_controller'; import { VisTypeVislibDependencies } from './plugin'; import { ColorSchemas } from '../../../../plugins/charts/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; export const createGoalVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({ name: 'goal', diff --git a/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts b/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts index c8ce335f09e788..39a583f3c96411 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts @@ -19,8 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { RangeValues } from '../../vis_default_editor/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { RangeValues, Schemas } from '../../vis_default_editor/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; import { AxisTypes, getHeatmapCollections, Positions, ScaleTypes } from './utils/collections'; import { HeatmapOptions } from './components/options'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts b/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts index 7b9b008481c409..15ef369e5150e2 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts @@ -23,8 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; - +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts b/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts index eca26b4f55f603..8b5811628855c8 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts @@ -23,8 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; - +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts index 343fda44340d11..2b177bff98d565 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts @@ -19,7 +19,6 @@ import { npStart } from 'ui/new_platform'; export const { createFiltersFromEvent } = npStart.plugins.data.actions; -export { AggType, AggGroupNames, IAggConfig, IAggType, Schemas } from 'ui/agg_types'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; import { search } from '../../../../plugins/data/public'; export const { tabifyAggResponse, tabifyGetColumns } = search; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/line.ts b/src/legacy/core_plugins/vis_type_vislib/public/line.ts index 7aaad52ed8841d..ac4cda869fe295 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/line.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/line.ts @@ -23,7 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/pie.ts b/src/legacy/core_plugins/vis_type_vislib/public/pie.ts index b56dba659ffc80..0f1bd93f5b5bd5 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/pie.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/pie.ts @@ -19,7 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { PieOptions } from './components/options'; import { getPositions, Positions } from './utils/collections'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/server/status/constants.js b/src/legacy/server/status/constants.js index d16e46008acc8f..3bb23749bae874 100644 --- a/src/legacy/server/status/constants.js +++ b/src/legacy/server/status/constants.js @@ -17,4 +17,4 @@ * under the License. */ -export const KIBANA_STATS_TYPE = 'kibana_stats'; // kibana stats per 5s intervals +export const KIBANA_STATS_TYPE = 'oss_kibana_stats'; // kibana stats per 5s intervals diff --git a/src/legacy/ui/public/agg_types/index.ts b/src/legacy/ui/public/agg_types/index.ts deleted file mode 100644 index 75c2cd43178726..00000000000000 --- a/src/legacy/ui/public/agg_types/index.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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. - */ - -/** - * Nothing to see here! - * - * Agg Types have moved to the new platform, and are being - * re-exported from ui/agg_types for backwards compatibility. - */ - -import { npStart } from 'ui/new_platform'; - -// runtime contracts -const { types } = npStart.plugins.data.search.aggs; -export const aggTypes = types.getAll(); -export const { createAggConfigs } = npStart.plugins.data.search.aggs; -export const { - AggConfig, - AggType, - aggTypeFieldFilters, - FieldParamType, - MetricAggType, - parentPipelineAggHelper, - siblingPipelineAggHelper, -} = npStart.plugins.data.search.__LEGACY; - -// types -export { - AggGroupNames, - AggParam, - AggParamOption, - AggParamType, - AggTypeFieldFilters, - AggTypeFilters, - BUCKET_TYPES, - DateRangeKey, - IAggConfig, - IAggConfigs, - IAggGroupNames, - IAggType, - IFieldParamType, - IMetricAggType, - IpRangeKey, - METRIC_TYPES, - OptionedParamEditorProps, - OptionedParamType, - OptionedValueProp, -} from '../../../../plugins/data/public'; - -// static code -import { search } from '../../../../plugins/data/public'; -export const { - aggGroupNamesMap, - aggTypeFilters, - CidrMask, - convertDateRangeToString, - convertIPRangeToString, - intervalOptions, - isDateHistogramBucketAggConfig, - isStringType, - isType, - isValidInterval, - parentPipelineType, - propFilter, - siblingPipelineType, - termsAggFilter, -} = search.aggs; - -export { ISchemas, Schemas, Schema } from '../../../core_plugins/vis_default_editor/public/schemas'; diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx b/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx index 39312c9340ff9e..97abdcb10016d3 100644 --- a/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx +++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.tsx @@ -19,14 +19,7 @@ import React, { Component } from 'react'; import { Subscription } from 'rxjs'; -import { - Comparators, - EuiFlexGroup, - EuiFlexItem, - EuiSpacer, - // @ts-ignore - Query, -} from '@elastic/eui'; +import { Comparators, EuiFlexGroup, EuiFlexItem, EuiSpacer, Query } from '@elastic/eui'; import { useParams } from 'react-router-dom'; import { CallOuts } from './components/call_outs'; @@ -38,7 +31,7 @@ import { ComponentRegistry } from '../'; import { getAriaName, toEditableConfig, DEFAULT_CATEGORY } from './lib'; -import { FieldSetting, IQuery, SettingsChanges } from './types'; +import { FieldSetting, SettingsChanges } from './types'; interface AdvancedSettingsProps { enableSaving: boolean; @@ -54,7 +47,7 @@ interface AdvancedSettingsComponentProps extends AdvancedSettingsProps { interface AdvancedSettingsState { footerQueryMatched: boolean; - query: IQuery; + query: Query; filteredSettings: Record; } @@ -156,7 +149,7 @@ export class AdvancedSettingsComponent extends Component< }, {}); } - onQueryChange = ({ query }: { query: IQuery }) => { + onQueryChange = ({ query }: { query: Query }) => { this.setState({ query, filteredSettings: this.mapSettings(Query.execute(query, this.settings)), diff --git a/src/plugins/advanced_settings/public/management_app/components/search/search.tsx b/src/plugins/advanced_settings/public/management_app/components/search/search.tsx index 51402296a44a22..74e4894a27a6dd 100644 --- a/src/plugins/advanced_settings/public/management_app/components/search/search.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/search/search.tsx @@ -19,19 +19,14 @@ import React, { Fragment, PureComponent } from 'react'; import { i18n } from '@kbn/i18n'; -import { - // @ts-ignore - EuiSearchBar, - EuiFormErrorText, -} from '@elastic/eui'; -import { IQuery } from '../../types'; +import { EuiSearchBar, EuiFormErrorText, Query } from '@elastic/eui'; import { getCategoryName } from '../../lib'; interface SearchProps { categories: string[]; - query: IQuery; - onQueryChange: ({ query }: { query: IQuery }) => void; + query: Query; + onQueryChange: ({ query }: { query: Query }) => void; } export class Search extends PureComponent { @@ -53,7 +48,7 @@ export class Search extends PureComponent { parseErrorMessage: null, }; - onChange = ({ query, error }: { query: IQuery; error: { message: string } }) => { + onChange = ({ query, error }: { query: Query | null; error: { message: string } | null }) => { if (error) { this.setState({ isSearchTextValid: false, @@ -66,7 +61,7 @@ export class Search extends PureComponent { isSearchTextValid: true, parseErrorMessage: null, }); - this.props.onQueryChange({ query }); + this.props.onQueryChange({ query: query! }); }; render() { @@ -82,12 +77,12 @@ export class Search extends PureComponent { const filters = [ { - type: 'field_value_selection', + type: 'field_value_selection' as const, field: 'category', name: i18n.translate('advancedSettings.categorySearchLabel', { defaultMessage: 'Category', }), - multiSelect: 'or', + multiSelect: 'or' as const, options: this.categories, }, ]; diff --git a/src/plugins/advanced_settings/public/management_app/types.ts b/src/plugins/advanced_settings/public/management_app/types.ts index ee9b9b0535b794..6e243926f7d7dc 100644 --- a/src/plugins/advanced_settings/public/management_app/types.ts +++ b/src/plugins/advanced_settings/public/management_app/types.ts @@ -54,9 +54,3 @@ export interface FieldState { isInvalid?: boolean; error?: string | null; } - -export interface IQuery { - ast: any; // incomplete - text: string; - syntax: any; // incomplete -} diff --git a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx index 170024c192e7f1..cf62de82bcf4b3 100644 --- a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -22,6 +22,7 @@ import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; import { parse } from 'query-string'; import React, { CSSProperties, useCallback, useEffect, useRef, useState } from 'react'; +import { useUIAceKeyboardMode } from '../../../../../../../es_ui_shared/public'; // @ts-ignore import mappings from '../../../../../lib/mappings/mappings'; import { ConsoleMenu } from '../../../../components'; @@ -34,7 +35,6 @@ import { import * as senseEditor from '../../../../models/sense_editor'; import { autoIndent, getDocumentation } from '../console_menu_actions'; import { subscribeResizeChecker } from '../subscribe_console_resize_checker'; -import { useUIAceKeyboardMode } from '../use_ui_ace_keyboard_mode'; import { applyCurrentSettings } from './apply_editor_settings'; import { registerCommands } from './keyboard_shortcuts'; diff --git a/src/plugins/data/common/field_formats/utils/serialize.ts b/src/plugins/data/common/field_formats/utils/serialize.ts index 9931f55c30a9e2..1092c90d19451a 100644 --- a/src/plugins/data/common/field_formats/utils/serialize.ts +++ b/src/plugins/data/common/field_formats/utils/serialize.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../../../../../legacy/ui/public/agg_types'; +import { IAggConfig } from 'src/plugins/data/public'; import { SerializedFieldFormat } from '../../../../expressions/common/types'; export const serializeFieldFormat = (agg: IAggConfig): SerializedFieldFormat => { diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 07d8d302bc18cc..dad3a8e639bc5c 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -513,7 +513,7 @@ export interface Filter { // Warning: (ae-missing-release-tag) "FilterBar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const FilterBar: React.ComponentClass, any> & { +export const FilterBar: React.ComponentClass, any> & { WrappedComponent: React.ComponentType; }; @@ -1322,7 +1322,7 @@ export interface QueryState { // Warning: (ae-missing-release-tag) "QueryStringInput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const QueryStringInput: React.FC>; +export const QueryStringInput: React.FC>; // @public (undocumented) export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField; @@ -1531,8 +1531,8 @@ export const search: { // Warning: (ae-missing-release-tag) "SearchBar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "onQueryChange" | "customSubmitButton" | "screenTitle" | "dataTestSubj" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "refreshInterval" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +export const SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "indexPatterns" | "refreshInterval" | "screenTitle" | "dataTestSubj" | "customSubmitButton" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; }; // Warning: (ae-forgotten-export) The symbol "SearchBarOwnProps" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 8ed01b9b61c7e2..5935c7cc38d035 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -29,3 +29,5 @@ export { } from './request/np_ready_request'; export { indices } from './indices'; + +export { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; diff --git a/src/plugins/console/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx b/src/plugins/es_ui_shared/public/use_ui_ace_keyboard_mode.tsx similarity index 99% rename from src/plugins/console/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx rename to src/plugins/es_ui_shared/public/use_ui_ace_keyboard_mode.tsx index ca74b19b76f161..a93906d50b64af 100644 --- a/src/plugins/console/public/application/containers/editor/legacy/use_ui_ace_keyboard_mode.tsx +++ b/src/plugins/es_ui_shared/public/use_ui_ace_keyboard_mode.tsx @@ -96,7 +96,7 @@ export function useUIAceKeyboardMode(aceTextAreaElement: HTMLTextAreaElement | n } return () => { if (aceTextAreaElement) { - document.removeEventListener('keydown', documentKeyDownListener); + document.removeEventListener('keydown', documentKeyDownListener, { capture: true }); aceTextAreaElement.removeEventListener('keydown', aceKeydownListener); const textAreaContainer = aceTextAreaElement.parentElement; if (textAreaContainer && textAreaContainer.contains(overlayMountNode.current!)) { diff --git a/src/plugins/kibana_legacy/public/angular/angular_config.tsx b/src/plugins/kibana_legacy/public/angular/angular_config.tsx index 67d62cab7409bf..71cd57ef2d72ec 100644 --- a/src/plugins/kibana_legacy/public/angular/angular_config.tsx +++ b/src/plugins/kibana_legacy/public/angular/angular_config.tsx @@ -226,7 +226,7 @@ const $setupUICapabilityRedirect = (newPlatform: CoreStart) => ( } if (!get(newPlatform.application.capabilities, route.requireUICapability)) { - $injector.get('kbnUrl').change('/home'); + $injector.get('$location').url('/home'); event.preventDefault(); } } diff --git a/src/plugins/kibana_legacy/public/index.ts b/src/plugins/kibana_legacy/public/index.ts index 18f01854de2599..75e81b05057470 100644 --- a/src/plugins/kibana_legacy/public/index.ts +++ b/src/plugins/kibana_legacy/public/index.ts @@ -27,6 +27,7 @@ export * from './plugin'; export { kbnBaseUrl } from '../common/kbn_base_url'; export { initAngularBootstrap } from './angular_bootstrap'; +export { PaginateDirectiveProvider, PaginateControlsDirectiveProvider } from './paginate/paginate'; export * from './angular'; export * from './notify'; export * from './utils'; diff --git a/src/plugins/kibana_legacy/public/paginate/paginate.d.ts b/src/plugins/kibana_legacy/public/paginate/paginate.d.ts new file mode 100644 index 00000000000000..a40b869b2ccbb6 --- /dev/null +++ b/src/plugins/kibana_legacy/public/paginate/paginate.d.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + +export function PaginateDirectiveProvider($parse: any, $compile: any): any; +export function PaginateControlsDirectiveProvider(): any; diff --git a/src/legacy/ui/public/directives/paginate.js b/src/plugins/kibana_legacy/public/paginate/paginate.js similarity index 93% rename from src/legacy/ui/public/directives/paginate.js rename to src/plugins/kibana_legacy/public/paginate/paginate.js index 802aaaf4537519..f7e623cdabd86d 100644 --- a/src/legacy/ui/public/directives/paginate.js +++ b/src/plugins/kibana_legacy/public/paginate/paginate.js @@ -19,8 +19,7 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; -import { uiModules } from '../modules'; -import paginateControlsTemplate from './partials/paginate_controls.html'; +import paginateControlsTemplate from './paginate_controls.html'; export function PaginateDirectiveProvider($parse, $compile) { return { @@ -61,12 +60,9 @@ export function PaginateDirectiveProvider($parse, $compile) { controller: function($scope, $document) { const self = this; const ALL = 0; - const allSizeTitle = i18n.translate( - 'common.ui.directives.paginate.size.allDropDownOptionLabel', - { - defaultMessage: 'All', - } - ); + const allSizeTitle = i18n.translate('kibana_legacy.paginate.size.allDropDownOptionLabel', { + defaultMessage: 'All', + }); self.sizeOptions = [ { title: '10', value: 10 }, @@ -229,8 +225,3 @@ export function PaginateControlsDirectiveProvider() { template: paginateControlsTemplate, }; } - -uiModules - .get('kibana') - .directive('paginate', PaginateDirectiveProvider) - .directive('paginateControls', PaginateControlsDirectiveProvider); diff --git a/src/legacy/ui/public/directives/partials/paginate_controls.html b/src/plugins/kibana_legacy/public/paginate/paginate_controls.html similarity index 96% rename from src/legacy/ui/public/directives/partials/paginate_controls.html rename to src/plugins/kibana_legacy/public/paginate/paginate_controls.html index c40021507c2339..a553bc22317203 100644 --- a/src/legacy/ui/public/directives/partials/paginate_controls.html +++ b/src/plugins/kibana_legacy/public/paginate/paginate_controls.html @@ -3,7 +3,7 @@ ng-if="linkToTop" ng-click="paginate.goToTop()" data-test-subj="paginateControlsLinkToTop" - i18n-id="common.ui.paginateControls.scrollTopButtonLabel" + i18n-id="kibana_legacy.paginate.controls.scrollTopButtonLabel" i18n-default-message="Scroll to top" > @@ -86,7 +86,7 @@
-
-
- - -
-
- -
-
-
-
- -`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar invalid date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with max date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with min date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with start and end date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with value 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx deleted file mode 100644 index 19004e6fdcc5ad..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeCalendar } from '..'; - -const startDate = moment.utc('2019-06-27'); -const endDate = moment.utc('2019-07-04'); - -storiesOf('renderers/TimeFilter/components/DatetimeCalendar', module) - .add('default', () => ( - - )) - .add('with value', () => ( - - )) - .add('with start and end date', () => ( - - )) - .add('with min date', () => ( - - )) - .add('with max date', () => ( - - )) - .add('invalid date', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss deleted file mode 100644 index 6133b9184d1c55..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss +++ /dev/null @@ -1,6 +0,0 @@ -.canvasDateTimeCal { - display: inline-grid; - height: 100%; - border: $euiBorderThin; - grid-template-rows: $euiSizeXL 1fr; -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx deleted file mode 100644 index 8c189682c959cd..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Moment } from 'moment'; -import { momentObj } from 'react-moment-proptypes'; -import { EuiDatePicker } from '@elastic/eui'; -import { DatetimeInput } from '../datetime_input'; - -export interface Props { - /** Selected date (Moment date object) */ - value?: Moment; - /** Function invoked when a date is selected from the datepicker */ - onSelect: (date: Moment | null) => void; - /** Function invoked when the date text input changes */ - onValueChange: (moment: Moment) => void; // Called with a moment - /** Start date of selected date range (Moment date object) */ - startDate?: Moment; - /** End date of selected date range (Moment date object) */ - endDate?: Moment; - /** Earliest selectable date (Moment date object) */ - minDate?: Moment; - /** Latest selectable date (Moment date object) */ - maxDate?: Moment; -} - -export const DatetimeCalendar: FunctionComponent = ({ - value, - onValueChange, - onSelect, - startDate, - endDate, - minDate, - maxDate, -}) => ( -
- - -
-); - -DatetimeCalendar.propTypes = { - value: PropTypes.oneOfType([momentObj, PropTypes.object]), // Handle both valid and invalid moment objects - onSelect: PropTypes.func.isRequired, - onValueChange: PropTypes.func.isRequired, // Called with a moment - startDate: momentObj, - endDate: momentObj, - minDate: momentObj, - maxDate: momentObj, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot deleted file mode 100644 index 1bda4b5246991b..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot +++ /dev/null @@ -1,67 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput default 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput invalid date 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput with date 1`] = ` -
-
- -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx deleted file mode 100644 index 060f04da88f99a..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeInput } from '..'; - -storiesOf('renderers/TimeFilter/components/DatetimeInput', module) - .add('default', () => ) - .add('with date', () => ( - - )) - .add('invalid date', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx deleted file mode 100644 index 32bdcde5ddda0b..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent, ChangeEvent } from 'react'; -import PropTypes from 'prop-types'; -import { EuiFieldText } from '@elastic/eui'; -import moment, { Moment } from 'moment'; - -export interface Props { - /** Selected string value of input */ - strValue: string; - /** Function invoked with string when input is changed */ - setStrValue: (value: string) => void; - /** Function invoked with moment when input is changed with valid datetime */ - setMoment: (value: Moment) => void; - /** Boolean denotes whether current input value is valid date */ - valid: boolean; - /** Function invoked with value validity when input is changed */ - setValid: (valid: boolean) => void; -} - -export const DatetimeInput: FunctionComponent = ({ - strValue, - setStrValue, - setMoment, - valid, - setValid, -}) => { - function check(e: ChangeEvent) { - const parsed = moment(e.target.value, 'YYYY-MM-DD HH:mm:ss', true); - if (parsed.isValid()) { - setMoment(parsed); - setValid(true); - } else { - setValid(false); - } - setStrValue(e.target.value); - } - - return ( - - ); -}; - -DatetimeInput.propTypes = { - setMoment: PropTypes.func, - strValue: PropTypes.string, - setStrValue: PropTypes.func, - valid: PropTypes.bool, - setValid: PropTypes.func, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts deleted file mode 100644 index ff0e52580b4212..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Moment } from 'moment'; -import { compose, withState, lifecycle } from 'recompose'; -import { DatetimeInput as Component, Props as ComponentProps } from './datetime_input'; - -export interface Props { - /** Input value (Moment date object) */ - moment?: Moment; - /** Function to invoke when the input changes */ - setMoment: (m: Moment) => void; -} - -export const DatetimeInput = compose( - withState('valid', 'setValid', () => true), - withState('strValue', 'setStrValue', ({ moment }) => - moment ? moment.format('YYYY-MM-DD HH:mm:ss') : '' - ), - lifecycle({ - componentDidUpdate(prevProps) { - const prevMoment = prevProps.moment; - - // If we don't have a current moment, do nothing - if (!this.props.moment) return; - - // If we previously had a moment and it's the same as the current moment, do nothing - if (prevMoment && prevMoment.isSame(this.props.moment)) { - return; - } - - // Set the string value of the current moment and mark as valid - this.props.setStrValue(this.props.moment.format('YYYY-MM-DD HH:mm:ss')); - this.props.setValid(true); - }, - }) -)(Component); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot deleted file mode 100644 index b3ec64fa55a079..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot +++ /dev/null @@ -1,249 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeQuickList with children 1`] = ` -
- - - - - - - - -
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeQuickList with start and end dates 1`] = ` -
- - - - - - - -
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx deleted file mode 100644 index 68ef3cf1300bc3..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { EuiButtonEmpty } from '@elastic/eui'; -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { DatetimeQuickList } from '..'; - -storiesOf('renderers/TimeFilter/components/DatetimeQuickList', module) - .add('with start and end dates', () => ( - - )) - .add('with children', () => ( - - Apply - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx deleted file mode 100644 index 9d5a3893dbcb87..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { ReactNode, FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { EuiButton, EuiButtonEmpty } from '@elastic/eui'; -import 'react-datetime/css/react-datetime.css'; -import { UnitStrings } from '../../../../../i18n/units'; - -const { quickRanges: strings } = UnitStrings; - -interface Props { - /** Initial start date string */ - from: string; - /** Initial end date string */ - to: string; - - /** Function invoked when a date range is clicked */ - onSelect: (from: string, to: string) => void; - - /** Nodes to display under the date range buttons */ - children?: ReactNode; -} - -const quickRanges = [ - { from: 'now/d', to: 'now', display: strings.getTodayLabel() }, - { from: 'now-24h', to: 'now', display: strings.getLast24HoursLabel() }, - { from: 'now-7d', to: 'now', display: strings.getLast7DaysLabel() }, - { from: 'now-14d', to: 'now', display: strings.getLast2WeeksLabel() }, - { from: 'now-30d', to: 'now', display: strings.getLast30DaysLabel() }, - { from: 'now-90d', to: 'now', display: strings.getLast90DaysLabel() }, - { from: 'now-1y', to: 'now', display: strings.getLast1YearLabel() }, -]; - -export const DatetimeQuickList: FunctionComponent = ({ from, to, onSelect, children }) => ( -
- {quickRanges.map((range, i) => - from === range.from && to === range.to ? ( - onSelect(range.from, range.to)}> - {range.display} - - ) : ( - onSelect(range.from, range.to)}> - {range.display} - - ) - )} - {children} -
-); - -DatetimeQuickList.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, - children: PropTypes.node, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot deleted file mode 100644 index 7bf08c3d6f24ee..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot +++ /dev/null @@ -1,122 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeRangeAbsolute default 1`] = ` -
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx deleted file mode 100644 index 01d2fe49e29e82..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeRangeAbsolute } from '..'; - -const startDate = moment.utc('2019-06-21'); -const endDate = moment.utc('2019-07-05'); - -storiesOf('renderers/TimeFilter/components/DatetimeRangeAbsolute', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss deleted file mode 100644 index 706bd90ad1edf0..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss +++ /dev/null @@ -1,7 +0,0 @@ -.canvasDateTimeRangeAbsolute { - display: flex; - - > div:not(:last-child) { - margin-right: $euiSizeS; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx deleted file mode 100644 index ddd755b4a12f4f..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Moment } from 'moment'; -import { momentObj } from 'react-moment-proptypes'; -import { DatetimeCalendar } from '../datetime_calendar'; - -interface Props { - /** Optional initial start date moment */ - from?: Moment; - /** Optional initial end date moment */ - to?: Moment; - - /** Function invoked when a date is selected from the datetime calendar */ - onSelect: (from?: Moment, to?: Moment) => void; -} - -export const DatetimeRangeAbsolute: FunctionComponent = ({ from, to, onSelect }) => ( -
-
- onSelect(val, to)} - onSelect={val => { - if (!val || !from) { - return; - } - - // sets the time to start of day if only the date was selected - if (from.format('hh:mm:ss a') === val.format('hh:mm:ss a')) { - onSelect(val.startOf('day'), to); - } else { - onSelect(val, to); - } - }} - /> -
-
- onSelect(from, val)} - onSelect={val => { - if (!val || !to) { - return; - } - - // set the time to end of day if only the date was selected - if (to.format('hh:mm:ss a') === val.format('hh:mm:ss a')) { - onSelect(from, val.endOf('day')); - } else { - onSelect(from, val); - } - }} - /> -
-
-); - -DatetimeRangeAbsolute.propTypes = { - from: momentObj, - to: momentObj, - onSelect: PropTypes.func.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx new file mode 100644 index 00000000000000..e2e9358bf99c6b --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { AdvancedSettings } from '../../../../public/lib/kibana_advanced_settings'; +import { TimeFilter as Component, Props } from './time_filter'; + +export const TimeFilter = (props: Props) => { + const customQuickRanges = (AdvancedSettings.get('timepicker:quickRanges') || []).map( + ({ from, to, display }: { from: string; to: string; display: string }) => ({ + start: from, + end: to, + label: display, + }) + ); + + const customDateFormat = AdvancedSettings.get('dateFormat'); + + return ( + + ); +}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot deleted file mode 100644 index 3730cfb5f4e5c4..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with absolute dates 1`] = ` - - ~ 5 months ago to ~ 4 months ago - -`; - -exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with relative dates 1`] = ` - - Last 7 days - -`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx deleted file mode 100644 index 951776f8a9558e..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { PrettyDuration } from '..'; - -storiesOf('renderers/TimeFilter/components/PrettyDuration', module) - .add('with relative dates', () => ) - .add('with absolute dates', () => ); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts deleted file mode 100644 index b713eb4d7cd5ea..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import dateMath from '@elastic/datemath'; -import moment, { Moment } from 'moment'; -import { quickRanges, QuickRange } from './quick_ranges'; -import { timeUnits, TimeUnit } from '../../../../../../common/lib/time_units'; - -const lookupByRange: { [key: string]: QuickRange } = {}; -quickRanges.forEach(frame => { - lookupByRange[`${frame.from} to ${frame.to}`] = frame; -}); - -function formatTime(time: string | Moment, roundUp = false) { - if (moment.isMoment(time)) { - return time.format('lll'); - } else { - if (time === 'now') { - return 'now'; - } else { - const tryParse = dateMath.parse(time, { roundUp }); - return moment.isMoment(tryParse) ? '~ ' + tryParse.fromNow() : time; - } - } -} - -function cantLookup(from: string, to: string) { - return `${formatTime(from)} to ${formatTime(to)}`; -} - -export function formatDuration(from: string, to: string) { - // If both parts are date math, try to look up a reasonable string - if (from && to && !moment.isMoment(from) && !moment.isMoment(to)) { - const tryLookup = lookupByRange[`${from.toString()} to ${to.toString()}`]; - if (tryLookup) { - return tryLookup.display; - } else { - const fromParts = from.toString().split('-'); - if (to.toString() === 'now' && fromParts[0] === 'now' && fromParts[1]) { - const rounded = fromParts[1].split('/'); - let text = `Last ${rounded[0]}`; - if (rounded[1]) { - const unit = rounded[1] as TimeUnit; - text = `${text} rounded to the ${timeUnits[unit]}`; - } - - return text; - } else { - return cantLookup(from, to); - } - } - // If at least one part is a moment, try to make pretty strings by parsing date math - } else { - return cantLookup(from, to); - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts deleted file mode 100644 index 1c436d3630b536..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UnitStrings } from '../../../../../../i18n/units'; - -export interface QuickRange { - /** Start date string of range */ - from: string; - /** Start date string of range */ - to: string; - /** Display name describing date range */ - display: string; -} - -const { quickRanges: strings } = UnitStrings; - -export const quickRanges: QuickRange[] = [ - { from: 'now/d', to: 'now/d', display: strings.getTodayLabel() }, - { from: 'now/w', to: 'now/w', display: strings.getThisWeekLabel() }, - { from: 'now/M', to: 'now/M', display: strings.getThisMonthLabel() }, - { from: 'now/y', to: 'now/y', display: strings.getThisYearLabel() }, - { from: 'now/d', to: 'now', display: strings.getTheDaySoFarLabel() }, - { from: 'now/w', to: 'now', display: strings.getWeekToDateLabel() }, - { from: 'now/M', to: 'now', display: strings.getMonthToDateLabel() }, - { from: 'now/y', to: 'now', display: strings.getYearToDateLabel() }, - - { from: 'now-1d/d', to: 'now-1d/d', display: strings.getYesterdayLabel() }, - { from: 'now-2d/d', to: 'now-2d/d', display: strings.getDayBeforeYesterdayLabel() }, - { from: 'now-7d/d', to: 'now-7d/d', display: strings.getThisDayLastWeek() }, - { from: 'now-1w/w', to: 'now-1w/w', display: strings.getPreviousWeekLabel() }, - { from: 'now-1M/M', to: 'now-1M/M', display: strings.getPreviousMonthLabel() }, - { from: 'now-1y/y', to: 'now-1y/y', display: strings.getPreviousYearLabel() }, - - { from: 'now-15m', to: 'now', display: strings.getLast15MinutesLabel() }, - { from: 'now-30m', to: 'now', display: strings.getLast30MinutesLabel() }, - { from: 'now-1h', to: 'now', display: strings.getLast1HourLabel() }, - { from: 'now-4h', to: 'now', display: strings.getLast4HoursLabel() }, - { from: 'now-12h', to: 'now', display: strings.getLast12HoursLabel() }, - { from: 'now-24h', to: 'now', display: strings.getLast24HoursLabel() }, - { from: 'now-7d', to: 'now', display: strings.getLast7DaysLabel() }, - { from: 'now-14d', to: 'now', display: strings.getLast2WeeksLabel() }, - - { from: 'now-30d', to: 'now', display: strings.getLast30DaysLabel() }, - { from: 'now-60d', to: 'now', display: strings.getLast60DaysLabel() }, - { from: 'now-90d', to: 'now', display: strings.getLast90DaysLabel() }, - { from: 'now-6M', to: 'now', display: strings.getLast6MonthsLabel() }, - { from: 'now-1y', to: 'now', display: strings.getLast1YearLabel() }, - { from: 'now-2y', to: 'now', display: strings.getLast2YearsLabel() }, - { from: 'now-5y', to: 'now', display: strings.getLast5YearsLabel() }, -]; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx deleted file mode 100644 index f1b65c586ff0c8..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { formatDuration } from './lib/format_duration'; - -interface Props { - /** Initial start date string */ - from: string; - /** Initial end date string */ - to: string; -} - -export const PrettyDuration: FunctionComponent = ({ from, to }) => ( - {formatDuration(from, to)} -); - -PrettyDuration.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx new file mode 100644 index 00000000000000..8d28287b320667 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx @@ -0,0 +1,87 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { EuiSuperDatePicker, OnTimeChangeProps, EuiSuperDatePickerCommonRange } from '@elastic/eui'; +import React from 'react'; +import PropTypes from 'prop-types'; +import { get } from 'lodash'; +import { fromExpression } from '@kbn/interpreter/common'; +import { UnitStrings } from '../../../../i18n/units'; + +const { quickRanges: strings } = UnitStrings; + +const defaultQuickRanges: EuiSuperDatePickerCommonRange[] = [ + { start: 'now-1d/d', end: 'now-1d/d', label: strings.getYesterdayLabel() }, + { start: 'now/d', end: 'now', label: strings.getTodayLabel() }, + { start: 'now-24h', end: 'now', label: strings.getLast24HoursLabel() }, + { start: 'now-7d', end: 'now', label: strings.getLast7DaysLabel() }, + { start: 'now-14d', end: 'now', label: strings.getLast2WeeksLabel() }, + { start: 'now-30d', end: 'now', label: strings.getLast30DaysLabel() }, + { start: 'now-90d', end: 'now', label: strings.getLast90DaysLabel() }, + { start: 'now-1y', end: 'now', label: strings.getLast1YearLabel() }, +]; + +export interface FilterMeta { + /** Name of datetime column to be filtered */ + column: string; + /** Start date string of filtered date range */ + start: string; + /** End date string of filtered date range */ + end: string; +} + +function getFilterMeta(filter: string): FilterMeta { + const ast = fromExpression(filter); + const column = get(ast, 'chain[0].arguments.column[0]'); + const start = get(ast, 'chain[0].arguments.from[0]'); + const end = get(ast, 'chain[0].arguments.to[0]'); + return { column, start, end }; +} + +export interface Props { + /** Initial value of the filter */ + filter: string; + /** Function invoked when the filter changes */ + commit: (filter: string) => void; + /** Elastic datemath format string */ + dateFormat?: string; + /** Array of time ranges */ + commonlyUsedRanges?: EuiSuperDatePickerCommonRange[]; +} + +export const TimeFilter = ({ filter, commit, dateFormat, commonlyUsedRanges = [] }: Props) => { + const setFilter = (column: string) => ({ start, end }: OnTimeChangeProps) => { + commit(`timefilter from="${start}" to=${end} column=${column}`); + }; + + const { column, start, end } = getFilterMeta(filter); + + return ( +
+ +
+ ); +}; + +TimeFilter.propTypes = { + filter: PropTypes.string.isRequired, + commit: PropTypes.func.isRequired, // Canvas filter + dateFormat: PropTypes.string, + commonlyUsedRanges: PropTypes.arrayOf( + PropTypes.shape({ + start: PropTypes.string.isRequired, + end: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + }) + ), +}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot deleted file mode 100644 index 9c070dded5810d..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot +++ /dev/null @@ -1,283 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter compact mode 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter default 1`] = ` -
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
- - - - - - - - -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx deleted file mode 100644 index b6b94bf3e4a05b..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { TimeFilter } from '..'; - -storiesOf('renderers/TimeFilter', module) - .add('default', () => ( - - )) - .add('compact mode', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts deleted file mode 100644 index cdea7d65915922..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimeFilter } from './time_filter'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx deleted file mode 100644 index cbe9793c806e19..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common'; -import { TimePicker } from '../time_picker'; -import { TimePickerPopover } from '../time_picker_popover'; - -export interface FilterMeta { - /** Name of datetime column to be filtered */ - column: string; - /** Start date string of filtered date range */ - from: string; - /** End date string of filtered date range */ - to: string; -} - -function getFilterMeta(filter: string): FilterMeta { - const ast = fromExpression(filter); - const column = get(ast, 'chain[0].arguments.column[0]'); - const from = get(ast, 'chain[0].arguments.from[0]'); - const to = get(ast, 'chain[0].arguments.to[0]'); - return { column, from, to }; -} - -export interface Props { - /** Initial value of the filter */ - filter: string; - /** Function invoked when the filter changes */ - commit: (filter: string) => void; - /** Determines if compact or full-sized time picker is displayed */ - compact?: boolean; -} - -export const TimeFilter = ({ filter, commit, compact }: Props) => { - const setFilter = (column: string) => (from: string, to: string) => { - commit(`timefilter from="${from}" to=${to} column=${column}`); - }; - - const { column, from, to } = getFilterMeta(filter); - - if (compact) { - return ; - } else { - return ; - } -}; - -TimeFilter.propTypes = { - filter: PropTypes.string.isRequired, - commit: PropTypes.func.isRequired, // Canvas filter - compact: PropTypes.bool, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot deleted file mode 100644 index 49ea8ccc5889e8..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot +++ /dev/null @@ -1,256 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/TimePicker default 1`] = ` -
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
- - - - - - - - -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx deleted file mode 100644 index e34d2d5f58561e..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { TimePicker } from '..'; - -const startDate = moment.utc('2018-04-04').toISOString(); -const endDate = moment.utc('2019-04-04').toISOString(); - -storiesOf('renderers/TimeFilter/components/TimePicker', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts deleted file mode 100644 index a220bd5eebc21a..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimePicker } from './time_picker'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss deleted file mode 100644 index 889db1fc8165dc..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss +++ /dev/null @@ -1,7 +0,0 @@ -.canvasTimePicker { - display: flex; - - > div:not(:last-child) { - margin-right: $euiSizeS; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx deleted file mode 100644 index 599b15524ddda0..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import dateMath from '@elastic/datemath'; -import { EuiButton } from '@elastic/eui'; -import moment from 'moment'; -import { DatetimeQuickList } from '../datetime_quick_list'; -import { DatetimeRangeAbsolute } from '../datetime_range_absolute'; -import { ComponentStrings } from '../../../../../i18n/components'; - -const { TimePicker: strings } = ComponentStrings; - -export interface Props { - /** Start date string */ - from: string; - /** End date string */ - to: string; - /** Function invoked when date range is changed */ - onSelect: (from: string, to: string) => void; -} - -export interface State { - range: { - /** Start date string of selected date range */ - from: string; - /** End date string of selected date range */ - to: string; - }; - /** Boolean denoting whether selected date range has been applied */ - isDirty: boolean; -} - -export class TimePicker extends Component { - static propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, - }; - - state = { - range: { from: this.props.from, to: this.props.to }, - isDirty: false, - }; - - componentDidUpdate(prevProps: Props) { - const { to, from } = this.props; - - if (prevProps.from !== from || prevProps.to !== to) { - this.setState({ - range: { from, to }, - isDirty: false, - }); - } - } - - _absoluteSelect = (from?: moment.Moment, to?: moment.Moment) => { - if (from && to) { - this.setState({ - range: { from: moment(from).toISOString(), to: moment(to).toISOString() }, - isDirty: true, - }); - } - }; - - render() { - const { onSelect } = this.props; - const { range, isDirty } = this.state; - const { from, to } = range; - - return ( -
- - - { - this.setState({ isDirty: false }); - onSelect(from, to); - }} - > - {strings.getApplyButtonLabel()} - - -
- ); - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot deleted file mode 100644 index 7e2474dbfb79cb..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/TimePickerPopover default 1`] = ` -
-
- -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx deleted file mode 100644 index 7555de1336b3e3..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { TimePickerPopover } from '..'; - -const startDate = moment.utc('2019-05-04').toISOString(); -const endDate = moment.utc('2019-06-04').toISOString(); - -storiesOf('renderers/TimeFilter/components/TimePickerPopover', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts deleted file mode 100644 index 482580ea2e3677..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimePickerPopover } from './time_picker_popover'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss deleted file mode 100644 index 1703c2c721dc08..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss +++ /dev/null @@ -1,19 +0,0 @@ -.canvasTimePickerPopover { - width: 100%; - - .canvasTimePickerPopover__button { - width: 100%; - padding: $euiSizeXS; - border: $euiBorderThin; - border-radius: $euiBorderRadius; - background-color: $euiColorEmptyShade; - - &:hover { - background-color: $euiColorLightestShade; - } - } - - .canvasTimePickerPopover__anchor { - width: 100%; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx deleted file mode 100644 index 8f6061b6883197..00000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent, MouseEvent } from 'react'; -import PropTypes from 'prop-types'; -// @ts-ignore untyped local -import { Popover } from '../../../../../public/components/popover'; -import { PrettyDuration } from '../pretty_duration'; -import { formatDuration } from '../pretty_duration/lib/format_duration'; -import { TimePicker } from '../time_picker'; - -export interface Props { - /** Start date string */ - from: string; - /** End date string */ - to: string; - /** Function invoked when date range is changed */ - onSelect: (from: string, to: string) => void; -} - -export const TimePickerPopover: FunctionComponent = ({ from, to, onSelect }) => { - const button = (handleClick: (event: MouseEvent) => void) => ( - - ); - - return ( - - {({ closePopover }) => ( - { - onSelect(...args); - closePopover(); - }} - /> - )} - - ); -}; - -TimePickerPopover.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js index 7fd6e81752b3c0..cbc514e218d743 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js @@ -9,7 +9,7 @@ import React from 'react'; import { toExpression } from '@kbn/interpreter/common'; import { syncFilterExpression } from '../../../public/lib/sync_filter_expression'; import { RendererStrings } from '../../../i18n'; -import { TimeFilter } from './components/time_filter'; +import { TimeFilter } from './components'; const { timeFilter: strings } = RendererStrings; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss new file mode 100644 index 00000000000000..442332697f3188 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss @@ -0,0 +1,11 @@ +.canvasTimeFilter .euiSuperDatePicker__flexWrapper { + width: 100%; + + &.euiFlexGroup--gutterSmall { + margin: 0; + + > .euiFlexItem { + margin: 0; + } + } +} \ No newline at end of file diff --git a/x-pack/legacy/plugins/canvas/i18n/units.ts b/x-pack/legacy/plugins/canvas/i18n/units.ts index 04b1fec9b1f8a7..a105031e7edf78 100644 --- a/x-pack/legacy/plugins/canvas/i18n/units.ts +++ b/x-pack/legacy/plugins/canvas/i18n/units.ts @@ -72,6 +72,10 @@ export const UnitStrings = { }), }, quickRanges: { + getYesterdayLabel: () => + i18n.translate('xpack.canvas.units.quickRange.yesterday', { + defaultMessage: 'Yesterday', + }), getTodayLabel: () => i18n.translate('xpack.canvas.units.quickRange.today', { defaultMessage: 'Today', @@ -100,93 +104,5 @@ export const UnitStrings = { i18n.translate('xpack.canvas.units.quickRange.last1Year', { defaultMessage: 'Last 1 year', }), - getThisWeekLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisWeek', { - defaultMessage: 'This week', - }), - getThisMonthLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisMonth', { - defaultMessage: 'This month', - }), - getThisYearLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisYear', { - defaultMessage: 'This year', - }), - getTheDaySoFarLabel: () => - i18n.translate('xpack.canvas.units.quickRange.theDaySoFar', { - defaultMessage: 'The day so far', - }), - getWeekToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.weekToDate', { - defaultMessage: 'Week to date', - }), - getMonthToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.monthToDate', { - defaultMessage: 'Month to date', - }), - getYearToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.yearToDate', { - defaultMessage: 'Year to date', - }), - getYesterdayLabel: () => - i18n.translate('xpack.canvas.units.quickRange.yesterday', { - defaultMessage: 'Yesterday', - }), - getDayBeforeYesterdayLabel: () => - i18n.translate('xpack.canvas.units.quickRange.dayBeforeYesterday', { - defaultMessage: 'Day before yesterday', - }), - getThisDayLastWeek: () => - i18n.translate('xpack.canvas.units.quickRange.thisDayLastWeek', { - defaultMessage: 'This day last week', - }), - getPreviousWeekLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousWeek', { - defaultMessage: 'Previous week', - }), - getPreviousMonthLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousMonth', { - defaultMessage: 'Previous month', - }), - getPreviousYearLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousYear', { - defaultMessage: 'Previous year', - }), - getLast15MinutesLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last15Minutes', { - defaultMessage: 'Last 15 minutes', - }), - getLast30MinutesLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last30Minutes', { - defaultMessage: 'Last 30 minutes', - }), - getLast1HourLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last1Hour', { - defaultMessage: 'Last 1 hour', - }), - getLast4HoursLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last4Hours', { - defaultMessage: 'Last 4 hours', - }), - getLast12HoursLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last12Hours', { - defaultMessage: 'Last 12 hours', - }), - getLast60DaysLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last60Days', { - defaultMessage: 'Last 60 days', - }), - getLast6MonthsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last6Months', { - defaultMessage: 'Last 6 months', - }), - getLast2YearsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last2Years', { - defaultMessage: 'Last 2 years', - }), - getLast5YearsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last5Years', { - defaultMessage: 'Last 5 years', - }), }, }; diff --git a/x-pack/legacy/plugins/canvas/public/components/custom_element_modal/__examples__/__snapshots__/custom_element_modal.examples.storyshot b/x-pack/legacy/plugins/canvas/public/components/custom_element_modal/__examples__/__snapshots__/custom_element_modal.examples.storyshot index 61ffc33cd9dde9..eb82d1b63fdc2a 100644 --- a/x-pack/legacy/plugins/canvas/public/components/custom_element_modal/__examples__/__snapshots__/custom_element_modal.examples.storyshot +++ b/x-pack/legacy/plugins/canvas/public/components/custom_element_modal/__examples__/__snapshots__/custom_element_modal.examples.storyshot @@ -193,6 +193,7 @@ Array [ >