Skip to content

Commit

Permalink
[Synthetics] Disable/enable status alert for viewer user permissions (#…
Browse files Browse the repository at this point in the history
…156146)

## Summary

Fixes #155937

For viewer user tooltip will be displayed and button is disabled.

Also fixed loading position for manual test run loader.

<img width="1770" alt="image"
src="https://user-images.githubusercontent.com/3505601/235106034-7e758a5d-7291-47a2-8a46-2327b367e4a8.png">
  • Loading branch information
shahzad31 authored Apr 28, 2023
1 parent 67b2110 commit dab1409
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ export function ActionsPopover({
},
},
{
name: monitor.isStatusAlertEnabled ? disableAlertLabel : enableMonitorAlertLabel,
name: (
<NoPermissionsTooltip canEditSynthetics={canEditSynthetics}>
{monitor.isStatusAlertEnabled ? disableAlertLabel : enableMonitorAlertLabel}
</NoPermissionsTooltip>
),
disabled: !canEditSynthetics,
icon: alertLoading ? (
<EuiLoadingSpinner size="s" />
) : monitor.isStatusAlertEnabled ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { useRef } from 'react';
import { selectErrorPopoverState, toggleErrorPopoverOpen } from '../../../../state';
import { useErrorDetailsLink } from '../../../common/links/error_details_link';
import { MonitorOverviewItem, OverviewPing } from '../../../../../../../common/runtime_types';
import { manualTestRunSelector } from '../../../../state/manual_test_runs';
import { manualTestRunSelector, isTestRunning } from '../../../../state/manual_test_runs';
import { useFormatTestRunAt } from '../../../../utils/monitor_test_result/test_time_formats';

const Container = styled.div`
Expand Down Expand Up @@ -62,7 +62,7 @@ export const MetricItemIcon = ({
dispatch(toggleErrorPopoverOpen(configIdByLocation));
};

const inProgress = testNowRun?.status === 'in-progress' || testNowRun?.status === 'loading';
const inProgress = isTestRunning(testNowRun);

const errorLink = useErrorDetailsLink({
configId: monitor.configId,
Expand All @@ -75,9 +75,11 @@ export const MetricItemIcon = ({

if (inProgress) {
return (
<EuiToolTip position="top" content="Test is in progress">
<EuiLoadingSpinner />
</EuiToolTip>
<Container>
<EuiToolTip position="top" content={TEST_IN_PROGRESS}>
<EuiLoadingSpinner />
</EuiToolTip>
</Container>
);
}

Expand Down Expand Up @@ -164,6 +166,10 @@ const ERROR_DETAILS = i18n.translate('xpack.synthetics.errorDetails.label', {
defaultMessage: 'Error details',
});

const TEST_IN_PROGRESS = i18n.translate('xpack.synthetics.inProgress.label', {
defaultMessage: 'Manual test run is in progress.',
});

const StyledIcon = euiStyled.div<{ boxShadow: string }>`
box-sizing: border-box;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export enum TestRunStatus {
COMPLETED = 'completed',
}

export const isTestRunning = (testRun?: ManualTestRun) =>
testRun?.status === TestRunStatus.IN_PROGRESS || testRun?.status === TestRunStatus.LOADING;

export interface ManualTestRun {
configId: string;
name: string;
Expand Down

0 comments on commit dab1409

Please sign in to comment.