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
72b7497d
Commit
72b7497d
authored
Dec 05, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added isDefault switch on settings
parent
aa6c52a1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
106 deletions
+59
-106
public/app/features/datasources/settings/BasicSettings.test.tsx
+3
-1
public/app/features/datasources/settings/BasicSettings.tsx
+25
-19
public/app/features/datasources/settings/DataSourceSettings.test.tsx
+1
-0
public/app/features/datasources/settings/DataSourceSettings.tsx
+8
-4
public/app/features/datasources/state/actions.ts
+13
-1
public/app/features/datasources/state/reducers.ts
+3
-0
yarn.lock
+6
-81
No files found.
public/app/features/datasources/settings/BasicSettings.test.tsx
View file @
72b7497d
...
...
@@ -5,7 +5,9 @@ import BasicSettings, { Props } from './BasicSettings';
const
setup
=
()
=>
{
const
props
:
Props
=
{
dataSourceName
:
'Graphite'
,
onChange
:
jest
.
fn
(),
isDefault
:
false
,
onDefaultChange
:
jest
.
fn
(),
onNameChange
:
jest
.
fn
(),
};
return
shallow
(<
BasicSettings
{
...
props
}
/>);
...
...
public/app/features/datasources/settings/BasicSettings.tsx
View file @
72b7497d
import
React
,
{
SFC
}
from
'react'
;
import
{
Label
}
from
'app/core/components/Label/Label'
;
import
{
Switch
}
from
'../../../core/components/Switch/Switch'
;
export
interface
Props
{
dataSourceName
:
string
;
onChange
:
(
name
:
string
)
=>
void
;
isDefault
:
boolean
;
onNameChange
:
(
name
:
string
)
=>
void
;
onDefaultChange
:
(
value
:
boolean
)
=>
void
;
}
const
BasicSettings
:
SFC
<
Props
>
=
({
dataSourceName
,
on
Change
})
=>
{
const
BasicSettings
:
SFC
<
Props
>
=
({
dataSourceName
,
isDefault
,
onDefaultChange
,
onName
Change
})
=>
{
return
(
<
div
className=
"gf-form-group"
>
<
div
className=
"gf-form max-width-30"
>
<
Label
tooltip=
{
'The name is used when you select the data source in panels. The Default data source is'
+
'preselected in new panels.'
}
>
Name
</
Label
>
<
input
className=
"gf-form-input max-width-23"
type=
"text"
value=
{
dataSourceName
}
placeholder=
"Name"
onChange=
{
event
=>
onChange
(
event
.
target
.
value
)
}
required
/>
<
div
className=
"gf-form-inline"
>
<
div
className=
"gf-form max-width-30"
style=
{
{
marginRight
:
'3px'
}
}
>
<
Label
tooltip=
{
'The name is used when you select the data source in panels. The Default data source is'
+
'preselected in new panels.'
}
>
Name
</
Label
>
<
input
className=
"gf-form-input max-width-23"
type=
"text"
value=
{
dataSourceName
}
placeholder=
"Name"
onChange=
{
event
=>
onNameChange
(
event
.
target
.
value
)
}
required
/>
</
div
>
<
Switch
label=
"Default"
checked=
{
isDefault
}
onChange=
{
event
=>
onDefaultChange
(
event
.
target
.
checked
)
}
/>
</
div
>
</
div
>
);
...
...
public/app/features/datasources/settings/DataSourceSettings.test.tsx
View file @
72b7497d
...
...
@@ -15,6 +15,7 @@ const setup = (propOverrides?: object) => {
loadDataSource
:
jest
.
fn
(),
setDataSourceName
:
jest
.
fn
(),
updateDataSource
:
jest
.
fn
(),
setIsDefault
:
jest
.
fn
(),
};
Object
.
assign
(
props
,
propOverrides
);
...
...
public/app/features/datasources/settings/DataSourceSettings.tsx
View file @
72b7497d
...
...
@@ -13,7 +13,7 @@ import { getBackendSrv } from 'app/core/services/backend_srv';
import
{
getDatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
import
{
getDataSource
,
getDataSourceMeta
}
from
'../state/selectors'
;
import
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
updateDataSource
}
from
'../state/actions'
;
import
{
deleteDataSource
,
loadDataSource
,
setDataSourceName
,
setIsDefault
,
updateDataSource
}
from
'../state/actions'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getRouteParamsId
}
from
'app/core/selectors/location'
;
...
...
@@ -29,6 +29,7 @@ export interface Props {
loadDataSource
:
typeof
loadDataSource
;
setDataSourceName
:
typeof
setDataSourceName
;
updateDataSource
:
typeof
updateDataSource
;
setIsDefault
:
typeof
setIsDefault
;
}
interface
State
{
...
...
@@ -164,7 +165,7 @@ export class DataSourceSettings extends PureComponent<Props, State> {
}
render
()
{
const
{
dataSource
,
dataSourceMeta
,
navModel
}
=
this
.
props
;
const
{
dataSource
,
dataSourceMeta
,
navModel
,
setDataSourceName
,
setIsDefault
}
=
this
.
props
;
const
{
testingMessage
,
testingStatus
}
=
this
.
state
;
return
(
...
...
@@ -177,8 +178,10 @@ export class DataSourceSettings extends PureComponent<Props, State> {
<
div
>
<
form
onSubmit=
{
this
.
onSubmit
}
>
<
BasicSettings
dataSourceName=
{
this
.
props
.
dataSource
.
name
}
onChange=
{
name
=>
this
.
props
.
setDataSourceName
(
name
)
}
dataSourceName=
{
dataSource
.
name
}
isDefault=
{
dataSource
.
isDefault
}
onDefaultChange=
{
state
=>
setIsDefault
(
state
)
}
onNameChange=
{
name
=>
setDataSourceName
(
name
)
}
/>
{
this
.
shouldRenderInfoBox
()
&&
<
div
className=
"grafana-info-box"
>
{
this
.
getInfoText
()
}
</
div
>
}
...
...
@@ -240,6 +243,7 @@ const mapDispatchToProps = {
loadDataSource
,
setDataSourceName
,
updateDataSource
,
setIsDefault
,
};
export
default
hot
(
module
)(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
DataSourceSettings
));
public/app/features/datasources/state/actions.ts
View file @
72b7497d
...
...
@@ -17,6 +17,7 @@ export enum ActionTypes {
SetDataSourcesLayoutMode
=
'SET_DATA_SOURCES_LAYOUT_MODE'
,
SetDataSourceTypeSearchQuery
=
'SET_DATA_SOURCE_TYPE_SEARCH_QUERY'
,
SetDataSourceName
=
'SET_DATA_SOURCE_NAME'
,
SetIsDefault
=
'SET_IS_DEFAULT'
,
}
interface
LoadDataSourcesAction
{
...
...
@@ -59,6 +60,11 @@ interface SetDataSourceNameAction {
payload
:
string
;
}
interface
SetIsDefaultAction
{
type
:
ActionTypes
.
SetIsDefault
;
payload
:
boolean
;
}
const
dataSourcesLoaded
=
(
dataSources
:
DataSource
[]):
LoadDataSourcesAction
=>
({
type
:
ActionTypes
.
LoadDataSources
,
payload
:
dataSources
,
...
...
@@ -99,6 +105,11 @@ export const setDataSourceName = (name: string) => ({
payload
:
name
,
});
export
const
setIsDefault
=
(
state
:
boolean
)
=>
({
type
:
ActionTypes
.
SetIsDefault
,
payload
:
state
,
});
export
type
Action
=
|
LoadDataSourcesAction
|
SetDataSourcesSearchQueryAction
...
...
@@ -109,7 +120,8 @@ export type Action =
|
LoadDataSourceAction
|
UpdateNavIndexAction
|
LoadDataSourceMetaAction
|
SetDataSourceNameAction
;
|
SetDataSourceNameAction
|
SetIsDefaultAction
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
>
;
...
...
public/app/features/datasources/state/reducers.ts
View file @
72b7497d
...
...
@@ -39,6 +39,9 @@ export const dataSourcesReducer = (state = initialState, action: Action): DataSo
case
ActionTypes
.
SetDataSourceName
:
return
{
...
state
,
dataSource
:
{
...
state
.
dataSource
,
name
:
action
.
payload
}
};
case
ActionTypes
.
SetIsDefault
:
return
{
...
state
,
dataSource
:
{
...
state
.
dataSource
,
isDefault
:
action
.
payload
}
};
}
return
state
;
...
...
yarn.lock
View file @
72b7497d
...
...
@@ -218,15 +218,6 @@
esutils "^2.0.2"
js-tokens "^4.0.0"
<<<<<<< HEAD
"@babel/runtime@^7.1.2":
version "7.1.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.5.tgz#4170907641cf1f61508f563ece3725150cc6fe39"
dependencies:
regenerator-runtime "^0.12.0"
||||||| merged common ancestors
=======
"@babel/parser@^7.1.2", "@babel/parser@^7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.3.tgz#2c92469bac2b7fbff810b67fca07bd138b48af77"
...
...
@@ -659,6 +650,12 @@
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-typescript" "^7.1.0"
"@babel/runtime@^7.1.2":
version "7.1.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.5.tgz#4170907641cf1f61508f563ece3725150cc6fe39"
dependencies:
regenerator-runtime "^0.12.0"
"@babel/template@^7.1.0", "@babel/template@^7.1.2":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.2.tgz#090484a574fef5a2d2d7726a674eceda5c5b5644"
...
...
@@ -683,7 +680,6 @@
globals "^11.1.0"
lodash "^4.17.10"
>>>>>>> master
"@babel/types@^7.0.0":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.1.2.tgz#183e7952cf6691628afdc2e2b90d03240bac80c0"
...
...
@@ -1845,21 +1841,10 @@ babel-jest@^23.6.0:
babel-plugin-istanbul "^4.1.6"
babel-preset-jest "^23.2.0"
<<<<<<< HEAD
babel-loader@^7.1.4:
version "7.1.5"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.5.tgz#e3ee0cd7394aa557e013b02d3e492bfd07aa6d68"
||||||| merged common ancestors
babel-loader@^7.1.4:
version "7.1.5"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.5.tgz#e3ee0cd7394aa557e013b02d3e492bfd07aa6d68"
integrity sha512-iCHfbieL5d1LfOQeeVJEUyD9rTwBcP/fcEbRCfempxTDuqrKpu0AZjLAQHEQa3Yqyj9ORKe2iHfoj4rHLf7xpw==
=======
babel-loader@^8.0.4:
version "8.0.4"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.4.tgz#7bbf20cbe4560629e2e41534147692d3fecbdce6"
integrity sha512-fhBhNkUToJcW9nV46v8w87AJOwAJDz84c1CL57n3Stj73FANM/b9TbCUK4YhdOwEyZ+OxhYpdeZDNzSI29Firw==
>>>>>>> master
dependencies:
find-cache-dir "^1.0.0"
loader-utils "^1.0.2"
...
...
@@ -2225,30 +2210,7 @@ babel-plugin-transform-strict-mode@^6.24.1:
babel-runtime "^6.22.0"
babel-types "^6.24.1"
<<<<<<< HEAD
babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"
babel-preset-es2015@^6.24.1, babel-preset-es2015@^6.9.0:
||||||| merged common ancestors
babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"
babel-preset-es2015@^6.24.1, babel-preset-es2015@^6.9.0:
=======
babel-preset-es2015@^6.9.0:
>>>>>>> master
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939"
dependencies:
...
...
@@ -6184,21 +6146,10 @@ header-case@^1.0.0:
no-case "^2.2.0"
upper-case "^1.1.3"
<<<<<<< HEAD
highlight-words-core@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/highlight-words-core/-/highlight-words-core-1.2.0.tgz#232bec301cbf2a4943d335dc748ce70e9024f3b1"
||||||| merged common ancestors
highlight-words-core@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/highlight-words-core/-/highlight-words-core-1.2.0.tgz#232bec301cbf2a4943d335dc748ce70e9024f3b1"
integrity sha512-nu5bMsWIgpsrlXEMNKSvbJMeUPhFxCOVT28DnI8UCVfhm3e98LC8oeyMNrc7E18+QQ4l/PvbeN7ojyN4XsmBdA==
=======
highlight-words-core@^1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/highlight-words-core/-/highlight-words-core-1.2.2.tgz#1eff6d7d9f0a22f155042a00791237791b1eeaaa"
integrity sha512-BXUKIkUuh6cmmxzi5OIbUJxrG8OAk2MqoL1DtO3Wo9D2faJg2ph5ntyuQeLqaHJmzER6H5tllCDA9ZnNe9BVGg==
>>>>>>> master
hmac-drbg@^1.0.0:
version "1.0.1"
...
...
@@ -10639,21 +10590,10 @@ react-grid-layout@0.16.6:
react-draggable "3.x"
react-resizable "1.x"
<<<<<<< HEAD
react-highlight-words@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/react-highlight-words/-/react-highlight-words-0.10.0.tgz#2e905c76c11635237f848ecad00600f1b6f6f4a8"
||||||| merged common ancestors
react-highlight-words@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/react-highlight-words/-/react-highlight-words-0.10.0.tgz#2e905c76c11635237f848ecad00600f1b6f6f4a8"
integrity sha512-/5jh6a8pir3baCOMC5j88MBmNciSwG5bXWNAAtbtDb3WYJoGn82e2zLCQFnghIBWod1h5y6/LRO8TS6ERbN5aQ==
=======
react-highlight-words@0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/react-highlight-words/-/react-highlight-words-0.11.0.tgz#4f3c2039a8fd275f3ab795e59946b0324d8e6bee"
integrity sha512-b+fgdQXNjX6RwHfiBYn6qH2D2mJEDNLuxdsqRseIiQffoCAoj7naMQ5EktUkmo9Bh1mXq/aMpJbdx7Lf2PytcQ==
>>>>>>> master
dependencies:
highlight-words-core "^1.2.0"
prop-types "^15.5.8"
...
...
@@ -11020,22 +10960,7 @@ regenerate@^1.2.1, regenerate@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
<<<<<<< HEAD
regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
regenerator-runtime@^0.11.0:
||||||| merged common ancestors
regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
integrity sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=
regenerator-runtime@^0.11.0:
=======
regenerator-runtime@^0.11.0, regenerator-runtime@^0.11.1:
>>>>>>> master
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
...
...
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