From 3954a1948c21236e6b0ca91e95e6189e2e6e2b15 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Wed, 29 Jan 2025 13:44:09 -0600 Subject: [PATCH] Data links: Remove messaging around deprecating compact Explore URLs (#99780) --- .../components/DataLinks/DataLinkEditor.tsx | 7 +---- .../DataLinksListItem.test.tsx | 11 ------- .../DataLinksListItem.tsx | 21 +++---------- .../grafana-ui/src/utils/dataLinks.test.ts | 31 ------------------- packages/grafana-ui/src/utils/dataLinks.ts | 5 --- 5 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 packages/grafana-ui/src/utils/dataLinks.test.ts diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx index cdd5e64eddf..e87d01fbea2 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinkEditor.tsx @@ -4,7 +4,6 @@ import { memo, ChangeEvent } from 'react'; import { VariableSuggestion, GrafanaTheme2, DataLink } from '@grafana/data'; import { useStyles2 } from '../../themes/index'; -import { isCompactUrl } from '../../utils/dataLinks'; import { t, Trans } from '../../utils/i18n'; import { Field } from '../Forms/Field'; import { Input } from '../Input/Input'; @@ -55,11 +54,7 @@ export const DataLinkEditor = memo(({ index, value, onChange, suggestions, isLas - + diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.test.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.test.tsx index 1ab1c27d4cd..b44576d53f7 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.test.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.test.tsx @@ -63,17 +63,6 @@ describe('DataLinksListItem', () => { expect(screen.getByText(/http:\/\/localhost\:3000/i)).toBeInTheDocument(); expect(screen.getByTitle(/http:\/\/localhost\:3000/i)).toBeInTheDocument(); }); - - it('that is a explore compact url, then the title should be a warning', () => { - const link = { - ...baseLink, - url: 'http://localhost:3000/explore?orgId=1&left=[%22now-1h%22,%22now%22,%22gdev-loki%22,{%22expr%22:%22{place=%22luna%22}%22,%22refId%22:%22A%22}]', - }; - setupTestContext({ link }); - - expect(screen.getByText(/http:\/\/localhost\:3000/i)).toBeInTheDocument(); - expect(screen.getByText(/Explore data link may not work in the future. Please edit./i)).toBeInTheDocument(); - }); }); describe('when link is missing title', () => { diff --git a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.tsx b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.tsx index 1c12a41dd2a..9bddc35da71 100644 --- a/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.tsx +++ b/packages/grafana-ui/src/components/DataLinks/DataLinksInlineEditor/DataLinksListItem.tsx @@ -4,12 +4,10 @@ import { Draggable } from '@hello-pangea/dnd'; import { DataFrame, DataLink, GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '../../../themes'; -import { isCompactUrl } from '../../../utils'; import { t } from '../../../utils/i18n'; import { Badge } from '../../Badge/Badge'; import { Icon } from '../../Icon/Icon'; import { IconButton } from '../../IconButton/IconButton'; -import { Tooltip } from '../../Tooltip/Tooltip'; export interface DataLinksListItemProps { index: number; @@ -29,8 +27,6 @@ export const DataLinksListItem = ({ link, onEdit, onRemove, index, itemKey }: Da const hasTitle = title.trim() !== ''; const hasUrl = url.trim() !== ''; - const isCompactExploreUrl = isCompactUrl(url); - return ( {(provided) => ( @@ -41,17 +37,12 @@ export const DataLinksListItem = ({ link, onEdit, onRemove, index, itemKey }: Da key={index} >
-
+
{hasTitle ? title : 'Data link title not provided'}
- -
- {hasUrl ? url : 'Data link url not provided'} -
-
+
+ {hasUrl ? url : 'Data link url not provided'} +
{oneClick && ( @@ -91,10 +82,6 @@ const getDataLinkListItemStyles = (theme: GrafanaTheme2) => { flexGrow: 1, maxWidth: `calc(100% - 100px)`, }), - errored: css({ - color: theme.colors.error.text, - fontStyle: 'italic', - }), notConfigured: css({ fontStyle: 'italic', }), diff --git a/packages/grafana-ui/src/utils/dataLinks.test.ts b/packages/grafana-ui/src/utils/dataLinks.test.ts deleted file mode 100644 index a4f5ae1a61b..00000000000 --- a/packages/grafana-ui/src/utils/dataLinks.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { isCompactUrl } from './dataLinks'; - -describe('Datalinks', () => { - it('isCompactUrl matches compact URL with segments', () => { - expect( - isCompactUrl( - 'http://localhost:3000/explore?orgId=1&left=[%22now-1h%22,%22now%22,%22gdev-loki%22,{%22expr%22:%22{place=%22luna%22}%22,%22refId%22:%22A%22}]' - ) - ).toEqual(true); - }); - - it('isCompactUrl matches compact URL without segments', () => { - expect(isCompactUrl('http://localhost:3000/explore?orgId=1&left=[%22now-1h%22,%22now%22,%22gdev-loki%22]')).toEqual( - true - ); - }); - - it('isCompactUrl matches compact URL with right pane', () => { - expect( - isCompactUrl('http://localhost:3000/explore?orgId=1&right=[%22now-1h%22,%22now%22,%22gdev-loki%22]') - ).toEqual(true); - }); - - it('isCompactUrl does not match non-compact url', () => { - expect( - isCompactUrl( - 'http://localhost:3000/explore?orgId=1&left={"datasource":"test[datasource]","queries":[{"refId":"A","datasource":{"type":"prometheus","uid":"gdev-prometheus"}}],"range":{"from":"now-1h","to":"now"}}' - ) - ).toEqual(false); - }); -}); diff --git a/packages/grafana-ui/src/utils/dataLinks.ts b/packages/grafana-ui/src/utils/dataLinks.ts index 35fe1cffdf7..f889cf5a2a0 100644 --- a/packages/grafana-ui/src/utils/dataLinks.ts +++ b/packages/grafana-ui/src/utils/dataLinks.ts @@ -29,8 +29,3 @@ export const actionModelToContextMenuItems: (actions: ActionModel[]) => MenuItem }; }); }; - -export const isCompactUrl = (url: string) => { - const compactExploreUrlRegex = /\/explore\?.*&(left|right)=\[(.*\,){2,}(.*){1}\]/; - return compactExploreUrlRegex.test(url); -};