Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename home plugin (#37) #131

Merged
merged 4 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/plugins/home/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { npSetup } from 'ui/new_platform';
npSetup.plugins.home.featureCatalogue.register(/* same details here */);

// For new plugins: first add 'home` to the list of `optionalPlugins`
// in your kibana.json file. Then access the plugin directly in `setup`:
// in your opensearch_dashboards.json file. Then access the plugin directly in `setup`:

class MyPlugin {
setup(core, plugins) {
Expand All @@ -33,22 +33,22 @@ Note that the old module supported providing a Angular DI function to receive An
Replaces the sample data mixin putting functions on the global `server` object.

### What happens when a user installs a sample data set?
1) Kibana deletes existing Elastic search indicies for the sample data set if they exist from previous installs.
2) Kibana creates Elasticsearch indicies with the provided field mappings.
3) Kibana uses bulk insert to ingest the new-line delimited json into the Elasticsearch index. Kibana migrates timestamps provided in new-line delimited json to the current time frame for any date field defined in `timeFields`
4) Kibana will install all saved objects for sample data set. This will override any saved objects previouslly installed for sample data set.
1) OpenSearch Dashboards deletes existing OpenSearch indicies for the sample data set if they exist from previous installs.
2) OpenSearch Dashboards creates OpenSearch indicies with the provided field mappings.
3) OpenSearch Dashboards uses bulk insert to ingest the new-line delimited json into the OpenSearch index. OpenSearch Dashboards migrates timestamps provided in new-line delimited json to the current time frame for any date field defined in `timeFields`
4) OpenSearch Dashboards will install all saved objects for sample data set. This will override any saved objects previouslly installed for sample data set.

Elasticsearch index names are prefixed with `kibana_sample_data_`. For more details see [createIndexName](/src/plugins/home/server/services/sample_data/lib/create_index_name.js)
OpenSearch index names are prefixed with `opensearch_dashboards_sample_data_`. For more details see [createIndexName](/src/plugins/home/server/services/sample_data/lib/create_index_name.js)

Sample data sets typically provide data that spans 5 weeks from the past and 5 weeks into the future so users see data relative to `now` for a few weeks after installing sample data sets.

### Adding new sample data sets
Use [existing sample data sets](/src/plugins/home/server/services/sample_data/data_sets) as examples.
To avoid bloating the Kibana distribution, keep data set size to a minimum.
To avoid bloating the OpenSearch Dashboards distribution, keep data set size to a minimum.

Follow the steps below to add new Sample data sets to Kibana.
Follow the steps below to add new Sample data sets to OpenSearch Dashboards.
1) Create new-line delimited json containing sample data.
2) Create file with Elasticsearch field mappings for sample data indices.
3) Create Kibana saved objects for sample data including index-patterns, visualizations, and dashboards. The best way to extract the saved objects is from the Kibana management -> saved objects [export UI](https://www.elastic.co/guide/en/kibana/current/managing-saved-objects.html#_export)
2) Create file with OpenSearch field mappings for sample data indices.
3) Create OpenSearch Dashboards saved objects for sample data including index-patterns, visualizations, and dashboards. The best way to extract the saved objects is from the OpenSearch Dashboards management -> saved objects [export UI](https://www.elastic.co/guide/en/OpenSearch Dashboards/current/managing-saved-objects.html#_export)
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
4) Define sample data spec conforming to [Data Set Schema](/src/plugins/home/server/services/sample_data/lib/sample_dataset_registry_types.ts).
5) Register sample data by calling `plguins.home.sampleData.registerSampleDataset(yourSpecProvider)` in your `setup` method where `yourSpecProvider` is a function that returns an object containing your sample data spec from step 4.
2 changes: 1 addition & 1 deletion src/plugins/home/common/instruction_variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const INSTRUCTION_VARIANT = {
};

const DISPLAY_MAP = {
[INSTRUCTION_VARIANT.ESC]: 'Elastic Cloud',
[INSTRUCTION_VARIANT.ESC]: 'OpenSearch Cloud',
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
[INSTRUCTION_VARIANT.OSX]: 'macOS',
[INSTRUCTION_VARIANT.DEB]: 'DEB',
[INSTRUCTION_VARIANT.RPM]: 'RPM',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { schema, TypeOf } from '@osd/config-schema';

export const configSchema = schema.object({
disableWelcomeScreen: schema.boolean({ defaultValue: false }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "home",
"version": "kibana",
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["data", "urlForwarding"],
"optionalPlugins": ["usageCollection", "telemetry"],
"requiredBundles": [
"kibanaReact"
"opensearchDashboardsReact"
]
}
12 changes: 6 additions & 6 deletions src/plugins/home/public/application/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { i18n } from '@kbn/i18n';
import { ScopedHistory, CoreStart } from 'kibana/public';
import { KibanaContextProvider } from '../../../kibana_react/public';
import { i18n } from '@osd/i18n';
import { ScopedHistory, CoreStart } from 'opensearch-dashboards/public';
import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public';
// @ts-ignore
import { HomeApp } from './components/home_app';
import { getServices } from './kibana_services';
import { getServices } from './opensearch_dashboards_services';

import './index.scss';

Expand Down Expand Up @@ -55,9 +55,9 @@ export const renderApp = async (
});

render(
<KibanaContextProvider services={{ ...coreStart }}>
<OpenSearchDashboardsContextProvider services={{ ...coreStart }}>
<HomeApp directories={directories} solutions={solutions} />
</KibanaContextProvider>,
</OpenSearchDashboardsContextProvider>,
element
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ const mockFeatures = [
},
{
category: 'admin',
description: 'Add and manage your fleet of Elastic Agents and integrations.',
description: 'Add and manage your fleet of OpenSearch Agents and integrations.',
showOnHomePage: true,
icon: 'indexManagementApp',
id: 'ingestManager',
order: 510,
path: '/app/ingestManager',
title: 'Add Elastic Agent',
title: 'Add OpenSearch Agent',
},
{
category: 'data',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React, { FC } from 'react';
import PropTypes from 'prop-types';
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
// @ts-expect-error untyped service
import { FeatureCatalogueEntry } from '../../services';
import { createAppNavigationHandler } from '../app_navigation_handler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { MouseEvent } from 'react';
import { getServices } from '../kibana_services';
import { getServices } from '../opensearch_dashboards_services';

export const createAppNavigationHandler = (targetUrl: string) => (event: MouseEvent) => {
if (event.altKey || event.metaKey || event.ctrlKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {

import { FeatureCatalogueCategory } from '../../services';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { createAppNavigationHandler } from './app_navigation_handler';

const ALL_TAB_ID = 'all';
Expand Down
31 changes: 15 additions & 16 deletions src/plugins/home/public/application/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import {
OverviewPageFooter,
OverviewPageHeader,
} from '../../../../../../src/plugins/kibana_react/public';
} from '../../../../../../src/plugins/opensearch_dashboards_react/public';
import { HOME_APP_BASE_PATH } from '../../../common/constants';
import { FeatureCatalogueCategory } from '../../services';
import { getServices } from '../kibana_services';
import { getServices } from '../opensearch_dashboards_services';
import { AddData } from './add_data';
import { ManageData } from './manage_data';
import { SolutionsSection } from './solutions_section';
Expand All @@ -54,7 +54,7 @@ export class Home extends Component {
// effect where home renders, and then a few ms after, the
// welcome screen fades in.
isLoading: isWelcomeEnabled,
isNewKibanaInstance: false,
isNewOpenSearchDashboardsInstance: false,
isWelcomeEnabled,
};
}
Expand All @@ -65,13 +65,13 @@ export class Home extends Component {

componentDidMount() {
this._isMounted = true;
this.fetchIsNewKibanaInstance();
this.fetchIsNewOpenSearchDashboardsInstance();

const homeTitle = i18n.translate('home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
getServices().chrome.setBreadcrumbs([{ text: homeTitle }]);
}

fetchIsNewKibanaInstance = async () => {
fetchIsNewOpenSearchDashboardsInstance = async () => {
try {
// Set a max-time on this query so we don't hang the page too long...
// Worst case, we don't show the welcome screen when we should.
Expand All @@ -89,7 +89,7 @@ export class Home extends Component {
perPage: 1,
});

this.endLoading({ isNewKibanaInstance: resp.total === 0 });
this.endLoading({ isNewOpenSearchDashboardsInstance: resp.total === 0 });
} catch (err) {
// An error here is relatively unimportant, as it only means we don't provide
// some UI niceties.
Expand Down Expand Up @@ -132,7 +132,7 @@ export class Home extends Component {

return (
<main
aria-labelledby="kbnOverviewPageHeader__title"
aria-labelledby="osdOverviewPageHeader__title"
className="homWrapper"
data-test-subj="homeApp"
>
Expand All @@ -154,11 +154,10 @@ export class Home extends Component {
) : null}

<EuiFlexGroup
className={`homData ${
addDataFeatures.length === 1 && manageDataFeatures.length === 1
? 'homData--compressed'
: 'homData--expanded'
}`}
className={`homData ${addDataFeatures.length === 1 && manageDataFeatures.length === 1
? 'homData--compressed'
: 'homData--expanded'
}`}
>
<EuiFlexItem>
<AddData addBasePath={addBasePath} features={addDataFeatures} />
Expand Down Expand Up @@ -193,13 +192,13 @@ export class Home extends Component {
}

render() {
const { isLoading, isWelcomeEnabled, isNewKibanaInstance } = this.state;
const { isLoading, isWelcomeEnabled, isNewOpenSearchDashboardsInstance } = this.state;

if (isWelcomeEnabled) {
if (isLoading) {
return this.renderLoading();
}
if (isNewKibanaInstance) {
if (isNewOpenSearchDashboardsInstance) {
return this.renderWelcome();
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/plugins/home/public/application/components/home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ import { Home } from './home';

import { FeatureCatalogueCategory } from '../../services';

jest.mock('../kibana_services', () => ({
jest.mock('../opensearch_dashboards_services', () => ({
getServices: () => ({
getBasePath: () => 'path',
tutorialVariables: () => ({}),
homeConfig: { disableWelcomeScreen: false },
chrome: {
setBreadcrumbs: () => {},
setBreadcrumbs: () => { },
},
}),
}));

jest.mock('../../../../../../src/plugins/kibana_react/public', () => ({
jest.mock('../../../../../../src/plugins/opensearch_dashboards_react/public', () => ({
OverviewPageFooter: jest.fn().mockReturnValue(<></>),
OverviewPageHeader: jest.fn().mockReturnValue(<></>),
}));
Expand All @@ -49,7 +49,7 @@ describe('home', () => {
solutions: [],
apmUiEnabled: true,
mlEnabled: true,
kibanaVersion: '99.2.1',
opensearchDashboardsVersion: '99.2.1',
fetchTelemetry: jest.fn(),
getTelemetryBannerId: jest.fn(),
setOptIn: jest.fn(),
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('home', () => {
const directoryEntry = {
id: 'stack-management',
title: 'Management',
description: 'Your center console for managing the Elastic Stack.',
description: 'Your center console for managing the OpenSearch Stack.',
icon: 'managementApp',
path: 'management_landing_page',
category: FeatureCatalogueCategory.ADMIN,
Expand Down Expand Up @@ -144,12 +144,12 @@ describe('home', () => {
describe('directories', () => {
test('should render solutions in the "solution section"', async () => {
const solutionEntry1 = {
id: 'kibana',
title: 'Kibana',
id: 'opensearchdashboards',
title: 'OpenSearch Dashboards',
subtitle: 'Visualize & analyze',
appDescriptions: ['Analyze data in dashboards'],
icon: 'logoKibana',
path: 'kibana_landing_page',
path: 'opensearch_dashboards_landing_page',
order: 1,
};
const solutionEntry2 = {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('home', () => {
const directoryEntry = {
id: 'index_patterns',
title: 'Index Patterns',
description: 'Manage the index patterns that help retrieve your data from Elasticsearch.',
description: 'Manage the index patterns that help retrieve your data from OpenSearch.',
icon: 'indexPatternApp',
path: 'index_management_landing_page',
showOnHomePage: true,
Expand All @@ -227,7 +227,7 @@ describe('home', () => {
const directoryEntry = {
id: 'stack-management',
title: 'Management',
description: 'Your center console for managing the Elastic Stack.',
description: 'Your center console for managing the OpenSearch Stack.',
icon: 'managementApp',
path: 'management_landing_page',
showOnHomePage: false,
Expand Down Expand Up @@ -309,16 +309,16 @@ describe('home', () => {
});
});

describe('isNewKibanaInstance', () => {
test('should set isNewKibanaInstance to true when there are no index patterns', async () => {
describe('isNewOpenSearchDashboardsInstance', () => {
test('should set isNewOpenSearchDashboardsInstance to true when there are no index patterns', async () => {
const component = await renderHome({
find: () => Promise.resolve({ total: 0 }),
});

expect(component).toMatchSnapshot();
});

test('should set isNewKibanaInstance to false when there are index patterns', async () => {
test('should set isNewOpenSearchDashboardsInstance to false when there are index patterns', async () => {
const component = await renderHome({
find: () => Promise.resolve({ total: 1 }),
});
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/home/public/application/components/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { I18nProvider } from '@osd/i18n/react';
import PropTypes from 'prop-types';
import { Home } from './home';
import { FeatureDirectory } from './feature_directory';
Expand All @@ -27,7 +27,7 @@ import { Tutorial } from './tutorial/tutorial';
import { HashRouter as Router, Switch, Route } from 'react-router-dom';
import { getTutorial } from '../load_tutorials';
import { replaceTemplateStrings } from './tutorial/replace_template_strings';
import { getServices } from '../kibana_services';
import { getServices } from '../opensearch_dashboards_services';
import { useMount } from 'react-use';

const RedirectToDefaultApp = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React, { FC } from 'react';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiHorizontalRule, EuiSpacer, EuiTitle, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
// @ts-expect-error untyped service
import { FeatureCatalogueEntry } from '../../services';
import { createAppNavigationHandler } from '../app_navigation_handler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
EuiTitle,
} from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';

export const NUM_LONG_LINKS = 5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

/*
* The UI and related logic for the welcome screen that *should* show only
* when it is enabled (the default) and there is no Kibana-consumed data
* in Elasticsearch.
* when it is enabled (the default) and there is no OpenSearch Dashboards-consumed data
* in OpenSearch.
*/

import React from 'react';
Expand All @@ -30,8 +30,8 @@ import {
EuiButton,
EuiButtonEmpty,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getServices } from '../../kibana_services';
import { FormattedMessage } from '@osd/i18n/react';
import { getServices } from '../../opensearch_dashboards_services';

interface Props {
urlBasePath: string;
Expand Down
Loading