Skip to content

Commit

Permalink
[Security Solution] show correct failed transform on failed transform…
Browse files Browse the repository at this point in the history
… banner (elastic#117608)
  • Loading branch information
joeypoon authored and kibanamachine committed Nov 5, 2021
1 parent 5e73f86 commit 7869250
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,8 @@ readonly links: {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
```

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ export class DocLinksService {
rubyOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/ruby-api/${DOC_LINK_VERSION}/ruby_client.html`,
rustGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/rust-api/${DOC_LINK_VERSION}/index.html`,
},
endpoints: {
troubleshooting: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/ts-management.html#ts-endpoints`,
},
},
});
}
Expand Down Expand Up @@ -768,5 +771,8 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}
3 changes: 3 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ import {
TRANSFORM_STATES,
} from '../../../../../common/constants';
import { TransformStats } from '../types';
import { metadataTransformPrefix } from '../../../../../common/endpoint/constants';
import {
metadataTransformPrefix,
METADATA_UNITED_TRANSFORM,
} from '../../../../../common/endpoint/constants';

// not sure why this can't be imported from '../../../../common/mock/formatted_relative';
// but sure enough it needs to be inline in this one file
Expand Down Expand Up @@ -1457,5 +1460,23 @@ describe('when on the endpoint list page', () => {
const banner = await screen.findByTestId('callout-endpoints-list-transform-failed');
expect(banner).toBeInTheDocument();
});

it('displays correct transform id when in failed state', async () => {
const transforms: TransformStats[] = [
{
id: `${metadataTransformPrefix}-0.20.0`,
state: TRANSFORM_STATES.STARTED,
} as TransformStats,
{
id: `${METADATA_UNITED_TRANSFORM}-1.2.1`,
state: TRANSFORM_STATES.FAILED,
} as TransformStats,
];
setEndpointListApiMockImplementation(coreStart.http, { transforms });
render();
const banner = await screen.findByTestId('callout-endpoints-list-transform-failed');
expect(banner).not.toHaveTextContent(transforms[0].id);
expect(banner).toHaveTextContent(transforms[1].id);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,19 @@ export const EndpointList = () => {
return endpointsExist && !patternsError;
}, [endpointsExist, patternsError]);

const transformFailedCalloutDescription = useMemo(
() => (
const transformFailedCalloutDescription = useMemo(() => {
const failingTransformIds = metadataTransformStats
.filter((transformStat) => WARNING_TRANSFORM_STATES.has(transformStat.state))
.map((transformStat) => transformStat.id)
.join(', ');

return (
<>
<FormattedMessage
id="xpack.securitySolution.endpoint.list.transformFailed.message"
defaultMessage="A required transform, {transformId}, is currently failing. Most of the time this can be fixed by {transformsPage}. For additional help, please visit the {docsPage}"
values={{
transformId: metadataTransformStats[0]?.id || metadataTransformPrefix,
transformId: failingTransformIds || metadataTransformPrefix,
transformsPage: (
<LinkToApp
data-test-subj="failed-transform-restart-link"
Expand All @@ -557,7 +562,7 @@ export const EndpointList = () => {
docsPage: (
<EuiLink
data-test-subj="failed-transform-docs-link"
href={services?.docLinks?.links.transforms.guide}
href={services?.docLinks?.links.endpoints.troubleshooting}
target="_blank"
>
<FormattedMessage
Expand All @@ -570,9 +575,8 @@ export const EndpointList = () => {
/>
<EuiSpacer size="s" />
</>
),
[metadataTransformStats, services?.docLinks?.links.transforms.guide]
);
);
}, [metadataTransformStats, services?.docLinks?.links.endpoints.troubleshooting]);

const transformFailedCallout = useMemo(() => {
if (!showTransformFailedCallout) {
Expand Down

0 comments on commit 7869250

Please sign in to comment.