Skip to content

Commit

Permalink
chore: rename useUrlParams to useLegacyUrlParams (#116062)
Browse files Browse the repository at this point in the history
* chore: rename useUrlParams to useLegacyUrlParams

* fix: revert uptime & fleet changes

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
luckened and kibanamachine authored Nov 3, 2021
1 parent 9e02087 commit 6c06b12
Show file tree
Hide file tree
Showing 61 changed files with 120 additions and 120 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/dev_docs/routing_and_linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const {

`useApmParams` will strip query parameters for which there is no validation. The route path should match exactly, but you can also use wildcards: `useApmParams('/*)`. In that case, the return type will be a union type of all possible matching routes.

Previously we used `useUrlParams` for path and query parameters, which we are trying to get away from. When possible, any usage of `useUrlParams` should be replaced by `useApmParams` or other custom hooks that use `useApmParams` internally.
Previously we used `useLegacyUrlParams` for path and query parameters, which we are trying to get away from. When possible, any usage of `useLegacyUrlParams` should be replaced by `useApmParams` or other custom hooks that use `useApmParams` internally.

## Linking

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
createExploratoryViewUrl,
HeaderMenuPortal,
} from '../../../../../../observability/public';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { AppMountParameters } from '../../../../../../../../src/core/public';
import { InspectorHeaderLink } from '../../../shared/apm_header_action_menu/inspector_header_link';
Expand All @@ -38,7 +38,7 @@ export function UXActionMenu({
const {
services: { http },
} = useKibana();
const { urlParams } = useUrlParams();
const { urlParams } = useLegacyUrlParams();
const { rangeTo, rangeFrom, serviceName } = urlParams;

const uxExploratoryViewLink = createExploratoryViewUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import moment from 'moment';
import React from 'react';
import { useHistory } from 'react-router-dom';
import { useUiSetting$ } from '../../../../../../../../src/plugins/kibana_react/public';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers';
import { ChartWrapper } from '../ChartWrapper';
import { I18LABELS } from '../translations';
Expand All @@ -43,7 +43,7 @@ interface Props {

export function PageViewsChart({ data, loading }: Props) {
const history = useHistory();
const { urlParams } = useUrlParams();
const { urlParams } = useLegacyUrlParams();

const { start, end } = urlParams;
const diffInDays = moment(new Date(end as string)).diff(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
} from '@elastic/eui';
import { I18LABELS } from '../translations';
import { getPercentileLabel } from '../UXMetrics/translations';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { Metrics } from './Metrics';

export function ClientMetrics() {
const {
urlParams: { percentile },
} = useUrlParams();
} = useLegacyUrlParams();

return (
<EuiPanel hasBorder={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { I18LABELS } from '../translations';
import { CsmSharedContext } from '../CsmSharedContext';
Expand All @@ -31,7 +31,7 @@ interface JSErrorItem {
}

export function JSErrors() {
const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();

const { start, end, serviceName, searchTerm } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { Fragment } from 'react';
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { FilterValueLabel } from '../../../../../../observability/public';
import { FiltersUIHook } from '../hooks/useLocalUIFilters';
import { UxLocalUIFilterName } from '../../../../../common/ux_ui_filter';
Expand Down Expand Up @@ -38,7 +38,7 @@ export function SelectedFilters({
const {
uxUiFilters,
urlParams: { searchTerm },
} = useUrlParams();
} = useLegacyUrlParams();
const { transactionUrl } = uxUiFilters;

const urlValues = transactionUrl ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as React from 'react';
import { useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { FilterValueLabel } from '../../../../../../observability/public';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers';
import { TRANSACTION_URL } from '../../../../../common/elasticsearch_fieldnames';
import { IndexPattern } from '../../../../../../../../src/plugins/data_views/common';
Expand All @@ -22,7 +22,7 @@ export function SelectedWildcards({ indexPattern }: Props) {

const {
urlParams: { searchTerm },
} = useUrlParams();
} = useLegacyUrlParams();

const updateSearchTerm = useCallback(
(searchTermN: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { I18LABELS } from '../translations';
import { BreakdownFilter } from '../Breakdowns/BreakdownFilter';
Expand All @@ -34,7 +34,7 @@ export function PageLoadDistribution() {
services: { http },
} = useKibana();

const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();

const { start, end, rangeFrom, rangeTo, searchTerm } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { useFetcher } from '../../../../hooks/use_fetcher';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { PercentileRange } from './index';

interface Props {
Expand All @@ -16,7 +16,7 @@ interface Props {
}

export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();
const { start, end, searchTerm } = urlParams;
const { min: minP, max: maxP } = percentileRange ?? {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { I18LABELS } from '../translations';
import { BreakdownFilter } from '../Breakdowns/BreakdownFilter';
Expand All @@ -28,7 +28,7 @@ export function PageViewsTrend() {
services: { http },
} = useKibana();

const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();
const { serviceName } = uxUiFilters;

const { start, end, searchTerm, rangeTo, rangeFrom } = urlParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import React from 'react';
import { ServiceNameFilter } from '../URLFilter/ServiceNameFilter';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { RUM_AGENT_NAMES } from '../../../../../common/agent_name';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';

export function WebApplicationSelect() {
const {
urlParams: { start, end },
} = useUrlParams();
} = useLegacyUrlParams();

const { data, status } = useFetcher(
(callApmApi) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiSelect } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect, useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { useUrlParams } from '../../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../../context/url_params_context/use_url_params';
import { fromQuery, toQuery } from '../../../../shared/Links/url_helpers';

interface Props {
Expand All @@ -21,7 +21,7 @@ function ServiceNameFilter({ loading, serviceNames }: Props) {
const history = useHistory();
const {
urlParams: { serviceName: selectedServiceName },
} = useUrlParams();
} = useLegacyUrlParams();

const options = serviceNames.map((type) => ({
text: type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { useEffect, useState } from 'react';
import { isEqual, map } from 'lodash';
import { i18n } from '@kbn/i18n';
import { useUrlParams } from '../../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../../context/url_params_context/use_url_params';
import { I18LABELS } from '../../translations';
import { formatToSec } from '../../UXMetrics/KeyUXMetrics';
import { getPercentileLabel } from '../../UXMetrics/translations';
Expand Down Expand Up @@ -93,7 +93,7 @@ export function URLSearch({
const {
uxUiFilters: { transactionUrl, transactionUrlExcluded },
urlParams,
} = useUrlParams();
} = useLegacyUrlParams();

const { searchTerm, percentile } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useDebounce from 'react-use/lib/useDebounce';
import { useState } from 'react';
import { useFetcher } from '../../../../../hooks/use_fetcher';
import { useUxQuery } from '../../hooks/useUxQuery';
import { useUrlParams } from '../../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../../context/url_params_context/use_url_params';

interface Props {
popoverIsOpen: boolean;
Expand All @@ -19,7 +19,7 @@ interface Props {
export const useUrlSearch = ({ popoverIsOpen, query }: Props) => {
const uxQuery = useUxQuery();

const { uxUiFilters } = useUrlParams();
const { uxUiFilters } = useLegacyUrlParams();

const { transactionUrl, transactionUrlExcluded, ...restFilters } =
uxUiFilters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import { useFetcher } from '../../../../hooks/use_fetcher';
import { useUxQuery } from '../hooks/useUxQuery';
import { getCoreVitalsComponent } from '../../../../../../observability/public';
import { CsmSharedContext } from '../CsmSharedContext';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { getPercentileLabel } from './translations';

export function UXMetrics() {
const {
urlParams: { percentile },
} = useUrlParams();
} = useLegacyUrlParams();

const uxQuery = useUxQuery();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useCallback, useEffect } from 'react';

import { EuiSelect } from '@elastic/eui';
import { useHistory } from 'react-router-dom';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers';
import { I18LABELS } from '../translations';

Expand All @@ -20,7 +20,7 @@ export function UserPercentile() {

const {
urlParams: { percentile },
} = useUrlParams();
} = useLegacyUrlParams();

const updatePercentile = useCallback(
(percentileN?: number, replaceHistory?: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer } from '@elastic/eui';
import { VisitorBreakdownChart } from '../Charts/VisitorBreakdownChart';
import { I18LABELS, VisitorBreakdownLabel } from '../translations';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';

export function VisitorBreakdown() {
const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();

const { start, end, searchTerm } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
isErrorEmbeddable,
} from '../../../../../../../../src/plugins/embeddable/public';
import { useLayerList } from './useLayerList';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import type { RenderTooltipContentParams } from '../../../../../../maps/public';
import { MapToolTip } from './MapToolTip';
Expand Down Expand Up @@ -50,7 +50,7 @@ interface KibanaDeps {
embeddable: EmbeddableStart;
}
export function EmbeddedMapComponent() {
const { urlParams } = useUrlParams();
const { urlParams } = useLegacyUrlParams();
const apmPluginContext = useApmPluginContext();

const { start, end, serviceName } = urlParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '../../../../../../maps/common';

import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../common/index_pattern_constants';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import {
SERVICE_NAME,
TRANSACTION_TYPE,
Expand Down Expand Up @@ -84,7 +84,7 @@ interface VectorLayerDescriptor extends BaseVectorLayerDescriptor {
}

export function useLayerList() {
const { urlParams } = useUrlParams();
const { urlParams } = useLegacyUrlParams();

const { serviceName } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useMemo } from 'react';
import { FieldFilter as Filter } from '@kbn/es-query';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import {
CLIENT_GEO_COUNTRY_ISO_CODE,
SERVICE_NAME,
Expand Down Expand Up @@ -92,7 +92,7 @@ const existFilter: Filter = {
};

export const useMapFilters = (): Filter[] => {
const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();

const { serviceName, searchTerm } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
toQuery,
} from '../../../../components/shared/Links/url_helpers';
import { removeUndefinedProps } from '../../../../context/url_params_context/helpers';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { getExcludedName } from '../LocalUIFilters';

export type FiltersUIHook = ReturnType<typeof useLocalUIFilters>;
Expand All @@ -28,7 +28,7 @@ export function useLocalUIFilters({
filterNames: UxLocalUIFilterName[];
}) {
const history = useHistory();
const { uxUiFilters } = useUrlParams();
const { uxUiFilters } = useLegacyUrlParams();

const setFilterValue = (name: UxLocalUIFilterName, value: string[]) => {
const search = omit(toQuery(history.location.search), name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import { useMemo } from 'react';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';

export function useUxQuery() {
const { urlParams, uxUiFilters } = useUrlParams();
const { urlParams, uxUiFilters } = useLegacyUrlParams();

const { start, end, searchTerm, percentile } = urlParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import { getNodeName, NodeType } from '../../../../common/connections';
import { useApmParams } from '../../../hooks/use_apm_params';
import { useUrlParams } from '../../../context/url_params_context/use_url_params';
import { useLegacyUrlParams } from '../../../context/url_params_context/use_url_params';
import { useFetcher } from '../../../hooks/use_fetcher';
import { getTimeRangeComparison } from '../../shared/time_comparison/get_time_range_comparison';
import { DependenciesTable } from '../../shared/dependencies_table';
Expand All @@ -19,7 +19,7 @@ import { useTimeRange } from '../../../hooks/use_time_range';
export function BackendDetailDependenciesTable() {
const {
urlParams: { comparisonEnabled, comparisonType },
} = useUrlParams();
} = useLegacyUrlParams();

const {
query: { backendName, rangeFrom, rangeTo, kuery, environment },
Expand Down
Loading

0 comments on commit 6c06b12

Please sign in to comment.