mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 11:36:05 +01:00
Provide completion proposals for adding collaborator.
This commit is contained in:
@@ -2,15 +2,15 @@ package app
|
|||||||
|
|
||||||
import service._
|
import service._
|
||||||
import util.Directory._
|
import util.Directory._
|
||||||
import util.OwnerOnlyAuthenticator
|
import util.{UsersOnlyAuthenticator, OwnerOnlyAuthenticator}
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import jp.sf.amateras.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
|
|
||||||
class SettingsController extends SettingsControllerBase
|
class SettingsController extends SettingsControllerBase
|
||||||
with RepositoryService with AccountService with OwnerOnlyAuthenticator
|
with RepositoryService with AccountService with OwnerOnlyAuthenticator with UsersOnlyAuthenticator
|
||||||
|
|
||||||
trait SettingsControllerBase extends ControllerBase {
|
trait SettingsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with OwnerOnlyAuthenticator =>
|
self: RepositoryService with AccountService with OwnerOnlyAuthenticator with UsersOnlyAuthenticator =>
|
||||||
|
|
||||||
case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean)
|
case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean)
|
||||||
|
|
||||||
@@ -70,6 +70,14 @@ trait SettingsControllerBase extends ControllerBase {
|
|||||||
settings.html.collaborators(getCollaborators(owner, repository), _)) getOrElse NotFound
|
settings.html.collaborators(getCollaborators(owner, repository), _)) getOrElse NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON API for collaborator completion.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/settings/collaborators/proposals")(usersOnly {
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(Map("options" -> getAllUsers.map(_.userName).toArray))
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the collaborator.
|
* Add the collaborator.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,3 +21,13 @@
|
|||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<script>
|
||||||
|
$('#userName').typeahead({
|
||||||
|
source: function (query, process) {
|
||||||
|
return $.get('@path/@repository.owner/@repository.name/settings/collaborators/proposals', { query: query },
|
||||||
|
function (data) {
|
||||||
|
return process(data.options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user