Skip to content

Commit

Permalink
Merge branch 'main' into move-structure-basic-detection_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
WafaaNasr authored Nov 22, 2023
2 parents f229f3b + 641983f commit 6db6a86
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 53 deletions.
6 changes: 3 additions & 3 deletions .buildkite/pull_requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
"repoName": "kibana",
"pipelineSlug": "kibana-kme-test",

"enabled": false,
"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["barlowm", "renovate[bot]"],
"set_commit_status": true,
"commit_status_context": "kibana-ci",
"commit_status_context": "kibana-ci-test",
"build_on_commit": true,
"build_on_comment": true,
"build_on_comment": false,
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"skip_ci_labels": [],
Expand Down
7 changes: 1 addition & 6 deletions .buildkite/scripts/steps/storybooks/build_and_upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const STORYBOOKS = [
'canvas',
'cases',
'cell_actions',
'ci_composite',
'cloud_chat',
'coloring',
'chart_icons',
Expand Down Expand Up @@ -93,14 +92,12 @@ const upload = () => {
console.log('--- Generating Storybooks HTML');

process.chdir(path.join('.', 'built_assets', 'storybook'));
fs.renameSync('ci_composite', 'composite');

const storybooks = execSync(`ls -1d */`)
.toString()
.trim()
.split('\n')
.map((filePath) => filePath.replace('/', ''))
.filter((filePath) => filePath !== 'composite');
.map((filePath) => filePath.replace('/', ''));

const listHtml = storybooks
.map((storybook) => `<li><a href="${STORYBOOK_BASE_URL}/${storybook}">${storybook}</a></li>`)
Expand All @@ -110,8 +107,6 @@ const upload = () => {
<html>
<body>
<h1>Storybooks</h1>
<p><a href="${STORYBOOK_BASE_URL}/composite">Composite Storybook</a></p>
<h2>All</h2>
<ul>
${listHtml}
</ul>
Expand Down
34 changes: 0 additions & 34 deletions .ci/.storybook/main.js

This file was deleted.

5 changes: 3 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@
"Team:Operations",
"release_note:skip"
],
"enabled": true
"enabled": true,
"allowedVersions": "<7.0"
},
{
"groupName": "react-query",
Expand Down Expand Up @@ -647,4 +648,4 @@
"enabled": true
}
]
}
}
1 change: 0 additions & 1 deletion src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const storybookAliases = {
canvas: 'x-pack/plugins/canvas/storybook',
cases: 'packages/kbn-cases-components/.storybook',
cell_actions: 'packages/kbn-cell-actions/.storybook',
ci_composite: '.ci/.storybook',
cloud_chat: 'x-pack/plugins/cloud_integrations/cloud_chat/.storybook',
coloring: 'packages/kbn-coloring/.storybook',
language_documentation_popover: 'packages/kbn-language-documentation-popover/.storybook',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const dataTableReducer = reducerWithInitialState(initialDataTableState)
[action.id]: {
...state.tableById[action.id],
expandedDetail: {
...state.tableById[action.id].expandedDetail,
...state.tableById[action.id]?.expandedDetail,
...updateTableDetailsPanel(action),
},
},
Expand Down
41 changes: 39 additions & 2 deletions x-pack/plugins/cloud/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ describe('Cloud Plugin', () => {
return { coreSetup, plugin };
};

it('registers help support URL', async () => {
const { plugin } = startPlugin();
it('registers help support URL: default', async () => {
const { plugin } = startPlugin({
id: undefined,
});

const coreStart = coreMock.createStart();
plugin.start(coreStart);
Expand All @@ -211,6 +213,41 @@ describe('Cloud Plugin', () => {
`);
});

it('registers help support URL: serverless projects', async () => {
const { plugin } = startPlugin({
id: 'my-awesome-project-id',
serverless: {
project_id: 'my-awesome-serverless-project-id',
},
});

const coreStart = coreMock.createStart();
plugin.start(coreStart);

expect(coreStart.chrome.setHelpSupportUrl).toHaveBeenCalledTimes(1);
expect(coreStart.chrome.setHelpSupportUrl.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"https://support.elastic.co/?serverless_project_id=my-awesome-serverless-project-id",
]
`);
});

it('registers help support URL: non-serverless projects', async () => {
const { plugin } = startPlugin({
id: 'my-awesome-project-id',
});

const coreStart = coreMock.createStart();
plugin.start(coreStart);

expect(coreStart.chrome.setHelpSupportUrl).toHaveBeenCalledTimes(1);
expect(coreStart.chrome.setHelpSupportUrl.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"https://support.elastic.co/?cloud_deployment_id=my-awesome-project-id",
]
`);
});

describe('isServerlessEnabled', () => {
it('is `true` when `serverless.projectId` is set', () => {
const { plugin } = startPlugin({
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/cloud/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kb
import { registerCloudDeploymentMetadataAnalyticsContext } from '../common/register_cloud_deployment_id_analytics_context';
import { getIsCloudEnabled } from '../common/is_cloud_enabled';
import { parseDeploymentIdFromDeploymentUrl } from '../common/parse_deployment_id_from_deployment_url';
import { ELASTIC_SUPPORT_LINK, CLOUD_SNAPSHOTS_PATH } from '../common/constants';
import { CLOUD_SNAPSHOTS_PATH } from '../common/constants';
import { decodeCloudId, type DecodedCloudId } from '../common/decode_cloud_id';
import type { CloudSetup, CloudStart } from './types';
import { getFullCloudUrl } from '../common/utils';
import { getSupportUrl } from './utils';

export interface CloudConfigType {
id?: string;
Expand Down Expand Up @@ -103,7 +104,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
}

public start(coreStart: CoreStart): CloudStart {
coreStart.chrome.setHelpSupportUrl(ELASTIC_SUPPORT_LINK);
coreStart.chrome.setHelpSupportUrl(getSupportUrl(this.config));

// Nest all the registered context providers under the Cloud Services Provider.
// This way, plugins only need to require Cloud's context provider to have all the enriched Cloud services.
Expand Down
21 changes: 21 additions & 0 deletions x-pack/plugins/cloud/public/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { ELASTIC_SUPPORT_LINK } from '../common/constants';
import { CloudConfigType } from './plugin';

export function getSupportUrl(config: CloudConfigType): string {
let supportUrl = ELASTIC_SUPPORT_LINK;
if (config.serverless?.project_id) {
// serverless projects use config.id and config.serverless.project_id
supportUrl += '?serverless_project_id=' + config.serverless.project_id;
} else if (config.id) {
// non-serverless Cloud projects only use config.id
supportUrl += '?cloud_deployment_id=' + config.id;
}
return supportUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as t from 'io-ts';
import { isLeft } from 'fp-ts/lib/Either';
import { PathReporter } from 'io-ts/lib/PathReporter';
import globby from 'globby';
import del from 'del';

/**
* Updates the `name` and `classname` attributes of each testcase.
Expand Down Expand Up @@ -195,6 +196,9 @@ ${boilerplate}

if ('error' in maybeValidationResult) {
logError(maybeValidationResult.error);
// Sending broken XML to Failed Test Reporter will cause a job to fail
await del(path);
log.warning(`${path} file was deleted.`);
// If there is an error, continue trying to process other files.
continue;
}
Expand All @@ -203,9 +207,11 @@ ${boilerplate}

const { processed, hadTestCases } = isReportAlreadyProcessed(reportJson);
if (hadTestCases === false) {
log.warning(`${path} had no test cases. Skipping it.
log.warning(`${path} had no test cases.
${boilerplate}
`);
await del(path);
log.warning(`${path} file was deleted.`);
// If there is an error, continue trying to process other files.
continue;
}
Expand All @@ -222,6 +228,9 @@ ${boilerplate}

if ('error' in maybeSpecFilePath) {
logError(maybeSpecFilePath.error);
// Sending broken XML to Failed Test Reporter will cause a job to fail
await del(path);
log.warning(`${path} file was deleted.`);
// If there is an error, continue trying to process other files.
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const dotnetDefinition: LanguageDefinition = {
installClient: 'dotnet add package Elastic.Clients.Elasticsearch.Serverless',
configureClient: ({ apiKey, cloudId }) => `using System;
using Elastic.Clients.Elasticsearch.Serverless;
using Elastic.Clients.Elasticsearch.QueryDsl;
using Elastic.Clients.Elasticsearch.Serverless.QueryDsl;
var client = new ElasticsearchClient("${cloudId}", new ApiKey("${apiKey}"));`,
testConnection: `var info = await client.InfoAsync();`,
Expand Down

0 comments on commit 6db6a86

Please sign in to comment.