Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7ae4076d
Commit
7ae4076d
authored
Sep 28, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added no datasources added
parent
166f93cf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
24 deletions
+45
-24
public/app/features/datasources/DataSourcesListPage.test.tsx
+2
-0
public/app/features/datasources/DataSourcesListPage.tsx
+12
-8
public/app/features/datasources/__snapshots__/DataSourcesListPage.test.tsx.snap
+27
-15
public/app/features/datasources/state/reducers.ts
+2
-1
public/app/features/datasources/state/selectors.ts
+1
-0
public/app/types/datasources.ts
+1
-0
No files found.
public/app/features/datasources/DataSourcesListPage.test.tsx
View file @
7ae4076d
...
...
@@ -11,6 +11,7 @@ const setup = (propOverrides?: object) => {
layoutMode
:
LayoutModes
.
Grid
,
loadDataSources
:
jest
.
fn
(),
navModel
:
{}
as
NavModel
,
dataSourcesCount
:
0
,
};
Object
.
assign
(
props
,
propOverrides
);
...
...
@@ -28,6 +29,7 @@ describe('Render', () => {
it
(
'should render action bar and datasources'
,
()
=>
{
const
wrapper
=
setup
({
dataSources
:
getMockDataSources
(
5
),
dataSourcesCount
:
5
,
});
expect
(
wrapper
).
toMatchSnapshot
();
...
...
public/app/features/datasources/DataSourcesListPage.tsx
View file @
7ae4076d
...
...
@@ -5,7 +5,7 @@ import PageHeader from '../../core/components/PageHeader/PageHeader';
import
DataSourcesActionBar
from
'./DataSourcesActionBar'
;
import
DataSourcesList
from
'./DataSourcesList'
;
import
{
loadDataSources
}
from
'./state/actions'
;
import
{
getDataSources
,
getDataSourcesLayoutMode
}
from
'./state/selectors'
;
import
{
getDataSources
,
getDataSources
Count
,
getDataSources
LayoutMode
}
from
'./state/selectors'
;
import
{
getNavModel
}
from
'../../core/selectors/navModel'
;
import
{
DataSource
,
NavModel
}
from
'app/types'
;
import
{
LayoutMode
}
from
'../../core/components/LayoutSelector/LayoutSelector'
;
...
...
@@ -14,6 +14,7 @@ import EmptyListCTA from '../../core/components/EmptyListCTA/EmptyListCTA';
export
interface
Props
{
navModel
:
NavModel
;
dataSources
:
DataSource
[];
dataSourcesCount
:
number
;
layoutMode
:
LayoutMode
;
loadDataSources
:
typeof
loadDataSources
;
}
...
...
@@ -39,18 +40,20 @@ export class DataSourcesListPage extends PureComponent<Props> {
}
render
()
{
const
{
navModel
,
dataSources
,
layoutMode
}
=
this
.
props
;
if
(
dataSources
.
length
===
0
)
{
return
<
EmptyListCTA
model=
{
emptyListModel
}
/>;
}
const
{
dataSources
,
dataSourcesCount
,
navModel
,
layoutMode
}
=
this
.
props
;
return
(
<
div
>
<
PageHeader
model=
{
navModel
}
/>
<
div
className=
"page-container page-body"
>
<
DataSourcesActionBar
/>
<
DataSourcesList
dataSources=
{
dataSources
}
layoutMode=
{
layoutMode
}
/>
{
dataSourcesCount
===
0
?
(
<
EmptyListCTA
model=
{
emptyListModel
}
/>
)
:
(
[
<
DataSourcesActionBar
key=
"action-bar"
/>,
<
DataSourcesList
dataSources=
{
dataSources
}
layoutMode=
{
layoutMode
}
key=
"list"
/>,
]
)
}
</
div
>
</
div
>
);
...
...
@@ -62,6 +65,7 @@ function mapStateToProps(state) {
navModel
:
getNavModel
(
state
.
navIndex
,
'datasources'
),
dataSources
:
getDataSources
(
state
.
dataSources
),
layoutMode
:
getDataSourcesLayoutMode
(
state
.
dataSources
),
dataSourcesCount
:
getDataSourcesCount
(
state
.
dataSources
),
};
}
...
...
public/app/features/datasources/__snapshots__/DataSourcesListPage.test.tsx.snap
View file @
7ae4076d
...
...
@@ -8,7 +8,9 @@ exports[`Render should render action bar and datasources 1`] = `
<div
className="page-container page-body"
>
<Connect(DataSourcesActionBar) />
<Connect(DataSourcesActionBar)
key="action-bar"
/>
<DataSourcesList
dataSources={
Array [
...
...
@@ -128,6 +130,7 @@ exports[`Render should render action bar and datasources 1`] = `
},
]
}
key="list"
layoutMode="grid"
/>
</div>
...
...
@@ -135,18 +138,27 @@ exports[`Render should render action bar and datasources 1`] = `
`;
exports[`Render should render component 1`] = `
<EmptyListCTA
model={
Object {
"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>
<PageHeader
model={Object {}}
/>
<div
className="page-container page-body"
>
<EmptyListCTA
model={
Object {
"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>
`;
public/app/features/datasources/state/reducers.ts
View file @
7ae4076d
...
...
@@ -6,12 +6,13 @@ const initialState: DataSourcesState = {
dataSources
:
[]
as
DataSource
[],
layoutMode
:
LayoutModes
.
Grid
,
searchQuery
:
''
,
dataSourcesCount
:
0
,
};
export
const
dataSourcesReducer
=
(
state
=
initialState
,
action
:
Action
):
DataSourcesState
=>
{
switch
(
action
.
type
)
{
case
ActionTypes
.
LoadDataSources
:
return
{
...
state
,
dataSources
:
action
.
payload
};
return
{
...
state
,
dataSources
:
action
.
payload
,
dataSourcesCount
:
action
.
payload
.
length
};
case
ActionTypes
.
SetDataSourcesSearchQuery
:
return
{
...
state
,
searchQuery
:
action
.
payload
};
...
...
public/app/features/datasources/state/selectors.ts
View file @
7ae4076d
...
...
@@ -8,3 +8,4 @@ export const getDataSources = state => {
export
const
getDataSourcesSearchQuery
=
state
=>
state
.
searchQuery
;
export
const
getDataSourcesLayoutMode
=
state
=>
state
.
layoutMode
;
export
const
getDataSourcesCount
=
state
=>
state
.
dataSourcesCount
;
public/app/types/datasources.ts
View file @
7ae4076d
...
...
@@ -21,4 +21,5 @@ export interface DataSourcesState {
dataSources
:
DataSource
[];
searchQuery
:
string
;
layoutMode
:
LayoutMode
;
dataSourcesCount
:
number
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment