mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added no datasources added
This commit is contained in:
parent
166f93cf54
commit
7ae4076ddd
@ -11,6 +11,7 @@ const setup = (propOverrides?: object) => {
|
|||||||
layoutMode: LayoutModes.Grid,
|
layoutMode: LayoutModes.Grid,
|
||||||
loadDataSources: jest.fn(),
|
loadDataSources: jest.fn(),
|
||||||
navModel: {} as NavModel,
|
navModel: {} as NavModel,
|
||||||
|
dataSourcesCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(props, propOverrides);
|
Object.assign(props, propOverrides);
|
||||||
@ -28,6 +29,7 @@ describe('Render', () => {
|
|||||||
it('should render action bar and datasources', () => {
|
it('should render action bar and datasources', () => {
|
||||||
const wrapper = setup({
|
const wrapper = setup({
|
||||||
dataSources: getMockDataSources(5),
|
dataSources: getMockDataSources(5),
|
||||||
|
dataSourcesCount: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
@ -5,7 +5,7 @@ import PageHeader from '../../core/components/PageHeader/PageHeader';
|
|||||||
import DataSourcesActionBar from './DataSourcesActionBar';
|
import DataSourcesActionBar from './DataSourcesActionBar';
|
||||||
import DataSourcesList from './DataSourcesList';
|
import DataSourcesList from './DataSourcesList';
|
||||||
import { loadDataSources } from './state/actions';
|
import { loadDataSources } from './state/actions';
|
||||||
import { getDataSources, getDataSourcesLayoutMode } from './state/selectors';
|
import { getDataSources, getDataSourcesCount, getDataSourcesLayoutMode } from './state/selectors';
|
||||||
import { getNavModel } from '../../core/selectors/navModel';
|
import { getNavModel } from '../../core/selectors/navModel';
|
||||||
import { DataSource, NavModel } from 'app/types';
|
import { DataSource, NavModel } from 'app/types';
|
||||||
import { LayoutMode } from '../../core/components/LayoutSelector/LayoutSelector';
|
import { LayoutMode } from '../../core/components/LayoutSelector/LayoutSelector';
|
||||||
@ -14,6 +14,7 @@ import EmptyListCTA from '../../core/components/EmptyListCTA/EmptyListCTA';
|
|||||||
export interface Props {
|
export interface Props {
|
||||||
navModel: NavModel;
|
navModel: NavModel;
|
||||||
dataSources: DataSource[];
|
dataSources: DataSource[];
|
||||||
|
dataSourcesCount: number;
|
||||||
layoutMode: LayoutMode;
|
layoutMode: LayoutMode;
|
||||||
loadDataSources: typeof loadDataSources;
|
loadDataSources: typeof loadDataSources;
|
||||||
}
|
}
|
||||||
@ -39,18 +40,20 @@ export class DataSourcesListPage extends PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { navModel, dataSources, layoutMode } = this.props;
|
const { dataSources, dataSourcesCount, navModel, layoutMode } = this.props;
|
||||||
|
|
||||||
if (dataSources.length === 0) {
|
|
||||||
return <EmptyListCTA model={emptyListModel} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageHeader model={navModel} />
|
<PageHeader model={navModel} />
|
||||||
<div className="page-container page-body">
|
<div className="page-container page-body">
|
||||||
<DataSourcesActionBar />
|
{dataSourcesCount === 0 ? (
|
||||||
<DataSourcesList dataSources={dataSources} layoutMode={layoutMode} />
|
<EmptyListCTA model={emptyListModel} />
|
||||||
|
) : (
|
||||||
|
[
|
||||||
|
<DataSourcesActionBar key="action-bar" />,
|
||||||
|
<DataSourcesList dataSources={dataSources} layoutMode={layoutMode} key="list" />,
|
||||||
|
]
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -62,6 +65,7 @@ function mapStateToProps(state) {
|
|||||||
navModel: getNavModel(state.navIndex, 'datasources'),
|
navModel: getNavModel(state.navIndex, 'datasources'),
|
||||||
dataSources: getDataSources(state.dataSources),
|
dataSources: getDataSources(state.dataSources),
|
||||||
layoutMode: getDataSourcesLayoutMode(state.dataSources),
|
layoutMode: getDataSourcesLayoutMode(state.dataSources),
|
||||||
|
dataSourcesCount: getDataSourcesCount(state.dataSources),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@ exports[`Render should render action bar and datasources 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="page-container page-body"
|
className="page-container page-body"
|
||||||
>
|
>
|
||||||
<Connect(DataSourcesActionBar) />
|
<Connect(DataSourcesActionBar)
|
||||||
|
key="action-bar"
|
||||||
|
/>
|
||||||
<DataSourcesList
|
<DataSourcesList
|
||||||
dataSources={
|
dataSources={
|
||||||
Array [
|
Array [
|
||||||
@ -128,6 +130,7 @@ exports[`Render should render action bar and datasources 1`] = `
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
key="list"
|
||||||
layoutMode="grid"
|
layoutMode="grid"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -135,18 +138,27 @@ exports[`Render should render action bar and datasources 1`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Render should render component 1`] = `
|
exports[`Render should render component 1`] = `
|
||||||
<EmptyListCTA
|
<div>
|
||||||
model={
|
<PageHeader
|
||||||
Object {
|
model={Object {}}
|
||||||
"buttonIcon": "gicon gicon-add-datasources",
|
/>
|
||||||
"buttonLink": "datasources/new",
|
<div
|
||||||
"buttonTitle": "Add data source",
|
className="page-container page-body"
|
||||||
"proTip": "You can also define data sources through configuration files.",
|
>
|
||||||
"proTipLink": "http://docs.grafana.org/administration/provisioning/#datasources?utm_source=grafana_ds_list",
|
<EmptyListCTA
|
||||||
"proTipLinkTitle": "Learn more",
|
model={
|
||||||
"proTipTarget": "_blank",
|
Object {
|
||||||
"title": "There are no data sources defined yet",
|
"buttonIcon": "gicon gicon-add-datasources",
|
||||||
}
|
"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",
|
||||||
|
"title": "There are no data sources defined yet",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -6,12 +6,13 @@ const initialState: DataSourcesState = {
|
|||||||
dataSources: [] as DataSource[],
|
dataSources: [] as DataSource[],
|
||||||
layoutMode: LayoutModes.Grid,
|
layoutMode: LayoutModes.Grid,
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
|
dataSourcesCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dataSourcesReducer = (state = initialState, action: Action): DataSourcesState => {
|
export const dataSourcesReducer = (state = initialState, action: Action): DataSourcesState => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.LoadDataSources:
|
case ActionTypes.LoadDataSources:
|
||||||
return { ...state, dataSources: action.payload };
|
return { ...state, dataSources: action.payload, dataSourcesCount: action.payload.length };
|
||||||
|
|
||||||
case ActionTypes.SetDataSourcesSearchQuery:
|
case ActionTypes.SetDataSourcesSearchQuery:
|
||||||
return { ...state, searchQuery: action.payload };
|
return { ...state, searchQuery: action.payload };
|
||||||
|
@ -8,3 +8,4 @@ export const getDataSources = state => {
|
|||||||
|
|
||||||
export const getDataSourcesSearchQuery = state => state.searchQuery;
|
export const getDataSourcesSearchQuery = state => state.searchQuery;
|
||||||
export const getDataSourcesLayoutMode = state => state.layoutMode;
|
export const getDataSourcesLayoutMode = state => state.layoutMode;
|
||||||
|
export const getDataSourcesCount = state => state.dataSourcesCount;
|
||||||
|
@ -21,4 +21,5 @@ export interface DataSourcesState {
|
|||||||
dataSources: DataSource[];
|
dataSources: DataSource[];
|
||||||
searchQuery: string;
|
searchQuery: string;
|
||||||
layoutMode: LayoutMode;
|
layoutMode: LayoutMode;
|
||||||
|
dataSourcesCount: number;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user