mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 09:05:45 -06:00
* refactor(Data Sources): rename file to follow naming convention * refactor: use react-redux hooks for interacting with the store * tests: update data-sources list related test files * refactor: extract datasource list page contents * refactor: pass dataSources to the DataSourcesList as a prop * refactor: use proper typing for navIndex mocks
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
|
import PageActionBar from 'app/core/components/PageActionBar/PageActionBar';
|
|
import { contextSrv } from 'app/core/core';
|
|
import { AccessControlAction, StoreState } from 'app/types';
|
|
|
|
import { setDataSourcesSearchQuery } from './state/reducers';
|
|
import { getDataSourcesSearchQuery } from './state/selectors';
|
|
|
|
export const DataSourcesListHeader = () => {
|
|
const dispatch = useDispatch();
|
|
const setSearchQuery = useCallback((q: string) => dispatch(setDataSourcesSearchQuery(q)), [dispatch]);
|
|
const searchQuery = useSelector(({ dataSources }: StoreState) => getDataSourcesSearchQuery(dataSources));
|
|
const canCreateDataSource = contextSrv.hasPermission(AccessControlAction.DataSourcesCreate);
|
|
|
|
const linkButton = {
|
|
href: 'datasources/new',
|
|
title: 'Add data source',
|
|
disabled: !canCreateDataSource,
|
|
};
|
|
|
|
return (
|
|
<PageActionBar searchQuery={searchQuery} setSearchQuery={setSearchQuery} linkButton={linkButton} key="action-bar" />
|
|
);
|
|
};
|