[Security Solution] show correct failed transform on failed transform banner (#117608)

This commit is contained in:
Joey F. Poon 2021-11-05 15:31:02 -05:00 committed by GitHub
parent 26757b64cd
commit 2f29e307fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 9 deletions

View file

@ -261,5 +261,8 @@ readonly links: {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
```

File diff suppressed because one or more lines are too long

View file

@ -507,6 +507,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`,
},
},
});
}
@ -770,5 +773,8 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}

View file

@ -729,6 +729,9 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}

View file

@ -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
@ -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);
});
});
});

View file

@ -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"
@ -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
@ -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) {