2019-01-17 11:51:07 -06:00
|
|
|
// Libraries
|
2018-09-28 04:05:34 -05:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { hot } from 'react-hot-loader';
|
2019-01-17 11:51:07 -06:00
|
|
|
// Components
|
2019-01-08 01:38:43 -06:00
|
|
|
import Page from 'app/core/components/Page/Page';
|
|
|
|
import OrgActionBar from 'app/core/components/OrgActionBar/OrgActionBar';
|
|
|
|
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
|
2018-09-28 04:05:34 -05:00
|
|
|
import DataSourcesList from './DataSourcesList';
|
2019-01-17 11:51:07 -06:00
|
|
|
// Types
|
2020-01-13 01:03:22 -06:00
|
|
|
import { DataSourceSettings, NavModel } from '@grafana/data';
|
@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
|
|
|
import { IconName } from '@grafana/ui';
|
2019-04-30 09:46:46 -05:00
|
|
|
import { StoreState } from 'app/types';
|
2019-01-08 01:38:43 -06:00
|
|
|
import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector';
|
2019-01-17 11:51:07 -06:00
|
|
|
// Actions
|
2020-01-13 01:03:22 -06:00
|
|
|
import { loadDataSources } from './state/actions';
|
2019-01-17 02:01:17 -06:00
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
2019-01-16 08:59:05 -06:00
|
|
|
|
2018-10-03 02:43:10 -05:00
|
|
|
import {
|
|
|
|
getDataSources,
|
|
|
|
getDataSourcesCount,
|
|
|
|
getDataSourcesLayoutMode,
|
|
|
|
getDataSourcesSearchQuery,
|
|
|
|
} from './state/selectors';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { setDataSourcesLayoutMode, setDataSourcesSearchQuery } from './state/reducers';
|
2018-09-28 04:05:34 -05:00
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
navModel: NavModel;
|
2019-01-17 11:51:07 -06:00
|
|
|
dataSources: DataSourceSettings[];
|
2018-09-28 04:29:18 -05:00
|
|
|
dataSourcesCount: number;
|
2018-09-28 04:05:34 -05:00
|
|
|
layoutMode: LayoutMode;
|
2018-10-03 02:43:10 -05:00
|
|
|
searchQuery: string;
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched: boolean;
|
2018-09-28 04:05:34 -05:00
|
|
|
loadDataSources: typeof loadDataSources;
|
2018-10-03 02:43:10 -05:00
|
|
|
setDataSourcesLayoutMode: typeof setDataSourcesLayoutMode;
|
|
|
|
setDataSourcesSearchQuery: typeof setDataSourcesSearchQuery;
|
2018-09-28 04:05:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const emptyListModel = {
|
|
|
|
title: 'There are no data sources defined yet',
|
@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() {
|
|
|
|
this.fetchDataSources();
|
|
|
|
}
|
|
|
|
|
|
|
|
async fetchDataSources() {
|
|
|
|
return await this.props.loadDataSources();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-10-03 02:43:10 -05:00
|
|
|
const {
|
|
|
|
dataSources,
|
|
|
|
dataSourcesCount,
|
|
|
|
navModel,
|
|
|
|
layoutMode,
|
|
|
|
searchQuery,
|
|
|
|
setDataSourcesSearchQuery,
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched,
|
2018-10-03 02:43:10 -05:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const linkButton = {
|
|
|
|
href: 'datasources/new',
|
|
|
|
title: 'Add data source',
|
|
|
|
};
|
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}>
|
|
|
|
<>
|
2019-08-20 10:19:21 -05:00
|
|
|
{hasFetched && dataSourcesCount === 0 && <EmptyListCTA {...emptyListModel} />}
|
2019-01-08 01:38:43 -06:00
|
|
|
{hasFetched &&
|
|
|
|
dataSourcesCount > 0 && [
|
|
|
|
<OrgActionBar
|
|
|
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-14 09:05:49 -06:00
|
|
|
function mapStateToProps(state: StoreState) {
|
2018-09-28 04:05:34 -05:00
|
|
|
return {
|
|
|
|
navModel: getNavModel(state.navIndex, 'datasources'),
|
|
|
|
dataSources: getDataSources(state.dataSources),
|
|
|
|
layoutMode: getDataSourcesLayoutMode(state.dataSources),
|
2018-09-28 04:29:18 -05:00
|
|
|
dataSourcesCount: getDataSourcesCount(state.dataSources),
|
2018-10-03 02:43:10 -05:00
|
|
|
searchQuery: getDataSourcesSearchQuery(state.dataSources),
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched: state.dataSources.hasFetched,
|
2018-09-28 04:05:34 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
loadDataSources,
|
2018-10-03 02:43:10 -05:00
|
|
|
setDataSourcesSearchQuery,
|
|
|
|
setDataSourcesLayoutMode,
|
2018-09-28 04:05:34 -05:00
|
|
|
};
|
|
|
|
|
2019-11-19 07:59:39 -06:00
|
|
|
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DataSourcesListPage));
|