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
66311a06
Commit
66311a06
authored
Oct 16, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removing datasource permissions states from grafana
parent
ef0def22
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
115 deletions
+13
-115
public/app/features/datasources/__mocks__/dataSourcesMocks.ts
+1
-30
public/app/features/datasources/state/actions.ts
+2
-52
public/app/features/datasources/state/reducers.ts
+1
-5
public/app/store/configureStore.ts
+8
-2
public/app/types/datasources.ts
+0
-23
public/app/types/index.ts
+1
-3
No files found.
public/app/features/datasources/__mocks__/dataSourcesMocks.ts
View file @
66311a06
import
{
DataSource
,
DataSourcePermission
}
from
'app/types'
;
import
{
DataSource
}
from
'app/types'
;
export
const
getMockDataSources
=
(
amount
:
number
):
DataSource
[]
=>
{
const
dataSources
=
[];
...
...
@@ -43,32 +43,3 @@ export const getMockDataSource = (): DataSource => {
user
:
''
,
};
};
export
const
getMockDataSourcePermissionsUser
=
():
DataSourcePermission
=>
{
return
{
created
:
'2018-10-10T16:50:45+02:00'
,
datasourceId
:
1
,
id
:
2
,
permission
:
1
,
permissionName
:
'Query'
,
updated
:
'2018-10-10T16:50:45+02:00'
,
userAvatarUrl
:
'/avatar/926aa85c6bcefa0b4deca3223f337ae1'
,
userEmail
:
'test@test.com'
,
userId
:
3
,
userLogin
:
'testUser'
,
};
};
export
const
getMockDataSourcePermissionsTeam
=
():
DataSourcePermission
=>
{
return
{
created
:
'2018-10-10T16:57:09+02:00'
,
datasourceId
:
1
,
id
:
6
,
permission
:
1
,
permissionName
:
'Query'
,
team
:
'A-team'
,
teamAvatarUrl
:
'/avatar/93c0801b955cbd443a8cfa91a401d7bc'
,
teamId
:
1
,
updated
:
'2018-10-10T16:57:09+02:00'
,
};
};
public/app/features/datasources/state/actions.ts
View file @
66311a06
import
{
ThunkAction
}
from
'redux-thunk'
;
import
{
DataSource
,
DataSourcePermissionDTO
,
Plugin
,
StoreState
}
from
'app/types'
;
import
{
DataSource
,
Plugin
,
StoreState
}
from
'app/types'
;
import
{
getBackendSrv
}
from
'../../../core/services/backend_srv'
;
import
{
LayoutMode
}
from
'../../../core/components/LayoutSelector/LayoutSelector'
;
import
{
updateLocation
,
updateNavIndex
,
UpdateNavIndexAction
}
from
'../../../core/actions'
;
...
...
@@ -11,7 +11,6 @@ export enum ActionTypes {
LoadDataSourceTypes
=
'LOAD_DATA_SOURCE_TYPES'
,
LoadDataSource
=
'LOAD_DATA_SOURCE'
,
LoadDataSourceMeta
=
'LOAD_DATA_SOURCE_META'
,
LoadDataSourcePermissions
=
'LOAD_DATA_SOURCE_PERMISSIONS'
,
SetDataSourcesSearchQuery
=
'SET_DATA_SOURCES_SEARCH_QUERY'
,
SetDataSourcesLayoutMode
=
'SET_DATA_SOURCES_LAYOUT_MODE'
,
SetDataSourceTypeSearchQuery
=
'SET_DATA_SOURCE_TYPE_SEARCH_QUERY'
,
...
...
@@ -52,11 +51,6 @@ export interface LoadDataSourceMetaAction {
payload
:
Plugin
;
}
export
interface
LoadDataSourcePermissionsAction
{
type
:
ActionTypes
.
LoadDataSourcePermissions
;
payload
:
DataSourcePermissionDTO
;
}
const
dataSourcesLoaded
=
(
dataSources
:
DataSource
[]):
LoadDataSourcesAction
=>
({
type
:
ActionTypes
.
LoadDataSources
,
payload
:
dataSources
,
...
...
@@ -77,13 +71,6 @@ const dataSourceTypesLoaded = (dataSourceTypes: Plugin[]): LoadDataSourceTypesAc
payload
:
dataSourceTypes
,
});
const
dataSourcePermissionsLoaded
=
(
dataSourcePermission
:
DataSourcePermissionDTO
):
LoadDataSourcePermissionsAction
=>
({
type
:
ActionTypes
.
LoadDataSourcePermissions
,
payload
:
dataSourcePermission
,
});
export
const
setDataSourcesSearchQuery
=
(
searchQuery
:
string
):
SetDataSourcesSearchQueryAction
=>
({
type
:
ActionTypes
.
SetDataSourcesSearchQuery
,
payload
:
searchQuery
,
...
...
@@ -108,8 +95,7 @@ export type Action =
|
SetDataSourceTypeSearchQueryAction
|
LoadDataSourceAction
|
UpdateNavIndexAction
|
LoadDataSourceMetaAction
|
LoadDataSourcePermissionsAction
;
|
LoadDataSourceMetaAction
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
>
;
...
...
@@ -159,42 +145,6 @@ export function loadDataSourceTypes(): ThunkResult<void> {
};
}
export
function
loadDataSourcePermissions
(
id
:
number
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
const
response
=
await
getBackendSrv
().
get
(
`/api/datasources/
${
id
}
/permissions`
);
dispatch
(
dataSourcePermissionsLoaded
(
response
));
};
}
export
function
enableDataSourcePermissions
(
id
:
number
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
await
getBackendSrv
().
post
(
`/api/datasources/
${
id
}
/enable-permissions`
,
{});
dispatch
(
loadDataSourcePermissions
(
id
));
};
}
export
function
disableDataSourcePermissions
(
id
:
number
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
await
getBackendSrv
().
post
(
`/api/datasources/
${
id
}
/disable-permissions`
,
{});
dispatch
(
loadDataSourcePermissions
(
id
));
};
}
export
function
addDataSourcePermission
(
id
:
number
,
data
:
object
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
await
getBackendSrv
().
post
(
`/api/datasources/
${
id
}
/permissions`
,
data
);
dispatch
(
loadDataSourcePermissions
(
id
));
};
}
export
function
removeDataSourcePermission
(
id
:
number
,
permissionId
:
number
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
await
getBackendSrv
().
delete
(
`/api/datasources/
${
id
}
/permissions/
${
permissionId
}
`
);
dispatch
(
loadDataSourcePermissions
(
id
));
};
}
export
function
nameExits
(
dataSources
,
name
)
{
return
(
dataSources
.
filter
(
dataSource
=>
{
...
...
public/app/features/datasources/state/reducers.ts
View file @
66311a06
import
{
DataSource
,
DataSource
PermissionDTO
,
DataSource
sState
,
Plugin
}
from
'app/types'
;
import
{
DataSource
,
DataSourcesState
,
Plugin
}
from
'app/types'
;
import
{
Action
,
ActionTypes
}
from
'./actions'
;
import
{
LayoutModes
}
from
'../../../core/components/LayoutSelector/LayoutSelector'
;
...
...
@@ -11,7 +11,6 @@ const initialState: DataSourcesState = {
dataSourceTypes
:
[]
as
Plugin
[],
dataSourceTypeSearchQuery
:
''
,
dataSourceMeta
:
{}
as
Plugin
,
dataSourcePermission
:
{}
as
DataSourcePermissionDTO
,
hasFetched
:
false
,
};
...
...
@@ -37,9 +36,6 @@ export const dataSourcesReducer = (state = initialState, action: Action): DataSo
case
ActionTypes
.
LoadDataSourceMeta
:
return
{
...
state
,
dataSourceMeta
:
action
.
payload
};
case
ActionTypes
.
LoadDataSourcePermissions
:
return
{
...
state
,
dataSourcePermission
:
action
.
payload
};
}
return
state
;
...
...
public/app/store/configureStore.ts
View file @
66311a06
...
...
@@ -11,7 +11,7 @@ import pluginReducers from 'app/features/plugins/state/reducers';
import
dataSourcesReducers
from
'app/features/datasources/state/reducers'
;
import
usersReducers
from
'app/features/users/state/reducers'
;
const
rootReducer
=
combineReducers
(
{
const
rootReducer
s
=
{
...
sharedReducers
,
...
alertingReducers
,
...
teamsReducers
,
...
...
@@ -21,13 +21,19 @@ const rootReducer = combineReducers({
...
pluginReducers
,
...
dataSourcesReducers
,
...
usersReducers
,
}
)
;
};
export
let
store
;
export
function
addRootReducer
(
reducers
)
{
Object
.
assign
(
rootReducers
,
...
reducers
);
}
export
function
configureStore
()
{
const
composeEnhancers
=
(
window
as
any
).
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
||
compose
;
const
rootReducer
=
combineReducers
(
rootReducers
);
if
(
process
.
env
.
NODE_ENV
!==
'production'
)
{
// DEV builds we had the logger middleware
store
=
createStore
(
rootReducer
,
{},
composeEnhancers
(
applyMiddleware
(
thunk
,
createLogger
())));
...
...
public/app/types/datasources.ts
View file @
66311a06
import
{
LayoutMode
}
from
'../core/components/LayoutSelector/LayoutSelector'
;
import
{
Plugin
}
from
'./plugins'
;
export
interface
DataSourcePermission
{
id
:
number
;
datasourceId
:
number
;
permission
:
number
;
permissionName
:
string
;
created
:
string
;
updated
:
string
;
userId
?:
number
;
userLogin
?:
string
;
userEmail
?:
string
;
userAvatarUrl
?:
string
;
teamId
?:
number
;
teamAvatarUrl
?:
string
;
team
?:
string
;
}
export
interface
DataSourcePermissionDTO
{
datasourceId
:
number
;
enabled
:
boolean
;
permissions
:
DataSourcePermission
[];
}
export
interface
DataSource
{
id
:
number
;
orgId
:
number
;
...
...
@@ -49,6 +27,5 @@ export interface DataSourcesState {
dataSourceTypes
:
Plugin
[];
dataSource
:
DataSource
;
dataSourceMeta
:
Plugin
;
dataSourcePermission
:
DataSourcePermissionDTO
;
hasFetched
:
boolean
;
}
public/app/types/index.ts
View file @
66311a06
...
...
@@ -7,7 +7,7 @@ import { DashboardState } from './dashboard';
import
{
DashboardAcl
,
OrgRole
,
PermissionLevel
}
from
'./acl'
;
import
{
ApiKey
,
ApiKeysState
,
NewApiKey
}
from
'./apiKeys'
;
import
{
Invitee
,
OrgUser
,
User
,
UsersState
}
from
'./user'
;
import
{
DataSource
,
DataSource
PermissionDTO
,
DataSourcePermission
,
DataSource
sState
}
from
'./datasources'
;
import
{
DataSource
,
DataSourcesState
}
from
'./datasources'
;
import
{
PluginMeta
,
Plugin
,
PluginsState
}
from
'./plugins'
;
export
{
...
...
@@ -41,8 +41,6 @@ export {
Plugin
,
PluginsState
,
DataSourcesState
,
DataSourcePermissionDTO
,
DataSourcePermission
,
Invitee
,
OrgUser
,
User
,
...
...
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