Skip to content

Commit

Permalink
Enable pass-through props for component wrapper, hide location and en…
Browse files Browse the repository at this point in the history
…abled for test run details.
  • Loading branch information
justinkambic committed Feb 28, 2023
1 parent b7d96fb commit 04f5701
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ const DescriptionLabel = euiStyled(EuiDescriptionListDescription)`
width: 60%;
`;

export interface MonitorDetailsPanelProps {
latestPing?: Ping;
loading: boolean;
configId: string;
monitor: EncryptedSyntheticsSavedMonitor | null;
hideEnabled?: boolean;
hideLocations?: boolean;
}

export const MonitorDetailsPanel = ({
monitor,
latestPing,
loading,
configId,
hideEnabled = false,
}: {
latestPing?: Ping;
loading: boolean;
configId: string;
monitor: EncryptedSyntheticsSavedMonitor | null;
hideEnabled?: boolean;
}) => {
hideLocations = false,
}: MonitorDetailsPanelProps) => {
const dispatch = useDispatch();

if (!monitor) {
Expand Down Expand Up @@ -116,10 +120,15 @@ export const MonitorDetailsPanel = ({
</DescriptionLabel>
<TitleLabel>{FREQUENCY_LABEL}</TitleLabel>
<DescriptionLabel>{frequencyStr(monitor[ConfigKey.SCHEDULE])}</DescriptionLabel>
<TitleLabel>{LOCATIONS_LABEL}</TitleLabel>
<DescriptionLabel>
<LocationsStatus configId={configId} monitorLocations={monitor.locations} />
</DescriptionLabel>

{!hideLocations && (
<>
<TitleLabel>{LOCATIONS_LABEL}</TitleLabel>
<DescriptionLabel>
<LocationsStatus configId={configId} monitorLocations={monitor.locations} />
</DescriptionLabel>
</>
)}

<TitleLabel>{TAGS_LABEL}</TitleLabel>
<DescriptionLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import React from 'react';
import { EuiLoadingContent } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { MonitorDetailsPanel } from '../../common/components/monitor_details_panel';
import {
MonitorDetailsPanelProps,
MonitorDetailsPanel,
} from '../../common/components/monitor_details_panel';
import { useSelectedMonitor } from '../hooks/use_selected_monitor';
import { ConfigKey } from '../../../../../../common/runtime_types';
import { useMonitorLatestPing } from '../hooks/use_monitor_latest_ping';

export const MonitorDetailsPanelContainer = () => {
export const MonitorDetailsPanelContainer = (props: Partial<MonitorDetailsPanelProps>) => {
const { latestPing } = useMonitorLatestPing();

const { monitorId: configId } = useParams<{ monitorId: string }>();
Expand All @@ -34,6 +37,7 @@ export const MonitorDetailsPanelContainer = () => {
monitor={monitor}
loading={loading}
configId={configId}
{...props}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const TestRunDetails = () => {
<EuiFlexItem grow={1}>
<StepDurationPanel legendPosition="bottom" />
<EuiSpacer size="m" />
<MonitorDetailsPanelContainer />
<MonitorDetailsPanelContainer hideEnabled hideLocations />
</EuiFlexItem>
</EuiFlexGroup>
)}
Expand Down

0 comments on commit 04f5701

Please sign in to comment.