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 index_pattern_management plugin (#37) #132

Merged
merged 3 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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "indexPatternManagement",
"version": "kibana",
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["management", "data", "urlForwarding"],
"requiredBundles": ["kibanaReact", "kibanaUtils"]
"requiredBundles": ["opensearchDashboardsReact", "opensearchDashboardsUtils"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { IndexPattern } from '../../../data/public';

export function getListBreadcrumbs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
EuiPopover,
} from '@elastic/eui';

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

interface State {
isPopoverOpen: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ that need to be tested with each change to this area of the code.
- Alias support
- Indices are the most common use case, but we also support aliases.
- Time field name
- This needs to be `undefined` if the user does not select one (other areas of Kibana depend on this)
- This needs to be `undefined` if the user does not select one (other areas of OpenSearch Dashboards depend on this)
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import React from 'react';
import { Header } from '../header';
import { mount } from 'enzyme';
import { KibanaContextProvider } from 'src/plugins/kibana_react/public';
import { OpenSearchDashboardsContextProvider } from 'src/plugins/opensearch_dashboards_react/public';
import { mockManagementPlugin } from '../../../../mocks';
import { DocLinksStart } from 'kibana/public';
import { DocLinksStart } from 'opensearch-dashboards/public';

describe('Header', () => {
const indexPatternName = 'test index pattern';
Expand All @@ -37,7 +37,7 @@ describe('Header', () => {
const component = mount(
<Header indexPatternName={indexPatternName} docLinks={mockedDocLinks} />,
{
wrappingComponent: KibanaContextProvider,
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
Expand All @@ -51,7 +51,7 @@ describe('Header', () => {
const component = mount(
<Header indexPatternName={indexPatternName} docLinks={mockedDocLinks} />,
{
wrappingComponent: KibanaContextProvider,
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
Expand All @@ -70,7 +70,7 @@ describe('Header', () => {
docLinks={mockedDocLinks}
/>,
{
wrappingComponent: KibanaContextProvider,
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import React from 'react';

import { EuiBetaBadge, EuiSpacer, EuiTitle, EuiText, EuiCode, EuiLink } from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { DocLinksStart } from 'kibana/public';
import { useKibana } from '../../../../../../../plugins/kibana_react/public';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { DocLinksStart } from 'opensearch-dashboards/public';
import { useOpenSearchDashboards } from '../../../../../../../plugins/opensearch_dashboards_react/public';
import { IndexPatternManagmentContext } from '../../../../types';

export const Header = ({
Expand All @@ -38,7 +38,7 @@ export const Header = ({
isBeta?: boolean;
docLinks: DocLinksStart;
}) => {
const changeTitle = useKibana<IndexPatternManagmentContext>().services.chrome.docTitle.change;
const changeTitle = useOpenSearchDashboards<IndexPatternManagmentContext>().services.chrome.docTitle.change;
const createIndexPatternHeader = i18n.translate(
'indexPatternManagement.createIndexPatternHeader',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';

import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiTitle } from '@elastic/eui';

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

export const LoadingState = () => (
<EuiFlexGroup justifyContent="center" alignItems="center" direction="column" gutterSize="s">
Expand All @@ -30,7 +30,7 @@ export const LoadingState = () => (
<h2 style={{ textAlign: 'center' }}>
<FormattedMessage
id="indexPatternManagement.createIndexPattern.loadingState.checkingLabel"
defaultMessage="Checking for Elasticsearch data"
defaultMessage="Checking for OpenSearch data"
/>
</h2>
</EuiTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import {
EuiSwitch,
} from '@elastic/eui';

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

interface HeaderProps {
isInputInvalid: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { shallow } from 'enzyme';
import { MatchedItem } from '../../../../types';

const indices = ([
{ name: 'kibana', tags: [] },
{ name: 'es', tags: [] },
{ name: 'opensearch-dashboards', tags: [] },
{ name: 'opensearch', tags: [] },
] as unknown) as MatchedItem[];

describe('IndicesList', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {

import { Pager } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import { PER_PAGE_INCREMENTS } from '../../../../constants';
import { MatchedItem, Tag } from '../../../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';

import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiLoadingSpinner } from '@elastic/eui';

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

export const LoadingIndices = ({ ...rest }) => (
<EuiFlexGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const tagsPartial = {

const matchedIndices = {
allIndices: ([
{ name: 'kibana', ...tagsPartial },
{ name: 'es', ...tagsPartial },
{ name: 'opensearch-dashboards', ...tagsPartial },
{ name: 'opensearch', ...tagsPartial },
] as unknown) as MatchedItem[],
exactMatchedIndices: [] as MatchedItem[],
partialMatchedIndices: ([{ name: 'kibana', ...tagsPartial }] as unknown) as MatchedItem[],
partialMatchedIndices: ([{ name: 'opensearch-dashboards', ...tagsPartial }] as unknown) as MatchedItem[],
};

describe('StatusMessage', () => {
Expand All @@ -52,7 +52,7 @@ describe('StatusMessage', () => {
it('should render with exact matches', () => {
const localMatchedIndices = {
...matchedIndices,
exactMatchedIndices: ([{ name: 'kibana', ...tagsPartial }] as unknown) as MatchedItem[],
exactMatchedIndices: ([{ name: 'opensearch-dashboards', ...tagsPartial }] as unknown) as MatchedItem[],
};

const component = shallow(
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import React from 'react';
import { EuiCallOut } from '@elastic/eui';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';

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

interface StatusMessageProps {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const StatusMessage: React.FC<StatusMessageProps> = ({
<span>
<FormattedMessage
id="indexPatternManagement.createIndexPattern.step.status.noSystemIndicesWithPromptLabel"
defaultMessage="No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch above."
defaultMessage="No OpenSearch indices match your pattern. To view the matching system indices, toggle the switch above."
/>
</span>
);
Expand All @@ -79,7 +79,7 @@ export const StatusMessage: React.FC<StatusMessageProps> = ({
<span>
<FormattedMessage
id="indexPatternManagement.createIndexPattern.step.status.noSystemIndicesLabel"
defaultMessage="No Elasticsearch indices match your pattern."
defaultMessage="No OpenSearch indices match your pattern."
/>
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import { SavedObjectsFindResponsePublic } from 'kibana/public';
import { SavedObjectsFindResponsePublic } from 'opensearch-dashboards/public';
import { StepIndexPattern, canPreselectTimeField } from './step_index_pattern';
import { Header } from './components/header';
import { IndexPatternCreationConfig } from '../../../../../../../plugins/index_pattern_management/public';
Expand All @@ -38,16 +38,16 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({
jest.mock('../../lib/get_indices', () => ({
getIndices: ({ pattern }: { pattern: string }) => {
if (pattern.startsWith('e')) {
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
return [{ name: 'es', item: {} }];
return [{ name: 'opensearch', item: {} }];
}

return [{ name: 'kibana', item: {} }];
return [{ name: 'opensearch-dashboards', item: {} }];
},
}));

const allIndices = [
{ name: 'kibana', tags: [], item: {} },
{ name: 'es', tags: [], item: {} },
{ name: 'opensearch-dashboards', tags: [], item: {} },
{ name: 'opensearch', tags: [], item: {} },
];

const goToNextStep = () => {};
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('StepIndexPattern', () => {
isIncludingSystemIndices: false,
goToNextStep,
indexPatternCreationType: mockIndexPatternCreationType,
initialQuery: 'kibana',
initialQuery: 'opensearch-dashboards',
},
mockContext
);
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -194,13 +194,13 @@ describe('StepIndexPattern', () => {
// Honesty, the state would match the result of the `k` query but
// it's hard to mock this in tests but if remove our fix
// (the early return if the queries do not match) then this
// equals [{name: 'es'}]
// equals [{name: 'opensearch'}]
expect(component.state('exactMatchedIndices')).toEqual([]);

// Ensure it works in the other code flow too (the other early return)

// Provide `es` so we do not auto append * and enter our other code flow
instance.onQueryChanged({ target: { value: 'es' } } as React.ChangeEvent<HTMLInputElement>);
// Provide `opensearch` so we do not auto append * and enter our other code flow
instance.onQueryChanged({ target: { value: 'opensearch' } } as React.ChangeEvent<HTMLInputElement>);
instance.lastQuery = 'k';
boktorbb marked this conversation as resolved.
Show resolved Hide resolved
await new Promise((resolve) => process.nextTick(resolve));
expect(component.state('exactMatchedIndices')).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import React, { Component } from 'react';
import { EuiSpacer, EuiCallOut, EuiSwitchEvent } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import {
indexPatterns,
IndexPatternAttributes,
Expand All @@ -37,7 +37,7 @@ import { LoadingIndices } from './components/loading_indices';
import { StatusMessage } from './components/status_message';
import { IndicesList } from './components/indices_list';
import { Header } from './components/header';
import { context as contextType } from '../../../../../../kibana_react/public';
import { context as contextType } from '../../../../../../opensearch_dashboards_react/public';
import { IndexPatternCreationConfig } from '../../../../../../../plugins/index_pattern_management/public';
import { MatchedItem } from '../../types';
import { IndexPatternManagmentContextValue } from '../../../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';

import { EuiFlexGroup, EuiFlexItem, EuiButton, EuiButtonEmpty } from '@elastic/eui';

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

export const ActionButtons = ({
goToPreviousStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import React from 'react';

import { EuiForm, EuiFormRow, EuiFieldText, EuiButtonEmpty, EuiSpacer } from '@elastic/eui';

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

interface AdvancedOptionsProps {
isVisible: boolean;
Expand Down Expand Up @@ -67,7 +67,7 @@ export const AdvancedOptions: React.FC<AdvancedOptionsProps> = ({
helpText={
<FormattedMessage
id="indexPatternManagement.createIndexPattern.stepTime.options.patternLabel"
defaultMessage="Kibana will provide a unique identifier for each index pattern. If you do not want to use this unique ID,
defaultMessage="OpenSearch Dashboards will provide a unique identifier for each index pattern. If you do not want to use this unique ID,
enter a custom one."
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';

import { EuiTitle, EuiSpacer, EuiText } from '@elastic/eui';

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

interface HeaderProps {
indexPattern: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
EuiLoadingSpinner,
} from '@elastic/eui';

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

interface TimeFieldProps {
isVisible: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import {
EuiLoadingSpinner,
EuiHorizontalRule,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import { ensureMinimumTime, extractTimeFields } from '../../lib';

import { Header } from './components/header';
import { TimeField } from './components/time_field';
import { AdvancedOptions } from './components/advanced_options';
import { ActionButtons } from './components/action_buttons';
import { context } from '../../../../../../kibana_react/public';
import { context } from '../../../../../../opensearch_dashboards_react/public';
import { IndexPatternManagmentContextValue } from '../../../../types';
import { IndexPatternCreationConfig } from '../../../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jest.mock('./components/header', () => ({ Header: 'Header' }));
jest.mock('./components/loading_state', () => ({ LoadingState: 'LoadingState' }));
jest.mock('./lib/get_indices', () => ({
getIndices: () => {
return [{ name: 'kibana' }];
return [{ name: 'opensearch-dashboards' }];
},
}));
const routeComponentPropsMock = {
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('CreateIndexPatternWizard', () => {
component.setState({
isInitiallyLoadingIndices: false,
isIncludingSystemIndices: true,
allIndices: [{ name: '.kibana ' }],
allIndices: [{ name: '.opensearch-dashboards ' }],
});

await component.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import {
EuiPageContent,
EuiHorizontalRule,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { i18n } from '@osd/i18n';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { DocLinksStart } from 'src/core/public';
import { StepIndexPattern } from './components/step_index_pattern';
import { StepTimeField } from './components/step_time_field';
import { Header } from './components/header';
import { LoadingState } from './components/loading_state';

import { context as contextType } from '../../../../kibana_react/public';
import { context as contextType } from '../../../../opensearch_dashboards_react/public';
import { getCreateBreadcrumbs } from '../breadcrumbs';
import { ensureMinimumTime, getIndices } from './lib';
import { IndexPatternCreationConfig } from '../..';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { IFieldType } from '../../../../../../plugins/data/public';

export function extractTimeFields(fields: IFieldType[]) {
Expand Down
Loading