diff --git a/src/actions/openpitrix.js b/src/actions/openpitrix.js index 0941490d47c..4736dcbe7da 100644 --- a/src/actions/openpitrix.js +++ b/src/actions/openpitrix.js @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with KubeSphere Console. If not, see . */ - +import React from 'react' import { Modal, Notify } from 'components/Base' import RepoAppModal from 'projects/components/Modals/RepoApp' @@ -199,4 +199,33 @@ export default { }) }, }, + 'openpitrix.template.delete': { + on({ store, detail, versions, success, ...props }) { + const type = t('App Templates') + const resource = detail.name + let desc = t.html('DELETE_CONFIRM_TIP', { type, resource }) + if (versions.length) { + desc = ( + + {desc} + {t('DELETE_APP_TEMPLATE_TIP')} + + ) + } + const modal = Modal.open({ + onOk: async () => { + await store.delete(detail) + Modal.close(modal) + Notify.success({ content: `${t('Deleted Successfully')}!` }) + success && success() + }, + store, + desc, + type, + resource, + modal: DeleteModal, + ...props, + }) + }, + }, } diff --git a/src/locales/en/app.js b/src/locales/en/app.js index 83e6f6ee7a0..891b9444580 100644 --- a/src/locales/en/app.js +++ b/src/locales/en/app.js @@ -255,4 +255,7 @@ export default { HELM_APP_SCHEMA_FORM_TIP: 'The app configuration can be displayed in a form. You can modify the default app configuration through either the form or YAML editor. Note: app data stored in different patterns are independent of each other.', + + DELETE_APP_TEMPLATE_TIP: + 'Before deleting an application template, you need to delete all versions.', } diff --git a/src/locales/es/app.js b/src/locales/es/app.js index 45206cf5aab..32cc3eab7c3 100644 --- a/src/locales/es/app.js +++ b/src/locales/es/app.js @@ -263,4 +263,7 @@ export default { HELM_APP_SCHEMA_FORM_TIP: 'The app configuration can be displayed in a form. You can modify the default app configuration through either the form or YAML editor. Note: app data stored in different patterns are independent of each other.', + + DELETE_APP_TEMPLATE_TIP: + 'Before deleting an application template, you need to delete all versions.', } diff --git a/src/locales/tc/app.js b/src/locales/tc/app.js index 672aef489cb..e9c3ae809a2 100644 --- a/src/locales/tc/app.js +++ b/src/locales/tc/app.js @@ -223,4 +223,6 @@ export default { HELM_APP_SCHEMA_FORM_TIP: '此應用支持表單模式,可選擇通過表單或 YAML 編輯器來修改預設應用配置。注意:不同模式之間數據獨立。', + + DELETE_APP_TEMPLATE_TIP: '删除应用模板前,需要先删除所有版本。', } diff --git a/src/locales/zh/app.js b/src/locales/zh/app.js index cc1a6f86cef..251172308f1 100644 --- a/src/locales/zh/app.js +++ b/src/locales/zh/app.js @@ -222,4 +222,6 @@ export default { HELM_APP_SCHEMA_FORM_TIP: '此应用支持表单模式,可选择通过表单或 YAML 编辑器来修改默认应用配置。注意:不同模式之间数据独立。', + + DELETE_APP_TEMPLATE_TIP: '删除应用模板前,需要先删除所有版本。', } diff --git a/src/pages/workspaces/containers/Apps/Detail/index.jsx b/src/pages/workspaces/containers/Apps/Detail/index.jsx index 48ac0ee7610..dc92c02ea7f 100644 --- a/src/pages/workspaces/containers/Apps/Detail/index.jsx +++ b/src/pages/workspaces/containers/Apps/Detail/index.jsx @@ -131,10 +131,9 @@ export default class RoleDetail extends React.Component { text: t('Delete'), action: 'manage', onClick: () => - this.trigger('resource.delete', { - store: this.store, - type: t('App Templates'), + this.trigger('openpitrix.template.delete', { detail, + versions: this.versionStore.list.data, success: () => this.routing.push(this.listUrl), }), },