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
adbefcc3
Unverified
Commit
adbefcc3
authored
Sep 02, 2019
by
Torkel Ödegaard
Committed by
GitHub
Sep 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataSourceSettings: Fixed issue changing data source name, fixes #18660 (#18826)
parent
fe658d7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
public/app/features/datasources/settings/DataSourceSettingsPage.test.tsx
+2
-1
public/app/features/datasources/settings/DataSourceSettingsPage.tsx
+17
-18
No files found.
public/app/features/datasources/settings/DataSourceSettingsPage.test.tsx
View file @
adbefcc3
...
@@ -5,7 +5,7 @@ import { DataSourceSettings, DataSourcePlugin, DataSourceConstructor } from '@gr
...
@@ -5,7 +5,7 @@ import { DataSourceSettings, DataSourcePlugin, DataSourceConstructor } from '@gr
import
{
NavModel
}
from
'@grafana/data'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
getMockDataSource
}
from
'../__mocks__/dataSourcesMocks'
;
import
{
getMockDataSource
}
from
'../__mocks__/dataSourcesMocks'
;
import
{
getMockPlugin
}
from
'../../plugins/__mocks__/pluginMocks'
;
import
{
getMockPlugin
}
from
'../../plugins/__mocks__/pluginMocks'
;
import
{
setDataSourceName
,
setIsDefault
}
from
'../state/actions'
;
import
{
setDataSourceName
,
setIsDefault
,
dataSourceLoaded
}
from
'../state/actions'
;
const
pluginMock
=
new
DataSourcePlugin
({}
as
DataSourceConstructor
<
any
>
);
const
pluginMock
=
new
DataSourcePlugin
({}
as
DataSourceConstructor
<
any
>
);
...
@@ -26,6 +26,7 @@ const setup = (propOverrides?: object) => {
...
@@ -26,6 +26,7 @@ const setup = (propOverrides?: object) => {
setDataSourceName
,
setDataSourceName
,
updateDataSource
:
jest
.
fn
(),
updateDataSource
:
jest
.
fn
(),
setIsDefault
,
setIsDefault
,
dataSourceLoaded
,
query
:
{},
query
:
{},
...
propOverrides
,
...
propOverrides
,
};
};
...
...
public/app/features/datasources/settings/DataSourceSettingsPage.tsx
View file @
adbefcc3
...
@@ -17,7 +17,14 @@ import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
...
@@ -17,7 +17,14 @@ import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
// Actions & selectors
// Actions & selectors
import
{
getDataSource
,
getDataSourceMeta
}
from
'../state/selectors'
;
import
{
getDataSource
,
getDataSourceMeta
}
from
'../state/selectors'
;
import
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
setIsDefault
,
updateDataSource
}
from
'../state/actions'
;
import
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
setIsDefault
,
updateDataSource
,
dataSourceLoaded
,
}
from
'../state/actions'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getRouteParamsId
}
from
'app/core/selectors/location'
;
import
{
getRouteParamsId
}
from
'app/core/selectors/location'
;
...
@@ -40,13 +47,13 @@ export interface Props {
...
@@ -40,13 +47,13 @@ export interface Props {
setDataSourceName
:
typeof
setDataSourceName
;
setDataSourceName
:
typeof
setDataSourceName
;
updateDataSource
:
typeof
updateDataSource
;
updateDataSource
:
typeof
updateDataSource
;
setIsDefault
:
typeof
setIsDefault
;
setIsDefault
:
typeof
setIsDefault
;
dataSourceLoaded
:
typeof
dataSourceLoaded
;
plugin
?:
GenericDataSourcePlugin
;
plugin
?:
GenericDataSourcePlugin
;
query
:
UrlQueryMap
;
query
:
UrlQueryMap
;
page
?:
string
;
page
?:
string
;
}
}
interface
State
{
interface
State
{
dataSource
:
DataSourceSettings
;
plugin
?:
GenericDataSourcePlugin
;
plugin
?:
GenericDataSourcePlugin
;
isTesting
?:
boolean
;
isTesting
?:
boolean
;
testingMessage
?:
string
;
testingMessage
?:
string
;
...
@@ -59,7 +66,6 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -59,7 +66,6 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
dataSource
:
props
.
dataSource
,
plugin
:
props
.
plugin
,
plugin
:
props
.
plugin
,
};
};
}
}
...
@@ -93,18 +99,10 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -93,18 +99,10 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
}
}
}
}
componentDidUpdate
(
prevProps
:
Props
)
{
const
{
dataSource
}
=
this
.
props
;
if
(
prevProps
.
dataSource
!==
dataSource
)
{
this
.
setState
({
dataSource
});
}
}
onSubmit
=
async
(
evt
:
React
.
FormEvent
<
HTMLFormElement
>
)
=>
{
onSubmit
=
async
(
evt
:
React
.
FormEvent
<
HTMLFormElement
>
)
=>
{
evt
.
preventDefault
();
evt
.
preventDefault
();
await
this
.
props
.
updateDataSource
({
...
this
.
state
.
dataSource
});
await
this
.
props
.
updateDataSource
({
...
this
.
props
.
dataSource
});
this
.
testDataSource
();
this
.
testDataSource
();
};
};
...
@@ -132,7 +130,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -132,7 +130,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
};
};
onModelChange
=
(
dataSource
:
DataSourceSettings
)
=>
{
onModelChange
=
(
dataSource
:
DataSourceSettings
)
=>
{
this
.
setState
({
dataSource
}
);
this
.
props
.
dataSourceLoaded
(
dataSource
);
};
};
isReadOnly
()
{
isReadOnly
()
{
...
@@ -149,7 +147,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -149,7 +147,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
}
}
async
testDataSource
()
{
async
testDataSource
()
{
const
dsApi
=
await
getDatasourceSrv
().
get
(
this
.
state
.
dataSource
.
name
);
const
dsApi
=
await
getDatasourceSrv
().
get
(
this
.
props
.
dataSource
.
name
);
if
(
!
dsApi
.
testDatasource
)
{
if
(
!
dsApi
.
testDatasource
)
{
return
;
return
;
...
@@ -185,7 +183,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -185,7 +183,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
}
}
get
hasDataSource
()
{
get
hasDataSource
()
{
return
this
.
state
.
dataSource
.
id
>
0
;
return
this
.
props
.
dataSource
.
id
>
0
;
}
}
renderLoadError
(
loadError
:
any
)
{
renderLoadError
(
loadError
:
any
)
{
...
@@ -245,8 +243,8 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -245,8 +243,8 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
}
}
renderSettings
()
{
renderSettings
()
{
const
{
dataSourceMeta
,
setDataSourceName
,
setIsDefault
}
=
this
.
props
;
const
{
dataSourceMeta
,
setDataSourceName
,
setIsDefault
,
dataSource
}
=
this
.
props
;
const
{
testingMessage
,
testingStatus
,
dataSource
,
plugin
}
=
this
.
state
;
const
{
testingMessage
,
testingStatus
,
plugin
}
=
this
.
state
;
return
(
return
(
<
form
onSubmit=
{
this
.
onSubmit
}
>
<
form
onSubmit=
{
this
.
onSubmit
}
>
...
@@ -270,7 +268,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
...
@@ -270,7 +268,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
{
plugin
&&
(
{
plugin
&&
(
<
PluginSettings
<
PluginSettings
plugin=
{
plugin
}
plugin=
{
plugin
}
dataSource=
{
this
.
state
.
dataSource
}
dataSource=
{
dataSource
}
dataSourceMeta=
{
dataSourceMeta
}
dataSourceMeta=
{
dataSourceMeta
}
onModelChange=
{
this
.
onModelChange
}
onModelChange=
{
this
.
onModelChange
}
/>
/>
...
@@ -348,6 +346,7 @@ const mapDispatchToProps = {
...
@@ -348,6 +346,7 @@ const mapDispatchToProps = {
setDataSourceName
,
setDataSourceName
,
updateDataSource
,
updateDataSource
,
setIsDefault
,
setIsDefault
,
dataSourceLoaded
,
};
};
export
default
hot
(
module
)(
export
default
hot
(
module
)(
...
...
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