-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 127126-sm-alert-kibana-url
- Loading branch information
Showing
1,376 changed files
with
12,592 additions
and
9,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source .buildkite/scripts/common/util.sh | ||
|
||
echo --- Ensure that all tests are in a CI Group | ||
checks-reporter-with-killswitch "Ensure that all tests are in a CI Group" \ | ||
node scripts/ensure_all_tests_in_ci_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/kbn-shared-ux-components/src/empty_state/kibana_no_data_page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
id: sharedUX/Components/KibanaNoDataPage | ||
slug: /shared-ux-components/kibana_no_data_page | ||
title: Kibana No Data Page | ||
summary: A page to be displayed when there is no data in Elasticsearch, or no data views | ||
tags: ['shared-ux', 'component'] | ||
date: 2022-04-20 | ||
--- | ||
|
||
## Description | ||
|
||
Many plugins display "no data" page, either when there is no data in Elasticsearch, or there haven't been any data views created yet. This component is meant | ||
to be used in those scenarios. It displays an appropriate message to the user and facilitate addition of integrations and creation of data views. | ||
|
||
## Component: `KibanaNoDataPage` | ||
|
||
- uses `hasUserDataView` and `hasData` API from `HasData` service in `data_views` plugin to check for existence of data / data views | ||
- uses `onDataViewCreated` callback to be called once the data view has been created | ||
- receives (noDataConfig)[https://github.com/elastic/kibana/blob/main/packages/kbn-shared-ux-components/src/page_template/no_data_page/types.ts] as configuration for the page in case of no data | ||
- needs to be wrapped in `ServicesContext` provided by the start contract of the `shared_ux` plugin to be used | ||
|
||
## EUI Promotion Status | ||
This component is not currently considered for promotion to EUI. |
72 changes: 72 additions & 0 deletions
72
packages/kbn-shared-ux-components/src/empty_state/kibana_no_data_page.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import React from 'react'; | ||
import { servicesFactory, DataServiceFactoryConfig } from '@kbn/shared-ux-storybook'; | ||
import { SharedUxServicesProvider } from '@kbn/shared-ux-services'; | ||
import mdx from './kibana_no_data_page.mdx'; | ||
import { NoDataPageProps } from '../page_template'; | ||
import { KibanaNoDataPage } from './kibana_no_data_page'; | ||
|
||
export default { | ||
title: 'No Data/Kibana No Data Page', | ||
description: 'A component to display when there is no data available', | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, | ||
}; | ||
|
||
const noDataConfig = { | ||
solution: 'Analytics', | ||
logo: 'logoKibana', | ||
action: { | ||
elasticAgent: { | ||
title: 'Add Integrations', | ||
}, | ||
}, | ||
docsLink: 'http://www.docs.com', | ||
}; | ||
|
||
type Params = Pick<NoDataPageProps, 'solution' | 'logo'> & DataServiceFactoryConfig; | ||
|
||
export const PureComponent = (params: Params) => { | ||
const { solution, logo, hasESData, hasUserDataView } = params; | ||
const serviceParams = { hasESData, hasUserDataView, hasDataViews: false }; | ||
const services = servicesFactory(serviceParams); | ||
return ( | ||
<SharedUxServicesProvider {...services}> | ||
<KibanaNoDataPage | ||
onDataViewCreated={action('onDataViewCreated')} | ||
noDataConfig={{ ...noDataConfig, solution, logo }} | ||
/> | ||
</SharedUxServicesProvider> | ||
); | ||
}; | ||
|
||
PureComponent.argTypes = { | ||
solution: { | ||
control: 'text', | ||
defaultValue: 'Observability', | ||
}, | ||
logo: { | ||
control: { type: 'radio' }, | ||
options: ['logoElastic', 'logoKibana', 'logoCloud', undefined], | ||
defaultValue: undefined, | ||
}, | ||
hasESData: { | ||
control: 'boolean', | ||
defaultValue: false, | ||
}, | ||
hasUserDataView: { | ||
control: 'boolean', | ||
defaultValue: false, | ||
}, | ||
}; |
71 changes: 71 additions & 0 deletions
71
packages/kbn-shared-ux-components/src/empty_state/kibana_no_data_page.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { mountWithIntl } from '@kbn/test-jest-helpers'; | ||
import { SharedUxServicesProvider, mockServicesFactory } from '@kbn/shared-ux-services'; | ||
|
||
import { KibanaNoDataPage } from './kibana_no_data_page'; | ||
import { NoDataConfigPage } from '../page_template'; | ||
import { NoDataViews } from './no_data_views'; | ||
|
||
describe('Kibana No Data Page', () => { | ||
const noDataConfig = { | ||
solution: 'Analytics', | ||
pageTitle: 'Analytics', | ||
logo: 'logoKibana', | ||
action: { | ||
elasticAgent: { | ||
title: 'Add Integrations', | ||
}, | ||
}, | ||
docsLink: 'http://www.docs.com', | ||
}; | ||
const onDataViewCreated = jest.fn(); | ||
const config = { | ||
hasESData: false, | ||
hasDataView: false, | ||
hasUserDataView: false, | ||
}; | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
test('renders NoDataConfigPage', async () => { | ||
const services = mockServicesFactory({ config: { ...config, hasESData: false } }); | ||
const component = mountWithIntl( | ||
<SharedUxServicesProvider {...services}> | ||
<KibanaNoDataPage noDataConfig={noDataConfig} onDataViewCreated={onDataViewCreated} /> | ||
</SharedUxServicesProvider> | ||
); | ||
|
||
await act(() => new Promise(setImmediate)); | ||
component.update(); | ||
|
||
expect(component.find(NoDataConfigPage).length).toBe(1); | ||
expect(component.find(NoDataViews).length).toBe(0); | ||
}); | ||
|
||
test('renders NoDataViews', async () => { | ||
const services = mockServicesFactory({ config: { ...config, hasESData: true } }); | ||
const component = mountWithIntl( | ||
<SharedUxServicesProvider {...services}> | ||
<KibanaNoDataPage noDataConfig={noDataConfig} onDataViewCreated={onDataViewCreated} /> | ||
</SharedUxServicesProvider> | ||
); | ||
|
||
await act(() => new Promise(setImmediate)); | ||
component.update(); | ||
|
||
expect(component.find(NoDataViews).length).toBe(1); | ||
expect(component.find(NoDataConfigPage).length).toBe(0); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/kbn-shared-ux-components/src/empty_state/kibana_no_data_page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useData } from '@kbn/shared-ux-services'; | ||
import { NoDataConfigPage, NoDataPageProps } from '../page_template'; | ||
import { NoDataViews } from './no_data_views'; | ||
|
||
export interface Props { | ||
onDataViewCreated: (dataView: unknown) => void; | ||
noDataConfig: NoDataPageProps; | ||
} | ||
|
||
export const KibanaNoDataPage = ({ onDataViewCreated, noDataConfig }: Props) => { | ||
const { hasESData, hasUserDataView } = useData(); | ||
const [dataExists, setDataExists] = useState(false); | ||
const [hasUserDataViews, setHasUserDataViews] = useState(false); | ||
|
||
useEffect(() => { | ||
const checkData = async () => { | ||
setDataExists(await hasESData()); | ||
setHasUserDataViews(await hasUserDataView()); | ||
}; | ||
// TODO: add error handling | ||
// https://github.com/elastic/kibana/issues/130913 | ||
checkData().catch(() => {}); | ||
}, [hasESData, hasUserDataView]); | ||
|
||
if (!dataExists) { | ||
return <NoDataConfigPage noDataConfig={noDataConfig} />; | ||
} | ||
|
||
if (!hasUserDataViews) { | ||
return <NoDataViews onDataViewCreated={onDataViewCreated} />; | ||
} | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.