[9.0] [Synthetics] Fix UI issue on Last test run panel and changed breadcrumb string when creating a monitor (#213874) (#214158)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Synthetics] Fix UI issue on Last test run panel and changed
breadcrumb string when creating a monitor
(#213874)](https://github.com/elastic/kibana/pull/213874)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-03-12T13:21:06Z","message":"[Synthetics]
Fix UI issue on Last test run panel and changed breadcrumb string when
creating a monitor (#213874)\n\nThis PR fixes #200921.\n\nThis is the
final result, where the step details button is correctly\nshown.\n<img
width=\"511\" alt=\"Screenshot 2025-03-11 at 09 57
33\"\nsrc=\"https://github.com/user-attachments/assets/c6017848-635a-4af5-aebc-68979ae115f9\"\n/>\n\nThis
PR also fixes #212246.\n<img width=\"1143\" alt=\"Screenshot 2025-03-11
at 11 09
55\"\nsrc=\"https://github.com/user-attachments/assets/20b75ba4-ce99-4cc9-a827-11e5cb03a6da\"\n/>","sha":"1b8fcd21e31963425153c34d4ca1be73d9bd7dcf","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0"],"title":"[Synthetics]
Fix UI issue on Last test run panel and changed breadcrumb string when
creating a
monitor","number":213874,"url":"https://github.com/elastic/kibana/pull/213874","mergeCommit":{"message":"[Synthetics]
Fix UI issue on Last test run panel and changed breadcrumb string when
creating a monitor (#213874)\n\nThis PR fixes #200921.\n\nThis is the
final result, where the step details button is correctly\nshown.\n<img
width=\"511\" alt=\"Screenshot 2025-03-11 at 09 57
33\"\nsrc=\"https://github.com/user-attachments/assets/c6017848-635a-4af5-aebc-68979ae115f9\"\n/>\n\nThis
PR also fixes #212246.\n<img width=\"1143\" alt=\"Screenshot 2025-03-11
at 11 09
55\"\nsrc=\"https://github.com/user-attachments/assets/20b75ba4-ce99-4cc9-a827-11e5cb03a6da\"\n/>","sha":"1b8fcd21e31963425153c34d4ca1be73d9bd7dcf"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213874","number":213874,"mergeCommit":{"message":"[Synthetics]
Fix UI issue on Last test run panel and changed breadcrumb string when
creating a monitor (#213874)\n\nThis PR fixes #200921.\n\nThis is the
final result, where the step details button is correctly\nshown.\n<img
width=\"511\" alt=\"Screenshot 2025-03-11 at 09 57
33\"\nsrc=\"https://github.com/user-attachments/assets/c6017848-635a-4af5-aebc-68979ae115f9\"\n/>\n\nThis
PR also fixes #212246.\n<img width=\"1143\" alt=\"Screenshot 2025-03-11
at 11 09
55\"\nsrc=\"https://github.com/user-attachments/assets/20b75ba4-ce99-4cc9-a827-11e5cb03a6da\"\n/>","sha":"1b8fcd21e31963425153c34d4ca1be73d9bd7dcf"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
This commit is contained in:
Kibana Machine 2025-03-13 02:19:57 +11:00 committed by GitHub
parent 66b752064b
commit 6536b6598d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 64 additions and 40 deletions

View file

@ -16,6 +16,7 @@ import React, {
useMemo,
} from 'react';
import {
Criteria,
EuiBasicTable,
EuiBasicTableColumn,
EuiButtonIcon,
@ -24,8 +25,8 @@ import {
EuiText,
EuiTextProps,
EuiTitle,
Pagination,
useEuiTheme,
useIsWithinMinBreakpoint,
} from '@elastic/eui';
import { EuiThemeComputed } from '@elastic/eui/src/services/theme/types';
@ -77,6 +78,8 @@ function mapStepIds(steps: JourneyStep[]) {
return steps.map(({ _id }) => _id).toString();
}
const MAX_STEPS_TO_SHOW = 5;
export const BrowserStepsList = ({
steps,
error,
@ -88,8 +91,34 @@ export const BrowserStepsList = ({
showExpand = true,
testNowMode = false,
}: Props) => {
const stepEnds: JourneyStep[] = steps.filter(isStepEnd);
const failedStep = stepEnds.find((step) => step.synthetics.step?.status === 'failed');
const [pageIndex, setPageIndex] = useState(0);
const allStepEnds: JourneyStep[] = steps.filter(isStepEnd);
const failedStep = allStepEnds.find((step) => step.synthetics.step?.status === 'failed');
const shouldPaginate = allStepEnds.length > MAX_STEPS_TO_SHOW;
const stepEnds = shouldPaginate
? allStepEnds.slice(
pageIndex * MAX_STEPS_TO_SHOW,
Math.min(pageIndex * MAX_STEPS_TO_SHOW + MAX_STEPS_TO_SHOW, allStepEnds.length)
)
: allStepEnds;
const pagination: Pagination | undefined = shouldPaginate
? {
pageIndex,
pageSize: MAX_STEPS_TO_SHOW,
totalItemCount: allStepEnds.length,
showPerPageOptions: false,
}
: undefined;
const onTableChange = ({ page }: Criteria<JourneyStep>) => {
if (page) {
setPageIndex(page.index);
}
};
/**
* This component is used in cases where the steps list is not pre-fetched at render time. In that case, we handle the auto-expand
* in the `useEffect` call below, which will update the expanded map after the data loads. At times, the component is also rendered
@ -105,7 +134,6 @@ export const BrowserStepsList = ({
const { euiTheme } = useEuiTheme();
const [expandedMap, setExpandedMap] = useState<Record<string, ReactElement>>(defaultExpanded);
const [stepIds, setStepIds] = useState<string>(mapStepIds(stepEnds));
const isTabletOrGreater = useIsWithinMinBreakpoint('s');
useEffect(() => {
/**
@ -284,35 +312,34 @@ export const BrowserStepsList = ({
];
return (
<>
<EuiBasicTable
css={{ overflowX: isTabletOrGreater ? 'auto' : undefined }}
cellProps={(row) => {
if (expandedMap[row._id]) {
return {
style: { verticalAlign: 'top' },
};
}
}}
compressed={compressed}
loading={loading}
columns={columns}
error={error?.message}
items={stepEnds}
noItemsMessage={
loading
? i18n.translate('xpack.synthetics.monitor.step.loading', {
defaultMessage: 'Loading steps...',
})
: i18n.translate('xpack.synthetics.monitor.step.noDataFound', {
defaultMessage: 'No data found',
})
<EuiBasicTable
cellProps={(row) => {
if (expandedMap[row._id]) {
return {
style: { verticalAlign: 'top' },
};
}
tableLayout="auto"
itemId="_id"
itemIdToExpandedRowMap={testNowMode || showExpand ? expandedMap : undefined}
/>
</>
}}
compressed={compressed}
loading={loading}
columns={columns}
error={error?.message}
items={stepEnds}
noItemsMessage={
loading
? i18n.translate('xpack.synthetics.monitor.step.loading', {
defaultMessage: 'Loading steps...',
})
: i18n.translate('xpack.synthetics.monitor.step.noDataFound', {
defaultMessage: 'No data found',
})
}
tableLayout="auto"
itemId="_id"
itemIdToExpandedRowMap={testNowMode || showExpand ? expandedMap : undefined}
onChange={onTableChange}
pagination={pagination}
/>
);
};

View file

@ -31,8 +31,8 @@ export const ResultDetails = ({
}) => {
return (
<div>
<EuiText className="eui-textNoWrap" size="s">
<StatusBadge status={parseBadgeStatus(pingStatus)} />{' '}
<StatusBadge status={parseBadgeStatus(pingStatus)} />
<EuiText size="s">
{!testNowMode
? i18n.translate('xpack.synthetics.step.duration.label', {
defaultMessage: 'after {value}',

View file

@ -30,7 +30,7 @@ export const useMonitorAddEditBreadcrumbs = (isEdit?: boolean) => {
export const ADD_MONITOR_CRUMB = i18n.translate(
'xpack.synthetics.monitorManagement.addMonitorCrumb',
{
defaultMessage: 'Add monitor',
defaultMessage: 'Create monitor',
}
);

View file

@ -10,7 +10,6 @@ import { EuiTitle, EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } fro
import { i18n } from '@kbn/i18n';
import { LoadWhenInView } from '@kbn/observability-shared-plugin/public';
import { SummaryPanel } from './summary_panel';
import { useTestFlyoutOpen } from '../../test_now_mode/hooks/use_test_flyout_open';
import { useMonitorDetailsPage } from '../use_monitor_details_page';
import { useMonitorRangeFrom } from '../hooks/use_monitor_range_from';
@ -26,8 +25,6 @@ import { MonitorPendingWrapper } from '../monitor_pending_wrapper';
export const MonitorSummary = () => {
const { from, to } = useMonitorRangeFrom();
const isFlyoutOpen = !!useTestFlyoutOpen();
const dateLabel = from === 'now-30d/d' ? LAST_30_DAYS_LABEL : TO_DATE_LABEL;
const redirect = useMonitorDetailsPage();
@ -70,13 +67,13 @@ export const MonitorSummary = () => {
/>
<EuiSpacer size="m" />
<EuiFlexGroup gutterSize="m" wrap={true}>
<EuiFlexItem css={isFlyoutOpen ? { minWidth: 260, maxWidth: 500 } : { maxWidth: 500 }}>
<EuiFlexItem css={{ minWidth: 430 }}>
<LastTestRun />
</EuiFlexItem>
<EuiFlexItem css={{ minWidth: 260 }}>
<MonitorAlerts dateLabel={dateLabel} from={from} to={to} />
<EuiSpacer size="m" />
<StepDurationPanel />
<StepDurationPanel legendPosition="bottom" />
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />