Skip to content

Commit

Permalink
Rename PointerEventContext to ChartPointerEventContext
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Nov 25, 2020
1 parent 10f8fda commit 836bd61
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { TransactionCharts } from '../../shared/charts/transaction_charts';
import { TransactionDistribution } from './Distribution';
import { WaterfallWithSummmary } from './WaterfallWithSummmary';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { PointerEventContextProvider } from '../../../context/pointer_event_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { useTrackPageview } from '../../../../../observability/public';
import { Projection } from '../../../../common/projections';
import { fromQuery, toQuery } from '../../shared/Links/url_helpers';
Expand Down Expand Up @@ -125,13 +125,13 @@ export function TransactionDetails({
<LocalUIFilters {...localUIFiltersConfig} />
</EuiFlexItem>
<EuiFlexItem grow={7}>
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<TransactionCharts
fetchStatus={transactionChartsStatus}
charts={transactionChartsData}
urlParams={urlParams}
/>
</PointerEventContextProvider>
</ChartPointerEventContextProvider>

<EuiHorizontalRule size="full" margin="l" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import React, { useMemo } from 'react';
import { useServiceMetricCharts } from '../../../hooks/useServiceMetricCharts';
import { MetricsChart } from '../../shared/charts/metrics_chart';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { PointerEventContextProvider } from '../../../context/pointer_event_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { Projection } from '../../../../common/projections';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { SearchBar } from '../../shared/search_bar';
Expand Down Expand Up @@ -57,7 +57,7 @@ export function ServiceMetrics({
<LocalUIFilters {...localFiltersConfig} />
</EuiFlexItem>
<EuiFlexItem grow={7}>
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<EuiFlexGrid columns={2} gutterSize="s">
{data.charts.map((chart) => (
<EuiFlexItem key={chart.key}>
Expand All @@ -73,7 +73,7 @@ export function ServiceMetrics({
))}
</EuiFlexGrid>
<EuiSpacer size="xxl" />
</PointerEventContextProvider>
</ChartPointerEventContextProvider>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import React from 'react';
import { RouteComponentProps } from 'react-router-dom';
import styled from 'styled-components';
import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes';
import { PointerEventContextProvider } from '../../../context/pointer_event_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { useAgentName } from '../../../hooks/useAgentName';
import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher';
import { useServiceMetricCharts } from '../../../hooks/useServiceMetricCharts';
Expand Down Expand Up @@ -178,7 +178,7 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
</MetadataFlexGroup>
)}
{agentName && (
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<EuiFlexGrid columns={2} gutterSize="s">
{data.charts.map((chart) => (
<EuiFlexItem key={chart.key}>
Expand All @@ -194,12 +194,12 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
))}
</EuiFlexGrid>
<EuiSpacer size="xxl" />
</PointerEventContextProvider>
</ChartPointerEventContextProvider>
)}
<SearchBar />
<EuiPage>
{agentName && (
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<EuiFlexGrid columns={2} gutterSize="s">
{data.charts.map((chart) => (
<EuiFlexItem key={chart.key}>
Expand All @@ -215,7 +215,7 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) {
))}
</EuiFlexGrid>
<EuiSpacer size="xxl" />
</PointerEventContextProvider>
</ChartPointerEventContextProvider>
)}
</EuiPage>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import { useTrackPageview } from '../../../../../observability/public';
import { isRumAgentName } from '../../../../common/agent_name';
import { PointerEventContextProvider } from '../../../context/pointer_event_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event_context';
import { TransactionBreakdownChart } from '../../shared/charts/transaction_breakdown_chart';
import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart';
import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink';
Expand Down Expand Up @@ -43,7 +43,7 @@ export function ServiceOverview({
useTrackPageview({ app: 'apm', path: 'service_overview', delay: 15000 });

return (
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<SearchBar />
<EuiPage>
<EuiFlexGroup direction="column" gutterSize="s">
Expand Down Expand Up @@ -170,6 +170,6 @@ export function ServiceOverview({
</EuiFlexItem>
</EuiFlexGroup>
</EuiPage>
</PointerEventContextProvider>
</ChartPointerEventContextProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useChartTheme } from '../../../../../observability/public';
import { TimeSeries } from '../../../../typings/timeseries';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { usePointerEvent } from '../../../hooks/use_pointer_event';
import { useChartPointerEvent } from '../../../hooks/use_chart_pointer_event';
import { unit } from '../../../style/variables';
import { Annotations } from './annotations';
import { ChartContainer } from './chart_container';
Expand Down Expand Up @@ -60,7 +60,7 @@ export function TimeseriesChart({
const history = useHistory();
const chartRef = React.createRef<Chart>();
const chartTheme = useChartTheme();
const { pointerEvent, setPointerEvent } = usePointerEvent();
const { pointerEvent, setPointerEvent } = useChartPointerEvent();
const { urlParams } = useUrlParams();
const { start, end } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { asPercent } from '../../../../../common/utils/formatters';
import { TimeSeries } from '../../../../../typings/timeseries';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { usePointerEvent } from '../../../../hooks/use_pointer_event';
import { useChartPointerEvent } from '../../../../hooks/use_chart_pointer_event';
import { unit } from '../../../../style/variables';
import { Annotations } from '../../charts/annotations';
import { ChartContainer } from '../../charts/chart_container';
Expand All @@ -45,7 +45,7 @@ export function TransactionBreakdownChartContents({
const history = useHistory();
const chartRef = React.createRef<Chart>();
const chartTheme = useChartTheme();
const { pointerEvent, setPointerEvent } = usePointerEvent();
const { pointerEvent, setPointerEvent } = useChartPointerEvent();
const { urlParams } = useUrlParams();
const { start, end } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
TRANSACTION_ROUTE_CHANGE,
} from '../../../../../common/transaction_types';
import { asTransactionRate } from '../../../../../common/utils/formatters';
import { PointerEventContextProvider } from '../../../../context/pointer_event_context';
import { ChartPointerEventContextProvider } from '../../../../context/chart_pointer_event_context';
import { LicenseContext } from '../../../../context/LicenseContext';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
Expand Down Expand Up @@ -51,7 +51,7 @@ export function TransactionCharts({

return (
<>
<PointerEventContextProvider>
<ChartPointerEventContextProvider>
<EuiFlexGrid columns={2} gutterSize="s">
<EuiFlexItem data-cy={`transaction-duration-charts`}>
<EuiPanel>
Expand Down Expand Up @@ -109,7 +109,7 @@ export function TransactionCharts({
<TransactionBreakdownChart />
</EuiFlexItem>
</EuiFlexGrid>
</PointerEventContextProvider>
</ChartPointerEventContextProvider>
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ import React, {

import { PointerEvent } from '@elastic/charts';

export const PointerEventContext = createContext<{
export const ChartPointerEventContext = createContext<{
pointerEvent: PointerEvent | null;
setPointerEvent: Dispatch<SetStateAction<PointerEvent | null>>;
} | null>(null);

export function PointerEventContextProvider({
export function ChartPointerEventContextProvider({
children,
}: {
children: ReactNode;
}) {
const [pointerEvent, setPointerEvent] = useState<PointerEvent | null>(null);

return (
<PointerEventContext.Provider
<ChartPointerEventContext.Provider
value={{ pointerEvent, setPointerEvent }}
children={children}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/

import { useContext } from 'react';
import { PointerEventContext } from '../context/pointer_event_context';
import { ChartPointerEventContext } from '../context/chart_pointer_event_context';

export function usePointerEvent() {
const context = useContext(PointerEventContext);
export function useChartPointerEvent() {
const context = useContext(ChartPointerEventContext);

if (!context) {
throw new Error('Missing PointerEventContext provider');
throw new Error('Missing ChartPointerEventContext provider');
}

return context;
Expand Down

0 comments on commit 836bd61

Please sign in to comment.