mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Data links: Remove messaging around deprecating compact Explore URLs (#99780)
This commit is contained in:
parent
1795a2b4e3
commit
3954a1948c
@ -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
|
||||
<Input value={value.title} onChange={onTitleChange} placeholder="Show details" />
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label="URL"
|
||||
invalid={isCompactUrl(value.url)}
|
||||
error="Data link is an Explore URL in a deprecated format. Please visit the URL to be redirected, and edit this data link to use that URL."
|
||||
>
|
||||
<Field label="URL">
|
||||
<DataLinkInput value={value.url} onChange={onUrlChange} suggestions={suggestions} />
|
||||
</Field>
|
||||
|
||||
|
@ -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', () => {
|
||||
|
@ -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 (
|
||||
<Draggable key={itemKey} draggableId={itemKey} index={index}>
|
||||
{(provided) => (
|
||||
@ -41,17 +37,12 @@ export const DataLinksListItem = ({ link, onEdit, onRemove, index, itemKey }: Da
|
||||
key={index}
|
||||
>
|
||||
<div className={styles.linkDetails}>
|
||||
<div className={cx(styles.url, !hasUrl && styles.notConfigured, isCompactExploreUrl && styles.errored)}>
|
||||
<div className={cx(styles.url, !hasUrl && styles.notConfigured)}>
|
||||
{hasTitle ? title : 'Data link title not provided'}
|
||||
</div>
|
||||
<Tooltip content={'Explore data link may not work in the future. Please edit.'} show={isCompactExploreUrl}>
|
||||
<div
|
||||
className={cx(styles.url, !hasUrl && styles.notConfigured, isCompactExploreUrl && styles.errored)}
|
||||
title={url}
|
||||
>
|
||||
{hasUrl ? url : 'Data link url not provided'}
|
||||
</div>
|
||||
</Tooltip>
|
||||
<div className={cx(styles.url, !hasUrl && styles.notConfigured)} title={url}>
|
||||
{hasUrl ? url : 'Data link url not provided'}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.icons}>
|
||||
{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',
|
||||
}),
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user