diff --git a/.buildkite/scripts/build_kibana.sh b/.buildkite/scripts/build_kibana.sh index 7a9878b5bcd13..e26d7790215f3 100755 --- a/.buildkite/scripts/build_kibana.sh +++ b/.buildkite/scripts/build_kibana.sh @@ -5,7 +5,11 @@ set -euo pipefail export KBN_NP_PLUGINS_BUILT=true echo "--- Build Kibana Distribution" -node scripts/build --debug +if [[ "${GITHUB_PR_LABELS:-}" == *"ci:build-all-platforms"* ]]; then + node scripts/build --all-platforms --skip-os-packages +else + node scripts/build +fi echo "--- Archive Kibana Distribution" linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" diff --git a/.buildkite/scripts/post_build_kibana.sh b/.buildkite/scripts/post_build_kibana.sh index 2194414dd22d3..5f26c80ddb6b6 100755 --- a/.buildkite/scripts/post_build_kibana.sh +++ b/.buildkite/scripts/post_build_kibana.sh @@ -12,7 +12,6 @@ fi echo "--- Upload Build Artifacts" # Moving to `target/` first will keep `buildkite-agent` from including directories in the artifact name cd "$KIBANA_DIR/target" -mv kibana-*-linux-x86_64.tar.gz kibana-default.tar.gz -buildkite-agent artifact upload kibana-default.tar.gz -buildkite-agent artifact upload kibana-default-plugins.tar.gz +cp kibana-*-linux-x86_64.tar.gz kibana-default.tar.gz +buildkite-agent artifact upload "./*.tar.gz;./*.zip" cd - diff --git a/src/plugins/index_pattern_field_editor/__jest__/client_integration/field_editor_flyout_preview.test.ts b/src/plugins/index_pattern_field_editor/__jest__/client_integration/field_editor_flyout_preview.test.ts index 65089bc24317b..67309aab44a76 100644 --- a/src/plugins/index_pattern_field_editor/__jest__/client_integration/field_editor_flyout_preview.test.ts +++ b/src/plugins/index_pattern_field_editor/__jest__/client_integration/field_editor_flyout_preview.test.ts @@ -366,6 +366,7 @@ describe('Field editor Preview panel', () => { subTitle: 'First doc - subTitle', title: 'First doc - title', }, + documentId: '001', index: 'testIndex', script: { source: 'echo("hello")', diff --git a/src/plugins/index_pattern_field_editor/public/components/preview/field_preview_context.tsx b/src/plugins/index_pattern_field_editor/public/components/preview/field_preview_context.tsx index e49e0ef6885d0..21ab055c9b05e 100644 --- a/src/plugins/index_pattern_field_editor/public/components/preview/field_preview_context.tsx +++ b/src/plugins/index_pattern_field_editor/public/components/preview/field_preview_context.tsx @@ -335,6 +335,7 @@ export const FieldPreviewProvider: FunctionComponent = ({ children }) => { document: params.document!, context: `${params.type!}_field` as FieldPreviewContext, script: params.script!, + documentId: currentDocId, }); if (currentApiCall !== previewCount.current) { diff --git a/src/plugins/index_pattern_field_editor/public/lib/api.ts b/src/plugins/index_pattern_field_editor/public/lib/api.ts index 9325b5c2faf47..9641619640a52 100644 --- a/src/plugins/index_pattern_field_editor/public/lib/api.ts +++ b/src/plugins/index_pattern_field_editor/public/lib/api.ts @@ -16,11 +16,13 @@ export const initApi = (httpClient: HttpSetup) => { context, script, document, + documentId, }: { index: string; context: FieldPreviewContext; script: { source: string } | null; document: Record; + documentId: string; }) => { return sendRequest(httpClient, { path: `${API_BASE_PATH}/field_preview`, @@ -30,6 +32,7 @@ export const initApi = (httpClient: HttpSetup) => { context, script, document, + documentId, }, }); }; diff --git a/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts b/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts index 11ec1ca7d5666..847dd41e0082b 100644 --- a/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts +++ b/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ +import { estypes } from '@elastic/elasticsearch'; import { schema } from '@kbn/config-schema'; -import { HttpResponsePayload } from 'kibana/server'; import { API_BASE_PATH } from '../../common/constants'; import { RouteDependencies } from '../types'; @@ -26,6 +26,7 @@ const bodySchema = schema.object({ schema.literal('long_field'), ]), document: schema.object({}, { unknowns: 'allow' }), + documentId: schema.string(), }); export const registerFieldPreviewRoute = ({ router }: RouteDependencies): void => { @@ -39,30 +40,41 @@ export const registerFieldPreviewRoute = ({ router }: RouteDependencies): void = async (ctx, req, res) => { const { client } = ctx.core.elasticsearch; - const body = JSON.stringify({ - script: req.body.script, - context: req.body.context, - context_setup: { - document: req.body.document, - index: req.body.index, - } as any, - }); + const type = req.body.context.split('_field')[0] as estypes.MappingRuntimeFieldType; + const body = { + runtime_mappings: { + my_runtime_field: { + type, + script: req.body.script, + }, + }, + size: 1, + query: { + term: { + _id: req.body.documentId, + }, + }, + fields: ['my_runtime_field'], + }; try { - const response = await client.asCurrentUser.scriptsPainlessExecute({ - // @ts-expect-error `ExecutePainlessScriptRequest.body` does not allow `string` + const response = await client.asCurrentUser.search({ + index: req.body.index, body, }); - const fieldValue = response.body.result as any[] as HttpResponsePayload; + const fieldValue = response.body.hits.hits[0]?.fields?.my_runtime_field ?? ''; return res.ok({ body: { values: fieldValue } }); - } catch (error) { + } catch (error: any) { // Assume invalid painless script was submitted // Return 200 with error object const handleCustomError = () => { return res.ok({ - body: { values: [], ...error.body }, + body: { + values: [], + error: error.body.error.failed_shards[0]?.reason ?? {}, + }, }); }; diff --git a/test/api_integration/apis/index_pattern_field_editor/field_preview.ts b/test/api_integration/apis/index_pattern_field_editor/field_preview.ts index a84accc8e5f03..7123be1deb18a 100644 --- a/test/api_integration/apis/index_pattern_field_editor/field_preview.ts +++ b/test/api_integration/apis/index_pattern_field_editor/field_preview.ts @@ -12,11 +12,14 @@ import { FtrProviderContext } from '../../ftr_provider_context'; import { API_BASE_PATH } from './constants'; const INDEX_NAME = 'api-integration-test-field-preview'; +const DOC_ID = '1'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('es'); + const document = { foo: 1, bar: 'hello' }; + const createIndex = async () => { await es.indices.create({ index: INDEX_NAME, @@ -35,6 +38,15 @@ export default function ({ getService }: FtrProviderContext) { }); }; + const addDoc = async () => { + await es.index({ + index: INDEX_NAME, + id: DOC_ID, + body: document, + refresh: 'wait_for', + }); + }; + const deleteIndex = async () => { await es.indices.delete({ index: INDEX_NAME, @@ -42,12 +54,13 @@ export default function ({ getService }: FtrProviderContext) { }; describe('Field preview', function () { - before(async () => await createIndex()); + before(async () => { + await createIndex(); + await addDoc(); + }); after(async () => await deleteIndex()); describe('should return the script value', () => { - const document = { foo: 1, bar: 'hello' }; - const tests = [ { context: 'keyword_field', @@ -77,6 +90,7 @@ export default function ({ getService }: FtrProviderContext) { const payload = { script: test.script, document, + documentId: DOC_ID, context: test.context, index: INDEX_NAME, }; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion.tsx index 8e1e6487197f9..7539055253732 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion.tsx @@ -132,7 +132,7 @@ export const CurationSuggestion: React.FC = () => { result={result} isMetaEngine={isMetaEngine} schemaForTypeHighlights={engine.schema} - resultPosition={index + 1} + resultPosition={index + existingCurationResults.length + 1} /> ))} @@ -152,7 +152,7 @@ export const CurationSuggestion: React.FC = () => { result={result} isMetaEngine={isMetaEngine} schemaForTypeHighlights={engine.schema} - resultPosition={index + 1} + resultPosition={index + suggestedPromotedDocuments.length + 1} /> ))} diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx index b061ab5ea2d4d..590bfac96770d 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/fix_issues_step/fix_issues_step.tsx @@ -70,7 +70,7 @@ export const getFixIssuesStep = ({

diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecation_count.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecation_count.tsx index 3312508a87073..32d214f0d80f2 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecation_count.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/shared/deprecation_count.tsx @@ -6,10 +6,11 @@ */ import React, { FunctionComponent } from 'react'; - import { EuiFlexGroup, EuiFlexItem, EuiHealth } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { LevelInfoTip } from './level_info_tip'; + const i18nTexts = { getCriticalStatusLabel: (count: number) => i18n.translate('xpack.upgradeAssistant.deprecationCount.criticalStatusLabel', { @@ -39,14 +40,31 @@ export const DeprecationCount: FunctionComponent = ({ return ( - - {i18nTexts.getCriticalStatusLabel(totalCriticalDeprecations)} - + + + + {i18nTexts.getCriticalStatusLabel(totalCriticalDeprecations)} + + + + + + + + - - {i18nTexts.getWarningStatusLabel(totalWarningDeprecations)} - + + + + {i18nTexts.getWarningStatusLabel(totalWarningDeprecations)} + + + + + + + ); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts b/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts index ef7916f6e8d17..0efc91035001a 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts +++ b/x-pack/plugins/upgrade_assistant/public/application/components/shared/index.ts @@ -9,3 +9,4 @@ export { NoDeprecationsPrompt } from './no_deprecations'; export { DeprecationCount } from './deprecation_count'; export { DeprecationBadge } from './deprecation_badge'; export { DeprecationsPageLoadingError } from './deprecations_page_loading_error'; +export { LevelInfoTip } from './level_info_tip'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/shared/level_info_tip.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/shared/level_info_tip.tsx new file mode 100644 index 0000000000000..d3600a7290b4e --- /dev/null +++ b/x-pack/plugins/upgrade_assistant/public/application/components/shared/level_info_tip.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FunctionComponent } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiIconTip } from '@elastic/eui'; + +const i18nTexts = { + critical: i18n.translate('xpack.upgradeAssistant.levelInfoTip.criticalLabel', { + defaultMessage: 'Critical issues must be resolved before you upgrade', + }), + warning: i18n.translate('xpack.upgradeAssistant.levelInfoTip.warningLabel', { + defaultMessage: 'Warning issues can be ignored at your discretion', + }), +}; + +interface Props { + level: 'critical' | 'warning'; +} + +export const LevelInfoTip: FunctionComponent = ({ level }) => { + return ; +};