mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasource: add button to navigate to explore from settings (#36119)
Fixes #13737
This commit is contained in:
@@ -8,6 +8,7 @@ const setup = (propOverrides?: object) => {
|
|||||||
onSubmit: jest.fn(),
|
onSubmit: jest.fn(),
|
||||||
onDelete: jest.fn(),
|
onDelete: jest.fn(),
|
||||||
onTest: jest.fn(),
|
onTest: jest.fn(),
|
||||||
|
exploreUrl: '/explore',
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(props, propOverrides);
|
Object.assign(props, propOverrides);
|
||||||
|
|||||||
@@ -5,18 +5,22 @@ import config from 'app/core/config';
|
|||||||
import { Button, LinkButton } from '@grafana/ui';
|
import { Button, LinkButton } from '@grafana/ui';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
exploreUrl: string;
|
||||||
isReadOnly: boolean;
|
isReadOnly: boolean;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onSubmit: (event: any) => void;
|
onSubmit: (event: any) => void;
|
||||||
onTest: (event: any) => void;
|
onTest: (event: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest }) => {
|
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest, exploreUrl }) => {
|
||||||
return (
|
return (
|
||||||
<div className="gf-form-button-row">
|
<div className="gf-form-button-row">
|
||||||
<LinkButton variant="secondary" fill="outline" href={`${config.appSubUrl}/datasources`}>
|
<LinkButton variant="secondary" fill="solid" href={`${config.appSubUrl}/datasources`}>
|
||||||
Back
|
Back
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
|
<LinkButton variant="secondary" fill="solid" href={exploreUrl}>
|
||||||
|
Explore
|
||||||
|
</LinkButton>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { getNavModel } from 'app/core/selectors/navModel';
|
|||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { StoreState } from 'app/types/';
|
import { StoreState } from 'app/types/';
|
||||||
import { DataSourceSettings } from '@grafana/data';
|
import { DataSourceSettings, urlUtil } from '@grafana/data';
|
||||||
import { Alert, Button, LinkButton } from '@grafana/ui';
|
import { Alert, Button, LinkButton } from '@grafana/ui';
|
||||||
import { getDataSourceLoadingNav, buildNavModel, getDataSourceNav } from '../state/navModel';
|
import { getDataSourceLoadingNav, buildNavModel, getDataSourceNav } from '../state/navModel';
|
||||||
import { PluginStateInfo } from 'app/features/plugins/PluginStateInfo';
|
import { PluginStateInfo } from 'app/features/plugins/PluginStateInfo';
|
||||||
@@ -149,6 +149,13 @@ export class DataSourceSettingsPage extends PureComponent<Props> {
|
|||||||
return this.props.dataSource.id > 0;
|
return this.props.dataSource.id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onNavigateToExplore() {
|
||||||
|
const { dataSource } = this.props;
|
||||||
|
const exploreState = JSON.stringify({ datasource: dataSource.name, context: 'explore' });
|
||||||
|
const url = urlUtil.renderUrl('/explore', { left: exploreState });
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
renderLoadError(loadError: any) {
|
renderLoadError(loadError: any) {
|
||||||
let showDelete = false;
|
let showDelete = false;
|
||||||
let msg = loadError.toString();
|
let msg = loadError.toString();
|
||||||
@@ -269,6 +276,7 @@ export class DataSourceSettingsPage extends PureComponent<Props> {
|
|||||||
isReadOnly={this.isReadOnly()}
|
isReadOnly={this.isReadOnly()}
|
||||||
onDelete={this.onDelete}
|
onDelete={this.onDelete}
|
||||||
onTest={(event) => this.onTest(event)}
|
onTest={(event) => this.onTest(event)}
|
||||||
|
exploreUrl={this.onNavigateToExplore()}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,12 +5,19 @@ exports[`Render should render component 1`] = `
|
|||||||
className="gf-form-button-row"
|
className="gf-form-button-row"
|
||||||
>
|
>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
fill="outline"
|
fill="solid"
|
||||||
href="/datasources"
|
href="/datasources"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
Back
|
Back
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
|
<LinkButton
|
||||||
|
fill="solid"
|
||||||
|
href="/explore"
|
||||||
|
variant="secondary"
|
||||||
|
>
|
||||||
|
Explore
|
||||||
|
</LinkButton>
|
||||||
<Button
|
<Button
|
||||||
aria-label="Data source settings page Delete button"
|
aria-label="Data source settings page Delete button"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
@@ -35,12 +42,19 @@ exports[`Render should render with buttons enabled 1`] = `
|
|||||||
className="gf-form-button-row"
|
className="gf-form-button-row"
|
||||||
>
|
>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
fill="outline"
|
fill="solid"
|
||||||
href="/datasources"
|
href="/datasources"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
Back
|
Back
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
|
<LinkButton
|
||||||
|
fill="solid"
|
||||||
|
href="/explore"
|
||||||
|
variant="secondary"
|
||||||
|
>
|
||||||
|
Explore
|
||||||
|
</LinkButton>
|
||||||
<Button
|
<Button
|
||||||
aria-label="Data source settings page Delete button"
|
aria-label="Data source settings page Delete button"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user