Convey("When user is editor and in the ACL",func(){
loggedInUserScenarioWithRole("When calling GET on","GET","/api/dashboards/id/1/acl","/api/dashboards/id/:dashboardId/acl",models.ROLE_EDITOR,func(sc*scenarioContext){
ifres,err:=sess.Query("SELECT 1 from "+dialect.Quote("dashboard_acl")+" WHERE dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId);err!=nil{
returnerr
}elseiflen(res)==1{
entity:=m.DashboardAcl{
Permissions:cmd.Permissions,
Updated:time.Now(),
Permission:cmd.Permission,
Updated:time.Now(),
}
if_,err:=sess.Cols("updated","permissions").Where("dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId).Update(&entity);err!=nil{
if_,err:=sess.Cols("updated","permission").Where("dashboard_id =? and (user_group_id=? or user_id=?)",cmd.DashboardId,cmd.UserGroupId,cmd.UserId).Update(&entity);err!=nil{
<selectclass="gf-form-input gf-size-auto"ng-model="acl.permission"ng-options="p.value as p.text for p in ctrl.permissionOptions"ng-change="ctrl.permissionChanged(acl)"></select>
<em>No permissions. Will only be accessible by admins.</em>
</td>
</tr>
</table>
<formname="addPermission"class="gf-form-group">
<h6class="muted">Add Permission For</h6>
<divclass="gf-form-inline">
<divclass="gf-form">
<divclass="gf-form-select-wrapper">
<selectclass="gf-form-input gf-size-auto"ng-model="ctrl.newType"ng-options="p.value as p.text for p in ctrl.aclTypes"ng-change="ctrl.typeChanged()"></select>
<trng-repeat="permission in ctrl.userPermissions"class="permissionlist__item">
<td><iclass="fa fa-fw fa-user"></i></td>
<td>{{permission.userLogin}}</td>
<td><selectclass="gf-form-input gf-size-auto"ng-model="permission.permissions"ng-options="p.value as p.text for p in ctrl.permissionTypeOptions"ng-change="ctrl.updatePermission(permission)"></select></td>
<trng-repeat="permission in ctrl.userGroupPermissions"class="permissionlist__item">
<td><iclass="fa fa-fw fa-users"></i></td>
<td>{{permission.userGroup}}</td>
<td><selectclass="gf-form-input gf-size-auto"ng-model="permission.permissions"ng-options="p.value as p.text for p in ctrl.permissionTypeOptions"ng-change="ctrl.updatePermission(permission)"></select></td>
<trng-repeat="role in ctrl.roles"class="permissionlist__item">
<td></td>
<td>{{role.name}}</td>
<td><selectclass="gf-form-input gf-size-auto"ng-model="role.permissions"ng-options="p.value as p.text for p in ctrl.roleOptions"ng-change="ctrl.updatePermission(role)"></select></td>
<!-- <td><select class="gf-form-input gf-size-auto" ng-model="permission.permissions" ng-options="p.value as p.text for p in ctrl.permissionTypeOptions" ng-change="ctrl.updatePermission(permission)"></select></td> -->
<!-- <tr ng-repeat="role in ctrl.roles" class="permissionlist__item"> -->
<!-- <td></td> -->
<!-- <td>{{role.name}}</td> -->
<!-- <td><select class="gf-form-input gf-size-auto" ng-model="role.permissions" ng-options="p.value as p.text for p in ctrl.roleOptions" ng-change="ctrl.updatePermission(role)"></select></td> -->