Skip to content

Commit

Permalink
Rename index_pattern_management plugin (#37) (#132)
Browse files Browse the repository at this point in the history
* Rename index_pattern_management plugin (#37)

Signed-off-by: Bishoy Boktor <[email protected]>

* Address PR comments

Signed-off-by: Bishoy Boktor <[email protected]>

* Address PR comments

Signed-off-by: Bishoy Boktor <[email protected]>
  • Loading branch information
boktorbb authored Mar 12, 2021
1 parent 7510210 commit 5915faa
Show file tree
Hide file tree
Showing 78 changed files with 278 additions and 280 deletions.
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,13 +52,13 @@ 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(
<StatusMessage
matchedIndices={localMatchedIndices}
query={'k*'}
query={'o*'}
isIncludingSystemIndices={false}
showSystemIndices={false}
/>
Expand All @@ -71,7 +71,7 @@ describe('StatusMessage', () => {
const component = shallow(
<StatusMessage
matchedIndices={matchedIndices}
query={'k'}
query={'o'}
isIncludingSystemIndices={false}
showSystemIndices={false}
/>
Expand All @@ -89,7 +89,7 @@ describe('StatusMessage', () => {
const component = shallow(
<StatusMessage
matchedIndices={localMatchedIndices}
query={'k'}
query={'o'}
isIncludingSystemIndices={false}
showSystemIndices={false}
/>
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 @@ -37,17 +37,17 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({

jest.mock('../../lib/get_indices', () => ({
getIndices: ({ pattern }: { pattern: string }) => {
if (pattern.startsWith('e')) {
return [{ name: 'es', item: {} }];
if (pattern.startsWith('o')) {
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
);
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('StepIndexPattern', () => {
mockContext
);
const instance = component.instance() as StepIndexPattern;
instance.onQueryChanged({ target: { value: 'k' } } as React.ChangeEvent<HTMLInputElement>);
instance.onQueryChanged({ target: { value: 'o' } } as React.ChangeEvent<HTMLInputElement>);

// Ensure all promises resolve
await new Promise((resolve) => process.nextTick(resolve));
Expand All @@ -156,8 +156,8 @@ describe('StepIndexPattern', () => {
mockContext
);
const instance = component.instance() as StepIndexPattern;
instance.onQueryChanged({ target: { value: 'k' } } as React.ChangeEvent<HTMLInputElement>);
expect(component.state('query')).toBe('k*');
instance.onQueryChanged({ target: { value: 'o' } } as React.ChangeEvent<HTMLInputElement>);
expect(component.state('query')).toBe('o*');
});

it('disables the next step if the index pattern exists', async () => {
Expand Down Expand Up @@ -187,21 +187,21 @@ describe('StepIndexPattern', () => {
mockContext
);
const instance = component.instance() as StepIndexPattern;
instance.onQueryChanged({ target: { value: 'e' } } as React.ChangeEvent<HTMLInputElement>);
instance.lastQuery = 'k';
instance.onQueryChanged({ target: { value: 'o' } } as React.ChangeEvent<HTMLInputElement>);
instance.lastQuery = 'o';
await new Promise((resolve) => process.nextTick(resolve));

// 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>);
instance.lastQuery = 'k';
// 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 = 'o';
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
Loading

0 comments on commit 5915faa

Please sign in to comment.