Skip to content

Commit

Permalink
【PAC】feat:新增代码库详情页 #8118
Browse files Browse the repository at this point in the history
  • Loading branch information
mingshewhe committed Oct 28, 2023
1 parent 6f53f46 commit 8e792e6
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 157 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license.
*
* A copy of the MIT License is included in this file.
*
*
* Terms of the MIT License:
* ---------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

package com.tencent.devops.common.pipeline.pojo.element

/**
* 插件属性
*/
data class ElementProp(
val name: String,
val value: Any,
val type: ElementPropType
)

/**
* 属性类型
*/
enum class ElementPropType(val value: String) {
VUEX_INPUT("vuex-input"),
STAFF_INPUT("staff-input"),
SELECTOR("selector");
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ package com.tencent.devops.common.pipeline.pojo.element.trigger

import com.tencent.devops.common.api.enums.RepositoryType
import com.tencent.devops.common.pipeline.enums.StartType
import com.tencent.devops.common.pipeline.pojo.element.ElementProp
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.CodeEventType
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.PathFilterType
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.selector
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.staffInput
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.vuexInput
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

Expand Down Expand Up @@ -116,68 +120,69 @@ data class CodeGitWebHookTriggerElement(
}

// 增加条件这里也要补充上,不然代码库触发器列表展示会不对
override fun triggerCondition(): Map<String, Any?> {
return when (eventType) {
override fun triggerCondition(): List<ElementProp> {
val props = when (eventType) {
CodeEventType.PUSH -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.MERGE_REQUEST -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includeSourceBranchName" to includeSourceBranchName,
"excludeSourceBranchName" to excludeSourceBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(name = "includeSourceBranchName", value = includeSourceBranchName),
vuexInput(name = "includeSourceBranchName", value = includeSourceBranchName),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.MERGE_REQUEST_ACCEPT -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includeSourceBranchName" to includeSourceBranchName,
"excludeSourceBranchName" to excludeSourceBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(name = "includeSourceBranchName", value = includeSourceBranchName),
vuexInput(name = "includeSourceBranchName", value = includeSourceBranchName),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.TAG_PUSH -> {
mapOf(
"tagName" to tagName,
"excludeTagName" to excludeTagName,
"fromBranches" to fromBranches
listOf(
vuexInput(name = "tagName", value = tagName),
vuexInput(name = "excludeTagName", value = excludeTagName),
vuexInput(name = "fromBranches", value = fromBranches),
)
}
CodeEventType.REVIEW -> {
mapOf(
"includeCrState" to includeCrState,
"includeCrTypes" to includeCrTypes
listOf(
selector(name = "includeCrState", value = includeCrState),
selector(name = "includeCrTypes", value = includeCrTypes)
)
}
CodeEventType.ISSUES -> {
mapOf(
"includeIssueAction" to includeIssueAction
listOf(
selector(name = "includeIssueAction", value = includeIssueAction)
)
}
CodeEventType.NOTE -> {
mapOf(
"includeNoteTypes" to includeNoteTypes,
"includeNoteComment" to includeNoteComment
listOf(
selector(name = "includeNoteTypes", value = includeNoteTypes),
vuexInput(name = "includeNoteComment", value = includeNoteComment)
)
}
else ->
emptyMap()
emptyList()
}
return props.filterNotNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ package com.tencent.devops.common.pipeline.pojo.element.trigger

import com.tencent.devops.common.api.enums.RepositoryType
import com.tencent.devops.common.pipeline.enums.StartType
import com.tencent.devops.common.pipeline.pojo.element.ElementProp
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.CodeEventType
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

Expand Down Expand Up @@ -71,31 +73,18 @@ data class CodeGithubWebHookTriggerElement(
}

// 增加条件这里也要补充上,不然代码库触发器列表展示会不对
override fun triggerCondition(): Map<String, Any?> {
return when (eventType) {
CodeEventType.PUSH -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"excludeUsers" to excludeUsers
override fun triggerCondition(): List<ElementProp> {
val props = when (eventType) {
CodeEventType.PUSH, CodeEventType.CREATE, CodeEventType.PULL_REQUEST -> {
listOf(
TriggerElementPropUtils.vuexInput(name = "branchName", value = branchName),
TriggerElementPropUtils.vuexInput(name = "excludeBranchName", value = excludeBranchName),
TriggerElementPropUtils.vuexInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.CREATE -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"excludeUsers" to excludeUsers
)
}
CodeEventType.PULL_REQUEST -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"excludeUsers" to excludeUsers
)
}
else ->
emptyMap()

else -> emptyList()
}
return props.filterNotNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ package com.tencent.devops.common.pipeline.pojo.element.trigger

import com.tencent.devops.common.api.enums.RepositoryType
import com.tencent.devops.common.pipeline.enums.StartType
import com.tencent.devops.common.pipeline.pojo.element.ElementProp
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.CodeEventType
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.PathFilterType
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.staffInput
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.vuexInput
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

Expand Down Expand Up @@ -94,50 +97,63 @@ data class CodeGitlabWebHookTriggerElement(
}

// 增加条件这里也要补充上,不然代码库触发器列表展示会不对
override fun triggerCondition(): Map<String, Any?> {
return when (eventType) {
override fun triggerCondition(): List<ElementProp> {
val props = when (eventType) {
CodeEventType.PUSH -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.MERGE_REQUEST -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includeSourceBranchName" to includeSourceBranchName,
"excludeSourceBranchName" to excludeSourceBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(
name = "includeSourceBranchName",
value = includeSourceBranchName
),
vuexInput(
name = "includeSourceBranchName",
value = includeSourceBranchName
),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.MERGE_REQUEST_ACCEPT -> {
mapOf(
"branchName" to branchName,
"excludeBranchName" to excludeBranchName,
"includeSourceBranchName" to includeSourceBranchName,
"excludeSourceBranchName" to excludeSourceBranchName,
"includePaths" to includePaths,
"excludePaths" to excludePaths,
"includeUsers" to includeUsers,
"excludeUsers" to excludeUsers
listOf(
vuexInput(name = "branchName", value = branchName),
vuexInput(name = "excludeBranchName", value = excludeBranchName),
vuexInput(
name = "includeSourceBranchName",
value = includeSourceBranchName
),
vuexInput(
name = "includeSourceBranchName",
value = includeSourceBranchName
),
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths),
staffInput(name = "includeUsers", value = includeUsers),
staffInput(name = "excludeUsers", value = excludeUsers)
)
}
CodeEventType.TAG_PUSH -> {
mapOf(
"tagName" to tagName,
"excludeTagName" to excludeTagName
listOf(
vuexInput(name = "tagName", value = tagName),
vuexInput(name = "excludeTagName", value = excludeTagName),
)
}
else ->
emptyMap()
emptyList()
}
return props.filterNotNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ package com.tencent.devops.common.pipeline.pojo.element.trigger

import com.tencent.devops.common.api.enums.RepositoryType
import com.tencent.devops.common.pipeline.enums.StartType
import com.tencent.devops.common.pipeline.pojo.element.ElementProp
import com.tencent.devops.common.pipeline.pojo.element.trigger.enums.CodeEventType
import com.tencent.devops.common.pipeline.utils.TriggerElementPropUtils.vuexInput
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

Expand Down Expand Up @@ -59,26 +61,27 @@ data class CodeP4WebHookTriggerElement(
}

// 增加条件这里也要补充上,不然代码库触发器列表展示会不对
override fun triggerCondition(): Map<String, Any?> {
return with(data.input) {
when (eventType) {
override fun triggerCondition(): List<ElementProp> {
with(data.input) {
val props = when (eventType) {
CodeEventType.CHANGE_COMMIT, CodeEventType.CHANGE_SUBMIT, CodeEventType.CHANGE_CONTENT -> {
mapOf(
"includePaths" to includePaths,
"excludePaths" to excludePaths
listOf(
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths)
)
}

CodeEventType.SHELVE_COMMIT, CodeEventType.SHELVE_SUBMIT, CodeEventType.SHELVE_DELETE -> {
mapOf(
"includePaths" to includePaths,
"excludePaths" to excludePaths
listOf(
vuexInput(name = "includePaths", value = includePaths),
vuexInput(name = "excludePaths", value = excludePaths)
)
}

else ->
emptyMap()
emptyList()
}
return props.filterNotNull()
}
}
}
Expand Down
Loading

0 comments on commit 8e792e6

Please sign in to comment.