Skip to content

Commit

Permalink
[Index Management] Add ingest pipelines link to the index details page (
Browse files Browse the repository at this point in the history
#170906)

## Summary

Fixes #165107
This PR adds a function to the extensions service in Index Management to
register additional content that is rendered in the bottom right corner
under the mappings docs link. This PR also adds a panel with the link to
the ingest pipelines search docs for the serverless search project.

### Screenshots 
<img width="1398" alt="Screenshot 2023-11-08 at 21 51 28"
src="https://github.com/elastic/kibana/assets/6585477/f6aeb5f6-1844-4fde-85d4-6aafe58484f9">



### Checklist


- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
yuliacech and kibanamachine authored Nov 10, 2023
1 parent cd909f0 commit 870cb9f
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 109 deletions.
5 changes: 3 additions & 2 deletions x-pack/plugins/index_management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ interface IndexDetailsTab {

An example of adding an ILM tab can be found in [this file](https://github.com/elastic/kibana/blob/main/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/index_lifecycle_summary.tsx#L250).

- `setIndexOverviewContent(content: IndexOverviewContent)`: replaces the default content in the overview tab (code block describing adding documents to the index) with the custom content. The custom content has the following interface:
- `setIndexOverviewContent(content: IndexContent)`: replaces the default content in the overview tab (code block describing adding documents to the index) with the custom content. The custom content has the following interface:
```ts
interface IndexOverviewContent {
interface IndexContent {
renderContent: (args: {
index: Index;
getUrlForApp: ApplicationStart['getUrlForApp'];
}) => ReturnType<FunctionComponent>;
```
- `setIndexMappingsContent(content: IndexContent)`: adds content to the mappings tab of the index details page. The content is displayed in the right bottom corner, below the mappings docs link.

## Indices tab

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,28 @@ describe('<IndexDetailsPage />', () => {
expect(httpSetup.get).toHaveBeenCalledTimes(numberOfRequests + 1);
});
});

it('renders the content set via the extensions service', async () => {
const mappingsContent = 'test mappings extension';
await act(async () => {
testBed = await setup({
httpSetup,
dependencies: {
services: {
extensionsService: {
_indexMappingsContent: {
renderContent: () => mappingsContent,
},
},
},
},
});
});
testBed.component.update();
await testBed.actions.clickIndexDetailsTab(IndexDetailsSection.Mappings);
const content = testBed.actions.getActiveTabContent();
expect(content).toContain(mappingsContent);
});
});

describe('Settings tab', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const defaultTabs: IndexDetailsTab[] = [
name: (
<FormattedMessage id="xpack.idxMgmt.indexDetails.mappingsTitle" defaultMessage="Mappings" />
),
renderTabContent: ({ index }) => <DetailsPageMappings indexName={index.name} />,
renderTabContent: ({ index }) => <DetailsPageMappings index={index} />,
order: 20,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,18 @@
*/

import React, { FunctionComponent, useEffect } from 'react';
import {
EuiButton,
EuiCodeBlock,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiLink,
EuiPageTemplate,
EuiPanel,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { EuiButton, EuiPageTemplate, EuiSpacer, EuiText } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';
import { SectionLoading } from '@kbn/es-ui-shared-plugin/public';
import { useLoadIndexMappings, documentationService } from '../../../../services';

import { DetailsPageMappingsContent } from './details_page_mappings_content';
import { Index } from '../../../../../../common';
import { useLoadIndexMappings } from '../../../../services';
import { breadcrumbService, IndexManagementBreadcrumb } from '../../../../services/breadcrumbs';

export const DetailsPageMappings: FunctionComponent<{ indexName: string }> = ({ indexName }) => {
const { isLoading, data, error, resendRequest } = useLoadIndexMappings(indexName);
export const DetailsPageMappings: FunctionComponent<{ index: Index }> = ({ index }) => {
const { isLoading, data, error, resendRequest } = useLoadIndexMappings(index.name);

useEffect(() => {
breadcrumbService.setBreadcrumbs(IndexManagementBreadcrumb.indexDetailsMappings);
Expand Down Expand Up @@ -63,7 +54,7 @@ export const DetailsPageMappings: FunctionComponent<{ indexName: string }> = ({
id="xpack.idxMgmt.indexDetails.mappings.errorDescription"
defaultMessage="We encountered an error loading mappings for index {indexName}. Make sure that the index name in the URL is correct and try again."
values={{
indexName,
indexName: index.name,
}}
/>
</EuiText>
Expand All @@ -86,82 +77,5 @@ export const DetailsPageMappings: FunctionComponent<{ indexName: string }> = ({
);
}

return (
// using "rowReverse" to keep docs links on the top of the mappings code block on smaller screen
<EuiFlexGroup
wrap
direction="rowReverse"
css={css`
height: 100%;
`}
>
<EuiFlexItem
grow={1}
css={css`
min-width: 400px;
`}
>
<EuiPanel grow={false} paddingSize="l">
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiIcon type="iInCircle" />
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle size="xs">
<h2>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardTitle"
defaultMessage="About index mappings"
/>
</h2>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
<EuiText>
<p>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardDescription"
defaultMessage="Your documents are made up of a set of fields. Index mappings give each field a type
(such as keyword, number, or date) and additional subfields. These index mappings determine the functions
available in your relevance tuning and search experience."
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<EuiLink
data-test-subj="indexDetailsMappingsDocsLink"
href={documentationService.getMappingDocumentationLink()}
target="_blank"
external
>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardLink"
defaultMessage="Learn more about mappings"
/>
</EuiLink>
</EuiPanel>
</EuiFlexItem>

<EuiFlexItem
grow={3}
css={css`
min-width: 600px;
`}
>
<EuiPanel>
<EuiCodeBlock
language="json"
isCopyable
data-test-subj="indexDetailsMappingsCodeBlock"
css={css`
height: 100%;
`}
>
{JSON.stringify(data, null, 2)}
</EuiCodeBlock>
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
);
return <DetailsPageMappingsContent index={index} data={data} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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 React, { FunctionComponent } from 'react';
import {
EuiCodeBlock,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiLink,
EuiPanel,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';

import { Index } from '../../../../../../common';
import { documentationService } from '../../../../services';
import { useAppContext } from '../../../../app_context';

export const DetailsPageMappingsContent: FunctionComponent<{ index: Index; data: any }> = ({
index,
data,
}) => {
const {
services: { extensionsService },
core: { getUrlForApp },
} = useAppContext();
return (
// using "rowReverse" to keep docs links on the top of the mappings code block on smaller screen
<EuiFlexGroup
wrap
direction="rowReverse"
css={css`
height: 100%;
`}
>
<EuiFlexItem
grow={1}
css={css`
min-width: 400px;
`}
>
<EuiPanel grow={false} paddingSize="l">
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiIcon type="iInCircle" />
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle size="xs">
<h2>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardTitle"
defaultMessage="About index mappings"
/>
</h2>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
<EuiText>
<p>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardDescription"
defaultMessage="Your documents are made up of a set of fields. Index mappings give each field a type
(such as keyword, number, or date) and additional subfields. These index mappings determine the functions
available in your relevance tuning and search experience."
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<EuiLink
data-test-subj="indexDetailsMappingsDocsLink"
href={documentationService.getMappingDocumentationLink()}
target="_blank"
external
>
<FormattedMessage
id="xpack.idxMgmt.indexDetails.mappings.docsCardLink"
defaultMessage="Learn more about mappings"
/>
</EuiLink>
</EuiPanel>
{extensionsService.indexMappingsContent && (
<>
<EuiSpacer />
{extensionsService.indexMappingsContent.renderContent({ index, getUrlForApp })}
</>
)}
</EuiFlexItem>

<EuiFlexItem
grow={3}
css={css`
min-width: 600px;
`}
>
<EuiPanel>
<EuiCodeBlock
language="json"
isCopyable
data-test-subj="indexDetailsMappingsCodeBlock"
css={css`
height: 100%;
`}
>
{JSON.stringify(data, null, 2)}
</EuiCodeBlock>
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
);
};
2 changes: 1 addition & 1 deletion x-pack/plugins/index_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const plugin = (ctx: PluginInitializerContext) => {
return new IndexMgmtUIPlugin(ctx);
};

export type { IndexManagementPluginSetup } from './types';
export type { IndexManagementPluginSetup, IndexManagementPluginStart } from './types';

export { getIndexListUri, getTemplateDetailsLink } from './application/services/routing';

Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/index_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class IndexMgmtUIPlugin {
};
}

public start() {}
public start() {
return {
extensionsService: this.extensionsService.setup(),
};
}
public stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const createServiceMock = (): ExtensionsSetupMock => ({
addToggle: jest.fn(),
addIndexDetailsTab: jest.fn(),
setIndexOverviewContent: jest.fn(),
setIndexMappingsContent: jest.fn(),
});

const createMock = () => {
Expand Down
Loading

0 comments on commit 870cb9f

Please sign in to comment.