-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:代码库优化一期功能点 #9347 #9584
feat:代码库优化一期功能点 #9347 #9584
Changes from 52 commits
9dd0804
dabe7ae
7df1dd0
ff9e2cf
fdc17ab
badf79b
9419b4c
08bf990
0a2d2fa
ac26a48
2bab2d6
0648373
c42ffae
51963bf
8dc691a
ef278d7
98e8304
38e632b
6b0859a
030e649
0769c7b
34a3620
84e0cf8
90f5cdf
3c56169
9953d89
76ef57e
effa47e
26fd0ed
62c3199
3ff10a7
2ea7fa1
a3fe82c
8ff5330
7cd69e6
cc7834b
814346d
98338c8
8e87ff3
b07d25d
d3fd67a
1bc37f2
13aeab2
7b6db06
f391d1d
a98fa3e
4b12635
430c4c8
0f67f7f
d4e269c
d9f494a
2216648
52906af
9b987ff
1336d7d
5dc9638
c0a9df2
9bcb3e5
02a5b0a
8e5c942
33e30f0
4ee7b0e
8fdf452
884c4ff
aa37ab9
2aa9347
8493754
f9ef752
09fad04
a74f0f9
9d961f4
d0c1326
f913751
def08ce
60d381b
2946eb9
dca97e3
35ec0a7
a1c434c
6c4c5ad
1409dc1
1299d9f
60af900
5e16eb5
11fcee9
5344793
9c84842
06f0781
7b29e13
4f0deb7
55b7fed
4f69f51
199b4ad
1eda151
e128c3a
2ee04ab
dbb835b
49c5667
de4fe3c
efc1849
449adfc
221df23
d2ce69d
e46dd7f
f275fa1
f5e4935
12ee606
f9fd762
c9b1b02
afb3d3e
0446f2d
42f55a9
5938675
4b392e8
0c35d4d
cd0aaec
47e1c71
2fa72bc
ab7accf
1e1f024
b0a7936
efdbcc6
c8c0e3f
b0c8592
f743869
2a7925a
cfa932b
27d8929
3a5fb72
0b8b91c
117c37b
ac853e2
ef61417
8c474f1
2c5413d
b7e99d3
968f149
06ab8bf
c82553d
4ea7d75
a99343a
17e3f67
e2b0d71
336fa1d
9969f80
4e05229
cbbfaa1
5c42849
8f445ef
1ea33d0
691756e
dac025c
d60d412
abe09a3
d387f7b
9df32fd
fd72e0e
7d67198
9714dd9
acd1df7
9831c13
6907926
d1b47c6
966d30e
a6df263
a7e98c2
afcf5e7
4265941
c10ccf7
bd01729
5298243
95f953d
3d6197c
cd436f8
3f8f32d
a102565
1f84778
3a1e705
1890df5
221c835
0865ab1
766729d
8763c75
4726615
d6b69e1
ab7ee55
1d93dda
f8c1bbd
b2c120c
3fec051
c48b0cf
e36edfc
f9b0a3a
0692ad7
a98ecc6
528bdd6
0c6edfe
2b093fc
ddeae61
f17200d
2e13d7f
30dfc05
a5320df
000b289
f525639
44177c7
911353b
db5eab9
acb6bbf
10b47b7
1d81c1e
00e6f3c
80dc9b5
a331a09
54e0a9b
627d019
2a7e127
759d3c7
ba7094b
ea82991
4f386cc
84be7a5
3814673
3523594
1d58fb5
794942f
a24a7ad
cdf7b09
bd75c6b
6cbad28
6689d5e
1f44f47
d2c5ead
8a4d0fa
922796f
89c17fb
7726808
b4b6b26
142ad61
01e2163
8be3a9d
050c4bc
6f0339e
061cdbb
5017ac9
82d730a
fa686a4
7c82fb4
e3a9559
75132fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,9 @@ | |
cursor: pointer; | ||
color: $primaryColor; | ||
} | ||
} | ||
a { | ||
color: #3c96ff; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<template> | ||
<div class="bk-form bk-form-vertical"> | ||
<template v-for="(obj, key) in atomPropsModel"> | ||
<form-field v-if="!obj.hidden && rely(obj, element)" :key="key" :desc="obj.desc" :desc-link="obj.descLink" :desc-link-text="obj.descLinkText" :required="obj.required" :label="obj.label" :is-error="errors.has(key)" :error-msg="errors.first(key)"> | ||
<component | ||
:is="obj.component" | ||
:name="key" | ||
:value="element[key]" | ||
disabled | ||
v-bind="obj"> | ||
</component> | ||
</form-field> | ||
</template> | ||
<form-field v-if="Object.keys(customTriggerControlModel).length"> | ||
<accordion show-checkbox :show-content="enableThirdFilter" key="customTriggerControl" :is-version="true"> | ||
<header class="var-header" style="height: 16px;" slot="header"> | ||
<span> | ||
{{ $t('codelib.自定义触发控制') }} | ||
<i class="bk-icon icon-info-circle ml5" v-bk-tooltips="$t('codelib.满足基础过滤条件后,根据第三方接口返回判断是否能够触发')"></i> | ||
<a class="title-link" target="blink" :href="customTriggerDocsLink">{{ $t('codelib.查看使用指引和示例') }}</a> | ||
</span> | ||
<input class="accordion-checkbox" disabled :checked="enableThirdFilter" type="checkbox" /> | ||
</header> | ||
<div slot="content" class="bk-form bk-form-vertical"> | ||
<template v-for="(obj, key) in customTriggerControlModel"> | ||
<form-field :key="key" :desc="obj.desc" :desc-link="obj.descLink" :desc-link-text="obj.descLinkText" :required="obj.required" :label="obj.label" :is-error="errors.has(key)" :error-msg="errors.first(key)"> | ||
<component | ||
:is="obj.component" | ||
:name="key" | ||
:value="element[key]" | ||
v-bind="obj"> | ||
</component> | ||
</form-field> | ||
</template> | ||
</div> | ||
</accordion> | ||
</form-field> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import atomMixin from './atomMixin' | ||
export default { | ||
name: 'code-git-web-hook-trigger', | ||
mixins: [atomMixin], | ||
props: { | ||
element: Object, | ||
atomPropsModel: Object | ||
}, | ||
data () { | ||
return { | ||
customTriggerControlModel: {}, | ||
enableThirdFilter: true, | ||
customTriggerDocsLink: 'https://github.com/Tencent/bk-ci/issues/7743#issue-1391717634' | ||
} | ||
}, | ||
watch: { | ||
element: { | ||
handler (val) { | ||
if (this.element.repositoryType === 'NAME') { | ||
this.atomPropsModel.repositoryName.hidden = false | ||
this.atomPropsModel.repositoryHashId.hidden = true | ||
} else { | ||
this.atomPropsModel.repositoryName.hidden = true | ||
this.atomPropsModel.repositoryHashId.hidden = false | ||
} | ||
}, | ||
deep: true, | ||
immediate: true | ||
} | ||
}, | ||
created () { | ||
this.customTriggerControlModel = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上面data的默认值就已经是空对象了,没必要再在这里初始化了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
const { thirdUrl, thirdSecretToken } = this.atomPropsModel | ||
if (thirdUrl && thirdSecretToken) { | ||
this.customTriggerControlModel.thirdUrl = thirdUrl | ||
this.customTriggerControlModel.thirdSecretToken = thirdSecretToken | ||
this.atomPropsModel.thirdUrl.hidden = true | ||
this.atomPropsModel.thirdSecretToken.hidden = true | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.title-link { | ||
cursor: pointer; | ||
margin-left: 10px; | ||
color: #3c96ff; | ||
} | ||
::v-deep .bk-label, | ||
::v-deep .bk-form-content, | ||
::v-deep .bk-form-radio { | ||
font-size: 12px !important; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div class="bk-form bk-form-vertical"> | ||
<template v-for="(obj, key) in atomPropsModel"> | ||
<form-field | ||
v-if="!obj.hidden && rely(obj, element)" | ||
:key="key" | ||
:desc="obj.desc" | ||
:desc-link="obj.descLink" | ||
:desc-link-text="obj.descLinkText" | ||
:required="obj.required" | ||
:label="obj.label"> | ||
<component | ||
:disabled="true" | ||
:is="obj.component || obj.type" | ||
:name="key" | ||
:value="element[key]" | ||
v-bind="obj" | ||
></component> | ||
</form-field> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import atomMixin from './atomMixin' | ||
export default { | ||
name: 'normal-atom', | ||
mixins: [atomMixin], | ||
props: { | ||
element: Object, | ||
atomPropsModel: Object | ||
}, | ||
watch: { | ||
element: { | ||
handler () { | ||
if (this.element.repositoryType === 'NAME') { | ||
this.atomPropsModel.repositoryName.hidden = false | ||
this.atomPropsModel.repositoryHashId.hidden = true | ||
} else { | ||
this.atomPropsModel.repositoryName.hidden = true | ||
this.atomPropsModel.repositoryHashId.hidden = false | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里跟上面是一样的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
deep: true, | ||
immediate: true | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
::v-deep .bk-label, | ||
::v-deep .bk-form-content, | ||
::v-deep .bk-form-radio { | ||
font-size: 12px !important; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import AtomCheckbox from '../AtomFormField/AtomCheckbox' | ||
import EnumInput from '../AtomFormField/EnumInput' | ||
import FormField from '../AtomFormField/FormField' | ||
import Selector from '../AtomFormField/Selector' | ||
import VuexInput from '../AtomFormField/VuexInput' | ||
import RequestSelector from '../AtomFormField/RequestSelector' | ||
import StaffInput from '../AtomFormField/StaffInput' | ||
import Accordion from '../AtomFormField/Accordion' | ||
import Tips from '../AtomFormField/Tips' | ||
import { rely } from './utils.js' | ||
|
||
const atomMixin = { | ||
components: { | ||
FormField, | ||
VuexInput, | ||
EnumInput, | ||
Selector, | ||
RequestSelector, | ||
AtomCheckbox, | ||
StaffInput, | ||
Accordion, | ||
Tips | ||
}, | ||
methods: { | ||
rely (obj, element) { | ||
return rely(obj, element) | ||
} | ||
} | ||
} | ||
|
||
export default atomMixin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 判断两个数组是否有交集 | ||
* @param {Array} arr1 | ||
* @param {Array} arr2 | ||
*/ | ||
export function hasIntersection (arr1, arr2) { | ||
try { | ||
return arr2.some(item => arr1.includes(item)) | ||
} catch (e) { | ||
return false | ||
} | ||
} | ||
|
||
/** | ||
* 根据插件字段rely配置决定是否显示 | ||
* @param {Object} fieldProps 插件字段配置 | ||
* @param {Object} values 插件表单值 | ||
*/ | ||
export function rely (fieldProps, values) { | ||
try { | ||
const { rely: { expression = [], operation = 'AND' } } = fieldProps | ||
const cb = item => { | ||
const { key, value, regex } = item | ||
if (Array.isArray(value)) { | ||
if (Array.isArray(values[key])) { | ||
return hasIntersection(value, values[key]) | ||
} | ||
return typeof values[key] !== 'undefined' && value.includes(values[key]) | ||
} else if (regex) { | ||
const reg = new RegExp(regex, 'i') | ||
return Array.isArray(values[key]) ? values[key].some(item => reg.test(item)) : reg.test(values[key]) | ||
} else { | ||
return Array.isArray(values[key]) ? values[key].some(item => item === value) : values[key] === value | ||
} | ||
} | ||
switch (operation) { | ||
case 'AND': | ||
return expression.every(cb) | ||
case 'OR': | ||
return expression.length > 0 ? expression.some(cb) : true | ||
case 'NOT': | ||
return expression.length > 0 ? !expression.some(cb) : true | ||
default: | ||
return true | ||
} | ||
} catch (e) { | ||
return true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<template> | ||
<div :class="{ 'devops-accordion': true, 'is-danger': isError, 'showCheckbox': showCheckbox }"> | ||
<header :active="isShow" @click="toggleContent" class="header"> | ||
<i class="devops-icon icon-angle-right" /> | ||
<slot name="header"></slot> | ||
</header> | ||
<transition name="slideLeft"> | ||
<section v-if="condition"> | ||
<section v-if="isShow" class="content"> | ||
<slot name="content"></slot> | ||
</section> | ||
</section> | ||
<section v-else> | ||
<section v-show="isShow" class="content"> | ||
<slot name="content"></slot> | ||
</section> | ||
</section> | ||
</transition> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'accordion', | ||
props: { | ||
afterToggle: Function, | ||
showContent: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
showCheckbox: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
isError: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
isVersion: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
condition: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
data () { | ||
return { | ||
isShow: this.showContent | ||
} | ||
}, | ||
watch: { | ||
showContent (val) { | ||
this.isShow = val | ||
} | ||
}, | ||
methods: { | ||
toggleContent: function () { | ||
if (this.isVersion) { | ||
this.isShow = this.showContent ? !this.isShow : this.isShow | ||
} else { | ||
this.isShow = !this.isShow | ||
} | ||
if (typeof this.afterToggle === 'function') { | ||
this.afterToggle(this.$el, this.isShow) | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import '../../scss/conf.scss'; | ||
.devops-accordion { | ||
border: 1px solid $borderColor; | ||
border-radius: 3px; | ||
margin: 12px 0; | ||
font-size: 12px; | ||
|
||
&.is-danger { | ||
color: $dangerColor; | ||
border-color: $dangerColor; | ||
|
||
.header { | ||
color: $dangerColor; | ||
} | ||
} | ||
.header { | ||
display: flex; | ||
color: $fontColor; | ||
background-color: white; | ||
padding: 10px 15px; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
.icon-angle-right { | ||
display: block; | ||
margin: 2px 12px 0 0; | ||
transition: all 0.3s ease; | ||
} | ||
&[active] { | ||
.icon-angle-right { | ||
transform: rotate(90deg) | ||
} | ||
} | ||
} | ||
.content { | ||
padding: 10px 15px; | ||
} | ||
|
||
&.showCheckbox { | ||
> .header { | ||
background-color: $fontWeightColor; | ||
color: white; | ||
.devops-icon { | ||
display: none; | ||
} | ||
.var-header { | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的逻辑有点复杂了,可以简单一点,这里两个主要的关联就是this.element.repositoryType === 'NAME'
可以简化一下,例如:
const showName = this.element.repositoryType === 'NAME'
this.atomPropsModel.repositoryName.hidden = !showName
this.atomPropsModel.repositoryHashId.hidden = showName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改