Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELS-8] - [Synthetics] Refactor monitor detail flyout #147828

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import React from 'react';

import { MonitorStatus } from '../common/components/monitor_status';
import { MonitorStatus } from '../monitor_status/monitor_status';
import { useSelectedMonitor } from './hooks/use_selected_monitor';
import { useMonitorLatestPing } from './hooks/use_monitor_latest_ping';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 { EuiDescriptionList, EuiBadge, EuiLoadingSpinner } from '@elastic/eui';
import { LABELS } from '../monitors_page/overview/overview/monitor_status_flyout';
import { EncryptedSyntheticsMonitor } from '../monitors_page/overview/types';

export interface MonitorStatusProps {
monitor: EncryptedSyntheticsMonitor;
loading?: boolean;
status?: string;
compressed?: boolean;
}

const statusListItems = ({ monitor, loading, status }: MonitorStatusProps) => {
const isBrowserType = monitor.type === 'browser';

const badge = () => {
switch (true) {
case loading:
return <EuiLoadingSpinner size="s" />;
case !status:
return <EuiBadge color="default">{LABELS.PENDING}</EuiBadge>;
case status === 'up':
return <EuiBadge color="success">{isBrowserType ? LABELS.SUCCESS : LABELS.UP}</EuiBadge>;
default:
return <EuiBadge color="danger">{isBrowserType ? LABELS.FAILED : LABELS.DOWN}</EuiBadge>;
}
};

return [{ title: LABELS.STATUS, description: badge }];
};
export const MonitorStatus = ({
monitor,
loading,
status,
compressed = true,
}: MonitorStatusProps) => {
return (
<EuiDescriptionList
align="left"
compressed={compressed}
listItems={statusListItems({ monitor, loading, status })}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
} from '../types';
import { useMonitorDetailLocator } from '../../hooks/use_monitor_detail_locator';
import { fetchSyntheticsMonitor } from '../../../../state/overview/api';
import { MonitorStatus } from '../../../common/components/monitor_status';
import { MonitorStatus } from '../../../monitor_status/monitor_status';

interface Props {
configId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 { i18n } from '@kbn/i18n';

const STATUS = i18n.translate('xpack.synthetics.monitorStatus.statusLabel', {
defaultMessage: 'Status',
});

const FAILED = i18n.translate('xpack.synthetics.monitorStatus.failedLabel', {
defaultMessage: 'Failed',
});

const PENDING = i18n.translate('xpack.synthetics.monitorStatus.pendingLabel', {
defaultMessage: 'Pending',
});

const SUCCESS = i18n.translate('xpack.synthetics.monitorStatus.succeededLabel', {
defaultMessage: 'Succeeded',
});

const UP = i18n.translate('xpack.synthetics.monitorStatus.upLabel', {
defaultMessage: 'Up',
});

const DOWN = i18n.translate('xpack.synthetics.monitorStatus.downLabel', {
defaultMessage: 'Down',
});

export const LABELS = {
STATUS,
FAILED,
PENDING,
SUCCESS,
UP,
DOWN,
};