mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 23:45:50 +01:00
(refs #1286) Add columns: ISSUES_OPTION and WIKI_OPTION
This commit is contained in:
@@ -4,6 +4,30 @@
|
||||
<column name="PERMISSION" type="varchar(10)" nullable="false" defaultValue="ADMIN"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="REPOSITORY">
|
||||
<column name="ALLOW_CREATE_ISSUE" type="boolean" nullable="false" defaultValueBoolean="false"/>
|
||||
<column name="WIKI_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||
<column name="ISSUES_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||
</addColumn>
|
||||
<update tableName="REPOSITORY">
|
||||
<column name="WIKI_OPTION" value="DISABLE"/>
|
||||
<where>ENABLE_WIKI = FALSE</where>
|
||||
</update>
|
||||
<update tableName="REPOSITORY">
|
||||
<column name="WIKI_OPTION" value="PRIVATE"/>
|
||||
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = FALSE</where>
|
||||
</update>
|
||||
<update tableName="REPOSITORY">
|
||||
<column name="WIKI_OPTION" value="PUBLIC"/>
|
||||
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = TRUE</where>
|
||||
</update>
|
||||
<update tableName="REPOSITORY">
|
||||
<column name="ISSUES_OPTION" value="DISABLE"/>
|
||||
<where>ENABLE_ISSUES = FALSE</where>
|
||||
</update>
|
||||
<update tableName="REPOSITORY">
|
||||
<column name="ISSUES_OPTION" value="PUBLIC"/>
|
||||
<where>ENABLE_ISSUES = TRUE</where>
|
||||
</update>
|
||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
||||
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
||||
</changeSet>
|
||||
|
||||
@@ -31,10 +31,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
repositoryName: String,
|
||||
description: Option[String],
|
||||
isPrivate: Boolean,
|
||||
enableIssues: Boolean,
|
||||
issuesOption: String,
|
||||
externalIssuesUrl: Option[String],
|
||||
enableWiki: Boolean,
|
||||
allowWikiEditing: Boolean,
|
||||
wikiOption: String,
|
||||
externalWikiUrl: Option[String],
|
||||
allowFork: Boolean
|
||||
)
|
||||
@@ -43,10 +42,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
"repositoryName" -> trim(label("Repository Name" , text(required, maxlength(40), identifier, renameRepositoryName))),
|
||||
"description" -> trim(label("Description" , optional(text()))),
|
||||
"isPrivate" -> trim(label("Repository Type" , boolean())),
|
||||
"enableIssues" -> trim(label("Enable Issues" , boolean())),
|
||||
"issuesOption" -> trim(label("Issues Option" , text(required))), // TODO enum check
|
||||
"externalIssuesUrl" -> trim(label("External Issues URL", optional(text(maxlength(200))))),
|
||||
"enableWiki" -> trim(label("Enable Wiki" , boolean())),
|
||||
"allowWikiEditing" -> trim(label("Allow Wiki Editing" , boolean())),
|
||||
"wikiOption" -> trim(label("Wiki Option" , text(required))), // TODO enum check
|
||||
"externalWikiUrl" -> trim(label("External Wiki URL" , optional(text(maxlength(200))))),
|
||||
"allowFork" -> trim(label("Allow Forking" , boolean()))
|
||||
)(OptionsForm.apply)
|
||||
@@ -109,10 +107,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
repository.repository.parentUserName.map { _ =>
|
||||
repository.repository.isPrivate
|
||||
} getOrElse form.isPrivate,
|
||||
form.enableIssues,
|
||||
form.issuesOption,
|
||||
form.externalIssuesUrl,
|
||||
form.enableWiki,
|
||||
form.allowWikiEditing,
|
||||
form.wikiOption,
|
||||
form.externalWikiUrl,
|
||||
form.allowFork
|
||||
)
|
||||
|
||||
@@ -240,9 +240,13 @@ trait WikiControllerBase extends ControllerBase {
|
||||
|
||||
private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName"))
|
||||
|
||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean =
|
||||
repository.repository.options.allowWikiEditing || (
|
||||
hasWritePermission(repository.owner, repository.name, context.loginAccount)
|
||||
)
|
||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||
repository.repository.options.wikiOption match {
|
||||
case "ALL" => true // TODO read permission
|
||||
case "PUBLIC" => true // TODO read permission
|
||||
case "PRIVATE" => hasWritePermission(repository.owner, repository.name, context.loginAccount)
|
||||
case "DISABLE" => false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,18 +17,16 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
||||
val originRepositoryName = column[String]("ORIGIN_REPOSITORY_NAME")
|
||||
val parentUserName = column[String]("PARENT_USER_NAME")
|
||||
val parentRepositoryName = column[String]("PARENT_REPOSITORY_NAME")
|
||||
val enableIssues = column[Boolean]("ENABLE_ISSUES")
|
||||
val issuesOption = column[String]("ISSUES_OPTION")
|
||||
val externalIssuesUrl = column[String]("EXTERNAL_ISSUES_URL")
|
||||
val enableWiki = column[Boolean]("ENABLE_WIKI")
|
||||
val allowWikiEditing = column[Boolean]("ALLOW_WIKI_EDITING")
|
||||
val wikiOption = column[String]("WIKI_OPTION")
|
||||
val externalWikiUrl = column[String]("EXTERNAL_WIKI_URL")
|
||||
val allowFork = column[Boolean]("ALLOW_FORK")
|
||||
val allowCreateIssue = column[Boolean]("ALLOW_CREATE_ISSUE")
|
||||
|
||||
def * = (
|
||||
(userName, repositoryName, isPrivate, description.?, defaultBranch,
|
||||
registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?),
|
||||
(enableIssues, externalIssuesUrl.?, enableWiki, allowWikiEditing, externalWikiUrl.?, allowFork, allowCreateIssue)
|
||||
(issuesOption, externalIssuesUrl.?, wikiOption, externalWikiUrl.?, allowFork)
|
||||
).shaped <> (
|
||||
{ case (repository, options) =>
|
||||
Repository(
|
||||
@@ -86,11 +84,9 @@ case class Repository(
|
||||
)
|
||||
|
||||
case class RepositoryOptions(
|
||||
enableIssues: Boolean,
|
||||
issuesOption: String,
|
||||
externalIssuesUrl: Option[String],
|
||||
enableWiki: Boolean,
|
||||
allowWikiEditing: Boolean,
|
||||
wikiOption: String,
|
||||
externalWikiUrl: Option[String],
|
||||
allowFork: Boolean,
|
||||
allowCreateIssue: Boolean
|
||||
allowFork: Boolean
|
||||
)
|
||||
|
||||
@@ -38,13 +38,11 @@ trait RepositoryService { self: AccountService =>
|
||||
parentUserName = parentUserName,
|
||||
parentRepositoryName = parentRepositoryName,
|
||||
options = RepositoryOptions(
|
||||
enableIssues = true,
|
||||
issuesOption = "PRIVATE",
|
||||
externalIssuesUrl = None,
|
||||
enableWiki = true,
|
||||
allowWikiEditing = true,
|
||||
wikiOption = "PUBLIC",
|
||||
externalWikiUrl = None,
|
||||
allowFork = true,
|
||||
allowCreateIssue = false
|
||||
allowFork = true
|
||||
)
|
||||
)
|
||||
|
||||
@@ -321,12 +319,12 @@ trait RepositoryService { self: AccountService =>
|
||||
*/
|
||||
def saveRepositoryOptions(userName: String, repositoryName: String,
|
||||
description: Option[String], isPrivate: Boolean,
|
||||
enableIssues: Boolean, externalIssuesUrl: Option[String],
|
||||
enableWiki: Boolean, allowWikiEditing: Boolean, externalWikiUrl: Option[String],
|
||||
issuesOption: String, externalIssuesUrl: Option[String],
|
||||
wikiOption: String, externalWikiUrl: Option[String],
|
||||
allowFork: Boolean)(implicit s: Session): Unit =
|
||||
Repositories.filter(_.byRepository(userName, repositoryName))
|
||||
.map { r => (r.description.?, r.isPrivate, r.enableIssues, r.externalIssuesUrl.?, r.enableWiki, r.allowWikiEditing, r.externalWikiUrl.?, r.allowFork, r.updatedDate) }
|
||||
.update (description, isPrivate, enableIssues, externalIssuesUrl, enableWiki, allowWikiEditing, externalWikiUrl, allowFork, currentDate)
|
||||
.map { r => (r.description.?, r.isPrivate, r.issuesOption, r.externalIssuesUrl.?, r.wikiOption, r.externalWikiUrl.?, r.allowFork, r.updatedDate) }
|
||||
.update (description, isPrivate, issuesOption, externalIssuesUrl, wikiOption, externalWikiUrl, allowFork, currentDate)
|
||||
|
||||
def saveRepositoryDefaultBranch(userName: String, repositoryName: String,
|
||||
defaultBranch: String)(implicit s: Session): Unit =
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
@menuitem("/branches", "branches", "Branches", "git-branch", repository.branchList.length)
|
||||
@menuitem("/tags", "tags", "Tags", "tag", repository.tags.length)
|
||||
}
|
||||
@if(repository.repository.options.enableIssues) {
|
||||
@if(repository.repository.options.issuesOption != "DISABLE") {
|
||||
@menuitem("/issues", "issues", "Issues", "issue-opened", repository.issueCount)
|
||||
@menuitem("/pulls", "pulls", "Pull Requests", "git-pull-request", repository.pullCount)
|
||||
@menuitem("/issues/labels", "labels", "Labels", "tag")
|
||||
@@ -37,7 +37,7 @@
|
||||
@menuitem(externalIssuesUrl, "issues", "Issues", "issue-opened")
|
||||
}
|
||||
}
|
||||
@if(repository.repository.options.enableWiki) {
|
||||
@if(repository.repository.options.wikiOption != "DISABLE") {
|
||||
@menuitem("/wiki", "wiki", "Wiki", "book")
|
||||
} else {
|
||||
@repository.repository.options.externalWikiUrl.map { externalWikiUrl =>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<div class="panel-heading strong">Features</div>
|
||||
<div class="panel-body">
|
||||
<fieldset class="form-group">
|
||||
@* TODO Make radio to choose issues option
|
||||
<label class="checkbox" for="enableIssues">
|
||||
<input type="checkbox" id="enableIssues" name="enableIssues"@if(repository.repository.options.enableIssues){ checked}/>
|
||||
Issues<br>
|
||||
@@ -52,12 +53,14 @@
|
||||
Provides Lightweight issue tracking integrated with this repository. Add issues to milestones, label issues, and close & reference issues from commit messages.
|
||||
</div>
|
||||
</label>
|
||||
*@
|
||||
<label for="externalIssuesUrl" class="strong">External URL:
|
||||
<span class="normal muted">(Put if you have the external issue tracking system for this project)</span>
|
||||
</label>
|
||||
<input type="text" class="form-control" id="externalIssuesUrl" name="externalIssuesUrl" value="@repository.repository.options.externalIssuesUrl"/>
|
||||
</fieldset>
|
||||
<fieldset class="form-group">
|
||||
@* TODO Make radio to choose wiki option
|
||||
<label class="checkbox" for="enableWiki">
|
||||
<input type="checkbox" id="enableWiki" name="enableWiki"@if(repository.repository.options.enableWiki){ checked}/>
|
||||
Wiki<br>
|
||||
@@ -69,6 +72,7 @@
|
||||
<input type="checkbox" id="allowWikiEditing" name="allowWikiEditing"@if(repository.repository.options.allowWikiEditing){ checked}/>
|
||||
Allow read-only users to edit Wiki pages<br>
|
||||
</label>
|
||||
*@
|
||||
<label for="externalWikiUrl" class="strong">External URL:
|
||||
<span class="normal muted">(Put if you have the external Wiki for this project)</span>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user