-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics] Step details page screenshot (#143452)
Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
74829e5
commit 80310d8
Showing
30 changed files
with
632 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...ck/plugins/synthetics/public/apps/synthetics/components/common/screenshot/empty_image.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* 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 from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
useEuiTheme, | ||
useEuiBackgroundColor, | ||
EuiIcon, | ||
EuiLoadingContent, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
|
||
export const IMAGE_WIDTH = 360; | ||
export const IMAGE_HEIGHT = 203; | ||
|
||
export const imageStyle = css` | ||
padding: 0; | ||
margin: auto; | ||
width: ${IMAGE_WIDTH}px; | ||
height: ${IMAGE_HEIGHT}px; | ||
object-fit: contain; | ||
overflow: hidden; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const EmptyImage = ({ | ||
isLoading = false, | ||
width = IMAGE_WIDTH, | ||
height = IMAGE_HEIGHT, | ||
}: { | ||
isLoading: boolean; | ||
width?: number; | ||
height?: number; | ||
}) => { | ||
const { euiTheme } = useEuiTheme(); | ||
|
||
return ( | ||
<div | ||
data-test-subj="stepScreenshotPlaceholder" | ||
role="img" | ||
aria-label={isLoading ? SCREENSHOT_LOADING_ARIA_LABEL : SCREENSHOT_NOT_AVAILABLE} | ||
title={isLoading ? SCREENSHOT_LOADING_ARIA_LABEL : SCREENSHOT_NOT_AVAILABLE} | ||
css={css` | ||
${imageStyle}; | ||
width: ${width}px; | ||
height: ${height}px; | ||
background: ${useEuiBackgroundColor('subdued')}; | ||
border: ${euiTheme.border.thin}; | ||
`} | ||
> | ||
{isLoading ? ( | ||
<EuiLoadingContent | ||
lines={1} | ||
data-test-subj="stepScreenshotPlaceholderLoading" | ||
css={css` | ||
width: 100%; | ||
height: 8%; | ||
transform: scale(1, 13); // To create a skeleton loading effect | ||
`} | ||
/> | ||
) : ( | ||
<div> | ||
<EuiIcon | ||
data-test-subj="stepScreenshotNotAvailable" | ||
type="eyeClosed" | ||
color={euiTheme.colors.disabledText} | ||
/> | ||
<EuiText color={euiTheme.colors.disabledText}>{IMAGE_UN_AVAILABLE}</EuiText> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export const SCREENSHOT_LOADING_ARIA_LABEL = i18n.translate( | ||
'xpack.synthetics.monitor.step.screenshot.ariaLabel', | ||
{ | ||
defaultMessage: 'Step screenshot is being loaded.', | ||
} | ||
); | ||
|
||
export const SCREENSHOT_NOT_AVAILABLE = i18n.translate( | ||
'xpack.synthetics.monitor.step.screenshot.notAvailable', | ||
{ | ||
defaultMessage: 'Step screenshot is not available.', | ||
} | ||
); | ||
|
||
export const IMAGE_UN_AVAILABLE = i18n.translate( | ||
'xpack.synthetics.monitor.step.screenshot.unAvailable', | ||
{ | ||
defaultMessage: 'Image unavailable', | ||
} | ||
); |
39 changes: 39 additions & 0 deletions
39
...ins/synthetics/public/apps/synthetics/components/common/screenshot/journey_screenshot.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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, { useMemo } from 'react'; | ||
import { useJourneySteps } from '../../monitor_details/hooks/use_journey_steps'; | ||
import { parseBadgeStatus } from '../monitor_test_result/status_badge'; | ||
import { JourneyStepScreenshotContainer } from './journey_step_screenshot_container'; | ||
|
||
export const JourneyScreenshot = ({ checkGroupId }: { checkGroupId: string }) => { | ||
const { loading: stepsLoading, stepEnds } = useJourneySteps(checkGroupId); | ||
const stepLabels = stepEnds.map((stepEnd) => stepEnd?.synthetics?.step?.name ?? ''); | ||
|
||
const lastSignificantStep = useMemo(() => { | ||
const copy = [...stepEnds]; | ||
// Sort desc by timestamp | ||
copy.sort( | ||
(stepA, stepB) => | ||
Number(new Date(stepB['@timestamp'])) - Number(new Date(stepA['@timestamp'])) | ||
); | ||
return copy.find( | ||
(stepEnd) => parseBadgeStatus(stepEnd?.synthetics?.step?.status ?? 'skipped') !== 'skipped' | ||
); | ||
}, [stepEnds]); | ||
|
||
return ( | ||
<JourneyStepScreenshotContainer | ||
checkGroup={lastSignificantStep?.monitor.check_group} | ||
initialStepNo={lastSignificantStep?.synthetics?.step?.index} | ||
stepStatus={lastSignificantStep?.synthetics.payload?.status} | ||
allStepsLoaded={!stepsLoading} | ||
stepLabels={stepLabels} | ||
retryFetchOnRevisit={false} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.