mirror of https://github.com/grafana/grafana
Improve empty state when no ds picker were found (#67422)
parent
e03a8b6826
commit
1afaf4d73e
@ -1,8 +1,6 @@ |
||||
{ |
||||
"npmClient": "yarn", |
||||
"useWorkspaces": true, |
||||
"packages": [ |
||||
"packages/*" |
||||
], |
||||
"packages": ["packages/*"], |
||||
"version": "10.1.0-pre" |
||||
} |
||||
|
@ -0,0 +1,32 @@ |
||||
import React from 'react'; |
||||
|
||||
import { LinkButton, ButtonVariant } from '@grafana/ui'; |
||||
import { config } from 'app/core/config'; |
||||
import { contextSrv } from 'app/core/core'; |
||||
import { ROUTES as CONNECTIONS_ROUTES } from 'app/features/connections/constants'; |
||||
import { DATASOURCES_ROUTES } from 'app/features/datasources/constants'; |
||||
import { AccessControlAction } from 'app/types'; |
||||
|
||||
interface AddNewDataSourceButtonProps { |
||||
onClick?: () => void; |
||||
variant?: ButtonVariant; |
||||
} |
||||
|
||||
export function AddNewDataSourceButton({ variant, onClick }: AddNewDataSourceButtonProps) { |
||||
const hasCreateRights = contextSrv.hasPermission(AccessControlAction.DataSourcesCreate); |
||||
const newDataSourceURL = config.featureToggles.dataConnectionsConsole |
||||
? CONNECTIONS_ROUTES.DataSourcesNew |
||||
: DATASOURCES_ROUTES.New; |
||||
|
||||
return ( |
||||
<LinkButton |
||||
variant={variant || 'primary'} |
||||
href={newDataSourceURL} |
||||
disabled={!hasCreateRights} |
||||
tooltip={!hasCreateRights ? 'You do not have permission to configure new data sources' : undefined} |
||||
onClick={onClick} |
||||
> |
||||
Configure a new data source |
||||
</LinkButton> |
||||
); |
||||
} |
Loading…
Reference in new issue