mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Hide assignee and milestone pulldown for not writable users.
This commit is contained in:
@@ -79,6 +79,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
(getCollaborators(owner, repository) :+ owner).sorted,
|
(getCollaborators(owner, repository) :+ owner).sorted,
|
||||||
getMilestones(owner, repository),
|
getMilestones(owner, repository),
|
||||||
getLabels(owner, repository),
|
getLabels(owner, repository),
|
||||||
|
hasWritePermission(owner, repository, context.loginAccount),
|
||||||
_)
|
_)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
})
|
})
|
||||||
@@ -110,15 +111,12 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
val issueId = params("id").toInt
|
val issueId = params("id").toInt
|
||||||
val writable = hasWritePermission(owner, repository, context.loginAccount)
|
|
||||||
|
|
||||||
getIssue(owner, repository, issueId.toString).map { issue =>
|
getIssue(owner, repository, issueId.toString).map { issue =>
|
||||||
if(writable || issue.openedUserName == context.loginAccount.get.userName){
|
if(hasWritePermission(owner, repository, context.loginAccount) || issue.openedUserName == context.loginAccount.get.userName){
|
||||||
updateIssue(owner, repository, issueId, form.title, form.content)
|
updateIssue(owner, repository, issueId, form.title, form.content)
|
||||||
redirect("/%s/%s/issues/_data/%d".format(owner, repository, issueId))
|
redirect("/%s/%s/issues/_data/%d".format(owner, repository, issueId))
|
||||||
} else {
|
} else Unauthorized
|
||||||
Unauthorized
|
|
||||||
}
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -139,21 +137,21 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
val commentId = params("id").toInt
|
val commentId = params("id").toInt
|
||||||
val writable = hasWritePermission(owner, repository, context.loginAccount)
|
|
||||||
|
|
||||||
getComment(commentId.toString).map { comment =>
|
getComment(commentId.toString).map { comment =>
|
||||||
if(writable || comment.commentedUserName == context.loginAccount.get.userName){
|
if(hasWritePermission(owner, repository, context.loginAccount) || comment.commentedUserName == context.loginAccount.get.userName){
|
||||||
updateComment(commentId, form.content)
|
updateComment(commentId, form.content)
|
||||||
redirect("/%s/%s/issue_comments/_data/%d".format(owner, repository, commentId))
|
redirect("/%s/%s/issue_comments/_data/%d".format(owner, repository, commentId))
|
||||||
} else {
|
} else Unauthorized
|
||||||
Unauthorized
|
|
||||||
}
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Authenticator
|
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly {
|
||||||
ajaxGet("/:owner/:repository/issues/_data/:id"){
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
|
||||||
getIssue(params("owner"), params("repository"), params("id")) map { x =>
|
getIssue(params("owner"), params("repository"), params("id")) map { x =>
|
||||||
|
if(hasWritePermission(owner, repository, context.loginAccount) || x.openedUserName == context.loginAccount.get.userName){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => issues.html.editissue(
|
case t if t == "html" => issues.html.editissue(
|
||||||
x.title, x.content, x.issueId, x.userName, x.repositoryName)
|
x.title, x.content, x.issueId, x.userName, x.repositoryName)
|
||||||
@@ -165,12 +163,16 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getRepository(x.userName, x.repositoryName, baseUrl).get, false, true, true)
|
getRepository(x.userName, x.repositoryName, baseUrl).get, false, true, true)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
} else Unauthorized
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
}
|
})
|
||||||
|
|
||||||
|
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly {
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
|
||||||
// TODO Authenticator
|
|
||||||
ajaxGet("/:owner/:repository/issue_comments/_data/:id"){
|
|
||||||
getComment(params("id")) map { x =>
|
getComment(params("id")) map { x =>
|
||||||
|
if(hasWritePermission(owner, repository, context.loginAccount) || x.commentedUserName == context.loginAccount.get.userName){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => issues.html.editcomment(
|
case t if t == "html" => issues.html.editcomment(
|
||||||
x.content, x.commentId, x.userName, x.repositoryName)
|
x.content, x.commentId, x.userName, x.repositoryName)
|
||||||
@@ -181,8 +183,9 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getRepository(x.userName, x.repositoryName, baseUrl).get, false, true, true)
|
getRepository(x.userName, x.repositoryName, baseUrl).get, false, true, true)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
} else Unauthorized
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
}
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/new")(collaboratorsOnly {
|
ajaxPost("/:owner/:repository/issues/:id/label/new")(collaboratorsOnly {
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@(collaborators: List[String],
|
@(collaborators: List[String],
|
||||||
milestones: List[model.Milestone],
|
milestones: List[model.Milestone],
|
||||||
labels: List[model.Label],
|
labels: List[model.Label],
|
||||||
|
hasWritePermission: Boolean,
|
||||||
repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||||
@import context._
|
@import context._
|
||||||
@import view.helpers._
|
@import view.helpers._
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
<input type="text" name="title" value="" placeholder="Title" style="width: 650px;"/>
|
<input type="text" name="title" value="" placeholder="Title" style="width: 650px;"/>
|
||||||
<div>
|
<div>
|
||||||
<span id="label-assigned">No one is assigned</span>
|
<span id="label-assigned">No one is assigned</span>
|
||||||
|
@if(hasWritePermission){
|
||||||
<input type="hidden" name="assignedUserName" value=""/>
|
<input type="hidden" name="assignedUserName" value=""/>
|
||||||
@helper.html.dropdown {
|
@helper.html.dropdown {
|
||||||
<li><a href="javascript:void(0);" class="assign" data-name="">Clear assignee</a></li>
|
<li><a href="javascript:void(0);" class="assign" data-name="">Clear assignee</a></li>
|
||||||
@@ -24,8 +26,10 @@
|
|||||||
<li><a href="javascript:void(0);" class="assign" data-name="@collaborator">@collaborator</a></li>
|
<li><a href="javascript:void(0);" class="assign" data-name="@collaborator">@collaborator</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<span id="label-milestone">No milestone</span>
|
<span id="label-milestone">No milestone</span>
|
||||||
|
@if(hasWritePermission){
|
||||||
<input type="hidden" name="milestoneId" value=""/>
|
<input type="hidden" name="milestoneId" value=""/>
|
||||||
@helper.html.dropdown {
|
@helper.html.dropdown {
|
||||||
<li><a href="javascript:void(0);" class="milestone" data-id="">No milestone</a></li>
|
<li><a href="javascript:void(0);" class="milestone" data-id="">No milestone</a></li>
|
||||||
@@ -34,6 +38,7 @@
|
|||||||
<li><a href="javascript:void(0);" class="milestone" data-id="@milestone.milestoneId">@milestone.title</a></li>
|
<li><a href="javascript:void(0);" class="milestone" data-id="@milestone.milestoneId">@milestone.title</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
@@ -43,6 +48,7 @@
|
|||||||
<input type="submit" class="btn btn-success" value="Submit new issue"/>
|
<input type="submit" class="btn btn-success" value="Submit new issue"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
|
@if(hasWritePermission){
|
||||||
<strong>Add Labels</strong>
|
<strong>Add Labels</strong>
|
||||||
<div>
|
<div>
|
||||||
<div id="label-list">
|
<div id="label-list">
|
||||||
@@ -59,6 +65,7 @@
|
|||||||
<input type="hidden" name="labelNames" value=""/>
|
<input type="hidden" name="labelNames" value=""/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user