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
6b9858c1
Commit
6b9858c1
authored
Jan 17, 2018
by
Johannes Schill
Committed by
Daniel Lee
Jan 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashfolders: Working user picker on the dashboard permissions page #10275
parent
2de04898
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
29 deletions
+26
-29
public/app/core/components/Permissions/Permissions.tsx
+15
-17
public/app/core/components/UserPicker/UserPicker.tsx
+5
-4
public/app/core/components/UserPicker/withPicker.tsx
+4
-1
public/app/stores/PermissionsStore/PermissionsStore.ts
+2
-7
No files found.
public/app/core/components/Permissions/Permissions.tsx
View file @
6b9858c1
import
React
,
{
Component
}
from
'react'
;
import
PermissionsList
from
'./PermissionsList'
;
import
_
from
'lodash'
;
import
DevTools
from
'mobx-react-devtools'
;
import
{
inject
,
observer
}
from
'mobx-react'
;
// import UserPicker
from 'app/core/components/UserPicker/UserPicker';
import
UserPicker
,
{
User
}
from
'app/core/components/UserPicker/UserPicker'
;
export
interface
DashboardAcl
{
id
?:
number
;
...
...
@@ -29,6 +28,7 @@ export interface IProps {
dashboardId
:
number
;
permissions
?:
any
;
isFolder
:
boolean
;
backendSrv
:
any
;
}
@
inject
(
'permissions'
)
...
...
@@ -49,6 +49,7 @@ class Permissions extends Component<IProps, any> {
newType
:
string
;
canUpdate
:
boolean
;
error
:
string
;
refreshList
:
any
;
readonly
duplicateError
=
'This permission exists already.'
;
...
...
@@ -59,6 +60,7 @@ class Permissions extends Component<IProps, any> {
this
.
typeChanged
=
this
.
typeChanged
.
bind
(
this
);
this
.
removeItem
=
this
.
removeItem
.
bind
(
this
);
this
.
update
=
this
.
update
.
bind
(
this
);
this
.
userPicked
=
this
.
userPicked
.
bind
(
this
);
permissions
.
load
(
dashboardId
,
isFolder
);
this
.
state
=
{
...
...
@@ -70,13 +72,8 @@ class Permissions extends Component<IProps, any> {
console
.
log
(
'nextProps'
,
nextProps
);
}
sortItems
(
items
)
{
return
_
.
orderBy
(
items
,
[
'sortRank'
,
'sortName'
],
[
'desc'
,
'asc'
]);
}
permissionChanged
(
index
:
number
,
permission
:
number
,
permissionName
:
string
)
{
const
{
permissions
}
=
this
.
props
;
// permissions.items[index].updatePermission(permission, permissionName);
permissions
.
updatePermissionOnIndex
(
index
,
permission
,
permissionName
);
}
...
...
@@ -117,9 +114,14 @@ class Permissions extends Component<IProps, any> {
});
}
userPicked
(
user
:
User
)
{
const
{
permissions
}
=
this
.
props
;
permissions
.
addStoreItem
({
userId
:
user
.
id
,
userLogin
:
user
.
login
,
permission
:
1
});
}
render
()
{
console
.
log
(
'Permissions render'
);
const
{
error
,
permissions
}
=
this
.
props
;
const
{
error
,
permissions
,
backendSrv
}
=
this
.
props
;
const
{
newType
}
=
this
.
state
;
return
(
...
...
@@ -155,30 +157,26 @@ class Permissions extends Component<IProps, any> {
/> */
}
</
div
>
</
div
>
{
/*
{
newType
===
'User'
?
(
<
div
className=
"gf-form"
>
{' '}
User picker
<user-picker user-picked="ctrl.userPicked($user)" />
{
/* <user-picker user-picked="ctrl.userPicked($user)" />
<select-user-picker
backendSrv="ctrl.backendSrv"
teamId="ctrl.$routeParams.id"
refreshList="ctrl.get"
teamMembers="ctrl.teamMembers"
/>
<UserPicker backendSrv={backendSrv}
teamId={0
} />
/>
*/
}
<
UserPicker
backendSrv=
{
backendSrv
}
userPicked=
{
this
.
userPicked
}
/>
</
div
>
)
:
null
}
{
newType
===
'Group'
?
(
<
div
className=
"gf-form"
>
{' '}
Team picker
<team-picker team-picked="ctrl.groupPicked($group)" />
{
/* <team-picker team-picked="ctrl.groupPicked($group)" /> */
}
</
div
>
)
:
null
}
*/
}
</
div
>
</
form
>
{
error
?
(
...
...
public/app/core/components/UserPicker/UserPicker.tsx
View file @
6b9858c1
...
...
@@ -13,9 +13,9 @@ export interface IProps {
export
interface
User
{
id
:
number
;
name
:
string
;
label
:
string
;
avatarUrl
:
string
;
login
:
string
;
email
:
string
;
}
class
UserPicker
extends
Component
<
IProps
,
any
>
{
...
...
@@ -33,12 +33,12 @@ class UserPicker extends Component<IProps, any> {
});
}
handleChange
(
user
)
{
handleChange
(
user
:
User
)
{
const
{
userPicked
}
=
this
.
props
;
userPicked
(
user
);
}
searchUsers
(
query
)
{
searchUsers
(
query
?:
string
)
{
const
{
toggleLoading
,
backendSrv
}
=
this
.
props
;
toggleLoading
(
true
);
...
...
@@ -48,6 +48,7 @@ class UserPicker extends Component<IProps, any> {
id
:
user
.
id
,
label
:
`
${
user
.
login
}
-
${
user
.
email
}
`
,
avatarUrl
:
user
.
avatarUrl
,
login
:
user
.
login
,
};
});
toggleLoading
(
false
);
...
...
public/app/core/components/UserPicker/withPicker.tsx
View file @
6b9858c1
import
React
,
{
Component
}
from
'react'
;
export
interface
IProps
{}
export
interface
IProps
{
backendSrv
:
any
;
userPicked
:
(
user
)
=>
void
;
}
// export interface User {
// id: number;
...
...
public/app/stores/PermissionsStore/PermissionsStore.ts
View file @
6b9858c1
...
...
@@ -51,13 +51,9 @@ export const PermissionsStore = types
self
.
canUpdate
=
true
;
},
updatePermissionOnIndex
(
idx
:
number
,
permission
:
number
,
permissionName
:
string
)
{
// self.items[idx].permission = permission;
// self.items[idx].permissionName = permissionName;
self
.
items
[
idx
].
updatePermission
(
permission
,
permissionName
);
self
.
canUpdate
=
true
;
},
// load: flow(function* load(dashboardId: number) {
update
:
flow
(
function
*
update
(
dashboardId
:
number
)
{
const
backendSrv
=
getEnv
(
self
).
backendSrv
;
const
updated
=
[];
...
...
@@ -95,13 +91,12 @@ const prepareServerResponse = (response, dashboardId: number, isFolder: boolean)
};
const
prepareItem
=
(
item
,
dashboardId
:
number
,
isFolder
:
boolean
)
=>
{
// TODO: this.meta
// item.inherited = !this.meta.isFolder && this.dashboardId !== item.dashboardId;
item
.
inherited
=
!
isFolder
&&
dashboardId
!==
item
.
dashboardId
;
// item.inherited = dashboardId !== item.dashboardId;
item
.
sortRank
=
0
;
if
(
item
.
userId
>
0
)
{
item
.
icon
=
'fa fa-fw fa-user'
;
// TODO: Check what sce.trustAsHtml did
// item.nameHtml = this.$sce.trustAsHtml(item.userLogin);
item
.
nameHtml
=
item
.
userLogin
;
item
.
sortName
=
item
.
userLogin
;
...
...
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