From fecb354d163f596d7b33f3eec90e31781baceb4a Mon Sep 17 00:00:00 2001 From: TheYoungManLi Date: Thu, 9 Dec 2021 15:49:56 +0800 Subject: [PATCH] fix: Incorrect information for exceeding the resource limit Signed-off-by: TheYoungManLi --- ...s-applicationWorkloads-deployments-list.js | 3 +++ .../ContainerList/QuotaCheck.jsx | 23 +++++++++++++------ src/utils/workload.js | 5 +++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/locales/en/l10n-projects-applicationWorkloads-deployments-list.js b/locales/en/l10n-projects-applicationWorkloads-deployments-list.js index 00ca94b92ab..b84401b2a71 100644 --- a/locales/en/l10n-projects-applicationWorkloads-deployments-list.js +++ b/locales/en/l10n-projects-applicationWorkloads-deployments-list.js @@ -30,6 +30,9 @@ module.exports = { 'Invalid name. The name can contain only lowercase letters, numbers, and hyphens (-), and must start and end with a lowercase letter or number. The maximum length is 63 characters.', NO_IMAGE_FOUND: 'No Image Found', CONTAINER_EMPTY_DESC: 'Please add at least one container.', + QUOTA_UNSET_TIP: 'Resource occupation is unset', + QUOTA_OVERCOST_TIP: + 'The current resource occupation has exceeded the remaining', // List > Create > Pod Settings > Port Settings WORKLOAD_PORT_NAME_DESC: diff --git a/src/components/Forms/Workload/ContainerSettings/ContainerList/QuotaCheck.jsx b/src/components/Forms/Workload/ContainerSettings/ContainerList/QuotaCheck.jsx index 039a04d09af..b138b479c93 100644 --- a/src/components/Forms/Workload/ContainerSettings/ContainerList/QuotaCheck.jsx +++ b/src/components/Forms/Workload/ContainerSettings/ContainerList/QuotaCheck.jsx @@ -182,14 +182,23 @@ export default class QuotaCheck extends Component { if (isEmpty(containers) && isEmpty(initContainers)) { return null } + const limitUnset = Object.values(checkResult).some( + item => item.overcost === 'unset' + ) + const overcost = Object.values(checkResult).some( + item => item.overcost === true + ) + const type = overcost || limitUnset ? 'error' : 'info' + const title = overcost + ? t('QUOTA_OVERCOST_TIP') + : limitUnset + ? t('QUOTA_UNSET_TIP') + : t('Remaining Quota') - const overcost = Object.values(checkResult).some(item => item.overcost) - const type = overcost ? 'error' : 'info' - const title = overcost ? t('QUOTA_OVERCOST_TIP') : t('Remaining Quota') - - const message = overcost - ? this.renderOverCostMessage(checkResult) - : this.renderQuotaMessage(checkResult) + const message = + overcost || limitUnset + ? this.renderOverCostMessage(checkResult) + : this.renderQuotaMessage(checkResult) return ( { namespaceQuota === Infinity ? undefined : `${namespaceQuota}${unit}`, workspaceQuota: workspaceQuota === Infinity ? undefined : `${workspaceQuota}${unit}`, - overcost: cost > workspaceQuota || cost > namespaceQuota, + overcost: + cost === Infinity + ? 'unset' + : cost > workspaceQuota || cost > namespaceQuota, } })