Skip to content

Commit

Permalink
Merge with 'main' after rebase for synthetics plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
awahab07 committed Sep 21, 2022
1 parent 39553a3 commit 5b9eee7
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export const BrowserStepsList = ({ steps, error, loading, showStepNumber = false
mobileOptions: { show: false },
render: (_val: string, item) => (
<EuiButtonIcon
aria-label={VIEW_DETAILS}
title={VIEW_DETAILS}
size="s"
href={`${basePath}/app/uptime/journey/${item.monitor.check_group}/step/${item.synthetics?.step?.index}`}
target="_blank"
Expand Down Expand Up @@ -166,6 +168,10 @@ const STEP_LABEL = i18n.translate('xpack.synthetics.monitor.step.label', {
defaultMessage: 'Step',
});

const STEP_DURATION = i18n.translate('xpack.synthetics.monitor.step.durationLabel', {
const STEP_DURATION = i18n.translate('xpack.synthetics.monitor.step.duration.label', {
defaultMessage: 'Duration',
});

const VIEW_DETAILS = i18n.translate('xpack.synthetics.monitor.step.viewDetails', {
defaultMessage: 'View Details',
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { AvailabilitySparklines } from './availability_sparklines';
import { LastTestRun } from './last_test_run';
import { LastTenTestRuns } from './last_ten_test_runs';

export const SummaryTabContent = () => {
export const MonitorSummary = () => {
const { euiTheme } = useEuiTheme();

return (
Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/synthetics/public/apps/synthetics/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ export const PageRouter: FC = () => {
<Switch>
{routes.map(
({
title,
path,
component: RouteComponent,
dataTestSubj,
pageHeader,
...pageTemplateProps
}: RouteProps) => (
title,
path,
component: RouteComponent,
dataTestSubj,
pageHeader,
...pageTemplateProps
}: RouteProps) => (
<Route path={path} key={dataTestSubj} exact={true}>
<div className={APP_WRAPPER_CLASS} data-test-subj={dataTestSubj}>
<RouteInit title={title} path={path} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useCallback, useContext, useState, useEffect, useRef } from 'react';
import React, { useCallback, useContext, useState, useEffect } from 'react';
import { useParams, Redirect } from 'react-router-dom';
import {
EuiFlexGroup,
Expand Down Expand Up @@ -38,11 +38,6 @@ import { monitorManagementListSelector } from '../../../state/selectors';

import { kibanaService } from '../../../state/kibana_service';

import {
PRIVATE_AVAILABLE_LABEL,
TEST_SCHEDULED_LABEL,
} from '../../overview/monitor_list/translations';

export interface ActionBarProps {
monitor: SyntheticsMonitor;
isValid: boolean;
Expand All @@ -68,11 +63,9 @@ export const ActionBar = ({
const [isSaving, setIsSaving] = useState(false);
const [isSuccessful, setIsSuccessful] = useState(false);
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean | undefined>(undefined);
const mouseMoveTimeoutIds = useRef<[number, number]>([0, 0]);
const isReadOnly = monitor[ConfigKey.MONITOR_SOURCE_TYPE] === SourceType.PROJECT;

const hasServiceManagedLocation = monitor.locations?.some((loc) => loc.isServiceManaged);
const isOnlyPrivateLocations = !locations.some((loc) => loc.isServiceManaged);

const { data, status } = useFetcher(() => {
if (!isSaving || !isValid) {
Expand Down Expand Up @@ -146,14 +139,11 @@ export const ActionBar = ({
<EuiFlexItem grow={false}>
<WarningText>{!isValid && hasBeenSubmitted && VALIDATION_ERROR_LABEL}</WarningText>
</EuiFlexItem>

{onTestNow && (
<EuiFlexItem grow={false}>
{/* Popover is used instead of EuiTooltip until the resolution of https://github.com/elastic/eui/issues/5604 */}
<EuiPopover
repositionOnScroll={true}
ownFocus={false}
initialFocus={''}
button={
<EuiButton
css={{ width: '100%' }}
Expand All @@ -164,24 +154,11 @@ export const ActionBar = ({
disabled={!isValid || isTestRunInProgress || !hasServiceManagedLocation}
data-test-subj={'monitorTestNowRunBtn'}
onClick={() => onTestNow()}
onMouseOver={() => {
// We need this custom logic to display a popover even when button is disabled.
clearTimeout(mouseMoveTimeoutIds.current[1]);
if (mouseMoveTimeoutIds.current[0] === 0) {
mouseMoveTimeoutIds.current[0] = setTimeout(() => {
clearTimeout(mouseMoveTimeoutIds.current[1]);
setIsPopoverOpen(true);
}, 250) as unknown as number;
}
onMouseEnter={() => {
setIsPopoverOpen(true);
}}
onMouseOut={() => {
// We need this custom logic to display a popover even when button is disabled.
clearTimeout(mouseMoveTimeoutIds.current[1]);
mouseMoveTimeoutIds.current[1] = setTimeout(() => {
clearTimeout(mouseMoveTimeoutIds.current[0]);
setIsPopoverOpen(false);
mouseMoveTimeoutIds.current = [0, 0];
}, 100) as unknown as number;
onMouseLeave={() => {
setIsPopoverOpen(false);
}}
>
{testRun ? RE_RUN_TEST_LABEL : RUN_TEST_LABEL}
Expand All @@ -190,13 +167,7 @@ export const ActionBar = ({
isOpen={isPopoverOpen}
>
<EuiText style={{ width: 260, outline: 'none' }}>
<p>
{isTestRunInProgress
? TEST_SCHEDULED_LABEL
: isOnlyPrivateLocations || (isValid && !hasServiceManagedLocation)
? PRIVATE_AVAILABLE_LABEL
: TEST_NOW_DESCRIPTION}
</p>
<p>{TEST_NOW_DESCRIPTION}</p>
</EuiText>
</EuiPopover>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export function useRunOnceErrors({
}) {
const [locationErrors, setLocationErrors] = useState<ServiceLocationErrors>([]);
const [runOnceServiceError, setRunOnceServiceError] = useState<Error | null>(null);
const publicLocations = useMemo(
() => (locations ?? []).filter((loc) => loc.isServiceManaged),
[locations]
);

useEffect(() => {
setLocationErrors([]);
Expand All @@ -47,16 +43,16 @@ export function useRunOnceErrors({
}, [serviceError]);

const locationsById: Record<string, Locations[number]> = useMemo(
() => (publicLocations as Locations).reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {}),
[publicLocations]
() => (locations as Locations).reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {}),
[locations]
);

const expectPings =
publicLocations.length - (locationErrors ?? []).filter(({ locationId }) => !!locationId).length;
locations.length - (locationErrors ?? []).filter(({ locationId }) => !!locationId).length;

const hasBlockingError =
!!runOnceServiceError ||
(locationErrors?.length && locationErrors?.length === publicLocations.length);
(locationErrors?.length && locationErrors?.length === locations.length);

const errorMessages = useMemo(() => {
if (hasBlockingError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

import { EuiButtonIcon, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Ping } from '../../../../../../common/runtime_types';
import { testNowMonitorAction } from '../../../../state/actions';
import { testNowRunSelector, TestRunStats } from '../../../../state/reducers/test_now_runs';
import * as labels from '../translations';

export const TestNowColumn = ({
monitorId,
Expand All @@ -28,15 +28,15 @@ export const TestNowColumn = ({

if (selectedMonitor.monitor.fleet_managed) {
return (
<EuiToolTip content={labels.PRIVATE_AVAILABLE_LABEL}>
<EuiToolTip content={PRIVATE_AVAILABLE_LABEL}>
<>--</>
</EuiToolTip>
);
}

if (!configId) {
return (
<EuiToolTip content={labels.TEST_NOW_AVAILABLE_LABEL}>
<EuiToolTip content={TEST_NOW_AVAILABLE_LABEL}>
<>--</>
</EuiToolTip>
);
Expand All @@ -54,13 +54,45 @@ export const TestNowColumn = ({
}

return (
<EuiToolTip content={testNowRun ? labels.TEST_SCHEDULED_LABEL : labels.TEST_NOW_LABEL}>
<EuiToolTip content={testNowRun ? TEST_SCHEDULED_LABEL : TEST_NOW_LABEL}>
<EuiButtonIcon
iconType="play"
onClick={() => testNowClick()}
isDisabled={!isTestNowCompleted}
aria-label={labels.TEST_NOW_ARIA_LABEL}
aria-label={TEST_NOW_ARIA_LABEL}
/>
</EuiToolTip>
);
};

export const TEST_NOW_ARIA_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.AriaLabel',
{
defaultMessage: 'CLick to run test now',
}
);

export const TEST_NOW_AVAILABLE_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.available',
{
defaultMessage: 'Test now is only available for monitors added via Monitor Management.',
}
);

export const PRIVATE_AVAILABLE_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.available.private',
{
defaultMessage: `You can't currently test monitors running on private locations on demand.`,
}
);

export const TEST_NOW_LABEL = i18n.translate('xpack.synthetics.monitorList.testNow.label', {
defaultMessage: 'Test now',
});

export const TEST_SCHEDULED_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.scheduled',
{
defaultMessage: 'Test is already scheduled',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,3 @@ export const STATUS_ALERT_COLUMN = i18n.translate(
export const TEST_NOW_COLUMN = i18n.translate('xpack.synthetics.monitorList.testNow.label', {
defaultMessage: 'Test now',
});

export const TEST_NOW_AVAILABLE_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.available',
{
defaultMessage: 'Test now is only available for monitors added via Monitor Management.',
}
);

export const TEST_SCHEDULED_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.scheduled',
{
defaultMessage: 'Test is already scheduled',
}
);

export const PRIVATE_AVAILABLE_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.available.private',
{
defaultMessage: `You can't currently test monitors running on private locations on demand.`,
}
);

export const TEST_NOW_ARIA_LABEL = i18n.translate(
'xpack.synthetics.monitorList.testNow.AriaLabel',
{
defaultMessage: 'Click to run test now',
}
);

export const TEST_NOW_LABEL = i18n.translate('xpack.synthetics.monitorList.testNow.label', {
defaultMessage: 'Test now',
});

0 comments on commit 5b9eee7

Please sign in to comment.