mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSources: fix DataSourceAddButton component (#60176)
* fix DataSourceAddButton component This component implicitly returned `false` when `canCreateDataSource` was false, and that way it didn't qualify as a function component. We fixed it to explicitly return null in this case. * DataSourceAddButton: update function signature This is more consistent with other code in this codebase.
This commit is contained in:
@@ -6,7 +6,7 @@ import { DataSourceAddButton } from 'app/features/datasources/components/DataSou
|
||||
import { DataSourcesList } from 'app/features/datasources/components/DataSourcesList';
|
||||
|
||||
export function DataSourcesListPage() {
|
||||
const actions = config.featureToggles.topnav ? DataSourceAddButton() : undefined;
|
||||
const actions = config.featureToggles.topnav ? <DataSourceAddButton /> : undefined;
|
||||
return (
|
||||
<Page navId={'connections-your-connections-datasources'} actions={actions}>
|
||||
<Page.Contents>
|
||||
|
||||
@@ -6,15 +6,13 @@ import { AccessControlAction } from 'app/types';
|
||||
|
||||
import { useDataSourcesRoutes } from '../state';
|
||||
|
||||
export function DataSourceAddButton() {
|
||||
export function DataSourceAddButton(): JSX.Element | null {
|
||||
const canCreateDataSource = contextSrv.hasPermission(AccessControlAction.DataSourcesCreate);
|
||||
const dataSourcesRoutes = useDataSourcesRoutes();
|
||||
|
||||
return (
|
||||
canCreateDataSource && (
|
||||
<LinkButton icon="plus" href={dataSourcesRoutes.New}>
|
||||
Add new data source
|
||||
</LinkButton>
|
||||
)
|
||||
);
|
||||
return canCreateDataSource ? (
|
||||
<LinkButton icon="plus" href={dataSourcesRoutes.New}>
|
||||
Add new data source
|
||||
</LinkButton>
|
||||
) : null;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { DataSourceAddButton } from '../components/DataSourceAddButton';
|
||||
import { DataSourcesList } from '../components/DataSourcesList';
|
||||
|
||||
export function DataSourcesListPage() {
|
||||
const actions = config.featureToggles.topnav ? DataSourceAddButton() : undefined;
|
||||
const actions = config.featureToggles.topnav ? <DataSourceAddButton /> : undefined;
|
||||
return (
|
||||
<Page navId="datasources" actions={actions}>
|
||||
<Page.Contents>
|
||||
|
||||
Reference in New Issue
Block a user