From da7c43c1dbfb5de687188b570af07f68f2229e26 Mon Sep 17 00:00:00 2001 From: Constance Date: Fri, 16 Jul 2021 16:25:55 -0700 Subject: [PATCH] [App Search] Fix bash API code example (#106015) * Fix bash/curl API code example not correctly having `\`s at the end of non-body lines - Doing this requires removing the `dedent()` fn which is messing up backslashes - Removing dedent requires setting the template literal indentation to 0 and changing the indent level on DOCUMENTS_API_JSON_EXAMPLE * I unindented DOCUMENTS_API_JSON_EXAMPLE too hard - the { is no longer lined up with the [ I think??? what am I even doing with my life --- .../document_creation/constants.tsx | 62 +++++++++---------- .../api_code_example.tsx | 35 +++++------ 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/constants.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/constants.tsx index c29bbc3b3a73..bd4dbfe8fa06 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/constants.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/constants.tsx @@ -36,34 +36,34 @@ export const DOCUMENT_CREATION_WARNINGS = { // This is indented the way it is to work with ApiCodeExample. // Use dedent() when calling this alone export const DOCUMENTS_API_JSON_EXAMPLE = `[ - { - "id": "park_rocky-mountain", - "title": "Rocky Mountain", - "description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).", - "nps_link": "https://www.nps.gov/romo/index.htm", - "states": [ - "Colorado" - ], - "visitors": 4517585, - "world_heritage_site": false, - "location": "40.4,-105.58", - "acres": 265795.2, - "square_km": 1075.6, - "date_established": "1915-01-26T06:00:00Z" - }, - { - "id": "park_saguaro", - "title": "Saguaro", - "description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.", - "nps_link": "https://www.nps.gov/sagu/index.htm", - "states": [ - "Arizona" - ], - "visitors": 820426, - "world_heritage_site": false, - "location": "32.25,-110.5", - "acres": 91715.72, - "square_km": 371.2, - "date_established": "1994-10-14T05:00:00Z" - } - ]`; + { + "id": "park_rocky-mountain", + "title": "Rocky Mountain", + "description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).", + "nps_link": "https://www.nps.gov/romo/index.htm", + "states": [ + "Colorado" + ], + "visitors": 4517585, + "world_heritage_site": false, + "location": "40.4,-105.58", + "acres": 265795.2, + "square_km": 1075.6, + "date_established": "1915-01-26T06:00:00Z" + }, + { + "id": "park_saguaro", + "title": "Saguaro", + "description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.", + "nps_link": "https://www.nps.gov/sagu/index.htm", + "states": [ + "Arizona" + ], + "visitors": 820426, + "world_heritage_site": false, + "location": "32.25,-110.5", + "acres": 91715.72, + "square_km": 371.2, + "date_established": "1994-10-14T05:00:00Z" + } + ]`; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.tsx index 079fd20e25af..e5f295f0368f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/creation_mode_components/api_code_example.tsx @@ -7,8 +7,6 @@ import React from 'react'; -import dedent from 'dedent'; - import { useValues, useActions } from 'kea'; import { @@ -107,23 +105,22 @@ export const FlyoutBody: React.FC = () => { - {dedent(` - curl -X POST '${documentsApiUrl}' - -H 'Content-Type: application/json' - -H 'Authorization: Bearer ${apiKey}' - -d '${DOCUMENTS_API_JSON_EXAMPLE}' - # Returns - # [ - # { - # "id": "park_rocky-mountain", - # "errors": [] - # }, - # { - # "id": "park_saguaro", - # "errors": [] - # } - # ] - `)} + {`\ +curl -X POST '${documentsApiUrl}' \\ + -H 'Content-Type: application/json' \\ + -H 'Authorization: Bearer ${apiKey}' \\ + -d '${DOCUMENTS_API_JSON_EXAMPLE}' +# Returns +# [ +# { +# "id": "park_rocky-mountain", +# "errors": [] +# }, +# { +# "id": "park_saguaro", +# "errors": [] +# } +# ]`} );