mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-13 17:05:50 +01:00
(refs #1286) Show whether group account on the collaborators proposal
This commit is contained in:
@@ -110,10 +110,10 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("options" -> (if(params.get("userOnly").isDefined) {
|
Map("options" -> (if(params.get("userOnly").isDefined) {
|
||||||
getAllUsers(false).filter(!_.isGroupAccount).map(_.userName).toArray
|
getAllUsers(false).filter(!_.isGroupAccount).map { t => (t.userName, t.isGroupAccount) }.toArray
|
||||||
} else {
|
} else {
|
||||||
getAllUsers(false).map(_.userName).toArray
|
getAllUsers(false).map { t => (t.userName, t.isGroupAccount) }.toArray
|
||||||
}))
|
}).map { case (userName, groupAccount) => userName + ":" + groupAccount })
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -355,8 +355,13 @@ trait RepositoryService { self: AccountService =>
|
|||||||
/**
|
/**
|
||||||
* Returns the list of collaborators name (user name or group name) which is sorted with ascending order.
|
* Returns the list of collaborators name (user name or group name) which is sorted with ascending order.
|
||||||
*/
|
*/
|
||||||
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[Collaborator] =
|
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[(Collaborator, Boolean)] =
|
||||||
Collaborators.filter(_.byRepository(userName, repositoryName)).sortBy(_.collaboratorName).list
|
Collaborators
|
||||||
|
.innerJoin(Accounts).on(_.collaboratorName === _.userName)
|
||||||
|
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
||||||
|
.map { case (t1, t2) => (t1, t2.groupAccount) }
|
||||||
|
.sortBy { case (t1, t2) => t1.collaboratorName }
|
||||||
|
.list
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of all collaborator name and permission which is sorted with ascending order.
|
* Returns the list of all collaborator name and permission which is sorted with ascending order.
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#@id').typeahead({
|
$('#@id').typeahead({
|
||||||
|
highlighter: function(item) {
|
||||||
|
var x = item.split(':');
|
||||||
|
return $('<div><strong>' + x[0] + '</strong>' + (x[1] == 'true' ? ' (group)' : '') + '</div>');
|
||||||
|
},
|
||||||
|
updater: function (item) {
|
||||||
|
return item.split(':')[0];
|
||||||
|
},
|
||||||
source: function (query, process) {
|
source: function (query, process) {
|
||||||
return $.get('@context.path/_user/proposals@if(userOnly){?userOnly}', { query: query },
|
return $.get('@context.path/_user/proposals@if(userOnly){?userOnly}', { query: query },
|
||||||
function (data) {
|
function (data) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@(collaborators: List[gitbucket.core.model.Collaborator],
|
@(collaborators: List[(gitbucket.core.model.Collaborator, Boolean)],
|
||||||
isGroupRepository: Boolean,
|
isGroupRepository: Boolean,
|
||||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import gitbucket.core.view.helpers
|
@import gitbucket.core.view.helpers
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
</ul>
|
</ul>
|
||||||
@gitbucket.core.helper.html.account("userName", 200, false)
|
@gitbucket.core.helper.html.account("userName", 200, false)
|
||||||
<input type="button" class="btn btn-default" value="Add" id="addCollaborator"/>
|
<input type="button" class="btn btn-default" value="Add" id="addCollaborator"/>
|
||||||
<input type="hidden" id="collaborators" name="collaborators" value="@collaborators.map(x => x.userName + ":" + x.permission).mkString(",")"/>
|
<input type="hidden" id="collaborators" name="collaborators" value="@collaborators.map(x => x._1.userName + ":" + x._1.permission).mkString(",")"/>
|
||||||
<div>
|
<div>
|
||||||
<span class="error" id="error-members"></span>
|
<span class="error" id="error-collaborators"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="align-right" style="margin-top: 20px;">
|
<div class="align-right" style="margin-top: 20px;">
|
||||||
<input type="submit" class="btn btn-success" value="Apply changes"/>
|
<input type="submit" class="btn btn-success" value="Apply changes"/>
|
||||||
@@ -29,7 +29,7 @@ $(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#addCollaborator').click(function(){
|
$('#addCollaborator').click(function(){
|
||||||
$('#error-members').text('');
|
$('#error-collaborators').text('');
|
||||||
var userName = $('#userName').val();
|
var userName = $('#userName').val();
|
||||||
|
|
||||||
// check empty
|
// check empty
|
||||||
@@ -42,7 +42,7 @@ $(function(){
|
|||||||
return $(this).data('name') == userName;
|
return $(this).data('name') == userName;
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
if(exists){
|
if(exists){
|
||||||
$('#error-members').text('User has been already added.');
|
$('#error-collaborators').text('User has been already added.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +51,9 @@ $(function(){
|
|||||||
'userName': userName
|
'userName': userName
|
||||||
}, function(data, status){
|
}, function(data, status){
|
||||||
if(data == 'true'){
|
if(data == 'true'){
|
||||||
addCollaboratorHTML(userName, 'ADMIN');
|
addCollaboratorHTML(userName, 'ADMIN'); // TODO isGroup
|
||||||
} else {
|
} else {
|
||||||
$('#error-members').text('User does not exist.');
|
$('#error-collaborators').text('User does not exist.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -67,11 +67,11 @@ $(function(){
|
|||||||
return !(e.keyCode == 13);
|
return !(e.keyCode == 13);
|
||||||
});
|
});
|
||||||
|
|
||||||
@collaborators.map { x =>
|
@collaborators.map { case (collaborator, isGroup) =>
|
||||||
addCollaboratorHTML('@x.collaboratorName', '@x.permission');
|
addCollaboratorHTML('@collaborator.collaboratorName', '@collaborator.permission', @isGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCollaboratorHTML(userName, permission){
|
function addCollaboratorHTML(userName, permission, isGroup){
|
||||||
var adminButton = $('<label class="btn btn-default btn-mini"><input type="radio" value="ADMIN" name="' + userName + '">Admin</label>');
|
var adminButton = $('<label class="btn btn-default btn-mini"><input type="radio" value="ADMIN" name="' + userName + '">Admin</label>');
|
||||||
if(permission == 'ADMIN'){
|
if(permission == 'ADMIN'){
|
||||||
adminButton.addClass('active');
|
adminButton.addClass('active');
|
||||||
@@ -93,7 +93,7 @@ $(function(){
|
|||||||
.append(readButton))
|
.append(readButton))
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append($('<a>').attr('href', '@context.path/' + userName).text(userName))
|
.append($('<a>').attr('href', '@context.path/' + userName).text(userName))
|
||||||
.append(' ')
|
.append(isGroup ? ' (group)' : '')
|
||||||
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user