Skip to content
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:流水线支持归档目录 #9320 #9646

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
<template>
<span v-if="hasPermission && artifactoryType !== 'IMAGE'" v-bk-tooltips="{
content: $t('details.noDownloadPermTips'),
disabled: hasPermission,
allowHTML: false
}">

<i
v-if="icon"
class="devops-icon icon-download"
@click.stop="downLoadFile"
/>
<bk-button
v-else
text
@click="downLoadFile"
:disabled="!hasPermission"

<div v-if="artifactoryType !== 'IMAGE'">
<bk-popover
:disabled="!hasPermission || !disabled"
>
{{ $t("download") }}
</bk-button>

<i
v-if="downloadIcon"
:class="['devops-icon icon-download', {
'artifactory-download-icon-disabled': btnDisabled
}]"
@click.stop="downLoadFile"
/>
<bk-button
v-else
text
@click="downLoadFile"
:disabled="btnDisabled"
>
{{ $t("download") }}
</bk-button>
<template slot="content">
<template v-if="disabled">
<p>{{ disabled ? $t('downloadDisabledTips') : $t('details.noDownloadPermTips') }}</p>
</template>
</template>
</bk-popover>
<bk-dialog
width="500"
v-model="visible"
Expand All @@ -40,14 +44,14 @@
</bk-button>
</footer>
</bk-dialog>
</span>
</div>
</template>

<script>
import { convertFileSize } from '@/utils/util'
export default {
emits: ['update:value'],
props: {
icon: Boolean,
downloadIcon: Boolean,
hasPermission: Boolean,
artifactoryType: {
type: String
Expand All @@ -60,18 +64,35 @@
type: String,
required: true
},
value: Boolean
output: {
type: Object,
required: true
}
},
data () {
return {
visible: false,
signingMap: new Map()
}
},
computed: {
disabled () {
// 目录超10Gb 禁用状态
if (this.output) {
const size = this.output.folder ? this.convertFileSize(this.getFolderSize(this.output), 'B') : this.output.size > 0 ? this.convertFileSize(this.output.size, 'B') : '--'
return this.output.folder ? size.includes('GB') && size.split(' ')[0] > 1 : false
}
return false
},
btnDisabled () {
return !this.hasPermission || this.disabled
}
},
beforeDestroy () {
this.cancelDownloading()
},
methods: {
convertFileSize,
setVisible (visible) {
this.visible = visible
},
Expand Down Expand Up @@ -142,6 +163,17 @@
this.resolve?.(false)
this.resolve = null
this.setVisible(false)
},
getFolderSize (payload) {
if (!payload.folder) return '0'
return this.getValuesByKey(payload.properties, 'size')
},
getValuesByKey (data, key) {
for (const item of data) {
if (key.includes(item.key)) {
return item.value
}
}
}
}
}
Expand All @@ -161,8 +193,12 @@
color: $primaryColor;
}
}
.artifactory-download-icon-disabled {
color: #979ba5;
cursor: not-allowed;
}
.signing-duration-tips {
color: #979797;
color: #979ba5;
font-size: 12px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,37 @@
</div>
</template>
</bk-table-column>
<bk-table-column :label="$t('details.path')" prop="fullName" show-overflow-tooltip></bk-table-column>
<bk-table-column :label="$t('details.filesize')" width="150" prop="size" show-overflow-tooltip>
<bk-table-column
:label="$t('details.path')"
prop="fullName"
show-overflow-tooltip
>
</bk-table-column>
<bk-table-column
:label="$t('details.filesize')"
width="150"
prop="size"
show-overflow-tooltip
>
<template slot-scope="props">
{{ !props.row.folder ? sizeFormatter(props.row.size) : sizeFormatter(getFolderSize(props.row)) }}
</template>
</bk-table-column>
<bk-table-column :label="$t('details.repoType')" width="150" prop="artifactoryType" :formatter="repoTypeFormatter" show-overflow-tooltip></bk-table-column>
<bk-table-column
:label="$t('details.repoType')"
width="150"
prop="artifactoryType"
:formatter="repoTypeFormatter"
show-overflow-tooltip
>
</bk-table-column>
<bk-table-column :label="$t('operate')" width="150">
<template slot-scope="props">
<artifact-download-button
:output="props.row"
:has-permission="hasPermission"
v-bind="props.row"
:artifactory-type="props.row.artifactoryType"
/>
</template>
</bk-table-column>
Expand Down Expand Up @@ -109,7 +128,8 @@
this.artifactories
= res.records.map((item) => ({
...item,
icon: item.folder ? 'folder' : extForFile(item.name)
icon: item.folder ? 'folder' : extForFile(item.name),
size: item.folder ? this.sizeFormatter(this.getFolderSize(item)) : this.sizeFormatter(item.size)
})) || []
this.hasPermission = permission
if (this.artifactories.length <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
/>
<artifact-download-button
v-if="output.downloadable"
icon
:output="output"
download-icon
:has-permission="hasPermission"
:path="output.fullPath"
:name="output.name"
Expand Down Expand Up @@ -81,6 +82,7 @@
<p class="pipeline-exec-output-actions">
<artifact-download-button
v-if="activeOutput.downloadable"
:output="activeOutput"
:has-permission="hasPermission"
:path="activeOutput.fullPath"
:name="activeOutput.name"
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/locale/pipeline/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1218,5 +1218,6 @@
"needSignTips": "{0} is an internal test version and is being downloaded, please wait",
"apkSignDurationTips": "Only the first download needs to wait. The preparation time is related to the package size. A 500MB package takes about 1 minute.",
"apkSignSuccess": "{0} is ready, start downloading",
"downloadLater": "Download later"
"downloadLater": "Download later",
"downloadDisabledTips": "Exceeds 10 GB. Please download in batches from the artifact repository."
}
3 changes: 2 additions & 1 deletion src/frontend/locale/pipeline/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1223,5 +1223,6 @@
"needSignTips": "{0} 为内部测试版本,正在准备下载,请稍等",
"apkSignDurationTips": "仅首次下载需等待,准备时长和包大小有关,500MB的包大概需要1分钟",
"apkSignSuccess": "{0} 已经准备完成,开始下载",
"downloadLater": "稍后再下载"
"downloadLater": "稍后再下载",
"downloadDisabledTips": "目录下的文件大小超过 10 G,请到制品库分批下载"
}