2018-09-28 04:05:34 -05:00
|
|
|
import React, { PureComponent } from 'react';
|
2021-07-23 04:33:26 -05:00
|
|
|
import { connect, ConnectedProps } from 'react-redux';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
|
|
|
import { IconName } from '@grafana/ui';
|
|
|
|
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
|
2019-01-08 01:38:43 -06:00
|
|
|
import Page from 'app/core/components/Page/Page';
|
2021-04-12 02:30:29 -05:00
|
|
|
import PageActionBar from 'app/core/components/PageActionBar/PageActionBar';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { contextSrv } from 'app/core/core';
|
2019-01-17 02:01:17 -06:00
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { StoreState, AccessControlAction } from 'app/types';
|
2019-01-16 08:59:05 -06:00
|
|
|
|
2022-04-22 08:33:13 -05:00
|
|
|
import DataSourcesList from './DataSourcesList';
|
|
|
|
import { loadDataSources } from './state/actions';
|
|
|
|
import { setDataSourcesLayoutMode, setDataSourcesSearchQuery } from './state/reducers';
|
2018-10-03 02:43:10 -05:00
|
|
|
import {
|
|
|
|
getDataSources,
|
|
|
|
getDataSourcesCount,
|
|
|
|
getDataSourcesLayoutMode,
|
|
|
|
getDataSourcesSearchQuery,
|
|
|
|
} from './state/selectors';
|
2018-09-28 04:05:34 -05:00
|
|
|
|
2021-07-23 04:33:26 -05:00
|
|
|
function mapStateToProps(state: StoreState) {
|
|
|
|
return {
|
|
|
|
navModel: getNavModel(state.navIndex, 'datasources'),
|
|
|
|
dataSources: getDataSources(state.dataSources),
|
|
|
|
layoutMode: getDataSourcesLayoutMode(state.dataSources),
|
|
|
|
dataSourcesCount: getDataSourcesCount(state.dataSources),
|
|
|
|
searchQuery: getDataSourcesSearchQuery(state.dataSources),
|
|
|
|
hasFetched: state.dataSources.hasFetched,
|
|
|
|
};
|
2018-09-28 04:05:34 -05:00
|
|
|
}
|
|
|
|
|
2021-07-23 04:33:26 -05:00
|
|
|
const mapDispatchToProps = {
|
|
|
|
loadDataSources,
|
|
|
|
setDataSourcesSearchQuery,
|
|
|
|
setDataSourcesLayoutMode,
|
|
|
|
};
|
|
|
|
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export type Props = ConnectedProps<typeof connector>;
|
|
|
|
|
2018-09-28 04:05:34 -05:00
|
|
|
const emptyListModel = {
|
2021-03-31 18:07:37 -05:00
|
|
|
title: 'No data sources defined',
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
buttonIcon: 'database' as IconName,
|
2018-09-28 04:05:34 -05:00
|
|
|
buttonLink: 'datasources/new',
|
|
|
|
buttonTitle: 'Add data source',
|
|
|
|
proTip: 'You can also define data sources through configuration files.',
|
|
|
|
proTipLink: 'http://docs.grafana.org/administration/provisioning/#datasources?utm_source=grafana_ds_list',
|
|
|
|
proTipLinkTitle: 'Learn more',
|
|
|
|
proTipTarget: '_blank',
|
|
|
|
};
|
|
|
|
|
|
|
|
export class DataSourcesListPage extends PureComponent<Props> {
|
|
|
|
componentDidMount() {
|
2021-02-22 06:02:10 -06:00
|
|
|
this.props.loadDataSources();
|
2018-09-28 04:05:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2022-02-02 06:02:32 -06:00
|
|
|
const { dataSources, dataSourcesCount, navModel, layoutMode, searchQuery, setDataSourcesSearchQuery, hasFetched } =
|
|
|
|
this.props;
|
2018-10-03 02:43:10 -05:00
|
|
|
|
2022-05-13 03:30:26 -05:00
|
|
|
const canCreateDataSource = contextSrv.hasPermission(AccessControlAction.DataSourcesCreate);
|
2021-09-08 02:47:55 -05:00
|
|
|
|
2018-10-03 02:43:10 -05:00
|
|
|
const linkButton = {
|
|
|
|
href: 'datasources/new',
|
|
|
|
title: 'Add data source',
|
2021-09-01 08:18:17 -05:00
|
|
|
disabled: !canCreateDataSource,
|
|
|
|
};
|
|
|
|
|
|
|
|
const emptyList = {
|
|
|
|
...emptyListModel,
|
|
|
|
buttonDisabled: !canCreateDataSource,
|
2018-10-03 02:43:10 -05:00
|
|
|
};
|
2018-09-28 04:05:34 -05:00
|
|
|
|
|
|
|
return (
|
2019-01-17 02:01:17 -06:00
|
|
|
<Page navModel={navModel}>
|
2019-01-08 01:38:43 -06:00
|
|
|
<Page.Contents isLoading={!hasFetched}>
|
|
|
|
<>
|
2021-09-01 08:18:17 -05:00
|
|
|
{hasFetched && dataSourcesCount === 0 && <EmptyListCTA {...emptyList} />}
|
2019-01-08 01:38:43 -06:00
|
|
|
{hasFetched &&
|
|
|
|
dataSourcesCount > 0 && [
|
2021-04-12 02:30:29 -05:00
|
|
|
<PageActionBar
|
2019-01-08 01:38:43 -06:00
|
|
|
searchQuery={searchQuery}
|
2021-01-20 00:59:48 -06:00
|
|
|
setSearchQuery={(query) => setDataSourcesSearchQuery(query)}
|
2019-01-08 01:38:43 -06:00
|
|
|
linkButton={linkButton}
|
|
|
|
key="action-bar"
|
|
|
|
/>,
|
|
|
|
<DataSourcesList dataSources={dataSources} layoutMode={layoutMode} key="list" />,
|
|
|
|
]}
|
|
|
|
</>
|
|
|
|
</Page.Contents>
|
|
|
|
</Page>
|
2018-09-28 04:05:34 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-31 05:55:05 -05:00
|
|
|
export default connector(DataSourcesListPage);
|