fix: 优化镜像清理弹框内容显示 (#2931)

Refs #2928
pull/2936/head v1.8.2
ssongliu 1 year ago committed by GitHub
parent 80c68b8e49
commit aa1f2d0f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,6 +119,7 @@ export namespace Container {
name: string;
tags: Array<string>;
size: string;
isUsed: boolean;
}
export interface ImageBuild {
from: string;

@ -286,7 +286,7 @@ const message = {
home: {
restart_1panel: 'Restart Panel',
restart_system: 'Restart Server',
operationSuccess: 'Operation successful! Restarting, please wait...',
operationSuccess: 'Operation succeeded, rebooting, please refresh the browser manually later!',
overview: 'Overview',
entranceHelper:
'Enabling a secure entrance can help improve system security. If necessary, go to the Control Panel settings, select Security, and enable the secure entrance.',
@ -519,8 +519,10 @@ const message = {
containerPruneHelper3: 'This operation cannot be rolled back. Do you want to continue?',
imagePrune: 'Image prune',
imagePruneSome: 'Clean unlabeled',
imagePruneSomeEmpty: 'No image with the "none" tag is to be cleared',
imagePruneSomeHelper: 'Clean the images with the tag "none" that are not used by any containers.',
imagePruneAll: 'Clean unused',
imagePruneAllEmpty: 'No unused images to be cleared',
imagePruneAllHelper: 'Clean the images that are not used by any containers.',
networkPrune: 'Network prune',
networkPruneHelper: 'Remove all unused networks. Do you want to continue?',

@ -284,7 +284,7 @@ const message = {
home: {
restart_1panel: '',
restart_system: '',
operationSuccess: '...',
operationSuccess: '',
overview: '',
entranceHelper: ' - ',
appInstalled: '',
@ -507,9 +507,11 @@ const message = {
containerPruneHelper3: '',
imagePrune: '',
imagePruneSome: '',
imagePruneSomeHelper: ' none 使',
imagePruneSomeEmpty: '使 none ',
imagePruneSomeHelper: ' none 使',
imagePruneAll: '使',
imagePruneAllHelper: '使',
imagePruneAllEmpty: '使',
imagePruneAllHelper: '使',
networkPrune: '',
networkPruneHelper: ' 使',
volumePrune: '',

@ -284,7 +284,7 @@ const message = {
home: {
restart_1panel: '',
restart_system: '',
operationSuccess: '...',
operationSuccess: '',
overview: '',
entranceHelper: ' - ',
appInstalled: '',
@ -508,9 +508,11 @@ const message = {
containerPruneHelper3: '',
imagePrune: '',
imagePruneSome: '',
imagePruneSomeHelper: ' none 使',
imagePruneSomeEmpty: '使 none ',
imagePruneSomeHelper: ' none 使',
imagePruneAll: '使',
imagePruneAllHelper: '使',
imagePruneAllEmpty: '使',
imagePruneAllHelper: '使',
networkPrune: '',
networkPruneHelper: ' 使',
volumePrune: '',

@ -12,19 +12,25 @@
<el-radio :label="true">{{ $t('container.imagePruneAll') }}</el-radio>
</el-radio-group>
</el-form-item>
<span>
{{ withTagAll ? $t('container.imagePruneAllHelper') : $t('container.imagePruneSomeHelper') }}
<span v-if="withTagAll">
{{ unUsedList.length !== 0 ? $t('container.imagePruneAllHelper') : $t('container.imagePruneAllEmpty') }}
</span>
<span v-else>
{{
unTagList.length !== 0 ? $t('container.imagePruneSomeHelper') : $t('container.imagePruneSomeEmpty')
}}
</span>
<div v-if="!withTagAll">
<ul v-for="(item, index) in imageList" :key="index">
<li v-if="item.tags && item.tags.length === 1 && item.tags[0].indexOf('<none>') !== -1">
<ul v-for="(item, index) in unTagList" :key="index">
<li>
{{ item.tags[0] }}
</li>
</ul>
</div>
<div v-else>
<ul v-for="(item, index) in imageList" :key="index">
<li v-if="item.tags && !item.isUsed">{{ item.tags.join(', ') }}</li>
<ul v-for="(item, index) in unUsedList" :key="index">
<li v-if="item.tags">{{ item.tags.join(', ') }}</li>
<li v-else>{{ item.id.replaceAll('sha256:', '').substring(0, 12) }}</li>
</ul>
</div>
</el-form>
@ -33,7 +39,7 @@
<el-button @click="dialogVisible = false">
{{ $t('commons.button.cancel') }}
</el-button>
<el-button type="primary" @click="onClean" :disabled="loading">
<el-button type="primary" :disabled="buttonDisable() || loading" @click="onClean">
{{ $t('commons.button.confirm') }}
</el-button>
</span>
@ -52,19 +58,34 @@ import { ref } from 'vue';
const dialogVisible = ref(false);
const withTagAll = ref(false);
const loading = ref();
const imageList = ref();
const unTagList = ref();
const unUsedList = ref();
interface DialogProps {
list: Array<Container.ImageInfo>;
}
const acceptParams = (params: DialogProps): void => {
imageList.value = params.list;
let list = params.list || [];
unTagList.value = [];
unUsedList.value = [];
for (const item of list) {
if (item.tags && item.tags.length === 1 && item.tags[0].indexOf('<none>') !== -1 && !item.isUsed) {
unTagList.value.push(item);
}
if (!item.isUsed) {
unUsedList.value.push(item);
}
}
dialogVisible.value = true;
withTagAll.value = false;
};
const emit = defineEmits<{ (e: 'search'): void }>();
const buttonDisable = () => {
return withTagAll.value ? unUsedList.value.length === 0 : unTagList.value.length === 0;
};
const onClean = async () => {
loading.value = true;
let params = {

Loading…
Cancel
Save