diff --git a/web/console/src/modules/cluster/components/resource/nodeManage/ComputerActionPanel.tsx b/web/console/src/modules/cluster/components/resource/nodeManage/ComputerActionPanel.tsx index 5b5f2ce59f..ebb4b5c4e3 100644 --- a/web/console/src/modules/cluster/components/resource/nodeManage/ComputerActionPanel.tsx +++ b/web/console/src/modules/cluster/components/resource/nodeManage/ComputerActionPanel.tsx @@ -75,7 +75,7 @@ export class ComputerActionPanel extends React.Component { item.metadata.role, `cpu: ${item?.status?.capacity?.cpu ?? '-'} 核; 内存: ${item?.status?.capacity?.memory ?? '-'}`, this._reduceIp(item), - item.spec.podCIDR, + item?.metadata?.annotations?.['tke.cloud.tencent.com/pod-cidrs'], dateFormatter(new Date(item.metadata.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') ]; rows.push(row); diff --git a/web/console/src/modules/cluster/components/resource/nodeManage/ComputerTablePanel.tsx b/web/console/src/modules/cluster/components/resource/nodeManage/ComputerTablePanel.tsx index 39b2026d98..e7329438a5 100644 --- a/web/console/src/modules/cluster/components/resource/nodeManage/ComputerTablePanel.tsx +++ b/web/console/src/modules/cluster/components/resource/nodeManage/ComputerTablePanel.tsx @@ -333,7 +333,11 @@ export class ComputerTablePanel extends React.Component { key: 'podCIDR', header: t('PodCIDR'), width: '12%', - render: x => {x.spec.podCIDR} + render: x => ( + <> + {x.metadata?.annotations?.['tke.cloud.tencent.com/pod-cidrs'] || '-'} + + ) }, { key: 'createTime', diff --git a/web/console/src/modules/cluster/components/resource/resourceDetail/ResourceNodeDetailPanel.tsx b/web/console/src/modules/cluster/components/resource/resourceDetail/ResourceNodeDetailPanel.tsx index c93d35356a..0016c7a989 100644 --- a/web/console/src/modules/cluster/components/resource/resourceDetail/ResourceNodeDetailPanel.tsx +++ b/web/console/src/modules/cluster/components/resource/resourceDetail/ResourceNodeDetailPanel.tsx @@ -107,7 +107,9 @@ export class ResourceNodeDetailPanel extends React.Component { {this._renderAllocatableResource(resourceIns.status.allocatable)} - {resourceIns.spec['podCIDR'] || '-'} + + {resourceIns.metadata?.annotations?.['tke.cloud.tencent.com/pod-cidrs'] || '-'} + diff --git a/web/console/tencent/paas-midleware/lib/index.js b/web/console/tencent/paas-midleware/lib/index.js index 8e81bed920..87e91fc06a 100644 --- a/web/console/tencent/paas-midleware/lib/index.js +++ b/web/console/tencent/paas-midleware/lib/index.js @@ -16,12 +16,15 @@ var reactRedux = require('react-redux'); var ffRedux = require('@tencent/ff-redux'); var ffComponent = require('@tencent/ff-component'); var InputPassword = require('@tencent/tea-component/lib/input/InputPassword'); +var Cookies = _interopDefault(require('js-cookie')); +var SparkMD5 = _interopDefault(require('spark-md5')); var axios = _interopDefault(require('axios')); var bridge = require('@tencent/tea-app/lib/bridge'); var jsBase64 = require('js-base64'); var redux = require('redux'); var reduxLogger = require('redux-logger'); var thunk = _interopDefault(require('redux-thunk')); +var ModalMain = require('@tencent/tea-component/lib/modal/ModalMain'); /** * @fileoverview @@ -33,7 +36,8 @@ var thunk = _interopDefault(require('redux-thunk')); /** * @type {import('@tencent/tea-app').I18NTranslation} */ -var translation = {// 使用 `tea scan` 命令扫描词条 +var translation = { + // 使用 `tea scan` 命令扫描词条 }; var zh = { translation: translation @@ -41,14 +45,13 @@ var zh = { var zh_1 = zh.translation; // 导入依赖 - +// 初始化国际化词条 teaApp.i18n.init({ translation: zh_1 }); var _a, _b; var ResourceTypeEnum; - (function (ResourceTypeEnum) { ResourceTypeEnum["ServiceBinding"] = "ServiceBinding"; ResourceTypeEnum["Backup"] = "ServiceOpsPlan"; @@ -57,7 +60,6 @@ var ResourceTypeEnum; ResourceTypeEnum["ServiceOpsBackup"] = "ServiceOpsBackup"; ResourceTypeEnum["Secret"] = "Secret"; })(ResourceTypeEnum || (ResourceTypeEnum = {})); - var ResourceTypeMap = (_a = {}, _a[ResourceTypeEnum.ServiceBinding] = { path: 'servicebindings', title: '服务绑定', @@ -97,14 +99,12 @@ var serviceMngTabs = [{ label: "规格管理" }]; var CreateSpecificOperatorEnum; - (function (CreateSpecificOperatorEnum) { CreateSpecificOperatorEnum["CreateResource"] = "CreateResource"; CreateSpecificOperatorEnum["BackupStrategy"] = "BackupStrategy"; CreateSpecificOperatorEnum["BackupNow"] = "BackupNow"; CreateSpecificOperatorEnum["CreateServiceBinding"] = "CreateServiceBinding"; })(CreateSpecificOperatorEnum || (CreateSpecificOperatorEnum = {})); - var CreateSpecificOperatorMap = (_b = {}, _b[CreateSpecificOperatorEnum.CreateResource] = { msg: i18n.t('新建资源成功') }, _b[CreateSpecificOperatorEnum.BackupStrategy] = { @@ -122,30 +122,25 @@ var SystemNamespace = 'ssm'; var showResourceDeleteLoading = function showResourceDeleteLoading(resource, originResources) { var loading = false; var resourceType = resource === null || resource === void 0 ? void 0 : resource.kind; - switch (resourceType) { case ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource: case ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceOpsBackup: case ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding: loading = originResources === null || originResources === void 0 ? void 0 : originResources.some(function (item) { var _a, _b, _c; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _b === void 0 ? void 0 : _b.name) && ((_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.deletionTimestamp); }); } - return loading; }; var ExcludeNamespaces = ['clusternet-system', 'ssm']; var _a$1, _b$1, _c, _d, _e, _f; var PlatformType; - (function (PlatformType) { PlatformType["TDCC"] = "tdcc"; PlatformType["TKESTACK"] = "tkeStack"; })(PlatformType || (PlatformType = {})); - var YunApiName = { DescribeServiceVendors: 'DescribeServiceVendors', DescribeServiceResources: 'DescribeServiceInstances', @@ -166,20 +161,15 @@ var middlewareRouteRegStr = (_e = {}, _e[PlatformType.TDCC] = { var rootNodeSelector = (_f = {}, _f[PlatformType.TDCC] = '#apaas-midleware', _f[PlatformType.TKESTACK] = '#apaas-midleware', _f); var requestResourceType; - (function (requestResourceType) { requestResourceType["MC"] = "MC"; })(requestResourceType || (requestResourceType = {})); - var ServiceDetailType; - (function (ServiceDetailType) { ServiceDetailType["ServiceClasses"] = "serviceclasses"; ServiceDetailType["ServiceBinding"] = "servicebinding"; })(ServiceDetailType || (ServiceDetailType = {})); - var ServiceNameType; - (function (ServiceNameType) { ServiceNameType["ETCD"] = "etcd"; ServiceNameType["MONGO"] = "mongo"; @@ -248,7 +238,6 @@ var isEmpty = function isEmpty(value) { * @LastEditors: brycewwang * @LastEditTime: 2022-06-14 22:27:26 */ - /* * Tencent is pleased to support the open source community by making TKEStack * available. @@ -266,7 +255,6 @@ var isEmpty = function isEmpty(value) { * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - /** * @returns 删除数据后的新数组,改变原数组 */ @@ -286,11 +274,9 @@ function parseQueryString(str) { if (str === void 0) { str = ''; } - var result = {}; str.replace(/^\?*/, '').split('&').forEach(function (item) { var keyVal = item.split('='); - if (keyVal.length > 0) { var key = decodeURIComponent(keyVal[0]); result[key] = keyVal[1] ? decodeURIComponent(keyVal[1]) : ''; @@ -302,14 +288,12 @@ function buildQueryString(obj) { if (obj === void 0) { obj = {}; } - var keys = remove(Object.keys(obj), function (value) { return value === ''; }); var queryStr = keys.map(function (key) { return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(obj[key])); }).join('&'); - if (queryStr) { return '?' + queryStr; } else { @@ -330,16 +314,13 @@ function buildQueryString(obj) { * } * @param options: K8sRestfulPathOptions */ - var reduceK8sQueryString = function reduceK8sQueryString(_a) { var _b; - var _c = _a.k8sQueryObj, - k8sQueryObj = _c === void 0 ? {} : _c, - _d = _a.restfulPath; + k8sQueryObj = _c === void 0 ? {} : _c, + _d = _a.restfulPath; var operator = '?'; var queryString = ''; - if (!isEmpty(k8sQueryObj)) { var queryKeys = (_b = Object.keys(k8sQueryObj)) === null || _b === void 0 ? void 0 : _b.filter(function (key) { return key === 'labelSelector'; @@ -347,23 +328,19 @@ var reduceK8sQueryString = function reduceK8sQueryString(_a) { queryKeys.forEach(function (queryKey, index) { if (index !== 0) { queryString += '&'; - } // 这里去判断每种资源的query,eg:fieldSelector、limit等 - - + } + // 这里去判断每种资源的query,eg:fieldSelector、limit等 var specificQuery = k8sQueryObj[queryKey]; - if (_typeof(specificQuery) === 'object') { // 这里是对于 query的字段里面,还有多种过滤条件,比如fieldSelector支持 involvedObject.name=*,involvedObject.kind=* var specificKeys = Object.keys(specificQuery), - specificString_1 = ''; + specificString_1 = ''; specificKeys.forEach(function (speKey, index) { if (index !== 0) { specificString_1 += ','; } - specificString_1 += speKey + '=' + specificQuery[speKey]; }); - if (specificString_1) { queryString += queryKey + '=' + specificString_1; } @@ -376,10 +353,9 @@ var reduceK8sQueryString = function reduceK8sQueryString(_a) { // if (restfulPath.includes('?')) { // operator = '&'; // } - - return queryString ? "".concat(operator).concat(queryString) : ''; -}; // interface K8sRestfulPathOptions { +}; +// interface K8sRestfulPathOptions { // /** 资源的配置 */ // // resourceInfo: ResourceInfo; // resourceInfo: any; @@ -481,19 +457,15 @@ var reduceK8sQueryString = function reduceK8sQueryString(_a) { // } var Cookie; - (function (Cookie) { Cookie.getCookie = function (name) { var _a, _b; - var result = ''; - if (document === null || document === void 0 ? void 0 : document.cookie) { (_b = (_a = document === null || document === void 0 ? void 0 : document.cookie) === null || _a === void 0 ? void 0 : _a.split(';')) === null || _b === void 0 ? void 0 : _b.forEach(function (item) { var _a = item === null || item === void 0 ? void 0 : item.split('='), - key = _a[0], - value = _a[1]; - + key = _a[0], + value = _a[1]; if ((key === null || key === void 0 ? void 0 : key.trim()) === (name === null || name === void 0 ? void 0 : name.trim())) { result = value === null || value === void 0 ? void 0 : value.trim(); } @@ -501,144 +473,136 @@ var Cookie; } else { result = ''; } - return result; }; })(Cookie || (Cookie = {})); var Util; - (function (Util) { Util.TkeStackDefaultClusterId = 'global'; - + Util.getCreator = function (platform, resource) { + var _a, _b, _c, _d, _e; + var name = ''; + if (platform === PlatformType.TDCC) { + name = ((_b = (_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/creator']) ? Util.getUserName(platform) : '-'; + } else { + name = (_e = (_d = (_c = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/creator']) !== null && _e !== void 0 ? _e : '-'; + } + return name; + }; Util.getUserName = function (platform) { var _a, _b, _c; - var name = ''; - if (document.cookie) { if (platform === PlatformType.TDCC) { try { - name = (_c = (_b = (_a = Cookie === null || Cookie === void 0 ? void 0 : Cookie.getCookie('nick')) === null || _a === void 0 ? void 0 : _a.split('@')) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.toString(); + name = (_c = (_b = (_a = decodeURIComponent(Cookie === null || Cookie === void 0 ? void 0 : Cookie.getCookie('nick'))) === null || _a === void 0 ? void 0 : _a.split('@')) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.toString(); } catch (error) { name = ''; } } } - return name; }; - + /** + * 查询云上平台uin + * @param platform + * @returns + */ + Util.getUin = function () { + var _a, _b; + var result = ''; + if (document.cookie) { + try { + result = (_b = (_a = decodeURIComponent(Cookie === null || Cookie === void 0 ? void 0 : Cookie.getCookie('uin'))) === null || _a === void 0 ? void 0 : _a.slice(1)) === null || _b === void 0 ? void 0 : _b.toString(); + } catch (error) { + result = ''; + } + } + return result; + }; Util.getReadableFileSizeString = function (fileSizeInBytes) { if (fileSizeInBytes === undefined) { return '-'; } - var i = -1; var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']; var size = fileSizeInBytes; - do { size = size / 1024; i = i + 1; } while (size > 1024); - return Math.max(size, 0.1).toFixed(1) + byteUnits[i]; }; - Util.getCOSClusterId = function (platform, hubCluster, cluster) { var clusterId = ''; - switch (platform) { case PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TKESTACK: clusterId = (cluster === null || cluster === void 0 ? void 0 : cluster.clusterId) || Util.TkeStackDefaultClusterId; break; - case PlatformType.TDCC: default: clusterId = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.clusterId; break; } - return clusterId; }; - Util.getDefaultRegion = function (platform, route) { var _a, _b; - var regionId; - switch (platform) { case PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TKESTACK: regionId = (_b = +((_a = route === null || route === void 0 ? void 0 : route.queries) === null || _a === void 0 ? void 0 : _a.rid)) !== null && _b !== void 0 ? _b : HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion; break; - case PlatformType.TDCC: default: regionId = HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion; break; } - return regionId; }; - Util.getClusterId = function (platform, resource, route) { var _a, _b, _c, _d, _e; - var clusterId; - switch (platform) { case PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TKESTACK: // clusterId = resource?.metadata?.labels?.['tdcc.cloud.tencent.com/cluster-id'] || resource?.metadata?.labels?.['ssm.infra.tce.io/cluster-id'] || route?.queries?.clusterid || TkeStackDefaultClusterId || '-'; clusterId = Util.TkeStackDefaultClusterId || '-'; break; - case PlatformType.TDCC: default: clusterId = ((_b = (_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['tdcc.cloud.tencent.com/cluster-id']) || ((_d = (_c = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/cluster-id']) || ((_e = route === null || route === void 0 ? void 0 : route.queries) === null || _e === void 0 ? void 0 : _e.clusterid) || '-'; break; } - return clusterId; }; - Util.getClusterName = function (platform, resource, route) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - var clusterName; - switch (platform) { case PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TKESTACK: clusterName = ((_b = (_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['tdcc.cloud.tencent.com/cluster-name']) || ((_d = (_c = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/cluster-name']) || ((_e = route === null || route === void 0 ? void 0 : route.queries) === null || _e === void 0 ? void 0 : _e.clusterid) || '-'; break; - case PlatformType.TDCC: default: clusterName = ((_g = (_f = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _f === void 0 ? void 0 : _f.labels) === null || _g === void 0 ? void 0 : _g['tdcc.cloud.tencent.com/cluster-name']) || ((_j = (_h = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _h === void 0 ? void 0 : _h.labels) === null || _j === void 0 ? void 0 : _j['ssm.infra.tce.io/cluster-name']) || ((_k = route === null || route === void 0 ? void 0 : route.queries) === null || _k === void 0 ? void 0 : _k.clusterid) || '-'; break; } - return clusterName; }; - Util.getInstanceId = function (platform, instanceName, serviceResource) { var _a, _b; - var result = !instanceName ? ((_a = serviceResource === null || serviceResource === void 0 ? void 0 : serviceResource.spec) === null || _a === void 0 ? void 0 : _a.externalID) ? (_b = serviceResource === null || serviceResource === void 0 ? void 0 : serviceResource.spec) === null || _b === void 0 ? void 0 : _b.externalID : '' : DefaultNamespace + '-' + instanceName; return result; }; - Util.getRouterPath = function (pathname) { var _a; - var path; - if (pathname === null || pathname === void 0 ? void 0 : pathname.includes((_a = PlatformType.TKESTACK) === null || _a === void 0 ? void 0 : _a.toLowerCase())) { path = "/tkestack/middleware"; } else { path = "/tdcc/middleware"; } - return path; }; })(Util || (Util = {})); @@ -649,7 +613,6 @@ function downloadText(crtText, filename, contentType) { contentType = 'text/plain;charset=utf-8;'; } var userAgent = navigator.userAgent; - if (navigator === null || navigator === void 0 ? void 0 : navigator['msSaveBlob']) { var blob = new Blob([crtText], { type: contentType @@ -662,7 +625,6 @@ function downloadText(crtText, filename, contentType) { type: contentType }); var link = document.createElement('a'); - if (link.download !== undefined) { var url = URL.createObjectURL(blob); link.setAttribute('href', url); @@ -678,7 +640,6 @@ function downloadKubeconfig(crtText, filename) { if (filename === void 0) { filename = 'kubeconfig'; } - downloadText(crtText, filename, 'applicatoin/octet-stream;charset=utf-8;'); } @@ -686,9 +647,7 @@ var _a$2, _b$2, _c$1, _d$1, _e$1, _f$1; /** * 类型 */ - var SchemaType; - (function (SchemaType) { SchemaType["Integer"] = "Integer"; SchemaType["String"] = "String"; @@ -699,23 +658,18 @@ var SchemaType; SchemaType["List"] = "List"; SchemaType["Map"] = "Map"; })(SchemaType || (SchemaType = {})); - var DashboardStatusEnum; - (function (DashboardStatusEnum) { DashboardStatusEnum["Creating"] = "Creating"; DashboardStatusEnum["Created"] = "Created"; DashboardStatusEnum["Ready"] = "Ready"; DashboardStatusEnum["Failed"] = "Failed"; })(DashboardStatusEnum || (DashboardStatusEnum = {})); - var SupportedOperationsEnum; - (function (SupportedOperationsEnum) { SupportedOperationsEnum["Backup"] = "Backup"; SupportedOperationsEnum["Restore"] = "Restore"; })(SupportedOperationsEnum || (SupportedOperationsEnum = {})); - var DashboardStatusMap = (_a$2 = {}, _a$2[DashboardStatusEnum.Created] = { text: 'Creating', className: 'text-warning' @@ -728,38 +682,30 @@ var DashboardStatusMap = (_a$2 = {}, _a$2[DashboardStatusEnum.Created] = { }, _a$2[DashboardStatusEnum.Failed] = { text: i18n.t('Failed'), className: 'text-danger' -}, _a$2); //查询RSIP信息 - +}, _a$2); +//查询RSIP信息 var getRsIps = function getRsIps(NodeInfo) { if (!NodeInfo) { return []; } - var mode = NodeInfo.mode, - nodes = NodeInfo.nodes; - + nodes = NodeInfo.nodes; switch (mode) { case 'VM': return nodes === null || nodes === void 0 ? void 0 : nodes.map(function (x) { var _a, _b; - return "".concat(x === null || x === void 0 ? void 0 : x.hostNode.host, ":").concat((_b = (_a = x === null || x === void 0 ? void 0 : x.ports) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : ''); }); - case 'Physical': return nodes === null || nodes === void 0 ? void 0 : nodes.map(function (x) { var _a, _b; - return "".concat(x === null || x === void 0 ? void 0 : x.hostNode.host, ":").concat((_b = (_a = x === null || x === void 0 ? void 0 : x.ports) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : ''); }); - case 'Container': return nodes === null || nodes === void 0 ? void 0 : nodes.map(function (x) { var _a, _b; - return "".concat(x === null || x === void 0 ? void 0 : x.containerNode.host, ":").concat((_b = (_a = x === null || x === void 0 ? void 0 : x.ports) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : ''); }); - default: return []; } @@ -768,7 +714,6 @@ var initServiceInstanceEdit = function initServiceInstanceEdit(data) { return { formData: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a, _b; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = getFormItemDefaultValue(cur), _a.unitMap = tslib.__assign(tslib.__assign({}, pre === null || pre === void 0 ? void 0 : pre.unitMap), (_b = {}, _b[cur === null || cur === void 0 ? void 0 : cur.name] = cur === null || cur === void 0 ? void 0 : cur.unit, _b)), _a)); }, { instanceName: '', @@ -778,7 +723,6 @@ var initServiceInstanceEdit = function initServiceInstanceEdit(data) { }), validator: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = { status: 1, message: '' @@ -800,29 +744,25 @@ var initServiceInstanceEdit = function initServiceInstanceEdit(data) { }; }; var InstanceMustPropMap; - (function (InstanceMustPropMap) { InstanceMustPropMap["InstanceName"] = "instanceName"; InstanceMustPropMap["ClusterId"] = "clusterId"; InstanceMustPropMap["Version"] = "version"; InstanceMustPropMap["Plan"] = "plan"; })(InstanceMustPropMap || (InstanceMustPropMap = {})); - -var NumberAndSymbolReg = /^[a-z][0-9a-z-]{1,62}$/; // 校验的相关配置 - +var NumberAndSymbolReg = /^[a-z][0-9a-z-]{1,62}$/; +// 校验的相关配置 var InstanceBaseValidateSchema = (_b$2 = {}, _b$2[InstanceMustPropMap === null || InstanceMustPropMap === void 0 ? void 0 : InstanceMustPropMap.InstanceName] = { rules: [{ type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var instanceName = (store === null || store === void 0 ? void 0 : store.formData).instanceName; - if (!instanceName || !NumberAndSymbolReg.test(instanceName)) { return { status: ffValidator.ValidatorStatusEnum.Failed, message: i18n.t('名称为2-63个字符,可包含数字、小写英文字以及短划线(-),且不能以短划线(-)开头') }; } - return { status: 1, message: '' @@ -834,14 +774,12 @@ var InstanceBaseValidateSchema = (_b$2 = {}, _b$2[InstanceMustPropMap === null | type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var clusterId = (store === null || store === void 0 ? void 0 : store.formData).clusterId; - if (!clusterId) { return { status: ffValidator.ValidatorStatusEnum.Failed, - message: i18n.t('目标集群不能为空') + message: i18n.t('必须选择目标集群') }; } - return { status: 1, message: '' @@ -853,14 +791,12 @@ var InstanceBaseValidateSchema = (_b$2 = {}, _b$2[InstanceMustPropMap === null | type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var version = (store === null || store === void 0 ? void 0 : store.formData).version; - if (!version) { return { status: ffValidator.ValidatorStatusEnum.Failed, message: i18n.t('版本不能为空') }; } - return { status: 1, message: '' @@ -872,14 +808,12 @@ var InstanceBaseValidateSchema = (_b$2 = {}, _b$2[InstanceMustPropMap === null | type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var plan = (store === null || store === void 0 ? void 0 : store.formData).plan; - if (!plan) { return { status: ffValidator.ValidatorStatusEnum.Failed, message: i18n.t('规格不能为空') }; } - return { status: 1, message: '' @@ -897,23 +831,18 @@ var isInSchemaProps = function isInSchemaProps(key, data) { }; var validateAllProps = function validateAllProps(serviceInstanceEdit, instanceSchemas) { var _a; - var vm; var formData = serviceInstanceEdit.formData; (_a = Object.keys(formData)) === null || _a === void 0 ? void 0 : _a.forEach(function (key) { var _a; - var _b, _c, _d, _e, _f, _g, _h, _j, _k; - var validator; - if (isRequireBaseProps(key)) { validator = (_d = (_c = (_b = InstanceBaseValidateSchema === null || InstanceBaseValidateSchema === void 0 ? void 0 : InstanceBaseValidateSchema[key]) === null || _b === void 0 ? void 0 : _b.rules) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.customFunc(formData[key], serviceInstanceEdit); } else if (isInSchemaProps(key, instanceSchemas)) { var schema = instanceSchemas === null || instanceSchemas === void 0 ? void 0 : instanceSchemas.find(function (item) { return (item === null || item === void 0 ? void 0 : item.name) === key; }); - if ((_e = serviceInstanceEdit === null || serviceInstanceEdit === void 0 ? void 0 : serviceInstanceEdit.formData) === null || _e === void 0 ? void 0 : _e.isSetParams) { validator = validatePlanSchema(schema, formData[key] + ((_f = formData === null || formData === void 0 ? void 0 : formData['unitMap']) === null || _f === void 0 ? void 0 : _f[key]), OperatorNumberUnitReg, formData); } else { @@ -952,7 +881,6 @@ var validateAllProps = function validateAllProps(serviceInstanceEdit, instanceSc message: '' }; } - vm = tslib.__assign(tslib.__assign({}, vm), (_a = {}, _a[key] = validator, _a)); }); return vm; @@ -961,19 +889,16 @@ var _validateInstance = function _validateInstance(data, instanceSchemas) { var validator = validateAllProps(data, instanceSchemas); return Object.keys(validator).every(function (key) { var _a; - return ((_a = validator === null || validator === void 0 ? void 0 : validator[key]) === null || _a === void 0 ? void 0 : _a.status) === ffValidator.ValidatorStatusEnum.Success; }); }; var ServiceInstanceStatusEnum; - (function (ServiceInstanceStatusEnum) { ServiceInstanceStatusEnum["InProgress"] = "InProgress"; ServiceInstanceStatusEnum["Ready"] = "Ready"; ServiceInstanceStatusEnum["Failed"] = "Failed"; ServiceInstanceStatusEnum["Unknown"] = "Unknown"; })(ServiceInstanceStatusEnum || (ServiceInstanceStatusEnum = {})); - var ServiceInstanceMap = (_c$1 = {}, _c$1[ServiceInstanceStatusEnum.InProgress] = { text: i18n.t('创建中'), className: 'text-warning' @@ -988,28 +913,25 @@ var ServiceInstanceMap = (_c$1 = {}, _c$1[ServiceInstanceStatusEnum.InProgress] className: 'text-weak' }, _c$1); var ServicePlanTypeEnum; - (function (ServicePlanTypeEnum) { ServicePlanTypeEnum["System"] = "System"; ServicePlanTypeEnum["Custom"] = "Custom"; })(ServicePlanTypeEnum || (ServicePlanTypeEnum = {})); - var ServicePlanTypeMap = (_d$1 = {}, _d$1[ServicePlanTypeEnum.System] = { text: i18n.t('预设'), className: 'text-success' }, _d$1[ServicePlanTypeEnum.Custom] = { text: i18n.t('自定义'), className: 'text-warning' -}, _d$1); // export const getAuthorName = (platform:string) => { +}, _d$1); +// export const getAuthorName = (platform:string) => { // if(platform === PlatformType?.TDCC){ // return localStorage?.getItem // }else{ // } // } // schema相关 start - var FormItemType; - (function (FormItemType) { FormItemType["Select"] = "select"; FormItemType["Input"] = "input"; @@ -1018,12 +940,9 @@ var FormItemType; FormItemType["InputNumber"] = "inputNumber"; FormItemType["MapField"] = "MapField"; })(FormItemType || (FormItemType = {})); - var getFormItemType = function getFormItemType(item) { var _a; - var type; - if ((_a = item === null || item === void 0 ? void 0 : item.candidates) === null || _a === void 0 ? void 0 : _a.length) { type = FormItemType.Select; } else if ((item === null || item === void 0 ? void 0 : item.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Boolean)) { @@ -1035,12 +954,10 @@ var getFormItemType = function getFormItemType(item) { } else { type = FormItemType.Input; } - return type; }; var getFormItemDefaultValue = function getFormItemDefaultValue(item) { var value = ''; - if (item === null || item === void 0 ? void 0 : item.value) { if ((item === null || item === void 0 ? void 0 : item.type) === 'Boolean') { value = (item === null || item === void 0 ? void 0 : item.value) === 'true'; @@ -1058,17 +975,14 @@ var getFormItemDefaultValue = function getFormItemDefaultValue(item) { value = ''; } } - return value; }; var prefixForSchema = function prefixForSchema(item, serviceName) { var _a; - return serviceName && ((_a = ['size']) === null || _a === void 0 ? void 0 : _a.includes(item === null || item === void 0 ? void 0 : item.name)) ? "".concat(serviceName) : i18n.t(''); }; var hideSchema = function hideSchema(item) { var _a, _b, _c, _d; - return ((_a = ['dashboardEnabled']) === null || _a === void 0 ? void 0 : _a.includes(item === null || item === void 0 ? void 0 : item.name)) || ((_b = ['spread']) === null || _b === void 0 ? void 0 : _b.includes(item === null || item === void 0 ? void 0 : item.name)) && ((_c = item === null || item === void 0 ? void 0 : item.candidates) === null || _c === void 0 ? void 0 : _c.length) === 1 && ((_d = item === null || item === void 0 ? void 0 : item.candidates) === null || _d === void 0 ? void 0 : _d[0]) === 'zone'; }; var SchemaInputNumOption = { @@ -1149,7 +1063,6 @@ var storageUnitMapping = { var DefaultUnitMap = (_e$1 = {}, _e$1[SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU] = cpuUnitMapping === null || cpuUnitMapping === void 0 ? void 0 : cpuUnitMapping.defaultValue, _e$1[SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage] = storageUnitMapping === null || storageUnitMapping === void 0 ? void 0 : storageUnitMapping.defaultValue, _e$1); var suffixUnitForSchema = function suffixUnitForSchema(item) { var _a; - var unit = ''; return i18n.t('{{unit}}', { unit: ((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.includes(i18n.t('(核)'))) ? i18n.t('') : unit @@ -1158,14 +1071,11 @@ var suffixUnitForSchema = function suffixUnitForSchema(item) { var UnitMappingList = (_f$1 = {}, _f$1[SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU] = cpuUnitMapping, _f$1[SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage] = storageUnitMapping, _f$1); var getFormattedValue = function getFormattedValue(_a) { var _b, _c, _d, _e; - var value = _a.value, - unit = _a.unit, - field = _a.field; - + unit = _a.unit, + field = _a.field; if (((_b = [SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU]) === null || _b === void 0 ? void 0 : _b.includes(field === null || field === void 0 ? void 0 : field.type)) || ((_c = ['cpu']) === null || _c === void 0 ? void 0 : _c.some(function (item) { var _a, _b; - return (_b = (_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(item); }))) { return ['m', 'mi'].some(function (x) { @@ -1173,7 +1083,6 @@ var getFormattedValue = function getFormattedValue(_a) { }) ? Number(value) : Number(value) * 1000; } else if (((_d = [SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage]) === null || _d === void 0 ? void 0 : _d.includes(field === null || field === void 0 ? void 0 : field.type)) || ((_e = ['memory', 'storage']) === null || _e === void 0 ? void 0 : _e.some(function (item) { var _a, _b; - return (_b = (_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(item); }))) { return ['m', 'mi'].some(function (x) { @@ -1185,17 +1094,14 @@ var getFormattedValue = function getFormattedValue(_a) { }; var validateFormItemEmpty = function validateFormItemEmpty(field, values) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; - var validator; - var fieldValue = values === null || values === void 0 ? void 0 : values[field === null || field === void 0 ? void 0 : field.name]; // 依赖项未启用,校验直接通过 - + var fieldValue = values === null || values === void 0 ? void 0 : values[field === null || field === void 0 ? void 0 : field.name]; + // 依赖项未启用,校验直接通过 if (field.enabledCondition && values) { var _w = field === null || field === void 0 ? void 0 : field.enabledCondition.split('=='), - conditionKey = _w[0], - conditionValue = _w[1]; - + conditionKey = _w[0], + conditionValue = _w[1]; var value = values[conditionKey]; - if (String(value) !== String(conditionValue)) { return { status: ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Success, @@ -1203,7 +1109,6 @@ var validateFormItemEmpty = function validateFormItemEmpty(field, values) { }; } } - if (!field.optional && (field === null || field === void 0 ? void 0 : field.type) !== (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Boolean)) { validator = { status: isEmpty(fieldValue) || ([SchemaType.Integer, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage].includes(field === null || field === void 0 ? void 0 : field.type) || ((_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.includes((_b = SchemaType.Storage) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase())) || ((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.includes((_d = SchemaType.CPU) === null || _d === void 0 ? void 0 : _d.toLocaleLowerCase())) || ((_e = field === null || field === void 0 ? void 0 : field.name) === null || _e === void 0 ? void 0 : _e.includes('memory'))) && +fieldValue < 0 ? ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Failed : ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Success, @@ -1215,14 +1120,11 @@ var validateFormItemEmpty = function validateFormItemEmpty(field, values) { message: ([SchemaType.Integer, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage].includes(field === null || field === void 0 ? void 0 : field.type) || ((_r = field === null || field === void 0 ? void 0 : field.name) === null || _r === void 0 ? void 0 : _r.includes((_s = SchemaType.Storage) === null || _s === void 0 ? void 0 : _s.toLocaleLowerCase())) || ((_t = field === null || field === void 0 ? void 0 : field.name) === null || _t === void 0 ? void 0 : _t.includes((_u = SchemaType.CPU) === null || _u === void 0 ? void 0 : _u.toLocaleLowerCase())) || ((_v = field === null || field === void 0 ? void 0 : field.name) === null || _v === void 0 ? void 0 : _v.includes('memory'))) && +fieldValue < 0 ? getFormItemEmptyMsg(field) : i18n.t('') }; } - return validator; }; var getFormItemEmptyMsg = function getFormItemEmptyMsg(field) { var _a, _b, _c, _d, _e; - var msg = ''; - if ([SchemaType.Integer, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage].includes(field === null || field === void 0 ? void 0 : field.type) || ((_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.includes((_b = SchemaType.Storage) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase())) || ((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.includes((_d = SchemaType.CPU) === null || _d === void 0 ? void 0 : _d.toLocaleLowerCase())) || ((_e = field === null || field === void 0 ? void 0 : field.name) === null || _e === void 0 ? void 0 : _e.includes('memory'))) { msg = "".concat(field === null || field === void 0 ? void 0 : field.label, "\u9700\u8981\u662F\u5927\u4E8E\u7B49\u4E8E0\u7684\u6570\u5B57"); } else if ((field === null || field === void 0 ? void 0 : field.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Boolean)) { @@ -1230,42 +1132,34 @@ var getFormItemEmptyMsg = function getFormItemEmptyMsg(field) { } else { msg = "".concat(field === null || field === void 0 ? void 0 : field.label, "\u4E0D\u80FD\u4E3A\u7A7A"); } - return i18n.t('{{msg}}', { msg: msg }); }; var validatePlanSchema = function validatePlanSchema(field, fieldValue, validator, values, serviceName, instance) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; - if (validator === void 0) { validator = OperatorNumberUnitReg; - } // 优先进行空校验 - - + } + // 优先进行空校验 var emptyValidator = validateFormItemEmpty(field, values); - if ((emptyValidator === null || emptyValidator === void 0 ? void 0 : emptyValidator.status) === (ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Failed)) { return emptyValidator; - } // 依赖项未启用,校验直接通过 - - + } + // 依赖项未启用,校验直接通过 if (field.enabledCondition && values) { var _p = field === null || field === void 0 ? void 0 : field.enabledCondition.split('=='), - conditionKey = _p[0], - conditionValue = _p[1]; - + conditionKey = _p[0], + conditionValue = _p[1]; var value_1 = values[conditionKey]; - if (String(value_1) !== String(conditionValue)) { return { status: ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Success, message: i18n.t('') }; } - } //校验rabbitmq的实例服务用户名不能和实例的管理用户相同 - - + } + //校验rabbitmq的实例服务用户名不能和实例的管理用户相同 if (serviceName === 'rabbitmq' && instance && (field === null || field === void 0 ? void 0 : field.name) === 'user' && ((_b = (_a = instance === null || instance === void 0 ? void 0 : instance.spec) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b.adminUser) === fieldValue) { return { status: ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Failed, @@ -1274,7 +1168,6 @@ var validatePlanSchema = function validatePlanSchema(field, fieldValue, validato }) }; } - if ([SchemaType.Integer, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.CPU, SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Storage].includes(field === null || field === void 0 ? void 0 : field.type) || ((_e = field === null || field === void 0 ? void 0 : field.name) === null || _e === void 0 ? void 0 : _e.includes((_f = SchemaType.Storage) === null || _f === void 0 ? void 0 : _f.toLocaleLowerCase())) || ((_g = field === null || field === void 0 ? void 0 : field.name) === null || _g === void 0 ? void 0 : _g.includes((_h = SchemaType.CPU) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase())) || ((_j = field === null || field === void 0 ? void 0 : field.name) === null || _j === void 0 ? void 0 : _j.includes('memory'))) { if (isEmpty(values[field === null || field === void 0 ? void 0 : field.name]) || isNaN(Number(values[field === null || field === void 0 ? void 0 : field.name])) || Number(values[field === null || field === void 0 ? void 0 : field.name]) < 0) { return { @@ -1285,30 +1178,24 @@ var validatePlanSchema = function validatePlanSchema(field, fieldValue, validato }; } } - var unitMapping = (_k = UnitMappingList === null || UnitMappingList === void 0 ? void 0 : UnitMappingList[field === null || field === void 0 ? void 0 : field.type]) !== null && _k !== void 0 ? _k : { defaultValue: '' }; - var _q = (_l = NumberUnitReg === null || NumberUnitReg === void 0 ? void 0 : NumberUnitReg.exec(fieldValue)) !== null && _l !== void 0 ? _l : ['', ''], - value = _q[1], - valueUnit = _q[2]; - + value = _q[1], + valueUnit = _q[2]; var isOr = (_m = field === null || field === void 0 ? void 0 : field.validator) === null || _m === void 0 ? void 0 : _m.includes('|'); var validations = isOr ? field === null || field === void 0 ? void 0 : field.validator.split('|') : (_o = field === null || field === void 0 ? void 0 : field.validator) === null || _o === void 0 ? void 0 : _o.split('&'); var errorMsgs = []; var inValids = validations === null || validations === void 0 ? void 0 : validations.map(function (validation) { var _a; - var fromValidation = validator === null || validator === void 0 ? void 0 : validator.exec(validation === null || validation === void 0 ? void 0 : validation.trim()); - if (!fromValidation) { return true; } - var operator = fromValidation[1], - number = fromValidation[2], - unit = fromValidation[3]; + number = fromValidation[2], + unit = fromValidation[3]; var formattedValue = getFormattedValue({ value: value, unit: valueUnit, @@ -1341,7 +1228,6 @@ var validatePlanSchema = function validatePlanSchema(field, fieldValue, validato }; var formatPlanSchemaData = function formatPlanSchemaData(key, value) { var result = ''; - if ((key === null || key === void 0 ? void 0 : key.toLowerCase()) === 'cpu') { result = value === null || value === void 0 ? void 0 : value.replace(/m$|mi$/, ''); } else if (['memory', 'storage'].includes(key === null || key === void 0 ? void 0 : key.toLowerCase())) { @@ -1349,14 +1235,11 @@ var formatPlanSchemaData = function formatPlanSchemaData(key, value) { } else { result = value; } - return result; }; var showUnitOptions = function showUnitOptions(field) { var _a, _b, _c, _d, _e, _f, _g; - var result = false; - if (((_a = field === null || field === void 0 ? void 0 : field.type) === null || _a === void 0 ? void 0 : _a.includes(SchemaType.CPU)) || ((_b = field === null || field === void 0 ? void 0 : field.name) === null || _b === void 0 ? void 0 : _b.includes((_c = SchemaType.CPU) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()))) { result = true; } else if (((_d = field === null || field === void 0 ? void 0 : field.type) === null || _d === void 0 ? void 0 : _d.includes(SchemaType.Storage)) || ((_e = field === null || field === void 0 ? void 0 : field.name) === null || _e === void 0 ? void 0 : _e.includes((_f = SchemaType.Storage) === null || _f === void 0 ? void 0 : _f.toLocaleLowerCase())) || ((_g = field === null || field === void 0 ? void 0 : field.name) === null || _g === void 0 ? void 0 : _g.includes('memory'))) { @@ -1364,18 +1247,14 @@ var showUnitOptions = function showUnitOptions(field) { } else { result = false; } - return result; }; var formatPlanSchemaUnit = function formatPlanSchemaUnit(field, filedValue) { var _a, _b, _c, _d, _e, _f, _g, _h, _j; - var result = ''; - var _k = (_a = NumberUnitReg === null || NumberUnitReg === void 0 ? void 0 : NumberUnitReg.exec(filedValue)) !== null && _a !== void 0 ? _a : ['', ''], - value = _k[1], - valueUnit = _k[2]; - + value = _k[1], + valueUnit = _k[2]; if (((_b = field === null || field === void 0 ? void 0 : field.type) === null || _b === void 0 ? void 0 : _b.includes(SchemaType.CPU)) || ((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.includes((_d = SchemaType.CPU) === null || _d === void 0 ? void 0 : _d.toLocaleLowerCase()))) { result = valueUnit || cpuUnitKeyMap.C; } else if (((_e = field === null || field === void 0 ? void 0 : field.type) === null || _e === void 0 ? void 0 : _e.includes(SchemaType.Storage)) || ((_f = field === null || field === void 0 ? void 0 : field.name) === null || _f === void 0 ? void 0 : _f.includes((_g = SchemaType.Storage) === null || _g === void 0 ? void 0 : _g.toLocaleLowerCase())) || ((_h = field === null || field === void 0 ? void 0 : field.name) === null || _h === void 0 ? void 0 : _h.includes('memory'))) { @@ -1383,29 +1262,50 @@ var formatPlanSchemaUnit = function formatPlanSchemaUnit(field, filedValue) { } else { result = ''; } - return result; }; var formatPlanSchemaSubmitData = function formatPlanSchemaSubmitData(field, filedValue, fieldUnit) { + var _a; var result; - if ((field === null || field === void 0 ? void 0 : field.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Integer)) { result = parseInt(filedValue); } else if ((field === null || field === void 0 ? void 0 : field.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Boolean)) { result = filedValue; } else if ((field === null || field === void 0 ? void 0 : field.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.List)) { result = filedValue === null || filedValue === void 0 ? void 0 : filedValue.split(','); + } else if ((field === null || field === void 0 ? void 0 : field.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.Map)) { + try { + var valueMap_1 = JSON.parse(filedValue); + var newValueMap = (_a = Object.keys(valueMap_1)) === null || _a === void 0 ? void 0 : _a.reduce(function (pre, cur) { + var _a; + var value; + // 当前字符值的内容是数字,将内容格式为数字类型 + if (!isNaN(parseInt(valueMap_1 === null || valueMap_1 === void 0 ? void 0 : valueMap_1[cur]))) { + value = parseInt(valueMap_1 === null || valueMap_1 === void 0 ? void 0 : valueMap_1[cur]); + } else if ((valueMap_1 === null || valueMap_1 === void 0 ? void 0 : valueMap_1[cur]) === 'true') { + // 当前字符值的内容是'true',将内容格式为布尔类型 + value = true; + } else if ((valueMap_1 === null || valueMap_1 === void 0 ? void 0 : valueMap_1[cur]) === 'false') { + // 当前字符值的内容是 'false',将内容格式为布尔类型 + value = false; + } else { + // 以上条件均不满足,则不进行格式话处理 + value = valueMap_1 === null || valueMap_1 === void 0 ? void 0 : valueMap_1[cur]; + } + return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur] = value, _a)); + }, {}); + result = newValueMap; + } catch (error) { + result = ''; + } } else { result = filedValue + (fieldUnit !== null && fieldUnit !== void 0 ? fieldUnit : ''); } - return result; }; var getUnitOptions = function getUnitOptions(field) { var _a, _b, _c, _d, _e, _f, _g; - var result = []; - if (((_a = field === null || field === void 0 ? void 0 : field.type) === null || _a === void 0 ? void 0 : _a.includes(SchemaType.CPU)) || ((_b = field === null || field === void 0 ? void 0 : field.name) === null || _b === void 0 ? void 0 : _b.includes((_c = SchemaType.CPU) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()))) { result = unitOptions.CPU; } else if (((_d = field === null || field === void 0 ? void 0 : field.type) === null || _d === void 0 ? void 0 : _d.includes(SchemaType.Storage)) || ((_e = field === null || field === void 0 ? void 0 : field.name) === null || _e === void 0 ? void 0 : _e.includes((_f = SchemaType.Storage) === null || _f === void 0 ? void 0 : _f.toLocaleLowerCase())) || ((_g = field === null || field === void 0 ? void 0 : field.name) === null || _g === void 0 ? void 0 : _g.includes('memory'))) { @@ -1413,33 +1313,45 @@ var getUnitOptions = function getUnitOptions(field) { } else { result = []; } - return result; }; +var formatPlanSchemaValue = function formatPlanSchemaValue(value) { + var newValue = ''; + if (!value) { + newValue = ''; + } else if (!isNaN(parseInt(value))) { + newValue = parseInt(value); + } else if (value === 'true') { + newValue = true; + } else if (value === 'false') { + newValue = false; + } else if (_typeof(value) === 'object') { + newValue = JSON.stringify(value); + } else { + newValue = value; + } + return newValue; +}; var NotSupportBindingSchemaVendors = ['etcd', 'zookeeper']; var _a$3; var PlanMustPropMap; - (function (PlanMustPropMap) { PlanMustPropMap["InstanceName"] = "instanceName"; PlanMustPropMap["ClusterId"] = "clusterId"; -})(PlanMustPropMap || (PlanMustPropMap = {})); // 校验的相关配置 - - +})(PlanMustPropMap || (PlanMustPropMap = {})); +// 校验的相关配置 var PlanBaseValidateSchema = (_a$3 = {}, _a$3[PlanMustPropMap === null || PlanMustPropMap === void 0 ? void 0 : PlanMustPropMap.InstanceName] = { rules: [{ type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var instanceName = (store === null || store === void 0 ? void 0 : store.formData).instanceName; - if (!instanceName || !NumberAndSymbolReg.test(instanceName)) { return { status: ffValidator.ValidatorStatusEnum.Failed, message: i18n.t('名称为2-63个字符,可包含数字、小写英文字以及短划线(-),且不能以短划线(-)开头') }; } - return { status: 1, message: '' @@ -1451,14 +1363,12 @@ var PlanBaseValidateSchema = (_a$3 = {}, _a$3[PlanMustPropMap === null || PlanMu type: ffValidator.RuleTypeEnum.custom, customFunc: function customFunc(value, store) { var clusterId = (store === null || store === void 0 ? void 0 : store.formData).clusterId; - if (!clusterId) { return { status: ffValidator.ValidatorStatusEnum.Failed, message: i18n.t('目标集群不能为空') }; } - return { status: 1, message: '' @@ -1471,16 +1381,12 @@ var isPlanRequireBaseProps = function isPlanRequireBaseProps(key) { }; var validateAllPlanProps = function validateAllPlanProps(edit, instanceSchemas) { var _a; - var vm; var formData = edit.formData; (_a = Object.keys(formData)) === null || _a === void 0 ? void 0 : _a.forEach(function (key) { var _a; - var _b, _c, _d, _e; - var validator; - if (isPlanRequireBaseProps(key)) { validator = (_d = (_c = (_b = PlanBaseValidateSchema === null || PlanBaseValidateSchema === void 0 ? void 0 : PlanBaseValidateSchema[key]) === null || _b === void 0 ? void 0 : _b.rules) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.customFunc(formData[key], edit); } else if (isInSchemaProps(key, instanceSchemas)) { @@ -1494,7 +1400,6 @@ var validateAllPlanProps = function validateAllPlanProps(edit, instanceSchemas) message: '' }; } - vm = tslib.__assign(tslib.__assign({}, vm), (_a = {}, _a[key] = validator, _a)); }); return vm; @@ -1503,7 +1408,6 @@ var _validatePlan = function _validatePlan(data, schemas) { var validator = validateAllPlanProps(data, schemas); return Object.keys(validator).every(function (key) { var _a; - return ((_a = validator === null || validator === void 0 ? void 0 : validator[key]) === null || _a === void 0 ? void 0 : _a.status) === ffValidator.ValidatorStatusEnum.Success; }); }; @@ -1511,7 +1415,6 @@ var initServicePlanEdit = function initServicePlanEdit(data) { return { formData: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a, _b; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = getFormItemDefaultValue(cur), _a.unitMap = tslib.__assign(tslib.__assign({}, pre === null || pre === void 0 ? void 0 : pre.unitMap), (_b = {}, _b[cur === null || cur === void 0 ? void 0 : cur.name] = cur === null || cur === void 0 ? void 0 : cur.unit, _b)), _a)); }, { instanceName: '', @@ -1519,7 +1422,6 @@ var initServicePlanEdit = function initServicePlanEdit(data) { }), validator: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = { status: 1, message: '' @@ -1534,11 +1436,9 @@ var initServicePlanEdit = function initServicePlanEdit(data) { }; var HubCluster; - (function (HubCluster) { HubCluster.DefaultRegion = 1; var StatusEnum; - (function (StatusEnum) { StatusEnum["Running"] = "Running"; StatusEnum["Initializing"] = "Initializing"; @@ -1547,21 +1447,20 @@ var HubCluster; var _a$4, _b$3, _c$2; var DetailTabType; - (function (DetailTabType) { DetailTabType["Detail"] = "ServiceDetail"; DetailTabType["BackUp"] = "ServiceOpsPlan"; DetailTabType["Monitor"] = "ServiceMonitor"; DetailTabType["ServiceBinding"] = "ServiceBinding"; })(DetailTabType || (DetailTabType = {})); - var detailTabs = [{ id: DetailTabType.Detail, label: i18n.t('基本信息') }, { id: DetailTabType.BackUp, label: i18n.t('备份') -}, // { +}, +// { // id: DetailTabType.Monitor, // label: t('监控') // }, @@ -1570,13 +1469,11 @@ var detailTabs = [{ label: i18n.t('服务绑定') }]; var BackupTypeNum; - (function (BackupTypeNum) { BackupTypeNum["Manual"] = "Manual"; BackupTypeNum["Schedule"] = "Schedule"; BackupTypeNum["Unknown"] = "unknown"; })(BackupTypeNum || (BackupTypeNum = {})); - var BackupTypeMap = (_a$4 = {}, _a$4[BackupTypeNum.Manual] = { text: i18n.t('手动备份'), className: 'text-warning' @@ -1588,13 +1485,11 @@ var BackupTypeMap = (_a$4 = {}, _a$4[BackupTypeNum.Manual] = { className: 'text-weak' }, _a$4); var BackupStatusNum; - (function (BackupStatusNum) { BackupStatusNum["Waiting"] = "Running"; BackupStatusNum["Success"] = "Succeed"; BackupStatusNum["Failed"] = "Failed"; })(BackupStatusNum || (BackupStatusNum = {})); - var BackupStatusMap = (_b$3 = {}, _b$3[BackupStatusNum.Waiting] = { text: i18n.t('备份中'), className: 'text-warning' @@ -1606,13 +1501,11 @@ var BackupStatusMap = (_b$3 = {}, _b$3[BackupStatusNum.Waiting] = { className: 'text-danger' }, _b$3); var ServiceBindingStatusNum; - (function (ServiceBindingStatusNum) { ServiceBindingStatusNum["Waiting"] = "Waiting"; ServiceBindingStatusNum["Ready"] = "Ready"; ServiceBindingStatusNum["Failed"] = "ServiceInstanceNotReady"; })(ServiceBindingStatusNum || (ServiceBindingStatusNum = {})); - var ServiceBindingStatusMap = (_c$2 = {}, _c$2[ServiceBindingStatusNum.Waiting] = { text: i18n.t('创建中'), className: 'text-warning' @@ -1651,7 +1544,6 @@ var BackupStrategyEditInitValue = { }; var Backup; - (function (Backup) { Backup.minReserveDay = 1; Backup.maxReserveDay = 30; @@ -1750,24 +1642,18 @@ var Backup; value: '23', text: '23:00' }]; - Backup.invalidFormItemMsg = function (data) { var _a, _b, _c; - return (_c = (_b = data === null || data === void 0 ? void 0 : data.validator[(_a = Object.keys(data === null || data === void 0 ? void 0 : data.validator)) === null || _a === void 0 ? void 0 : _a.find(function (item) { var _a; - return ((_a = data === null || data === void 0 ? void 0 : data.validator[item]) === null || _a === void 0 ? void 0 : _a.status) === 2; })]) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : ''; }; - Backup._validateAll = function (data) { var _a; - var allValidator = Backup.getValidatorModel(data); var key = (_a = Object.keys(allValidator)) === null || _a === void 0 ? void 0 : _a.find(function (key) { var _a; - return ((_a = allValidator === null || allValidator === void 0 ? void 0 : allValidator[key]) === null || _a === void 0 ? void 0 : _a.status) === ffValidator.ValidatorStatusEnum.Failed; }); var inValidItem = allValidator === null || allValidator === void 0 ? void 0 : allValidator[key]; @@ -1776,18 +1662,13 @@ var Backup; message: !inValidItem ? i18n.t('') : inValidItem === null || inValidItem === void 0 ? void 0 : inValidItem.message }; }; - Backup.getValidatorModel = function (backupStrategyEdit) { var _a; - var formData = backupStrategyEdit.formData; return (_a = Object === null || Object === void 0 ? void 0 : Object.keys(formData)) === null || _a === void 0 ? void 0 : _a.reduce(function (pre, key) { var _a; - var _b, _c, _d, _e; - var validator; - if (!(formData === null || formData === void 0 ? void 0 : formData.enable)) { validator = { message: '', @@ -1811,26 +1692,24 @@ var Backup; }; } } - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[key] = validator, _a)); }, {}); }; - Backup.reduceBackupStrategyJson = function (data) { var backupDate = data.backupDate, - backupTime = data.backupTime, - backupReserveDay = data.backupReserveDay, - instanceName = data.instanceName, - enable = data.enable, - instanceId = data.instanceId, - serviceName = data.serviceName, - _a = data.mode, - mode = _a === void 0 ? 'create' : _a; + backupTime = data.backupTime, + backupReserveDay = data.backupReserveDay, + instanceName = data.instanceName, + enable = data.enable, + instanceId = data.instanceId, + serviceName = data.serviceName, + _a = data.mode, + mode = _a === void 0 ? 'create' : _a; var weekStr = backupDate.sort().join(',') || '*'; var hourStr = backupTime.sort().join(',') || '0'; - var minuteStr = '0'; //cron 格式:`* * * * * *`,即:分 时 天 月 周 年(可省略) + var minuteStr = '0'; + //cron 格式:`* * * * * *`,即:分 时 天 月 周 年(可省略) // const cron = `${minuteStr} ${hourStr} ? * ${weekStr}`; - var cron = "".concat(minuteStr, " ").concat(hourStr, " ? * ").concat(weekStr); var jsonData = { apiVersion: "infra.tce.io/v1", @@ -1850,7 +1729,6 @@ var Backup; } } }; - if (enable) { jsonData.spec['retain'] = { days: backupReserveDay @@ -1862,13 +1740,11 @@ var Backup; } }; } - return JSON.stringify(jsonData); }; })(Backup || (Backup = {})); var ServiceBinding; - (function (ServiceBinding) { ServiceBinding.ServiceBindingEditInitValue = { formData: { @@ -1906,13 +1782,11 @@ var ServiceBinding; }] } }; - ServiceBinding._validateServiceBindingItem = function (key, value) { var _a, _b; var rules = (_b = (_a = ServiceBinding.ServiceBindingEditSchema === null || ServiceBinding.ServiceBindingEditSchema === void 0 ? void 0 : ServiceBinding.ServiceBindingEditSchema[key]) === null || _a === void 0 ? void 0 : _a.rules) !== null && _b !== void 0 ? _b : []; var notMatchRule = rules === null || rules === void 0 ? void 0 : rules.find(function (item) { var _a; - var isNotMatchRule = (item === null || item === void 0 ? void 0 : item.required) && !value || (item === null || item === void 0 ? void 0 : item.reg) && !((_a = item === null || item === void 0 ? void 0 : item.reg) === null || _a === void 0 ? void 0 : _a.test(value)) || !!(item === null || item === void 0 ? void 0 : item.max) && !!value && (value === null || value === void 0 ? void 0 : value.length) > (item === null || item === void 0 ? void 0 : item.max); return isNotMatchRule; }); @@ -1920,44 +1794,36 @@ var ServiceBinding; status: !notMatchRule ? ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Success : ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Failed, message: !notMatchRule ? '' : notMatchRule === null || notMatchRule === void 0 ? void 0 : notMatchRule.message }; - }; // export const _validatePlanSchema = (value:string | number | boolean,planSchema:PlanSchema):Validation =>{ + }; + // export const _validatePlanSchema = (value:string | number | boolean,planSchema:PlanSchema):Validation =>{ // return { // status: planSchema?.optional ? ValidatorStatusEnum?.Success : ValidatorStatusEnum?.Failed, // message: '' // }; // } - - ServiceBinding._validateFormItem = function (editData, planSchemas, serviceName, instance) { var _a; - var formData = editData.formData; return (_a = Object === null || Object === void 0 ? void 0 : Object.keys(formData)) === null || _a === void 0 ? void 0 : _a.reduce(function (pre, key) { var _a; - var validator; var schema = planSchemas === null || planSchemas === void 0 ? void 0 : planSchemas.find(function (item) { return (item === null || item === void 0 ? void 0 : item.name) === key; - }); //当前属性是否是来自后端的schema属性 - + }); + //当前属性是否是来自后端的schema属性 if (schema) { validator = validatePlanSchema(schema, formData[key], OperatorNumberUnitReg, formData, serviceName, instance); } else { validator = ServiceBinding._validateServiceBindingItem(key, formData === null || formData === void 0 ? void 0 : formData[key]); } - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[key] = validator, _a)); }, {}); }; - ServiceBinding._validateAll = function (data, planSchemas, serviceName, instance) { var _a; - var allValidator = ServiceBinding._validateFormItem(data, planSchemas, serviceName, instance); - var key = (_a = Object.keys(allValidator)) === null || _a === void 0 ? void 0 : _a.find(function (key) { var _a; - return ((_a = allValidator === null || allValidator === void 0 ? void 0 : allValidator[key]) === null || _a === void 0 ? void 0 : _a.status) === ffValidator.ValidatorStatusEnum.Failed; }); var inValidItem = allValidator === null || allValidator === void 0 ? void 0 : allValidator[key]; @@ -1966,17 +1832,14 @@ var ServiceBinding; message: !inValidItem ? i18n.t('') : inValidItem === null || inValidItem === void 0 ? void 0 : inValidItem.message }; }; - ServiceBinding.initServiceResourceEdit = function (data) { return { formData: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = getFormItemDefaultValue(cur), _a)); }, tslib.__assign({}, ServiceBinding.ServiceBindingEditInitValue === null || ServiceBinding.ServiceBindingEditInitValue === void 0 ? void 0 : ServiceBinding.ServiceBindingEditInitValue.formData)), validator: data === null || data === void 0 ? void 0 : data.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = { status: 1, message: '' @@ -1986,16 +1849,14 @@ var ServiceBinding; }; })(ServiceBinding || (ServiceBinding = {})); +// import { yunApiFeedback } from './yunApiFeedback'; // import { Aegis } from './aegis'; - function appendFunction(origin, append) { return function appended() { var args = []; - for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = origin.apply(this, args); return append.apply(this, [result].concat(args)); }; @@ -2005,45 +1866,36 @@ function appendFunction(origin, append) { * @param prevpath: string 之前的路由 * @param currentpath: string 当前的路由 */ - - var isInSameModule = function isInSameModule(prevpath, currentpath) { var _a = prevpath.split('/').filter(function (item) { - return item !== ''; - }), - prevBusiness = _a[0], - prevModule = _a[1], - prevRest = _a.slice(2), - _b = currentpath.split('/').filter(function (item) { - return item !== ''; - }), - currentBusiness = _b[0], - currentModule = _b[1], - currentRest = _b.slice(2); - + return item !== ''; + }), + prevBusiness = _a[0], + prevModule = _a[1], + prevRest = _a.slice(2), + _b = currentpath.split('/').filter(function (item) { + return item !== ''; + }), + currentBusiness = _b[0], + currentModule = _b[1], + currentRest = _b.slice(2); if (prevModule !== currentModule) { return false; } - return true; }; - var nmcRouter = seajs.require('router'); - var pageManager = seajs.require('nmc/main/pagemanager'); - function getFragment() { var debug = nmcRouter.debug || ''; var debugReg = new RegExp('^' + debug.replace('/', '\\/')); var fragment = nmcRouter.getFragment().split('?'); return fragment[0].replace(debugReg, ''); } - function getQueryString() { var str = nmcRouter.getFragment().split('?'); return str[1] ? '?' + str[1] : ''; } - function getInitialState(rule) { var fragment = getFragment(); var params = nmcRouter.matchRoute(rule, fragment) || []; @@ -2056,29 +1908,22 @@ function getInitialState(rule) { queries: queries }; } - var RouterNavigateAction = 'RouterNavigate'; - function generateRouterReducer(rule) { function routerReducer(state, action) { if (state === void 0) { state = getInitialState(rule); } - if (action.type === RouterNavigateAction) { return action.payload; } - return state; } - return routerReducer; } - var curFragment = '', - curQueryString = '', - curQueries = {}; - + curQueryString = '', + curQueries = {}; function navigateAction(fragment, params, queryString, queries) { return { type: RouterNavigateAction, @@ -2090,12 +1935,9 @@ function navigateAction(fragment, params, queryString, queries) { } }; } - function getCurrentRouterStatus(fragment, params, qString, queries) { var queryString = qString; - var flag = false; - /**记录是否变化, 默认无变化 */ - + var flag = false; /**记录是否变化, 默认无变化 */ if (fragment === curFragment && curQueryString && !queryString) { /**path无变化,参数变化 */ queryString = curQueryString; @@ -2106,42 +1948,33 @@ function getCurrentRouterStatus(fragment, params, qString, queries) { curQueries = queries; flag = true; } - return { flag: flag, queries: curQueries }; } - function startAction(rule) { return function (dispatch) { var _a = getInitialState(rule), - fragment = _a.fragment, - params = _a.params, - queryString = _a.queryString, - queries = _a.queries; - + fragment = _a.fragment, + params = _a.params, + queryString = _a.queryString, + queries = _a.queries; dispatch(navigateAction(fragment, params, queryString, queries)); nmcRouter.use(rule, function () { var args = []; - for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var params = args.slice(); var fragment = getFragment(); /* eslint-disable */ - _typeof(params[params.length - 1]) === 'object' ? params.pop() : {}; // nmcRouter parse error - /* eslint-enable */ - var queryString = getQueryString(); var queries = parseQueryString(queryString); dispatch(navigateAction(fragment, params, queryString, queries)); var curStatus = getCurrentRouterStatus(fragment, params, queryString, queries); - if (curStatus.flag) { // 更新导航状态 var parts = fragment.split('/'); @@ -2155,19 +1988,17 @@ function startAction(rule) { }); }; } - function generateRouterDecorator(rule) { function decorator(target) { function onMount() { var _this = this; - - _this.props.dispatch(startAction(rule)); // Aegis.init(); - + _this.props.dispatch(startAction(rule)); + // Aegis.init(); } function onUnmount() { - - nmcRouter.unuse(rule); //当离开模块的时候,也清楚掉error + nmcRouter.unuse(rule); + //当离开模块的时候,也清楚掉error // yunApiFeedback.clearApiError(); } @@ -2175,53 +2006,39 @@ function generateRouterDecorator(rule) { proto.componentWillMount = proto.componentWillMount ? appendFunction(proto.componentWillMount, onMount) : onMount; proto.componentWillUnmount = proto.componentWillUnmount ? appendFunction(proto.componentWillUnmount, onUnmount) : onUnmount; } - return decorator; } - var NAMED_PARAM_REGEX = /\(\/:(\w+)\)/g; var RemoveExec4TdccCluster = /\(\/\(cluster\|startup\)\)/g; - -var Router = -/** @class */ -function () { +var Router = /** @class */function () { /* eslint-disable */ function Router(rule, defaults) { var _this_1 = this; - this.rule = rule; this.defaults = defaults; this.paramNames = []; this.rule.replace(NAMED_PARAM_REGEX, function (match, name) { _this_1.paramNames.push(name); - return match; }); } /* eslint-enable */ - - Router.prototype.getReducer = function () { return generateRouterReducer(this.rule); }; - Router.prototype.serve = function () { return generateRouterDecorator(this.rule); }; - Router.prototype.buildFragment = function (params) { var _this_1 = this; - if (params === void 0) { params = {}; - } // TODO 优化默认路由生成 - - + } + // TODO 优化默认路由生成 var temp = this.rule.replace(NAMED_PARAM_REGEX, function (matched, name) { if (typeof params[name] === 'undefined' || params[name] === undefined || params[name] === _this_1.defaults[name]) { return '/' + _this_1.defaults[name]; } - return '/' + params[name]; }); temp = temp.replace(/([^:])[\/\\\\]{2,}/, '$1/'); @@ -2229,10 +2046,8 @@ function () { temp = temp.replace(RemoveExec4TdccCluster, ''); return temp; }; - Router.prototype.resolve = function (state) { var _this_1 = this; - var resolved = {}; var paramNames = this.paramNames.slice(); var paramValues = state.params.slice(); @@ -2241,47 +2056,38 @@ function () { }); return resolved; }; - Router.prototype.buildUrl = function (params, queries) { if (params === void 0) { params = {}; } - return this.buildFragment(params) + buildQueryString(queries); }; - Router.prototype.navigate = function (params, queries, url) { if (params === void 0) { params = {}; } - if (url) { nmcRouter.navigate(url); } else { var nextLocationPath = this.buildFragment(params); var prevLocationPath = location.pathname; - if (isInSameModule(prevLocationPath, nextLocationPath)) { nmcRouter.navigate(nextLocationPath + buildQueryString(queries)); } } }; - return Router; }(); var SubEnum; - (function (SubEnum) { SubEnum["List"] = "list"; SubEnum["Detail"] = "detail"; - SubEnum["Create"] = "create"; //编辑实例 - + SubEnum["Create"] = "create"; + //编辑实例 SubEnum["Edit"] = "edit"; })(SubEnum || (SubEnum = {})); - var TabEnum; - (function (TabEnum) { TabEnum["Info"] = "info"; TabEnum["Instance"] = "instance"; @@ -2290,51 +2096,37 @@ var TabEnum; /** * @param sub 当前的模式,create | update | detail */ - - var router = new Router("".concat(Util === null || Util === void 0 ? void 0 : Util.getRouterPath(location === null || location === void 0 ? void 0 : location.pathname), "(/:sub)(/:tab)"), { sub: SubEnum.List, tab: '' }); var routerSea = seajs.require('router'); - function PaasHeader(props) { var _a, _b, _c; var route = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.route; }); - var tabId = reactRedux.useSelector(function (state) { - var _a; - - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.selectedTab; - }); + var tab = (router === null || router === void 0 ? void 0 : router.resolve(route)).tab; var platform = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.platform; }); var services = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.services; }); var urlParams = router === null || router === void 0 ? void 0 : router.resolve(route); - var _d = route === null || route === void 0 ? void 0 : route.queries, - _e = _d.servicename, - servicename = _e === void 0 ? '-' : _e, - _f = _d.instancename, - instancename = _f === void 0 ? '-' : _f, - mode = _d.mode; - + _e = _d.servicename, + servicename = _e === void 0 ? '-' : _e, + _f = _d.instancename, + instancename = _f === void 0 ? '-' : _f, + mode = _d.mode; var headerTitle; - var goBack = function goBack() { var _a; - router.navigate({ sub: 'list', tab: undefined @@ -2344,10 +2136,9 @@ function PaasHeader(props) { mode: "list" }); }; - if (platform === (PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TDCC)) { if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'create') { - headerTitle = "\u65B0\u5EFA".concat(servicename !== null && servicename !== void 0 ? servicename : '-').concat((_a = ResourceTypeMap === null || ResourceTypeMap === void 0 ? void 0 : ResourceTypeMap[tabId]) === null || _a === void 0 ? void 0 : _a.title); + headerTitle = "\u65B0\u5EFA".concat(servicename !== null && servicename !== void 0 ? servicename : '-').concat((_a = ResourceTypeMap === null || ResourceTypeMap === void 0 ? void 0 : ResourceTypeMap[tab]) === null || _a === void 0 ? void 0 : _a.title); } else if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'detail') { headerTitle = "".concat(servicename, "\u5B9E\u4F8B / ").concat(instancename, "\u5B9E\u4F8B\u8BE6\u60C5"); } else { @@ -2355,14 +2146,13 @@ function PaasHeader(props) { } } else { if (mode === 'create') { - headerTitle = "\u65B0\u5EFA".concat(servicename !== null && servicename !== void 0 ? servicename : '-').concat((_b = ResourceTypeMap === null || ResourceTypeMap === void 0 ? void 0 : ResourceTypeMap[tabId]) === null || _b === void 0 ? void 0 : _b.title); + headerTitle = "\u65B0\u5EFA".concat(servicename !== null && servicename !== void 0 ? servicename : '-').concat((_b = ResourceTypeMap === null || ResourceTypeMap === void 0 ? void 0 : ResourceTypeMap[tab]) === null || _b === void 0 ? void 0 : _b.title); } else if (mode === 'detail') { headerTitle = "".concat(servicename, "\u5B9E\u4F8B / ").concat(instancename, "\u5B9E\u4F8B\u8BE6\u60C5"); } else { headerTitle = '中间件列表'; } } - var showBackIcon = !((_c = ['', 'list']) === null || _c === void 0 ? void 0 : _c.includes(urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub)); return React__default.createElement(teaComponent.Card, { style: { @@ -2399,7 +2189,7 @@ function PaasHeader(props) { function LoadingPanel(props) { var _a = props.text, - text = _a === void 0 ? '' : _a; + text = _a === void 0 ? '' : _a; return React__default.createElement("div", { style: { width: '100%' @@ -2409,27 +2199,22 @@ function LoadingPanel(props) { }), React__default.createElement(teaComponent.Text, null, text, i18n.t('加载中'))); } -var TipInfo = -/** @class */ -function (_super) { +var TipInfo = /** @class */function (_super) { tslib.__extends(TipInfo, _super); - function TipInfo() { return _super !== null && _super.apply(this, arguments) || this; } - TipInfo.prototype.render = function () { var _a = this.props, - _b = _a.style, - style = _b === void 0 ? {} : _b, - _c = _a.isShow, - isShow = _c === void 0 ? true : _c, - _d = _a.isForm, - isForm = _d === void 0 ? false : _d, - restProps = tslib.__rest(_a, ["style", "isShow", "isForm"]), - renderStyle = style; // 用于在创建表单当中 展示错误信息 - - + _b = _a.style, + style = _b === void 0 ? {} : _b, + _c = _a.isShow, + isShow = _c === void 0 ? true : _c, + _d = _a.isForm, + isForm = _d === void 0 ? false : _d, + restProps = tslib.__rest(_a, ["style", "isShow", "isForm"]), + renderStyle = style; + // 用于在创建表单当中 展示错误信息 if (isForm) { renderStyle = Object.assign({}, renderStyle, { //内部布局是flex @@ -2441,25 +2226,23 @@ function (_super) { overflow: 'auto' }); } - return isShow ? React__default.createElement(teaComponent.Alert, tslib.__assign({ style: renderStyle }, restProps), this.props.children) : React__default.createElement("noscript", null); }; - return TipInfo; }(React__default.Component); function RetryPanel(props) { var _a = props.style, - style = _a === void 0 ? {} : _a, - action = props.action, - _b = props.loadingText, - loadingText = _b === void 0 ? i18n.t('加载失败') : _b, - _c = props.retryText, - retryText = _c === void 0 ? i18n.t('刷新重试') : _c, - _d = props.loadingTextTheme, - loadingTextTheme = _d === void 0 ? 'danger' : _d; + style = _a === void 0 ? {} : _a, + action = props.action, + _b = props.loadingText, + loadingText = _b === void 0 ? i18n.t('加载失败') : _b, + _c = props.retryText, + retryText = _c === void 0 ? i18n.t('刷新重试') : _c, + _d = props.loadingTextTheme, + loadingTextTheme = _d === void 0 ? 'danger' : _d; return React__default.createElement("div", { style: tslib.__assign({ width: '100%', @@ -2485,7 +2268,6 @@ function uuid() { var getWorkflowError = function getWorkflowError(workflow) { var _a, _b, _c, _d, _e, _f, _g, _h; - var message = ((_c = (_b = (_a = workflow === null || workflow === void 0 ? void 0 : workflow.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || ((_f = (_e = (_d = workflow === null || workflow === void 0 ? void 0 : workflow.results) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.Message); var error = (_h = (_g = workflow === null || workflow === void 0 ? void 0 : workflow.results) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.error; return message; @@ -2498,25 +2280,21 @@ var initRecords = [{ }]; var MapField = function MapField(_a) { var plan = _a.plan, - onChange = _a.onChange; - + onChange = _a.onChange; var _b = React.useState(initRecords), - records = _b[0], - setRecords = _b[1]; - + records = _b[0], + setRecords = _b[1]; React.useEffect(function () { onChange && onChange({ field: plan === null || plan === void 0 ? void 0 : plan.name, value: records }); }, [records]); - var _delete = function _delete(id) { setRecords(records === null || records === void 0 ? void 0 : records.filter(function (item) { return (item === null || item === void 0 ? void 0 : item.id) !== id; })); }; - var _add = function _add() { var newItem = { id: uuid(), @@ -2525,20 +2303,16 @@ var MapField = function MapField(_a) { }; setRecords(records === null || records === void 0 ? void 0 : records.concat([newItem])); }; - var _update = function _update(fieldName, selectItem, value) { if (value === void 0) { value = ''; } - var newRecords = records === null || records === void 0 ? void 0 : records.map(function (item) { var _a; - return tslib.__assign(tslib.__assign({}, item), (_a = {}, _a[fieldName] = (item === null || item === void 0 ? void 0 : item.id) === (selectItem === null || selectItem === void 0 ? void 0 : selectItem.id) ? value : item === null || item === void 0 ? void 0 : item[fieldName], _a)); }); setRecords(newRecords); }; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Table, { bordered: true, recordKey: "id", @@ -2586,35 +2360,29 @@ var MapField = function MapField(_a) { function UpdateResource(props) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; - var _p = props.base, - platform = _p.platform, - isI18n = _p.isI18n, - route = _p.route, - _q = props.list, - services = _q.services, - servicePlanEdit = _q.servicePlanEdit, - updateResourceWorkflow = _q.updateResourceWorkflow, - resourceDetail = props.detail.resourceDetail, - actions = props.actions; + platform = _p.platform, + isI18n = _p.isI18n, + route = _p.route, + _q = props.list, + services = _q.services, + servicePlanEdit = _q.servicePlanEdit, + updateResourceWorkflow = _q.updateResourceWorkflow, + resourceDetail = props.detail.resourceDetail, + actions = props.actions; var servicename = (route === null || route === void 0 ? void 0 : route.queries).servicename; var instanceParamsFields = (_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceSchema; - var reduceCreateServiceResourceDataJson = function reduceCreateServiceResourceDataJson(data) { var _a, _b, _c, _d, _e, _f; - var _g = data === null || data === void 0 ? void 0 : data.formData, - instanceName = _g.instanceName, - description = _g.description, - clusterId = _g.clusterId; //拼接中间件实例参数部分属性值 - - + instanceName = _g.instanceName, + description = _g.description, + clusterId = _g.clusterId; + //拼接中间件实例参数部分属性值 var parameters = (_c = (_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceSchema) === null || _c === void 0 ? void 0 : _c.reduce(function (pre, cur) { var _a; - - var _b, _c, _d, _e; // return Object.assign(pre,!!data?.formData?.[cur?.name] ? {[cur?.name]:data?.formData?.[cur?.name] + (data?.formData?.['unitMap']?.[cur?.name] ?? '')} : {}); - - + var _b, _c, _d, _e; + // return Object.assign(pre,!!data?.formData?.[cur?.name] ? {[cur?.name]:data?.formData?.[cur?.name] + (data?.formData?.['unitMap']?.[cur?.name] ?? '')} : {}); return Object.assign(pre, ((_b = data === null || data === void 0 ? void 0 : data.formData) === null || _b === void 0 ? void 0 : _b[cur === null || cur === void 0 ? void 0 : cur.name]) !== '' ? (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = formatPlanSchemaSubmitData(cur, (_c = data === null || data === void 0 ? void 0 : data.formData) === null || _c === void 0 ? void 0 : _c[cur === null || cur === void 0 ? void 0 : cur.name], (_e = (_d = data === null || data === void 0 ? void 0 : data.formData) === null || _d === void 0 ? void 0 : _d['unitMap']) === null || _e === void 0 ? void 0 : _e[cur === null || cur === void 0 ? void 0 : cur.name]), _a) : {}); }, {}); var json = { @@ -2633,20 +2401,15 @@ function UpdateResource(props) { metadata: tslib.__assign({}, parameters) } }; - if (description) { json.spec['description'] = description; } - return JSON.stringify(json); }; - var _submit = function _submit() { var _a, _b, _c, _d; - var formData = servicePlanEdit.formData; actions.create.validatePlan((_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceSchema); - if (_validatePlan(servicePlanEdit, (_d = (_c = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.instanceSchema)) { var params = { platform: platform, @@ -2660,12 +2423,10 @@ function UpdateResource(props) { actions.create.updateResource.perform(); } }; - var _cancel = function _cancel() { actions.create.updateResource.reset(); actions.list.showCreateResourceDialog(false); }; - var loading = !((_c = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _c === void 0 ? void 0 : _c.fetched) || (resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object.fetchState) === ffRedux.FetchState.Fetching; var loadSchemaFailed = ((_d = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _d === void 0 ? void 0 : _d.error) || ((_e = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _e === void 0 ? void 0 : _e.fetchState) === ffRedux.FetchState.Failed; var isSubmitting = (updateResourceWorkflow === null || updateResourceWorkflow === void 0 ? void 0 : updateResourceWorkflow.operationState) === ffRedux.OperationState.Performing; @@ -2692,7 +2453,6 @@ function UpdateResource(props) { value: (_j = servicePlanEdit === null || servicePlanEdit === void 0 ? void 0 : servicePlanEdit.formData) === null || _j === void 0 ? void 0 : _j['instanceName'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updatePlan('instanceName', e); }, onBlur: function onBlur() {}, @@ -2714,18 +2474,15 @@ function UpdateResource(props) { value: (_o = servicePlanEdit === null || servicePlanEdit === void 0 ? void 0 : servicePlanEdit.formData) === null || _o === void 0 ? void 0 : _o['description'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updatePlan('description', e); }, onBlur: function onBlur() {} } }), instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item, index) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - var _l = (_b = (_a = item.description) === null || _a === void 0 ? void 0 : _a.split('---')) !== null && _b !== void 0 ? _b : [], - english = _l[0], - chinese = _l[1]; - + english = _l[0], + chinese = _l[1]; return React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -2781,10 +2538,9 @@ function UpdateResource(props) { plan: item, onChange: function onChange(_a) { var field = _a.field, - value = _a.value; + value = _a.value; actions === null || actions === void 0 ? void 0 : actions.create.updatePlan(item === null || item === void 0 ? void 0 : item.name, JSON.stringify(value === null || value === void 0 ? void 0 : value.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.key] = cur === null || cur === void 0 ? void 0 : cur.value, _a)); }, {}))); } @@ -2798,9 +2554,7 @@ function UpdateResource(props) { value: (_k = (_j = servicePlanEdit === null || servicePlanEdit === void 0 ? void 0 : servicePlanEdit.formData) === null || _j === void 0 ? void 0 : _j['unitMap']) === null || _k === void 0 ? void 0 : _k[item === null || item === void 0 ? void 0 : item.name], onChange: function onChange(e) { var _a; - var _b; - actions === null || actions === void 0 ? void 0 : actions.create.updatePlan('unitMap', tslib.__assign(tslib.__assign({}, (_b = servicePlanEdit === null || servicePlanEdit === void 0 ? void 0 : servicePlanEdit.formData) === null || _b === void 0 ? void 0 : _b['unitMap']), (_a = {}, _a[item === null || item === void 0 ? void 0 : item.name] = e, _a))); } })); @@ -2825,12 +2579,11 @@ function UpdateResource(props) { function ServiceCreateDialog(props) { var _a, _b; - var showCreateResourceDialog = props.list.showCreateResourceDialog, - resourceDetail = props.detail.resourceDetail, - actions = props.actions, - _c = props.mode, - mode = _c === void 0 ? 'edit' : _c; + resourceDetail = props.detail.resourceDetail, + actions = props.actions, + _c = props.mode, + mode = _c === void 0 ? 'edit' : _c; var loading = ((_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.loading) || (resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object.fetchState) === ffRedux.FetchState.Fetching; var failed = (resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object.fetchState) === ffRedux.FetchState.Failed; var resource = (_b = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _b === void 0 ? void 0 : _b.data; @@ -2845,45 +2598,34 @@ function ServiceCreateDialog(props) { } var routerSea$1 = seajs.require('router'); - function ServiceDetailHeader(props) { var _a, _b, _c, _d, _e, _f; - var services = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.services; }); var selectedTab = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.selectedTab; }); var resource = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.serviceResources; }); var platform = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.platform; }); var actions = props.actions; - var _g = React.useState([]), - searchBoxValues = _g[0], - setSearchBoxValues = _g[1]; - + searchBoxValues = _g[0], + setSearchBoxValues = _g[1]; var _h = React.useState(0), - searchBoxLength = _h[0], - setSearchBoxLength = _h[1]; - + searchBoxLength = _h[0], + setSearchBoxLength = _h[1]; var onCreate = function onCreate() { var _a, _b, _c, _d, _e; - (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.serviceResources) === null || _b === void 0 ? void 0 : _b.clearPolling(); - if (selectedTab === ResourceTypeEnum.ServiceResource) { router.navigate({ sub: 'create', @@ -2913,10 +2655,8 @@ function ServiceDetailHeader(props) { }); } }; - var btnText = selectedTab === ResourceTypeEnum.ServiceResource ? i18n.t('创建中间件实例') : i18n.t('创建规格'); /** 生成手动刷新按钮 */ - var _renderManualRenew = function _renderManualRenew() { var loading = resource.list.loading || resource.list.fetchState === ffRedux.FetchState.Fetching; return React__default.createElement(teaComponent.Button, { @@ -2932,8 +2672,6 @@ function ServiceDetailHeader(props) { }) ; }; /** 生成搜索框 */ - - var _renderTagSearchBox = function _renderTagSearchBox() { // tagSearch的过滤选项 var attributes = [{ @@ -2957,21 +2695,17 @@ function ServiceDetailHeader(props) { })) ; }; /** 搜索框的操作,不同的搜索进行相对应的操作 */ - - var _handleClickForTagSearch = function _handleClickForTagSearch(tags) { // 这里是控制tagSearch的展示 setSearchBoxValues(tags); - setSearchBoxLength(tags.length); // 如果检测到 tags的长度变化,并且key为 resourceName 去掉了,则清除搜索条件 - + setSearchBoxLength(tags.length); + // 如果检测到 tags的长度变化,并且key为 resourceName 去掉了,则清除搜索条件 if (tags.length === 0 || tags.length === 1 && resource.query.search && tags[0].attr && tags[0].attr.key !== 'resourceName') { actions.list.serviceResources.changeKeyword(''); actions.list.serviceResources.performSearch(''); } - tags.forEach(function (tagItem) { var attrKey = tagItem.attr ? tagItem.attr.key : null; - if (attrKey === 'resourceName' || attrKey === null) { var search = tagItem.values[0].name; actions.list.serviceResources.changeKeyword(search); @@ -2979,7 +2713,6 @@ function ServiceDetailHeader(props) { } }); }; - var isDisabledCreate = !((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.length); var title = !((_c = services === null || services === void 0 ? void 0 : services.selection) === null || _c === void 0 ? void 0 : _c.name) ? i18n.t('请您选择左侧的服务') : !((_e = (_d = services === null || services === void 0 ? void 0 : services.selection) === null || _d === void 0 ? void 0 : _d.clusters) === null || _e === void 0 ? void 0 : _e.length) ? i18n.t('{{title}}', { title: "".concat((_f = services === null || services === void 0 ? void 0 : services.selection) === null || _f === void 0 ? void 0 : _f.name, "\u5C1A\u672A\u5728\u76EE\u6807\u96C6\u7FA4\u5F00\u542F\uFF0C\u8BF7\u60A8\u524D\u5F80\u5206\u5E03\u5F0F\u4E91\u4E2D\u5FC3\u6982\u89C8\u9875\u5F00\u542F") @@ -3010,7 +2743,6 @@ function dateFormatter(date, format) { if (date.toString() === 'Invalid Date') { return '-'; } - var o = { /** * 完整年份 @@ -3019,7 +2751,6 @@ function dateFormatter(date, format) { YYYY: function YYYY() { return date.getFullYear().toString(); }, - /** * 年份后两位 * @example 15 16 17 18 @@ -3027,7 +2758,6 @@ function dateFormatter(date, format) { YY: function YY() { return this.YYYY().slice(-2); }, - /** * 月份,保持两位数 * @example 01 02 03 .... 11 12 @@ -3035,7 +2765,6 @@ function dateFormatter(date, format) { MM: function MM() { return leftPad(this.M(), 2); }, - /** * 月份 * @example 1 2 3 .... 11 12 @@ -3043,7 +2772,6 @@ function dateFormatter(date, format) { M: function M() { return (date.getMonth() + 1).toString(); }, - /** * 每月中的日期,保持两位数 * @example 01 02 03 .... 30 31 @@ -3051,7 +2779,6 @@ function dateFormatter(date, format) { DD: function DD() { return leftPad(this.D(), 2); }, - /** * 每月中的日期 * @example 1 2 3 .... 30 31 @@ -3059,7 +2786,6 @@ function dateFormatter(date, format) { D: function D() { return date.getDate().toString(); }, - /** * 小时,24 小时制,保持两位数 * @example 00 01 02 .... 22 23 @@ -3067,7 +2793,6 @@ function dateFormatter(date, format) { HH: function HH() { return leftPad(this.H(), 2); }, - /** * 小时,24 小时制 * @example 0 1 2 .... 22 23 @@ -3075,7 +2800,6 @@ function dateFormatter(date, format) { H: function H() { return date.getHours().toString(); }, - /** * 小时,12 小时制,保持两位数 * @example 00 01 02 .... 22 23 @@ -3083,7 +2807,6 @@ function dateFormatter(date, format) { hh: function hh() { return leftPad(this.h(), 2); }, - /** * 小时,12 小时制 * @example 0 1 2 .... 22 23 @@ -3092,7 +2815,6 @@ function dateFormatter(date, format) { var h = (date.getHours() % 12).toString(); return h === '0' ? '12' : h; }, - /** * 分钟,保持两位数 * @example 00 01 02 .... 59 60 @@ -3100,7 +2822,6 @@ function dateFormatter(date, format) { mm: function mm() { return leftPad(this.m(), 2); }, - /** * 分钟 * @example 0 1 2 .... 59 60 @@ -3108,7 +2829,6 @@ function dateFormatter(date, format) { m: function m() { return date.getMinutes().toString(); }, - /** * 秒,保持两位数 * @example 00 01 02 .... 59 60 @@ -3116,7 +2836,6 @@ function dateFormatter(date, format) { ss: function ss() { return leftPad(this.s(), 2); }, - /** * 秒 * @example 0 1 2 .... 59 60 @@ -3133,12 +2852,10 @@ function dateFormatter(date, format) { }); }, format); } - function leftPad(num, width, c) { if (c === void 0) { c = '0'; } - var numStr = num.toString(); var padWidth = width - numStr.length; return padWidth > 0 ? new Array(padWidth + 1).join(c.toString()) + numStr : numStr; @@ -3153,10 +2870,20 @@ var Method = { put: 'PUT' }; -var DefaultRegion = 1; +var CSRF_TOKEN = null; +function createCSRFHeader() { + var _a; + if (CSRF_TOKEN === null) { + var tkeCookie = (_a = Cookies.get('tke')) !== null && _a !== void 0 ? _a : ''; + CSRF_TOKEN = SparkMD5.hash(tkeCookie); + } + return { + 'X-CSRF-TOKEN': CSRF_TOKEN + }; +} +var DefaultRegion = 1; var util = seajs.require('util'); - var getRegionId = function getRegionId() { return DefaultRegion; }; @@ -3165,64 +2892,52 @@ var getProjectName = function getProjectName() { return rId; }; -var isI18nSite = teaApp.i18n.site === 2; // zh 为中文,en为英文 - +// site 1 为 国内站,2为国际站 +var isI18nSite = teaApp.i18n.site === 2; +// zh 为中文,en为英文 var isEngLng = teaApp.i18n.lng === 'en'; /** * 统一的请求处理 * @param userParams: RequestParams */ - var reduceYunApiNetworkRequest = function reduceYunApiNetworkRequest(userParams, clusterId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var method, url, _a, userDefinedHeader, _b, apiParams, rsp, module, regionId, _c, interfaceName, _d, restParams, opts, params, requestRegionId, error_1; - var _e, _f; - return tslib.__generator(this, function (_g) { switch (_g.label) { case 0: - method = userParams.method, url = userParams.url, _a = userParams.userDefinedHeader, userDefinedHeader = _a === void 0 ? {} : _a, _b = userParams.data, apiParams = userParams.apiParams; // 请求tke-apiserver的 cluster的header - + method = userParams.method, url = userParams.url, _a = userParams.userDefinedHeader, userDefinedHeader = _a === void 0 ? {} : _a, _b = userParams.data, apiParams = userParams.apiParams; + // 请求tke-apiserver的 cluster的header if (clusterId) { userDefinedHeader = Object.assign({}, userDefinedHeader, { 'X-TKE-ClusterName': clusterId }); } - module = apiParams.module, regionId = apiParams.regionId, _c = apiParams.interfaceName, interfaceName = _c === void 0 ? 'ForwardRequest' : _c, _d = apiParams.restParams, restParams = _d === void 0 ? {} : _d, opts = apiParams.opts; - params = restParams; // 自定义header,只有forwardRequest 这个请求有用 - + params = restParams; + // 自定义header,只有forwardRequest 这个请求有用 if (userDefinedHeader['Accept']) { params['Accept'] = userDefinedHeader['Accept']; } - if (userDefinedHeader['Content-Type']) { params['ContentType'] = userDefinedHeader['Content-Type']; } - if (userDefinedHeader['X-TKE-ClusterName']) { params['ClusterName'] = userDefinedHeader['X-TKE-ClusterName']; } - params['Language'] = !isEngLng ? 'zh-CN' : 'en-US'; requestRegionId = regionId; - if (isNaN(requestRegionId)) { requestRegionId = getRegionId(); } else { requestRegionId = requestRegionId ? requestRegionId : getRegionId(); } - _g.label = 1; - case 1: _g.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , teaApp.app.capi.requestV3({ + return [4 /*yield*/, teaApp.app.capi.requestV3({ regionId: requestRegionId, serviceType: module, cmd: interfaceName, @@ -3231,22 +2946,15 @@ var reduceYunApiNetworkRequest = function reduceYunApiNetworkRequest(userParams, tipErr: (_e = opts === null || opts === void 0 ? void 0 : opts.tipErr) !== null && _e !== void 0 ? _e : true, tipLoading: (_f = opts === null || opts === void 0 ? void 0 : opts.global) !== null && _f !== void 0 ? _f : false })]; - case 2: rsp = _g.sent(); - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: - error_1 = _g.sent(); //在原来上包了一层data,通过tea.app调用的需要返回error.data - + error_1 = _g.sent(); + //在原来上包了一层data,通过tea.app调用的需要返回error.data throw error_1.data; - case 4: - return [2 - /*return*/ - , reduceYunApiNetworkResponse(rsp, true)]; + return [2 /*return*/, reduceYunApiNetworkResponse(rsp, true)]; } }); }); @@ -3256,14 +2964,12 @@ var reduceYunApiNetworkRequest = function reduceYunApiNetworkRequest(userParams, * @param type 判断当前控制台的类型 * @param response 请求返回的数据 */ - var reduceYunApiNetworkResponse = function reduceYunApiNetworkResponse(response, isApp, interfaceName) { if (isApp === void 0) { isApp = false; } - - var result; // 平台的sdk进行 - + var result; + // 平台的sdk进行 if (isApp) { var finalData = response.data.Response; result = { @@ -3277,8 +2983,8 @@ var reduceYunApiNetworkResponse = function reduceYunApiNetworkResponse(response, result = response; } else { // 此为V3接口的判断 - var rsp = response.Response; // 如果请求发生了错误,其kind为status - + var rsp = response.Response; + // 如果请求发生了错误,其kind为status result = { code: 0, data: rsp, @@ -3286,81 +2992,68 @@ var reduceYunApiNetworkResponse = function reduceYunApiNetworkResponse(response, }; } } - return result; }; /** 获取当前的uuid */ - var uuid$1 = function uuid() { var s = []; var hexDigits = '0123456789abcdef'; - for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } - s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010 - s[19] = hexDigits.substr(s[19] & 0x3 | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 - s[8] = s[13] = s[18] = s[23] = '-'; var uuid = s.join(''); return uuid; }; /** 获取当前控制台modules 的域名匹配项 */ - var GET_CONSOLE_MODULE_BASE_URL = location.origin || ''; /** * 统一的请求处理 * @param userParams: RequestParams */ - var reduceTkeStackNetworkRequest = function reduceTkeStackNetworkRequest(userParams, clusterId, projectId, keyword) { return tslib.__awaiter(void 0, void 0, void 0, function () { - var method, url, _a, userDefinedHeader, _b, data, apiParams, _c, // baseURL = getConsoleAPIAddress(ConsoleModuleAddressEnum.PLATFORM) - baseURL, rsp, pid, searchParams, params, error_1, uuid_1, response; - + var method, url, _a, userDefinedHeader, _b, data, apiParams, _c, + // baseURL = getConsoleAPIAddress(ConsoleModuleAddressEnum.PLATFORM) + baseURL, rsp, pid, searchParams, params, error_1, uuid_1, response; return tslib.__generator(this, function (_d) { switch (_d.label) { case 0: - method = userParams.method, url = userParams.url, _a = userParams.userDefinedHeader, userDefinedHeader = _a === void 0 ? {} : _a, _b = userParams.data, data = _b === void 0 ? {} : _b, apiParams = userParams.apiParams, _c = userParams.baseURL, baseURL = _c === void 0 ? GET_CONSOLE_MODULE_BASE_URL : _c; // 请求tke-apiserver的 cluster的header - + method = userParams.method, url = userParams.url, _a = userParams.userDefinedHeader, userDefinedHeader = _a === void 0 ? {} : _a, _b = userParams.data, data = _b === void 0 ? {} : _b, apiParams = userParams.apiParams, _c = userParams.baseURL, baseURL = _c === void 0 ? GET_CONSOLE_MODULE_BASE_URL : _c; + // 请求tke-apiserver的 cluster的header if (clusterId) { userDefinedHeader = Object.assign({}, userDefinedHeader, { 'X-TKE-ClusterName': clusterId }); } - pid = projectId; - try { searchParams = parseQueryString(location.search); - } catch (error) {} // 这里指定为undefined而不是'',因为业务视图下helm仓库的逻辑有时候不需要传业务id,但会因为这里的逻辑从cookie中读取业务id并传到后端, + } catch (error) {} + // 这里指定为undefined而不是'',因为业务视图下helm仓库的逻辑有时候不需要传业务id,但会因为这里的逻辑从cookie中读取业务id并传到后端, // 导致过滤逻辑出现问题。调用方会显式指定 projectId = '' 来避免这种情况 - - if (pid === undefined) { if (searchParams && (searchParams.projectName || searchParams.projectId)) { pid = searchParams.projectName || searchParams.projectId; } else { pid = getProjectName(); } - } /// #endif - - + } + /// #endif if (pid) { userDefinedHeader = Object.assign({}, { 'X-TKE-ProjectName': pid }, userDefinedHeader); } - if (keyword) { userDefinedHeader = Object.assign({}, userDefinedHeader, { 'X-TKE-FuzzyResourceName': keyword }); } - + console.log(userDefinedHeader, 'userDefinedHeader...'); params = { method: method, baseURL: baseURL, @@ -3371,31 +3064,21 @@ var reduceTkeStackNetworkRequest = function reduceTkeStackNetworkRequest(userPar 'Content-Type': 'application/json' }, userDefinedHeader) }; - if (data) { params = Object.assign({}, params, { data: data }); } - _d.label = 1; - case 1: _d.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , axios(params)]; - + return [4 /*yield*/, axios(params)]; case 2: rsp = _d.sent(); - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: - error_1 = _d.sent(); // 如果返回是 401的话,自动登出,此时是鉴权不过,cookies失效了 - + error_1 = _d.sent(); + // 如果返回是 401的话,自动登出,此时是鉴权不过,cookies失效了 if (error_1.response && error_1.response.status === 401) { location.reload(); } else if (error_1.response && error_1.response.status === 403) { @@ -3415,16 +3098,10 @@ var reduceTkeStackNetworkRequest = function reduceTkeStackNetworkRequest(userPar } else { throw error_1; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: response = reduceTkeStackNetworkResponse(rsp); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); @@ -3434,12 +3111,10 @@ var reduceTkeStackNetworkRequest = function reduceTkeStackNetworkRequest(userPar * @param type 判断当前控制台的类型 * @param response 请求返回的数据 */ - var reduceTkeStackNetworkResponse = function reduceTkeStackNetworkResponse(response) { if (response === void 0) { response = {}; } - var result; result = { code: response.status >= 200 && response.status < 300 ? 0 : response.status, @@ -3451,17 +3126,16 @@ var reduceTkeStackNetworkResponse = function reduceTkeStackNetworkResponse(respo var reduceNetworkRequest = function reduceNetworkRequest(params) { var newParams = tslib.__assign({}, params); - var platform = params === null || params === void 0 ? void 0 : params.platform; - if (platform === PlatformType.TDCC) { return reduceYunApiNetworkRequest(newParams); } else if (platform === PlatformType.TKESTACK) { var _a = newParams === null || newParams === void 0 ? void 0 : newParams.restParams, - ClusterId = _a.ClusterId, - ProjectId = _a.ProjectId; - - return reduceTkeStackNetworkRequest(newParams, ClusterId, ProjectId); + ClusterId = _a.ClusterId, + ProjectId = _a.ProjectId; + return reduceTkeStackNetworkRequest(tslib.__assign(tslib.__assign({}, newParams), { + userDefinedHeader: tslib.__assign(tslib.__assign({}, newParams.userDefinedHeader), createCSRFHeader()) + }), ClusterId, ProjectId); } else { return reduceYunApiNetworkRequest(newParams); } @@ -3471,7 +3145,6 @@ var reduceNetworkRequest = function reduceNetworkRequest(params) { * @param target T[] * @param error any */ - var operationResult = function operationResult(target, error, response) { if (target instanceof Array) { return target.map(function (x) { @@ -3483,7 +3156,6 @@ var operationResult = function operationResult(target, error, response) { }; }); } - return [{ success: !error, target: target, @@ -3493,19 +3165,13 @@ var operationResult = function operationResult(target, error, response) { }; var tips$1 = seajs.require('tips'); - -var RequestResult = -/** @class */ -function () { +var RequestResult = /** @class */function () { function RequestResult() {} - return RequestResult; }(); var RequestApi; - (function (RequestApi) { var _this = this; - RequestApi.SEND = function (args) { return tslib.__awaiter(_this, void 0, void 0, function () { var params, resp, response, error_1, errorMsg; @@ -3515,18 +3181,13 @@ var RequestApi; params = tslib.__assign({}, args); resp = new RequestResult(); _a.label = 1; - case 1: _a.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , reduceNetworkRequest(params)]; - + return [4 /*yield*/, reduceNetworkRequest(params)]; case 2: response = _a.sent(); - - if (response.code !== 0 && // ( + if (response.code !== 0 && + // ( // response.code !== 'ResourceNotFound' || // !response.message?.includes('404') // ) && @@ -3539,41 +3200,30 @@ var RequestApi; resp.error = null; resp.code = response.code; } - - return [2 - /*return*/ - , resp]; - + return [2 /*return*/, resp]; case 3: error_1 = _a.sent(); errorMsg = void 0; - if (args.method !== Method.get) { errorMsg = "\u64CD\u4F5C\u5931\u8D25:" + (error_1 === null || error_1 === void 0 ? void 0 : error_1.message); } else { errorMsg = error_1 === null || error_1 === void 0 ? void 0 : error_1.message; } - - if ( // ( + if ( + // ( // error.code !== 'ResourceNotFound' || // !error.message?.includes('404') // ) && args.method !== Method.get) { tips$1.error(errorMsg, 2000); } - resp.data = args.data; resp.error = error_1 === null || error_1 === void 0 ? void 0 : error_1.message; resp.message = error_1 === null || error_1 === void 0 ? void 0 : error_1.message; resp.code = error_1 === null || error_1 === void 0 ? void 0 : error_1.code; - return [2 - /*return*/ - , resp]; - + return [2 /*return*/, resp]; case 4: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -3587,20 +3237,14 @@ var RequestApi; case 0: args.method = Method.get; args.data = null; - return [4 - /*yield*/ - , RequestApi.SEND(args)]; - + return [4 /*yield*/, RequestApi.SEND(args)]; case 1: response = _a.sent(); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); }; - RequestApi.DELETE = function (args) { return tslib.__awaiter(_this, void 0, void 0, function () { var response; @@ -3609,20 +3253,14 @@ var RequestApi; case 0: args.method = Method["delete"]; args.data = null; - return [4 - /*yield*/ - , RequestApi.SEND(args)]; - + return [4 /*yield*/, RequestApi.SEND(args)]; case 1: response = _a.sent(); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); }; - RequestApi.POST = function (args) { return tslib.__awaiter(_this, void 0, void 0, function () { var response; @@ -3631,20 +3269,14 @@ var RequestApi; case 0: args.method = Method.post; args.data = JSON.stringify(args.data); - return [4 - /*yield*/ - , RequestApi.SEND(args)]; - + return [4 /*yield*/, RequestApi.SEND(args)]; case 1: response = _a.sent(); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); }; - RequestApi.PUT = function (args) { return tslib.__awaiter(_this, void 0, void 0, function () { var response; @@ -3653,20 +3285,14 @@ var RequestApi; case 0: args.method = Method.put; args.data = JSON.stringify(args.data); - return [4 - /*yield*/ - , RequestApi.SEND(args)]; - + return [4 /*yield*/, RequestApi.SEND(args)]; case 1: response = _a.sent(); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); }; - RequestApi.PATCH = function (args) { return tslib.__awaiter(_this, void 0, void 0, function () { var response; @@ -3675,92 +3301,76 @@ var RequestApi; case 0: args.method = Method.patch; args.data = JSON.stringify(args.data); - return [4 - /*yield*/ - , RequestApi.SEND(args)]; - + return [4 /*yield*/, RequestApi.SEND(args)]; case 1: response = _a.sent(); - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); }; })(RequestApi || (RequestApi = {})); +var _a$5, _b$4; var ClusterType; - (function (ClusterType) { ClusterType["TKE"] = "tke"; ClusterType["EKS"] = "eks"; ClusterType["EDGE"] = "tkeedge"; ClusterType["External"] = "external"; })(ClusterType || (ClusterType = {})); - +var ClusterResourceModuleName = (_a$5 = {}, _a$5[ClusterType.TKE] = 'tke', _a$5[ClusterType.EKS] = 'tke', _a$5[ClusterType.EDGE] = 'tke', _a$5[ClusterType.External] = 'tdcc', _a$5); +var ClusterResourceVersionName = (_b$4 = {}, _b$4[ClusterType.TKE] = '2018-05-25', _b$4[ClusterType.EKS] = '2018-05-25', _b$4[ClusterType.EDGE] = '2018-05-25', _b$4[ClusterType.External] = '2022-01-25', _b$4); var ExternalCluster; - (function (ExternalCluster) { var StatusEnum; - (function (StatusEnum) { StatusEnum["Running"] = "Running"; StatusEnum["Failed"] = "Failed"; - StatusEnum["Waiting"] = "Waiting"; // Initializing = 'Initializing', + StatusEnum["Waiting"] = "Waiting"; + // Initializing = 'Initializing', // Confined = 'Confined', // Idling = 'Idling', // Upgrading = 'Upgrading', - - StatusEnum["Terminating"] = "Terminating"; // Upscaling = 'Upscaling', + StatusEnum["Terminating"] = "Terminating"; + // Upscaling = 'Upscaling', // Downscaling = 'Downscaling' })(StatusEnum = ExternalCluster.StatusEnum || (ExternalCluster.StatusEnum = {})); - ExternalCluster.TKEStackDefaultCluster = 'global'; - ExternalCluster.getClusterDetailUrl = function (clusterInfo, regionId) { var _a = clusterInfo || {}, - clusterCategory = _a.clusterCategory, - originalRegion = _a.originalRegion, - originalClusterId = _a.originalClusterId; - + clusterCategory = _a.clusterCategory, + originalRegion = _a.originalRegion, + originalClusterId = _a.originalClusterId; var url = "/tke2/external/sub/list/basic/info?rid=".concat(regionId, "&clusterId=").concat(clusterInfo === null || clusterInfo === void 0 ? void 0 : clusterInfo.clusterId); - if (clusterCategory && originalRegion && originalClusterId) { switch (clusterCategory) { case 'tke': url = "/tke2/cluster/sub/list/basic/info?rid=".concat(originalRegion, "&clusterId=").concat(originalClusterId); break; - case 'eks': url = "/tke2/ecluster/sub/list/basic/info?rid=".concat(originalRegion, "&clusterId=").concat(originalClusterId); break; - case 'tkeedge': url = "/tke2/edge/sub/list/basic/info?rid=".concat(originalRegion, "&clusterId=").concat(originalClusterId); break; } } - return url; }; })(ExternalCluster || (ExternalCluster = {})); -var tips$2 = seajs.require('tips'); // 获取应用实例列表 - - +var tips$2 = seajs.require('tips'); +// 获取应用实例列表 var fetchHubCluster = function fetchHubCluster(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, regionId, platform, params, response, result; - var _a, _b, _c, _d; - return tslib.__generator(this, function (_e) { switch (_e.label) { case 0: userDefinedHeader = {}; regionId = queryParams.regionId, platform = queryParams.platform; - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -3789,18 +3399,13 @@ var fetchHubCluster = function fetchHubCluster(queryParams) { } }; } - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 1: response = _e.sent(); result = { records: [], recordCount: 0 }; - if (platform === PlatformType.TDCC) { result.records = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Clusters) === null || _b === void 0 ? void 0 : _b.map(function (cluster) { return { @@ -3822,29 +3427,23 @@ var fetchHubCluster = function fetchHubCluster(queryParams) { name: 'global' }]; } - result.recordCount = (_d = result === null || result === void 0 ? void 0 : result.records) === null || _d === void 0 ? void 0 : _d.length; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); -}; // 获取应用实例列表 - +}; +// 获取应用实例列表 var fetchOpenedServices = function fetchOpenedServices(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, params, namespace, response, result, error_1; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return tslib.__generator(this, function (_m) { switch (_m.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform; namespace = SystemNamespace; - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -3875,23 +3474,16 @@ var fetchOpenedServices = function fetchOpenedServices(queryParams) { platform: platform }; } - result = { records: [], recordCount: 0 }; _m.label = 1; - case 1: _m.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _m.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { result.records = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Vendors) === null || _b === void 0 ? void 0 : _b.map(function (item) { @@ -3913,9 +3505,8 @@ var fetchOpenedServices = function fetchOpenedServices(queryParams) { clusters: [ExternalCluster === null || ExternalCluster === void 0 ? void 0 : ExternalCluster.TKEStackDefaultCluster] }; })) !== null && _g !== void 0 ? _g : []; - } // 过滤掉未开启的中间件服务 - - + } + // 过滤掉未开启的中间件服务 result.records = (_h = result === null || result === void 0 ? void 0 : result.records) === null || _h === void 0 ? void 0 : _h.filter(function (item) { return item === null || item === void 0 ? void 0 : item.enabled; }); @@ -3925,29 +3516,18 @@ var fetchOpenedServices = function fetchOpenedServices(queryParams) { } else { result['hasError'] = true; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_1 = _m.sent(); - if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.code) === 404 || ((_l = error_1 === null || error_1 === void 0 ? void 0 : error_1.message) === null || _l === void 0 ? void 0 : _l.includes('404'))) { result['hasError'] = platform === PlatformType.TKESTACK ? false : true; } else { result['hasError'] = true; throw error_1; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -3955,11 +3535,9 @@ var fetchOpenedServices = function fetchOpenedServices(queryParams) { var fetchServiceResources = function fetchServiceResources(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, serviceName, _a, resourceType, paging, search, k8sQueryObj, params, extendParams, result, url, queryString, response, instances, error_2, keys, propertyKeys_1, pageIndex, pageSize, maxPageIndex; - - var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; - - return tslib.__generator(this, function (_v) { - switch (_v.label) { + var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; + return tslib.__generator(this, function (_w) { + switch (_w.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, _a = queryParams.resourceType, resourceType = _a === void 0 ? ResourceTypeEnum.ServiceResource : _a, paging = queryParams.paging, search = queryParams.search, k8sQueryObj = queryParams.k8sQueryObj; @@ -3968,7 +3546,6 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { records: [], recordCount: 0 }; - if ([ResourceTypeEnum.Backup, ResourceTypeEnum.ServiceBinding].includes(resourceType)) { extendParams = { Path: "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(SystemNamespace, "/").concat((_b = ResourceTypeMap[resourceType]) === null || _b === void 0 ? void 0 : _b.path), @@ -3982,7 +3559,6 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { Method: undefined }; } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4003,7 +3579,6 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { }; } else if (platform === PlatformType.TKESTACK) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_c = ResourceTypeMap[resourceType]) === null || _c === void 0 ? void 0 : _c.path); - if (k8sQueryObj) { queryString = reduceK8sQueryString({ k8sQueryObj: k8sQueryObj, @@ -4011,7 +3586,6 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { }); url = url + queryString; } - params = { userDefinedHeader: userDefinedHeader, url: url, @@ -4022,19 +3596,12 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { platform: platform }; } - - _v.label = 1; - + _w.label = 1; case 1: - _v.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + _w.trys.push([1, 3,, 4]); + return [4 /*yield*/, RequestApi.GET(params)]; case 2: - response = _v.sent(); - + response = _w.sent(); if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { instances = JSON.parse(resourceType === ResourceTypeEnum.ServiceResource ? (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.Instances : (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.Plans); @@ -4042,49 +3609,38 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { } else { result.records = (_j = (_h = (_g = response === null || response === void 0 ? void 0 : response.data) === null || _g === void 0 ? void 0 : _g.items) === null || _h === void 0 ? void 0 : _h.filter(function (item) { var _a; - return ((_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass) === serviceName; })) !== null && _j !== void 0 ? _j : []; } } else { result['hasError'] = true; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: - error_2 = _v.sent(); + error_2 = _w.sent(); result['hasError'] = true; - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: // 前端过滤 if (search) { result.records = (_k = result.records) === null || _k === void 0 ? void 0 : _k.filter(function (item) { var _a, _b; - return (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes(search); }); - } // 非metadata?.name属性,需要前端自己进行过滤显示 - - + } + // 非metadata?.name属性,需要前端自己进行过滤显示 if (k8sQueryObj && (k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector) && !((_l = Object === null || Object === void 0 ? void 0 : Object.keys(k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector)) === null || _l === void 0 ? void 0 : _l.includes('metadata.name'))) { keys = Object === null || Object === void 0 ? void 0 : Object.keys(k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector); propertyKeys_1 = (_m = keys[0]) === null || _m === void 0 ? void 0 : _m.split('.'); result.records = (_o = result.records) === null || _o === void 0 ? void 0 : _o.filter(function (item) { var _a; - return (_a = Object.keys(k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector)) === null || _a === void 0 ? void 0 : _a.every(function (key) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item[propertyKeys_1 === null || propertyKeys_1 === void 0 ? void 0 : propertyKeys_1[0]]) === null || _a === void 0 ? void 0 : _a[propertyKeys_1[1]]) === ((_b = k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector) === null || _b === void 0 ? void 0 : _b[key]); }); }); - } // 过滤 + } + // 过滤 // if(instanceId){ // result.records = result?.records?.filter((item) => { // return resourceType === ResourceTypeEnum?.Backup ? @@ -4099,36 +3655,36 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { // ); // }); // } - // 按照创建时间降序排列 - - - result.records = (_p = result.records) === null || _p === void 0 ? void 0 : _p.sort(function (pre, cur) { - var _a, _b, _c, _d; - - return ((_b = new Date((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp)) === null || _b === void 0 ? void 0 : _b.getTime()) - ((_d = new Date((_c = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _c === void 0 ? void 0 : _c.creationTimestamp)) === null || _d === void 0 ? void 0 : _d.getTime()); - }); // 统计总数 - - result.recordCount = (_r = (_q = result.records) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0; // 前端分页 - + //servicePlan首先按照规格类型自定义、预设顺序排序 + if (resourceType === ResourceTypeEnum.ServicePlan) { + result.records = (_p = result.records) === null || _p === void 0 ? void 0 : _p.sort(function (pre, cur) { + var _a, _b, _c, _d, _e; + return (_c = (_b = (_a = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/owner']) === null || _c === void 0 ? void 0 : _c.localeCompare((_e = (_d = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _d === void 0 ? void 0 : _d.labels) === null || _e === void 0 ? void 0 : _e['ssm.infra.tce.io/owner'], 'zh-CN'); + }); + } else { + // 按照创建时间降序排列 + result.records = (_q = result.records) === null || _q === void 0 ? void 0 : _q.sort(function (pre, cur) { + var _a, _b, _c, _d; + return ((_b = new Date((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp)) === null || _b === void 0 ? void 0 : _b.getTime()) - ((_d = new Date((_c = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _c === void 0 ? void 0 : _c.creationTimestamp)) === null || _d === void 0 ? void 0 : _d.getTime()); + }); + } + // 统计总数 + result.recordCount = (_s = (_r = result.records) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 0; + // 前端分页 if (paging) { - pageIndex = (_s = paging === null || paging === void 0 ? void 0 : paging.pageIndex) !== null && _s !== void 0 ? _s : 1; - pageSize = (_t = paging === null || paging === void 0 ? void 0 : paging.pageSize) !== null && _t !== void 0 ? _t : 20; - maxPageIndex = Math.ceil(((_u = result.records) === null || _u === void 0 ? void 0 : _u.length) / pageSize); - + pageIndex = (_t = paging === null || paging === void 0 ? void 0 : paging.pageIndex) !== null && _t !== void 0 ? _t : 1; + pageSize = (_u = paging === null || paging === void 0 ? void 0 : paging.pageSize) !== null && _u !== void 0 ? _u : 20; + maxPageIndex = Math.ceil(((_v = result.records) === null || _v === void 0 ? void 0 : _v.length) / pageSize); if (pageIndex > maxPageIndex) { pageIndex = maxPageIndex; } - if (pageIndex === 1) { result.records = result.records.slice(pageIndex - 1, pageIndex * pageSize); } else { result.records = result.records.slice((pageIndex - 1) * pageSize, pageIndex * pageSize); } } - - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -4138,20 +3694,16 @@ var fetchServiceResources = function fetchServiceResources(queryParams) { * @param queryParams * @returns */ - var fetchResourceSchemas = function fetchResourceSchemas(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, regionId, platform, serviceName, clusterId, params, url, response, result, responseBody, error_3; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; - return tslib.__generator(this, function (_v) { switch (_v.label) { case 0: userDefinedHeader = {}; regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, clusterId = queryParams.clusterId; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/serviceclasses/").concat(serviceName); - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4184,41 +3736,27 @@ var fetchResourceSchemas = function fetchResourceSchemas(queryParams) { platform: platform }; } - _v.label = 1; - case 1: _v.trys.push([1, 3,, 4]); - responseBody = void 0; - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _v.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { responseBody = JSON.parse((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.ResponseBody); } else { responseBody = response === null || response === void 0 ? void 0 : response.data; } - result = { - // instanceCreateParameterSchema: responseBody?.spec?.instanceCreateParameterSchema?.map(item => ({...item,value:formatPlanSchemaData(item?.type,item?.default),unit:formatPlanSchemaUnit(item,item?.default), - // })), // 后端暂不支持kafka的依赖 zk 的来源为new的场景,故临时过滤掉new选项 instanceCreateParameterSchema: (_c = (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.spec) === null || _b === void 0 ? void 0 : _b.instanceCreateParameterSchema) === null || _c === void 0 ? void 0 : _c.map(function (item) { var _a; - var candidates = (_a = item === null || item === void 0 ? void 0 : item.candidates) === null || _a === void 0 ? void 0 : _a.filter(function (candidate) { if ((item === null || item === void 0 ? void 0 : item.name) === 'dep_zk_source') { return candidate !== 'new'; - } // else if(platform === PlatformType?.TKESTACK && item?.name === 'scope'){ - // return candidate !== 'global'; - // } - else { + } else { return true; } }); @@ -4266,19 +3804,12 @@ var fetchResourceSchemas = function fetchResourceSchemas(queryParams) { } else { throw response; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_3 = _v.sent(); throw error_3; - case 4: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -4288,19 +3819,15 @@ var fetchResourceSchemas = function fetchResourceSchemas(queryParams) { * @param queryParams * @returns */ - var fetchExternalClusters = function fetchExternalClusters(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, regionId, platform, clusterIds, _a, regional, params, url, response, result, error_5; - var _b, _c, _d, _e, _f, _g, _h; - return tslib.__generator(this, function (_j) { switch (_j.label) { case 0: userDefinedHeader = {}; regionId = queryParams.regionId, platform = queryParams.platform, clusterIds = queryParams.clusterIds, _a = queryParams.regional, regional = _a === void 0 ? false : _a; - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4335,23 +3862,16 @@ var fetchExternalClusters = function fetchExternalClusters(queryParams) { platform: platform }; } - result = { records: [], recordCount: 0 }; _j.label = 1; - case 1: _j.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _j.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { result.records = (_d = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.Clusters) === null || _c === void 0 ? void 0 : _c.map(function (item) { @@ -4364,7 +3884,6 @@ var fetchExternalClusters = function fetchExternalClusters(queryParams) { } else { result.records = (_g = (_f = (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.items) === null || _f === void 0 ? void 0 : _f.map(function (item) { var _a, _b, _c; - return { clusterId: (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name, status: (_b = item === null || item === void 0 ? void 0 : item.status) === null || _b === void 0 ? void 0 : _b.phase, @@ -4377,23 +3896,14 @@ var fetchExternalClusters = function fetchExternalClusters(queryParams) { } else { result['hasError'] = true; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_5 = _j.sent(); result['hasError'] = true; - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: result.recordCount = (_h = result === null || result === void 0 ? void 0 : result.records) === null || _h === void 0 ? void 0 : _h.length; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -4403,28 +3913,22 @@ var fetchExternalClusters = function fetchExternalClusters(queryParams) { * @param queryParams * @returns */ - var createServiceResource = function createServiceResource(resource, regionId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, _a, clusterId, jsonData, platform, _b, resourceType, instanceName, specificOperate, _c, namespace, params, url, response; - var _d, _e; - return tslib.__generator(this, function (_f) { switch (_f.label) { case 0: userDefinedHeader = {}; _a = resource === null || resource === void 0 ? void 0 : resource[0], clusterId = _a.clusterId, jsonData = _a.jsonData, platform = _a.platform, _b = _a.resourceType, resourceType = _b === void 0 ? ResourceTypeEnum.ServiceResource : _b, instanceName = _a.instanceName, specificOperate = _a.specificOperate, _c = _a.namespace, namespace = _c === void 0 ? SystemNamespace : _c; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_d = ResourceTypeMap[resourceType]) === null || _d === void 0 ? void 0 : _d.path); - if (resourceType === ResourceTypeEnum.ServicePlan) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_e = ResourceTypeMap[resourceType]) === null || _e === void 0 ? void 0 : _e.path); } - if (instanceName) { url += "/".concat(instanceName); } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4460,34 +3964,19 @@ var createServiceResource = function createServiceResource(resource, regionId) { data: JSON.parse(jsonData) }; } - - return [4 - /*yield*/ - , RequestApi.POST(params)]; - + return [4 /*yield*/, RequestApi.POST(params)]; case 1: response = _f.sent(); - try { if ((response === null || response === void 0 ? void 0 : response.code) === 0) { specificOperate && specificOperate !== CreateSpecificOperatorEnum.CreateResource && tips$2.success(CreateSpecificOperatorMap === null || CreateSpecificOperatorMap === void 0 ? void 0 : CreateSpecificOperatorMap[specificOperate].msg); - return [2 - /*return*/ - , operationResult(resource)]; + return [2 /*return*/, operationResult(resource)]; } - - return [2 - /*return*/ - , operationResult(resource, response)]; + return [2 /*return*/, operationResult(resource, response)]; } catch (error) { - return [2 - /*return*/ - , operationResult(resource, error)]; + return [2 /*return*/, operationResult(resource, error)]; } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -4497,13 +3986,10 @@ var createServiceResource = function createServiceResource(resource, regionId) { * @param queryParams * @returns */ - var updateServiceResource = function updateServiceResource(resource, regionId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, _a, clusterId, jsonData, platform, _b, resourceType, instanceName, _c, namespace, params, url, response; - var _d, _e; - return tslib.__generator(this, function (_f) { switch (_f.label) { case 0: @@ -4512,15 +3998,12 @@ var updateServiceResource = function updateServiceResource(resource, regionId) { }; _a = resource === null || resource === void 0 ? void 0 : resource[0], clusterId = _a.clusterId, jsonData = _a.jsonData, platform = _a.platform, _b = _a.resourceType, resourceType = _b === void 0 ? ResourceTypeEnum.ServiceResource : _b, instanceName = _a.instanceName, _c = _a.namespace, namespace = _c === void 0 ? SystemNamespace : _c; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_d = ResourceTypeMap[resourceType]) === null || _d === void 0 ? void 0 : _d.path); - if (resourceType === ResourceTypeEnum.ServicePlan) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_e = ResourceTypeMap[resourceType]) === null || _e === void 0 ? void 0 : _e.path); } - if (instanceName) { url += "/".concat(instanceName); } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4556,51 +4039,34 @@ var updateServiceResource = function updateServiceResource(resource, regionId) { platform: platform }; } - - return [4 - /*yield*/ - , RequestApi.PATCH(params)]; - + return [4 /*yield*/, RequestApi.PATCH(params)]; case 1: response = _f.sent(); - try { if (platform === PlatformType.TDCC) {} else {} - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { tips$2.success(i18n.t('编辑成功')); - return [2 - /*return*/ - , operationResult(resource)]; + return [2 /*return*/, operationResult(resource)]; } - - return [2 - /*return*/ - , operationResult(resource, response)]; + return [2 /*return*/, operationResult(resource, response)]; } catch (error) { - return [2 - /*return*/ - , operationResult(resource, error)]; + return [2 /*return*/, operationResult(resource, error)]; } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); }; + var deleteMulServiceResource = function deleteMulServiceResource(resource, regionId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, platform, resourceType, resourceInfos, namespace, allRequests, result, errorResponse; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: _a = resource === null || resource === void 0 ? void 0 : resource[0], clusterId = _a.clusterId, platform = _a.platform, resourceType = _a.resourceType, resourceInfos = _a.resourceInfos, namespace = _a.namespace; allRequests = resourceInfos === null || resourceInfos === void 0 ? void 0 : resourceInfos.map(function (item) { var _a; - return (_a = deleteServiceResource({ platform: platform, clusterId: clusterId, @@ -4614,28 +4080,18 @@ var deleteMulServiceResource = function deleteMulServiceResource(resource, regio return error; }); }); - return [4 - /*yield*/ - , Promise.all(allRequests)]; - + return [4 /*yield*/, Promise.all(allRequests)]; case 1: result = _b.sent(); errorResponse = result === null || result === void 0 ? void 0 : result.find(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item[0]) === null || _a === void 0 ? void 0 : _a.error) || !((_b = item === null || item === void 0 ? void 0 : item[0]) === null || _b === void 0 ? void 0 : _b.success); }); - if (!errorResponse) { tips$2.success(i18n.t('删除成功')); - return [2 - /*return*/ - , operationResult(resource)]; + return [2 /*return*/, operationResult(resource)]; } - - return [2 - /*return*/ - , operationResult(resource, errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error)]; + return [2 /*return*/, operationResult(resource, errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error)]; } }); }); @@ -4645,13 +4101,10 @@ var deleteMulServiceResource = function deleteMulServiceResource(resource, regio * @param queryParams * @returns */ - var deleteServiceResource = function deleteServiceResource(resource, regionId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, platform, resourceInfo, resourceType, instanceName, namespace, params, url, response; - var _a, _b, _c, _d, _e, _f, _g; - return tslib.__generator(this, function (_h) { switch (_h.label) { case 0: @@ -4661,15 +4114,12 @@ var deleteServiceResource = function deleteServiceResource(resource, regionId) { instanceName = (_b = resource === null || resource === void 0 ? void 0 : resource.resourceIns) !== null && _b !== void 0 ? _b : (_c = resourceInfo === null || resourceInfo === void 0 ? void 0 : resourceInfo.metadata) === null || _c === void 0 ? void 0 : _c.name; namespace = (_d = resource === null || resource === void 0 ? void 0 : resource.namespace) !== null && _d !== void 0 ? _d : (_e = resourceInfo === null || resourceInfo === void 0 ? void 0 : resourceInfo.metadata) === null || _e === void 0 ? void 0 : _e.namespace; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_f = ResourceTypeMap[resourceType]) === null || _f === void 0 ? void 0 : _f.path); - if (resourceType === ResourceTypeEnum.ServicePlan) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_g = ResourceTypeMap[resourceType]) === null || _g === void 0 ? void 0 : _g.path); } - if (instanceName) { url += "/".concat(instanceName); } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4703,33 +4153,18 @@ var deleteServiceResource = function deleteServiceResource(resource, regionId) { method: Method["delete"] }; } - - return [4 - /*yield*/ - , RequestApi.DELETE(params)]; - + return [4 /*yield*/, RequestApi.DELETE(params)]; case 1: response = _h.sent(); - try { if ((response === null || response === void 0 ? void 0 : response.code) === 0) { - return [2 - /*return*/ - , operationResult(resource)]; + return [2 /*return*/, operationResult(resource)]; } - - return [2 - /*return*/ - , operationResult(resource, response)]; + return [2 /*return*/, operationResult(resource, response)]; } catch (error) { - return [2 - /*return*/ - , operationResult(resource, error)]; + return [2 /*return*/, operationResult(resource, error)]; } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -4739,32 +4174,25 @@ var deleteServiceResource = function deleteServiceResource(resource, regionId) { * @param queryParams * @returns */ - var fetchServiceResourceDetail = function fetchServiceResourceDetail(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, serviceName, resourceIns, _a, resourceType, _b, namespace, params, url, response, result, responseBody; - var _c, _d, _e, _f, _g, _h, _j, _k; - return tslib.__generator(this, function (_l) { switch (_l.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, resourceIns = queryParams.resourceIns, _a = queryParams.resourceType, resourceType = _a === void 0 ? ResourceTypeEnum.ServiceResource : _a, _b = queryParams.namespace, namespace = _b === void 0 ? SystemNamespace : _b; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_c = ResourceTypeMap[resourceType]) === null || _c === void 0 ? void 0 : _c.path); - if (resourceType === ResourceTypeEnum.ServicePlan) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_d = ResourceTypeMap[resourceType]) === null || _d === void 0 ? void 0 : _d.path); } - if (resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.Secret)) { url = "/api/v1/namespaces/".concat(namespace, "/secrets"); } - if (resourceIns) { url += "?fieldSelector=metadata.name=".concat(resourceIns); } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4797,34 +4225,24 @@ var fetchServiceResourceDetail = function fetchServiceResourceDetail(queryParams platform: platform }; } - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 1: response = _l.sent(); - try { if (platform === PlatformType.TDCC) { responseBody = JSON.parse((_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.ResponseBody); result = (_g = (_f = responseBody === null || responseBody === void 0 ? void 0 : responseBody.items) === null || _f === void 0 ? void 0 : _f.filter(function (item) { var _a; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === resourceIns; })) === null || _g === void 0 ? void 0 : _g[0]; } else { result = (_k = (_j = (_h = response === null || response === void 0 ? void 0 : response.data) === null || _h === void 0 ? void 0 : _h.items) === null || _j === void 0 ? void 0 : _j.filter(function (item) { var _a; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === resourceIns; })) === null || _k === void 0 ? void 0 : _k[0]; } } catch (error) {} - - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -4834,11 +4252,9 @@ var fetchServiceResourceDetail = function fetchServiceResourceDetail(queryParams * @param queryParams * @returns */ - var openInstanceConsole = function openInstanceConsole(resource, regionId) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, _a, clusterId, platform, instanceName, jsonData, serviceName, isOpen, params, url, response; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: @@ -4847,7 +4263,6 @@ var openInstanceConsole = function openInstanceConsole(resource, regionId) { }; _a = resource === null || resource === void 0 ? void 0 : resource[0], clusterId = _a.clusterId, platform = _a.platform, instanceName = _a.instanceName, jsonData = _a.jsonData, serviceName = _a.serviceName, isOpen = _a.isOpen; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(SystemNamespace, "/serviceinstances/").concat(instanceName); - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4881,38 +4296,22 @@ var openInstanceConsole = function openInstanceConsole(resource, regionId) { platform: platform }; } - - return [4 - /*yield*/ - , RequestApi.POST(params)]; - + return [4 /*yield*/, RequestApi.POST(params)]; case 1: response = _b.sent(); - try { if (platform === PlatformType.TDCC) {} else {} - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { tips$2.success(isOpen ? i18n.t('安装成功') : i18n.t('卸载成功')); - return [2 - /*return*/ - , operationResult(resource)]; + return [2 /*return*/, operationResult(resource)]; } - tips$2.error(response === null || response === void 0 ? void 0 : response.message); - return [2 - /*return*/ - , operationResult(resource, response)]; + return [2 /*return*/, operationResult(resource, response)]; } catch (error) { tips$2.error(error); - return [2 - /*return*/ - , operationResult(resource, error)]; + return [2 /*return*/, operationResult(resource, error)]; } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -4922,27 +4321,22 @@ var openInstanceConsole = function openInstanceConsole(resource, regionId) { * @param queryParams * @returns */ - var fetchInstanceResources = function fetchInstanceResources(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, serviceName, _a, resourceType, resourceIns, instanceId, k8sQueryObj, paging, _b, namespace, params, url, queryString, response, result, responseBody, error_6, keys, propertyKeys_2, pageIndex, pageSize, maxPageIndex; - var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s; - return tslib.__generator(this, function (_t) { switch (_t.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, _a = queryParams.resourceType, resourceType = _a === void 0 ? ResourceTypeEnum.ServiceResource : _a, resourceIns = queryParams.resourceIns, instanceId = queryParams.instanceId, k8sQueryObj = queryParams.k8sQueryObj, paging = queryParams.paging, _b = queryParams.namespace, namespace = _b === void 0 ? SystemNamespace : _b; url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_c = ResourceTypeMap[resourceType]) === null || _c === void 0 ? void 0 : _c.path); - if (resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding)) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/").concat((_d = ResourceTypeMap[resourceType]) === null || _d === void 0 ? void 0 : _d.path); } else if (resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.Backup)) { url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/sso/serviceopsbackups"); - } //目前query参数查询只支持labelSelector - - + } + //目前query参数查询只支持labelSelector if (k8sQueryObj && (k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.labelSelector)) { queryString = reduceK8sQueryString({ k8sQueryObj: k8sQueryObj, @@ -4950,7 +4344,6 @@ var fetchInstanceResources = function fetchInstanceResources(queryParams) { }); url = url + queryString; } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -4984,23 +4377,16 @@ var fetchInstanceResources = function fetchInstanceResources(queryParams) { platform: platform }; } - result = { records: [], recordCount: 0 }; _t.label = 1; - case 1: _t.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _t.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { responseBody = JSON.parse((_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.ResponseBody); @@ -5011,18 +4397,11 @@ var fetchInstanceResources = function fetchInstanceResources(queryParams) { } else { result['hasError'] = true; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_6 = _t.sent(); result['hasError'] = true; - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: // 非metadata?.name属性,需要前端自己进行过滤显示 if (k8sQueryObj && (k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector) && !((_j = Object === null || Object === void 0 ? void 0 : Object.keys(k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector)) === null || _j === void 0 ? void 0 : _j.includes('metadata.name'))) { @@ -5030,51 +4409,40 @@ var fetchInstanceResources = function fetchInstanceResources(queryParams) { propertyKeys_2 = (_k = keys[0]) === null || _k === void 0 ? void 0 : _k.split('.'); result.records = (_l = result.records) === null || _l === void 0 ? void 0 : _l.filter(function (item) { var _a; - return (_a = Object.keys(k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector)) === null || _a === void 0 ? void 0 : _a.every(function (key) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item[propertyKeys_2 === null || propertyKeys_2 === void 0 ? void 0 : propertyKeys_2[0]]) === null || _a === void 0 ? void 0 : _a[propertyKeys_2[1]]) === ((_b = k8sQueryObj === null || k8sQueryObj === void 0 ? void 0 : k8sQueryObj.fieldSelector) === null || _b === void 0 ? void 0 : _b[key]); }); }); - } // 过滤 - - + } + // 过滤 if (instanceId) { result.records = (_m = result === null || result === void 0 ? void 0 : result.records) === null || _m === void 0 ? void 0 : _m.filter(function (item) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - return resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.Backup) ? ((_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.instanceID) === instanceId || ((_d = (_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/instanceId']) === instanceId || ((_f = (_e = item === null || item === void 0 ? void 0 : item.metadata) === null || _e === void 0 ? void 0 : _e.labels) === null || _f === void 0 ? void 0 : _f['ssm.infra.tce.io/instance-id']) === instanceId : ((_h = (_g = item === null || item === void 0 ? void 0 : item.metadata) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h['ssm.infra.tce.io/instanceId']) === instanceId || ((_k = (_j = item === null || item === void 0 ? void 0 : item.metadata) === null || _j === void 0 ? void 0 : _j.labels) === null || _k === void 0 ? void 0 : _k['ssm.infra.tce.io/instance-id']) === instanceId; }); - } // 按照时间降序排序 - - + } + // 按照时间降序排序 result.records = (_o = result.records) === null || _o === void 0 ? void 0 : _o.sort(function (pre, cur) { var _a, _b, _c, _d; - return ((_b = new Date((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp)) === null || _b === void 0 ? void 0 : _b.getTime()) - ((_d = new Date((_c = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _c === void 0 ? void 0 : _c.creationTimestamp)) === null || _d === void 0 ? void 0 : _d.getTime()); }); - result.recordCount = (_p = result === null || result === void 0 ? void 0 : result.records) === null || _p === void 0 ? void 0 : _p.length; // 前端分页 - + result.recordCount = (_p = result === null || result === void 0 ? void 0 : result.records) === null || _p === void 0 ? void 0 : _p.length; + // 前端分页 if (paging) { pageIndex = (_q = paging === null || paging === void 0 ? void 0 : paging.pageIndex) !== null && _q !== void 0 ? _q : 1; pageSize = (_r = paging === null || paging === void 0 ? void 0 : paging.pageSize) !== null && _r !== void 0 ? _r : 20; maxPageIndex = Math.ceil(((_s = result.records) === null || _s === void 0 ? void 0 : _s.length) / pageSize); - if (pageIndex > maxPageIndex) { pageIndex = maxPageIndex; } - if (pageIndex === 1) { result.records = result.records.slice(pageIndex - 1, pageIndex * pageSize); } else { result.records = result.records.slice((pageIndex - 1) * pageSize, pageIndex * pageSize); } } - - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -5084,20 +4452,16 @@ var fetchInstanceResources = function fetchInstanceResources(queryParams) { * @param queryParams * @returns */ - var checkCosResource = function checkCosResource(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, platform, regionId, k8sQueryObj, params, url, queryString, response, result; - var _a; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, platform = queryParams.platform, regionId = queryParams.regionId, k8sQueryObj = queryParams.k8sQueryObj; url = "/api/v1/namespaces/ssm/secrets/backup-cos"; - if (k8sQueryObj) { queryString = reduceK8sQueryString({ k8sQueryObj: k8sQueryObj, @@ -5105,7 +4469,6 @@ var checkCosResource = function checkCosResource(queryParams) { }); url = url + queryString; } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -5138,14 +4501,9 @@ var checkCosResource = function checkCosResource(queryParams) { platform: platform }; } - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 1: response = _b.sent(); - try { if (platform === PlatformType.TDCC) { result = JSON.parse((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.ResponseBody); @@ -5153,10 +4511,7 @@ var checkCosResource = function checkCosResource(queryParams) { result = response === null || response === void 0 ? void 0 : response.data; } } catch (error) {} - - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -5166,20 +4521,16 @@ var checkCosResource = function checkCosResource(queryParams) { * @param queryParams * @returns */ - var fetchNamespaces = function fetchNamespaces(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, serviceName, k8sQueryObj, params, url, queryString, response, result, responseBody, error_7; - var _a, _b, _c, _d, _e, _f; - return tslib.__generator(this, function (_g) { switch (_g.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, k8sQueryObj = queryParams.k8sQueryObj; url = '/api/v1/namespaces'; - if (k8sQueryObj) { queryString = reduceK8sQueryString({ k8sQueryObj: k8sQueryObj, @@ -5187,7 +4538,6 @@ var fetchNamespaces = function fetchNamespaces(queryParams) { }); url = url + queryString; } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -5220,23 +4570,16 @@ var fetchNamespaces = function fetchNamespaces(queryParams) { platform: platform }; } - result = { records: [], recordCount: 0 }; _g.label = 1; - case 1: _g.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _g.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { responseBody = JSON.parse((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.ResponseBody); @@ -5247,29 +4590,19 @@ var fetchNamespaces = function fetchNamespaces(queryParams) { } else { result['hasError'] = true; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_7 = _g.sent(); result['hasError'] = true; - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: //过滤掉指定的命名空间 result.records = (_e = result === null || result === void 0 ? void 0 : result.records) === null || _e === void 0 ? void 0 : _e.filter(function (item) { var _a; - return !(ExcludeNamespaces === null || ExcludeNamespaces === void 0 ? void 0 : ExcludeNamespaces.includes((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name)); }); result.recordCount = (_f = result === null || result === void 0 ? void 0 : result.records) === null || _f === void 0 ? void 0 : _f.length; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -5277,16 +4610,13 @@ var fetchNamespaces = function fetchNamespaces(queryParams) { var fetchUserInfo = function fetchUserInfo(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var url, userDefinedHeader, platform, params, result, response, error_8; - var _a; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: url = ''; userDefinedHeader = {}; platform = queryParams.platform; - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -5317,37 +4647,23 @@ var fetchUserInfo = function fetchUserInfo(queryParams) { platform: platform }; } - _b.label = 1; - case 1: _b.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _b.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) ; else { result = (_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : {}; } } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_8 = _b.sent(); throw error_8; - case 4: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -5357,26 +4673,23 @@ var fetchUserInfo = function fetchUserInfo(queryParams) { * @param queryParams * @returns */ - var fetchBackStrategy = function fetchBackStrategy(queryParams) { return tslib.__awaiter(void 0, void 0, void 0, function () { var userDefinedHeader, clusterId, regionId, platform, serviceName, instanceId, _a, resourceType, k8sQueryObj, params, namespace, url, response, result, responseBody, error_9; - var _b, _c, _d, _e, _f, _g, _h; - return tslib.__generator(this, function (_j) { switch (_j.label) { case 0: userDefinedHeader = {}; clusterId = queryParams.clusterId, regionId = queryParams.regionId, platform = queryParams.platform, serviceName = queryParams.serviceName, instanceId = queryParams.instanceId, _a = queryParams.resourceType, resourceType = _a === void 0 ? ResourceTypeEnum.ServiceResource : _a, k8sQueryObj = queryParams.k8sQueryObj; namespace = SystemNamespace; - url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_b = ResourceTypeMap[resourceType]) === null || _b === void 0 ? void 0 : _b.path); //目前query参数查询只支持labelSelector + url = "/apis/platform.tkestack.io/v1/clusters/".concat(clusterId, "/proxy?path=/apis/infra.tce.io/v1/namespaces/").concat(namespace, "/").concat((_b = ResourceTypeMap[resourceType]) === null || _b === void 0 ? void 0 : _b.path); + //目前query参数查询只支持labelSelector // if (k8sQueryObj && k8sQueryObj?.labelSelector) { // // 这里是去拼接,是否需要在k8s url后面拼接一些queryString // const queryString = reduceK8sQueryString({ k8sQueryObj, restfulPath: url }); // url = url + queryString; // } - if (platform === PlatformType.TDCC) { params = { userDefinedHeader: userDefinedHeader, @@ -5409,84 +4722,125 @@ var fetchBackStrategy = function fetchBackStrategy(queryParams) { platform: platform }; } - _j.label = 1; - case 1: _j.trys.push([1, 3,, 4]); - - return [4 - /*yield*/ - , RequestApi.GET(params)]; - + return [4 /*yield*/, RequestApi.GET(params)]; case 2: response = _j.sent(); - if ((response === null || response === void 0 ? void 0 : response.code) === 0) { if (platform === PlatformType.TDCC) { responseBody = JSON.parse((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.ResponseBody); result = (_e = (_d = responseBody === null || responseBody === void 0 ? void 0 : responseBody.items) === null || _d === void 0 ? void 0 : _d.filter(function (item) { var _a, _b, _c, _d; - return ((_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.trigger) === null || _b === void 0 ? void 0 : _b.type) === (BackupTypeNum === null || BackupTypeNum === void 0 ? void 0 : BackupTypeNum.Schedule) && ((_d = (_c = item === null || item === void 0 ? void 0 : item.spec) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.instanceID) === instanceId; })) === null || _e === void 0 ? void 0 : _e[0]; } else { result = (_h = (_g = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.items) === null || _g === void 0 ? void 0 : _g.filter(function (item) { var _a, _b, _c, _d; - return ((_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.trigger) === null || _b === void 0 ? void 0 : _b.type) === (BackupTypeNum === null || BackupTypeNum === void 0 ? void 0 : BackupTypeNum.Schedule) && ((_d = (_c = item === null || item === void 0 ? void 0 : item.spec) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.instanceID) === instanceId; })) === null || _h === void 0 ? void 0 : _h[0]; } } else { throw response; } - - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 3: error_9 = _j.sent(); - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 4: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); }; - -function ServiceDetailTable(props) { - var _this = this; - - var _a, _b, _c; - - var actions = props.actions, - _d = props.base, - platform = _d.platform, - route = _d.route, - regionId = _d.regionId, - _e = props.list, - serviceResourceList = _e.serviceResourceList, - externalClusters = _e.externalClusters; +/** + * 获取当前集群的admin角色 + * @param resource: CreateResource + * @param regionid: number 当前的地域Id + */ +var getClusterAdminRole = function getClusterAdminRole(resource, regionId) { + return tslib.__awaiter(void 0, void 0, void 0, function () { + var _a, clusterId, _b, clusterType, platform, userDefinedHeader, InterfaceNameMap, params, response, error_10; + var _c; + return tslib.__generator(this, function (_d) { + switch (_d.label) { + case 0: + _a = resource[0], clusterId = _a.clusterId, _b = _a.clusterType, clusterType = _b === void 0 ? ClusterType.TKE : _b, platform = _a.platform; + userDefinedHeader = {}; + InterfaceNameMap = (_c = {}, _c[ClusterType.TKE] = 'AcquireClusterAdminRole', _c[ClusterType.EKS] = 'AcquireEKSClusterAdminRole', _c[ClusterType.External] = 'AcquireClusterAdminRole', _c); + if (platform === PlatformType.TDCC) { + params = { + userDefinedHeader: userDefinedHeader, + apiParams: { + module: ClusterResourceModuleName === null || ClusterResourceModuleName === void 0 ? void 0 : ClusterResourceModuleName[clusterType], + interfaceName: InterfaceNameMap === null || InterfaceNameMap === void 0 ? void 0 : InterfaceNameMap[clusterType], + regionId: regionId, + restParams: { + Version: ClusterResourceVersionName === null || ClusterResourceVersionName === void 0 ? void 0 : ClusterResourceVersionName[clusterType], + ClusterId: clusterId, + Filters: [] + }, + opts: { + tipErr: false, + global: false + } + }, + platform: platform + }; + } else if (platform === PlatformType.TKESTACK) { + params = { + userDefinedHeader: userDefinedHeader, + // url, + restParams: { + ClusterId: clusterId, + ProjectId: '' + }, + platform: platform + }; + } + _d.label = 1; + case 1: + _d.trys.push([1, 3,, 4]); + return [4 /*yield*/, RequestApi.SEND(params)]; + case 2: + response = _d.sent(); + if ((response === null || response === void 0 ? void 0 : response.code) === 0) { + return [2 /*return*/, operationResult(resource)]; + } else { + return [2 /*return*/, operationResult(resource, response)]; + } + case 3: + error_10 = _d.sent(); + return [2 /*return*/, operationResult(resource, error_10)]; + case 4: + return [2 /*return*/]; + } + }); + }); +}; + +function ServiceDetailTable(props) { + var _this = this; + var _a, _b, _c; + var actions = props.actions, + _d = props.base, + platform = _d.platform, + route = _d.route, + regionId = _d.regionId, + _e = props.list, + serviceResourceList = _e.serviceResourceList, + externalClusters = _e.externalClusters; var serviceResources = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.serviceResources; }); var selectedTab = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.base) === null || _a === void 0 ? void 0 : _a.selectedTab; }); - var _navigateDetail = function _navigateDetail(item) { var _a, _b, _c, _d; - var serviceName = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass; var instanceName = (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name; var clusterId = Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item, route); @@ -5503,14 +4857,12 @@ function ServiceDetailTable(props) { mode: 'detail' }); }; - var showInstance = function showInstance(item) { var _a, _b, _c, _d; - var clusterId = Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item, route); var serviceName = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass; - var servicePlan = (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name; // 过滤条件 - + var servicePlan = (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name; + // 过滤条件 var k8sQueryObj = { fieldSelector: { 'spec.servicePlan': servicePlan @@ -5519,8 +4871,8 @@ function ServiceDetailTable(props) { 'ssm.infra.tce.io/cluster-id': clusterId } }; - actions.list.showInstanceDialog(true); // 查看实例列表 - + actions.list.showInstanceDialog(true); + // 查看实例列表 (_c = actions.detail.instanceResource) === null || _c === void 0 ? void 0 : _c.clear(); actions.detail.instanceResource.applyFilter({ platform: platform, @@ -5533,22 +4885,16 @@ function ServiceDetailTable(props) { namespace: DefaultNamespace }); }; - var resourceMap = React.useMemo(function () { var _a, _b, _c, _d, _e, _f, _g, _h; - var result = {}; var resources = (_b = (_a = serviceResourceList === null || serviceResourceList === void 0 ? void 0 : serviceResourceList.list) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.records; - if (selectedTab === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServicePlan)) { result = (_e = (_d = (_c = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records) === null || _e === void 0 ? void 0 : _e.reduce(function (pre, cur) { var _a; - var _b, _c; - var instances = resources === null || resources === void 0 ? void 0 : resources.filter(function (item) { var _a, _b; - return ((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = item === null || item === void 0 ? void 0 : item.spec) === null || _b === void 0 ? void 0 : _b.servicePlan) && (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, cur)) === (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item)); }); return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[(_b = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _b === void 0 ? void 0 : _b.uid] = (_c = instances === null || instances === void 0 ? void 0 : instances.length) !== null && _c !== void 0 ? _c : 0, _a)); @@ -5556,32 +4902,26 @@ function ServiceDetailTable(props) { } else if (selectedTab === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource)) { result = (_h = (_g = (_f = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.records) === null || _h === void 0 ? void 0 : _h.reduce(function (pre, cur) { var _a; - var _b, _c; - var plan = resources === null || resources === void 0 ? void 0 : resources.find(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = cur === null || cur === void 0 ? void 0 : cur.spec) === null || _b === void 0 ? void 0 : _b.servicePlan) && (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, cur)) === (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item)); }); var map = ((_b = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _b === void 0 ? void 0 : _b.uid) && plan ? (_a = {}, _a[(_c = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _c === void 0 ? void 0 : _c.uid] = plan, _a) : {}; return tslib.__assign(tslib.__assign({}, pre), map); }, {}); } - return result; }, [(_a = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _a === void 0 ? void 0 : _a.data, (_b = serviceResourceList === null || serviceResourceList === void 0 ? void 0 : serviceResourceList.list) === null || _b === void 0 ? void 0 : _b.data, selectedTab]); var resourceMapLoading = ((_c = serviceResourceList === null || serviceResourceList === void 0 ? void 0 : serviceResourceList.list) === null || _c === void 0 ? void 0 : _c.fetchState) === (ffRedux.FetchState === null || ffRedux.FetchState === void 0 ? void 0 : ffRedux.FetchState.Fetching); var columns = React.useMemo(function () { var cols = []; - if (selectedTab === ResourceTypeEnum.ServicePlan) { cols = [{ key: 'name', header: i18n.t('名称'), render: function render(item) { var _a, _b, _c; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Button, { type: 'link', onClick: function onClick() { @@ -5596,7 +4936,6 @@ function ServiceDetailTable(props) { header: i18n.t('描述'), render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '-')); } }, { @@ -5613,7 +4952,6 @@ function ServiceDetailTable(props) { header: i18n.t('规格类型'), render: function render(item) { var _a, _b, _c, _d, _e, _f; - return React__default.createElement(teaComponent.Text, { className: (_c = ServicePlanTypeMap === null || ServicePlanTypeMap === void 0 ? void 0 : ServicePlanTypeMap[((_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/owner']) || ServicePlanTypeEnum.Custom]) === null || _c === void 0 ? void 0 : _c.className }, (_f = ServicePlanTypeMap === null || ServicePlanTypeMap === void 0 ? void 0 : ServicePlanTypeMap[((_e = (_d = item === null || item === void 0 ? void 0 : item.metadata) === null || _d === void 0 ? void 0 : _d.labels) === null || _e === void 0 ? void 0 : _e['ssm.infra.tce.io/owner']) || ServicePlanTypeEnum.Custom]) === null || _f === void 0 ? void 0 : _f.text); @@ -5623,7 +4961,6 @@ function ServiceDetailTable(props) { header: i18n.t('实例个数'), render: function render(item) { var _a, _b; - var data = resourceMap && ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.uid) ? resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.uid] : 0; return React__default.createElement(React__default.Fragment, null, resourceMapLoading ? React__default.createElement(teaComponent.Icon, { type: "loading" @@ -5634,7 +4971,6 @@ function ServiceDetailTable(props) { header: i18n.t('CPU'), render: function render(item) { var _a; - return React__default.createElement(teaComponent.Text, null, (_a = item === null || item === void 0 ? void 0 : item.spec.metadata) === null || _a === void 0 ? void 0 : _a.cpu); } }, { @@ -5642,7 +4978,6 @@ function ServiceDetailTable(props) { header: i18n.t('内存'), render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_a = item === null || item === void 0 ? void 0 : item.spec.metadata) === null || _a === void 0 ? void 0 : _a.memory)); } }, { @@ -5650,16 +4985,20 @@ function ServiceDetailTable(props) { header: i18n.t('存储'), render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_a = item === null || item === void 0 ? void 0 : item.spec.metadata) === null || _a === void 0 ? void 0 : _a.storage)); } }, { key: 'user', header: i18n.t('创建人'), render: function render(item) { - var _a, _b, _c; - - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/creator']) !== null && _c !== void 0 ? _c : '-')); + return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, Util.getCreator(platform, item))); + } + }, { + key: 'creationTimestamp', + header: i18n.t('时间戳'), + render: function render(item) { + var _a; + return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') || '-')); } }, { key: 'operate', @@ -5673,15 +5012,14 @@ function ServiceDetailTable(props) { key: 'name', header: i18n.t('名称'), render: function render(item) { - var _a, _b, _c; - + var _a, _b; return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Button, { type: 'link', onClick: function onClick() { _navigateDetail(item); } - }, (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name), ((_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name) && React__default.createElement(teaComponent.Copy, { - text: (_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.name + }, (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name), React__default.createElement(teaComponent.Copy, { + text: (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name })); } }, { @@ -5689,7 +5027,6 @@ function ServiceDetailTable(props) { header: i18n.t('版本'), render: function render(item) { var _a, _b, _c; - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b.version) !== null && _c !== void 0 ? _c : '-')); } }, { @@ -5706,9 +5043,8 @@ function ServiceDetailTable(props) { header: i18n.t('状态'), render: function render(item) { var _a, _b, _c, _d, _e, _f, _g, _h; - var state = ((_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.state) || '-'; - var className = ((_b = item === null || item === void 0 ? void 0 : item.status) === null || _b === void 0 ? void 0 : _b.state) === (ServiceInstanceStatusEnum === null || ServiceInstanceStatusEnum === void 0 ? void 0 : ServiceInstanceStatusEnum.Ready) ? 'text-success' : ''; + var className = ServiceInstanceMap === null || ServiceInstanceMap === void 0 ? void 0 : ServiceInstanceMap[((_b = item === null || item === void 0 ? void 0 : item.status) === null || _b === void 0 ? void 0 : _b.state) || (ServiceInstanceStatusEnum === null || ServiceInstanceStatusEnum === void 0 ? void 0 : ServiceInstanceStatusEnum.Unknown)].className; var isDeleting = showResourceDeleteLoading(item, (_d = (_c = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records); return React__default.createElement(React__default.Fragment, null, isDeleting && React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Icon, { type: 'loading' @@ -5737,7 +5073,6 @@ function ServiceDetailTable(props) { header: i18n.t('命名空间'), render: function render(item) { var _a; - return React__default.createElement(teaComponent.Text, null, (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.namespace); } }, { @@ -5745,31 +5080,25 @@ function ServiceDetailTable(props) { header: i18n.t('规格'), render: function render(item) { var _a, _b, _c, _d, _e, _f, _g, _h; - var resource = resourceMap && ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.uid) ? resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.uid] : {}; - if (resourceMapLoading) { return React__default.createElement(teaComponent.Icon, { type: 'loading' }); } - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, i18n.t('CPU: '), (_d = (_c = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.cpu), React__default.createElement("p", null, i18n.t('内存: '), (_f = (_e = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.memory), React__default.createElement("p", null, i18n.t('存储: '), (_h = (_g = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.storage)); } }, { key: 'user', header: i18n.t('创建人'), render: function render(item) { - var _a, _b, _c; - - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/creator']) !== null && _c !== void 0 ? _c : '-')); + return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, Util.getCreator(platform, item))); } }, { key: 'creationTimestamp', header: i18n.t('时间戳'), render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') || '-')); } }, { @@ -5780,15 +5109,11 @@ function ServiceDetailTable(props) { } }]; } - return cols; }, [selectedTab, serviceResourceList === null || serviceResourceList === void 0 ? void 0 : serviceResourceList.list]); - var renderOperateButtons = function renderOperateButtons(item) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; var buttons; - if (selectedTab === ResourceTypeEnum.ServicePlan) { buttons = [{ text: i18n.t('查看实例'), @@ -5799,7 +5124,6 @@ function ServiceDetailTable(props) { text: i18n.t('编辑'), handleClick: function handleClick() { var _a, _b; - var clusterId = Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item, route); var serviceName = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass; var resourceIns = (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name; @@ -5813,20 +5137,22 @@ function ServiceDetailTable(props) { }); actions.list.showCreateResourceDialog(true); }, - hidden: ((_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System + hidden: ((_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System, + disabled: resourceMap && ((_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.uid) && (resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_d = item === null || item === void 0 ? void 0 : item.metadata) === null || _d === void 0 ? void 0 : _d.uid]) > 0, + tooltips: resourceMap && ((_e = item === null || item === void 0 ? void 0 : item.metadata) === null || _e === void 0 ? void 0 : _e.uid) && (resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_f = item === null || item === void 0 ? void 0 : item.metadata) === null || _f === void 0 ? void 0 : _f.uid]) > 0 ? i18n.t('当前规格正在被实例引用,不可进行编辑') : i18n.t('') }, { text: i18n.t('删除'), handleClick: function handleClick() { actions.list.selectDeleteResources([item]); }, - hidden: ((_d = (_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System, - disabled: ((_f = (_e = item === null || item === void 0 ? void 0 : item.metadata) === null || _e === void 0 ? void 0 : _e.labels) === null || _f === void 0 ? void 0 : _f['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System, - tooltips: ((_h = (_g = item === null || item === void 0 ? void 0 : item.metadata) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System ? i18n.t('预设规格') : i18n.t('') + hidden: ((_h = (_g = item === null || item === void 0 ? void 0 : item.metadata) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System, + disabled: ((_k = (_j = item === null || item === void 0 ? void 0 : item.metadata) === null || _j === void 0 ? void 0 : _j.labels) === null || _k === void 0 ? void 0 : _k['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System || resourceMap && ((_l = item === null || item === void 0 ? void 0 : item.metadata) === null || _l === void 0 ? void 0 : _l.uid) && (resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_m = item === null || item === void 0 ? void 0 : item.metadata) === null || _m === void 0 ? void 0 : _m.uid]) > 0, + tooltips: ((_p = (_o = item === null || item === void 0 ? void 0 : item.metadata) === null || _o === void 0 ? void 0 : _o.labels) === null || _p === void 0 ? void 0 : _p['ssm.infra.tce.io/owner']) === ServicePlanTypeEnum.System ? i18n.t('预设规格') : resourceMap && ((_q = item === null || item === void 0 ? void 0 : item.metadata) === null || _q === void 0 ? void 0 : _q.uid) && (resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_r = item === null || item === void 0 ? void 0 : item.metadata) === null || _r === void 0 ? void 0 : _r.uid]) > 0 ? i18n.t('当前规格正在被实例引用,不可进行删除') : i18n.t('') }]; } else { buttons = [{ text: i18n.t('管理'), - disabled: !!((_j = item === null || item === void 0 ? void 0 : item.metadata) === null || _j === void 0 ? void 0 : _j.deletionTimestamp), + disabled: !!((_s = item === null || item === void 0 ? void 0 : item.metadata) === null || _s === void 0 ? void 0 : _s.deletionTimestamp), handleClick: function handleClick() { _navigateDetail(item); } @@ -5835,9 +5161,7 @@ function ServiceDetailTable(props) { handleClick: function handleClick() { return tslib.__awaiter(_this, void 0, void 0, function () { var clusterId, serviceName, resourceIns, instanceId, result; - var _a, _b, _c, _d, _e; - return tslib.__generator(this, function (_f) { switch (_f.label) { case 0: @@ -5845,9 +5169,7 @@ function ServiceDetailTable(props) { serviceName = ((_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass) || ((_b = route === null || route === void 0 ? void 0 : route.queries) === null || _b === void 0 ? void 0 : _b.servicename); resourceIns = (_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.name; instanceId = ((_d = item === null || item === void 0 ? void 0 : item.spec) === null || _d === void 0 ? void 0 : _d.externalID) || (Util === null || Util === void 0 ? void 0 : Util.getInstanceId(platform, (_e = route === null || route === void 0 ? void 0 : route.queries) === null || _e === void 0 ? void 0 : _e.instancename, serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.selection)); - return [4 - /*yield*/ - , fetchInstanceResources({ + return [4 /*yield*/, fetchInstanceResources({ platform: platform, clusterId: clusterId, resourceIns: resourceIns, @@ -5860,32 +5182,26 @@ function ServiceDetailTable(props) { } } })]; - case 1: result = _f.sent(); - if (!(result === null || result === void 0 ? void 0 : result.hasError) && (result === null || result === void 0 ? void 0 : result.recordCount) > 0) { teaComponent.message.warning({ content: "\u5B9E\u4F8B\u3010".concat(resourceIns, "\u3011\u5173\u8054\u4E86\u670D\u52A1\u7ED1\u5B9A,\u8BF7\u60A8\u89E3\u7ED1\u540E\u518D\u5220\u9664!") }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; } !(result === null || result === void 0 ? void 0 : result.hasError) && actions.list.selectDeleteResources([item]); - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); }, - disabled: !!((_k = item === null || item === void 0 ? void 0 : item.metadata) === null || _k === void 0 ? void 0 : _k.deletionTimestamp), + + disabled: !!((_t = item === null || item === void 0 ? void 0 : item.metadata) === null || _t === void 0 ? void 0 : _t.deletionTimestamp), tooltips: '' }]; } - return buttons === null || buttons === void 0 ? void 0 : buttons.map(function (item, index) { return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Bubble, { key: index, @@ -5902,7 +5218,6 @@ function ServiceDetailTable(props) { })))); }); }; - return React__default.createElement(ffComponent.TablePanel, { style: { maxHeight: 600, @@ -5917,7 +5232,6 @@ function ServiceDetailTable(props) { key: "".concat(selectedTab, "table"), recordKey: function recordKey(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.uid; }, columns: columns, @@ -5926,7 +5240,6 @@ function ServiceDetailTable(props) { isNeedPagination: true, rowDisabled: function rowDisabled(record) { var _a; - return !!((_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp); } }); @@ -5934,18 +5247,15 @@ function ServiceDetailTable(props) { function ServiceInstanceTable(props) { var _a, _b, _c; - var actions = props.actions, - _d = props.base, - selectedTab = _d.selectedTab, - platform = _d.platform, - route = _d.route, - instanceResource = props.detail.instanceResource, - servicePlans = props.list.servicePlans; - + _d = props.base, + selectedTab = _d.selectedTab, + platform = _d.platform, + route = _d.route, + instanceResource = props.detail.instanceResource, + servicePlans = props.list.servicePlans; var _navigateDetail = function _navigateDetail(item) { var _a, _b; - var serviceName = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass; var instanceName = (_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.name; var clusterId = Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item, route); @@ -5958,21 +5268,16 @@ function ServiceInstanceTable(props) { clusterid: clusterId }); }; - var resourceMap = React.useMemo(function () { var _a, _b, _c, _d; - var result = {}; var resources = (_b = (_a = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.records; var serviceResources = (_d = (_c = instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.list) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records; result = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.reduce(function (pre, cur) { var _a; - var _b, _c; - var plan = resources === null || resources === void 0 ? void 0 : resources.find(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = cur === null || cur === void 0 ? void 0 : cur.spec) === null || _b === void 0 ? void 0 : _b.servicePlan) && (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, cur)) === (Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, item)); }); var map = ((_b = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _b === void 0 ? void 0 : _b.uid) && plan ? (_a = {}, _a[(_c = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _c === void 0 ? void 0 : _c.uid] = plan, _a) : {}; @@ -5986,7 +5291,6 @@ function ServiceInstanceTable(props) { header: i18n.t('名称'), render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Button, { type: 'link', onClick: function onClick() { @@ -5999,7 +5303,6 @@ function ServiceInstanceTable(props) { header: i18n.t('版本'), render: function render(item) { var _a, _b, _c; - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b.version) !== null && _c !== void 0 ? _c : '-')); } }, { @@ -6016,7 +5319,6 @@ function ServiceInstanceTable(props) { header: i18n.t('状态'), render: function render(item) { var _a, _b, _c, _d, _e, _f, _g; - var state = (_b = (_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : '-'; var className = ((_c = item === null || item === void 0 ? void 0 : item.status) === null || _c === void 0 ? void 0 : _c.state) === (ServiceInstanceStatusEnum === null || ServiceInstanceStatusEnum === void 0 ? void 0 : ServiceInstanceStatusEnum.Ready) ? 'text-success' : ''; return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, { @@ -6041,7 +5343,6 @@ function ServiceInstanceTable(props) { header: i18n.t('命名空间'), render: function render(item) { var _a; - return React__default.createElement(teaComponent.Text, null, (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.namespace); } }, { @@ -6049,31 +5350,25 @@ function ServiceInstanceTable(props) { header: i18n.t('规格'), render: function render(item) { var _a, _b, _c, _d, _e, _f, _g, _h; - var resource = resourceMap && ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.uid) ? resourceMap === null || resourceMap === void 0 ? void 0 : resourceMap[(_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.uid] : {}; - if (resourceMapLoading) { return React__default.createElement(teaComponent.Icon, { type: 'loading' }); } - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, i18n.t('CPU: '), ((_d = (_c = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.cpu) || '-'), React__default.createElement("p", null, i18n.t('内存: '), ((_f = (_e = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.memory) || '-'), React__default.createElement("p", null, i18n.t('存储: '), ((_h = (_g = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.storage) || '-')); } }, { key: 'user', header: i18n.t('创建人'), render: function render(item) { - var _a, _b, _c; - - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['ssm.infra.tce.io/creator']) !== null && _c !== void 0 ? _c : '-')); + return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, Util.getCreator(platform, item))); } }, { key: 'creationTimestamp', header: i18n.t('时间戳'), render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement("p", null, dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') || '-')); } }]; @@ -6081,7 +5376,6 @@ function ServiceInstanceTable(props) { isNeedCard: false, recordKey: function recordKey(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name; }, columns: columns, @@ -6093,8 +5387,8 @@ function ServiceInstanceTable(props) { function ServiceInstanceTableDialog(props) { var showInstanceTableDialog = props.list.showInstanceTableDialog, - actions = props.actions, - children = props.children; + actions = props.actions, + children = props.children; return React__default.createElement(teaComponent.Modal, { visible: showInstanceTableDialog && children !== null, caption: i18n.t('查看实例'), @@ -6112,14 +5406,12 @@ function ServiceDetail(props) { } var routerSea$2 = seajs.require('router'); - function PaasContentPanel(props) { var base = props.base, - actions = props.actions; + actions = props.actions; var selectedTab = base === null || base === void 0 ? void 0 : base.selectedTab; var serviceName = reactRedux.useSelector(function (state) { var _a, _b, _c; - return (_c = (_b = (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.selection) === null || _c === void 0 ? void 0 : _c.name; }); return React__default.createElement(teaComponent.Layout.Content, { @@ -6165,26 +5457,21 @@ function PaasContentPanel(props) { function PaasSiderPanel(props) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - var _m = React.useState(''), - selected = _m[0], - setSelected = _m[1]; - + selected = _m[0], + setSelected = _m[1]; var _o = React.useState({ - records: [], - recordCount: 0, - fetched: false - }), - menus = _o[0], - setMenus = _o[1]; - + records: [], + recordCount: 0, + fetched: false + }), + menus = _o[0], + setMenus = _o[1]; var services = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.services; }); var actions = props.actions; - function LoadingPanel() { return React__default.createElement(teaComponent.Card, { bordered: false, @@ -6202,7 +5489,6 @@ function PaasSiderPanel(props) { type: 'loading' }), React__default.createElement(teaComponent.Text, null, i18n.t('加载中')))); } - function EmptyPanel() { return React__default.createElement(teaComponent.Card, { bordered: false, @@ -6217,7 +5503,6 @@ function PaasSiderPanel(props) { } }, React__default.createElement(teaComponent.Card.Body, null, i18n.t('您尚未开通分布式云中心数据服务,请前往分布式云中心【数据服务->服务概览】开通'))); } - function RetryPanel(retryProps) { return React__default.createElement(teaComponent.Card, { bordered: false, @@ -6240,11 +5525,9 @@ function PaasSiderPanel(props) { } }, i18n.t('刷新重试'))); } - var _renderMenuList = function _renderMenuList(subRouters) { return React__default.createElement(teaComponent.Menu, null, subRouters === null || subRouters === void 0 ? void 0 : subRouters.map(function (item, index) { var _a, _b, _c, _d; - return React__default.createElement("div", { key: item === null || item === void 0 ? void 0 : item.name }, !((_a = item === null || item === void 0 ? void 0 : item.sub) === null || _a === void 0 ? void 0 : _a.length) && React__default.createElement(teaComponent.Menu.Item, { @@ -6255,7 +5538,6 @@ function PaasSiderPanel(props) { selected: ((_b = services === null || services === void 0 ? void 0 : services.selection) === null || _b === void 0 ? void 0 : _b.name) === (item === null || item === void 0 ? void 0 : item.name), onClick: function onClick() { var _a, _b; - (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.select(item !== null && item !== void 0 ? item : {}); } }), ((_c = item === null || item === void 0 ? void 0 : item.sub) === null || _c === void 0 ? void 0 : _c.length) > 0 && React__default.createElement(teaComponent.Menu.SubMenu, { @@ -6263,21 +5545,18 @@ function PaasSiderPanel(props) { key: item === null || item === void 0 ? void 0 : item.name }, (_d = item === null || item === void 0 ? void 0 : item.sub) === null || _d === void 0 ? void 0 : _d.map(function (subItem) { var _a; - return React__default.createElement(teaComponent.Menu.Item, { key: subItem === null || subItem === void 0 ? void 0 : subItem.name, title: subItem === null || subItem === void 0 ? void 0 : subItem.name, selected: ((_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.name) === (item === null || item === void 0 ? void 0 : item.name), onClick: function onClick() { var _a, _b; - (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.select(item !== null && item !== void 0 ? item : {}); } }); }))); })); }; - var isEmpty = ((_a = services === null || services === void 0 ? void 0 : services.list) === null || _a === void 0 ? void 0 : _a.fetched) && ((_d = (_c = (_b = services === null || services === void 0 ? void 0 : services.list) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.records) === null || _d === void 0 ? void 0 : _d.length) === 0; var isLoading = ((_e = services === null || services === void 0 ? void 0 : services.list) === null || _e === void 0 ? void 0 : _e.fetchState) === ffRedux.FetchState.Fetching || !((_f = services === null || services === void 0 ? void 0 : services.list) === null || _f === void 0 ? void 0 : _f.fetched); var failed = ((_g = services === null || services === void 0 ? void 0 : services.list) === null || _g === void 0 ? void 0 : _g.fetchState) === (ffRedux.FetchState === null || ffRedux.FetchState === void 0 ? void 0 : ffRedux.FetchState.Failed) || ((_j = (_h = services === null || services === void 0 ? void 0 : services.list) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j['hasError']); @@ -6286,7 +5565,6 @@ function PaasSiderPanel(props) { }, isLoading && React__default.createElement(LoadingPanel, null), !isLoading && failed && React__default.createElement(RetryPanel, { onRetry: function onRetry() { var _a, _b; - (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.fetch(); } }), !isLoading && !failed && isEmpty && React__default.createElement(EmptyPanel, null), !isLoading && !failed && !isEmpty && _renderMenuList((_l = (_k = services === null || services === void 0 ? void 0 : services.list) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.records))); @@ -6310,9 +5588,7 @@ function prefixPageId(obj, pageId) { obj[key] = pageId + '_' + obj[key]; }); } - var Base; - (function (Base) { Base["IsI18n"] = "IsI18n"; Base["FETCH_PLATFORM"] = "FETCH_PLATFORM"; @@ -6323,10 +5599,9 @@ var Base; Base["Clear"] = "Clear"; Base["FETCH_UserInfo"] = "FETCH_UserInfo"; Base["UPDATE_ROUTE"] = "UPDATE_ROUTE"; + Base["GetClusterAdminRoleFlow"] = "GetClusterAdminRoleFlow"; })(Base || (Base = {})); - var Create; - (function (Create) { Create["SERVICE_INSTANCE_EDIT"] = "SERVICE_INSTANCE_EDIT"; Create["SERVICE_INSTANCE_EDIT_VALIDATOR"] = "SERVICE_INSTANCE_EDIT_VALIDATOR"; @@ -6335,9 +5610,7 @@ var Create; Create["SERVICE_PLAN_EDIT"] = "SERVICE_PLAN_EDIT"; Create["CREATE_SERVICE_INSTANCE"] = "CREATE_SERVICE_INSTANCE"; })(Create || (Create = {})); - var List; - (function (List) { List["FETCH_SERVICES"] = "FETCH_SERVICES"; List["FETCH_CREATE_RESOURCE_SCHEMAS"] = "FETCH_CREATE_RESOURCE_SCHEMAS"; @@ -6352,9 +5625,7 @@ var List; List["FETCH_EXTERNAL_CLUSTERS"] = "FETCH_EXTERNAL_CLUSTERS"; List["Clear"] = "Clear"; })(List || (List = {})); - var Detail; - (function (Detail) { Detail["RESOURCE_DETAIL"] = "RESOURCE_DETAIL"; Detail["Clear"] = "Clear"; @@ -6373,7 +5644,6 @@ var Detail; Detail["SELECT_DETAIL_RESOURCE"] = "SELECT_DETAIL_RESOURCE"; Detail["FETCH_BACKUP_STRATEGY"] = "FETCH_BACKUP_STRATEGY"; })(Detail || (Detail = {})); - prefixPageId(Base, 'Base'); prefixPageId(Create, 'Create'); prefixPageId(List, 'List'); @@ -6385,17 +5655,14 @@ var ActionType = { Detail: Detail }; -var _a$5; - -var _b$4; +var _a$6; +var _b$5; var detailActions = { selectDetailTab: function selectDetailTab(tabId) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, _b, route, platform, selectedTab, regionId, serviceResources, _c, servicename, instancename, clusterid, instanceId; - var _d, _e, _f, _g, _h; - return tslib.__generator(this, function (_j) { dispatch({ type: ActionType.Detail.Select_Detail_Tab, @@ -6407,7 +5674,6 @@ var detailActions = { dispatch((_d = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceDetail) === null || _d === void 0 ? void 0 : _d.clear()); dispatch((_e = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _e === void 0 ? void 0 : _e.clear()); dispatch((_f = detailActions === null || detailActions === void 0 ? void 0 : detailActions.serviceInstanceSchema) === null || _f === void 0 ? void 0 : _f.clear()); - if (tabId === DetailTabType.Detail) { dispatch(detailActions.instanceDetail.applyFilter({ platform: platform, @@ -6456,22 +5722,18 @@ var detailActions = { resourceType: tabId })); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + instanceDetail: ffRedux.createFFObjectActions({ actionName: ActionType.Detail.RESOURCE_DETAIL, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, regionId, resourceIns, serviceName, resourceType, _b, namespace, _c, _d, platform, route, selectDetailResource, response, resource, secretResource, resourceSchemas, instanceSchema; - var _e, _f; - return tslib.__generator(this, function (_g) { switch (_g.label) { case 0: @@ -6481,9 +5743,7 @@ var detailActions = { resource: null, instanceSchema: [] }; - return [4 - /*yield*/ - , fetchServiceResourceDetail({ + return [4 /*yield*/, fetchServiceResourceDetail({ clusterId: clusterId, regionId: regionId, serviceName: serviceName, @@ -6492,15 +5752,10 @@ var detailActions = { resourceType: resourceType ? resourceType : ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource, namespace: namespace })]; - case 1: resource = _g.sent(); - if (!(resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding))) return [3 - /*break*/ - , 3]; - return [4 - /*yield*/ - , fetchServiceResourceDetail({ + if (!(resourceType === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding))) return [3 /*break*/, 3]; + return [4 /*yield*/, fetchServiceResourceDetail({ clusterId: clusterId, regionId: regionId, serviceName: serviceName, @@ -6509,26 +5764,20 @@ var detailActions = { resourceType: ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.Secret, namespace: namespace })]; - case 2: secretResource = _g.sent(); _g.label = 3; - case 3: - return [4 - /*yield*/ - , fetchResourceSchemas({ + return [4 /*yield*/, fetchResourceSchemas({ clusterId: clusterId, regionId: regionId, serviceName: serviceName, platform: platform, resourceType: resourceType })]; - case 4: resourceSchemas = _g.sent(); instanceSchema = []; - if (resourceType === ResourceTypeEnum.ServicePlan) { instanceSchema = resourceSchemas === null || resourceSchemas === void 0 ? void 0 : resourceSchemas.planSchema; } else if (resourceType === ResourceTypeEnum.ServiceBinding) { @@ -6536,17 +5785,14 @@ var detailActions = { } else { instanceSchema = resourceSchemas === null || resourceSchemas === void 0 ? void 0 : resourceSchemas.instanceCreateParameterSchema; } - response = { resource: resource, instanceSchema: (_f = instanceSchema === null || instanceSchema === void 0 ? void 0 : instanceSchema.filter(function (item) { var _a; - if (item === null || item === void 0 ? void 0 : item.enabledCondition) { var _b = (_a = item === null || item === void 0 ? void 0 : item.enabledCondition) === null || _a === void 0 ? void 0 : _a.split('=='), - conditionKey_1 = _b[0], - conditionValue = _b[1]; - + conditionKey_1 = _b[0], + conditionValue = _b[1]; var values = instanceSchema === null || instanceSchema === void 0 ? void 0 : instanceSchema.find(function (schema) { return (schema === null || schema === void 0 ? void 0 : schema.name) === conditionKey_1; }); @@ -6556,25 +5802,20 @@ var detailActions = { return true; } }).map(function (item) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; - + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; var schemaValue = ''; var schemaName = item === null || item === void 0 ? void 0 : item.name; - switch (resourceType) { case ResourceTypeEnum.ServiceResource: - schemaValue = ((_a = resource === null || resource === void 0 ? void 0 : resource.status) === null || _a === void 0 ? void 0 : _a.metadata) && schemaName || !isEmpty((_b = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _b === void 0 ? void 0 : _b.parameters) ? (_j = (_f = (_e = (_d = (_c = resource === null || resource === void 0 ? void 0 : resource.status) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d[schemaName]) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : (_h = (_g = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _g === void 0 ? void 0 : _g.parameters[schemaName]) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : '-' : ''; + schemaValue = ((_a = resource === null || resource === void 0 ? void 0 : resource.status) === null || _a === void 0 ? void 0 : _a.metadata) && schemaName || !isEmpty((_b = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _b === void 0 ? void 0 : _b.parameters) ? formatPlanSchemaValue(((_d = (_c = resource === null || resource === void 0 ? void 0 : resource.status) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d[schemaName]) || ((_e = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _e === void 0 ? void 0 : _e.parameters[schemaName])) || '-' : ''; break; - case ResourceTypeEnum.ServiceBinding: - schemaValue = (secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) && schemaName && ((_k = secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) === null || _k === void 0 ? void 0 : _k[schemaName]) ? (_o = (_m = jsBase64.Base64.atob((_l = secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) === null || _l === void 0 ? void 0 : _l[schemaName])) === null || _m === void 0 ? void 0 : _m.toString()) !== null && _o !== void 0 ? _o : '-' : ''; + schemaValue = (secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) && schemaName && ((_f = secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) === null || _f === void 0 ? void 0 : _f[schemaName]) ? ((_h = jsBase64.Base64.atob((_g = secretResource === null || secretResource === void 0 ? void 0 : secretResource.data) === null || _g === void 0 ? void 0 : _g[schemaName])) === null || _h === void 0 ? void 0 : _h.toString()) || '-' : ''; break; - default: - schemaValue = ((_p = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _p === void 0 ? void 0 : _p.metadata) && schemaName ? (_t = (_s = (_r = (_q = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _q === void 0 ? void 0 : _q.metadata) === null || _r === void 0 ? void 0 : _r[schemaName]) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : '-' : ''; + schemaValue = ((_j = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _j === void 0 ? void 0 : _j.metadata) && schemaName ? formatPlanSchemaValue((_m = (_l = (_k = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _k === void 0 ? void 0 : _k.metadata) === null || _l === void 0 ? void 0 : _l[schemaName]) === null || _m === void 0 ? void 0 : _m.toString()) || '-' : ''; break; } - return tslib.__assign(tslib.__assign({}, item), { value: formatPlanSchemaData(item === null || item === void 0 ? void 0 : item.type, schemaValue), unit: formatPlanSchemaUnit(item, schemaValue) @@ -6583,9 +5824,7 @@ var detailActions = { return !hideSchema(item); }) }; - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); @@ -6595,13 +5834,11 @@ var detailActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; - if (record === null || record === void 0 ? void 0 : record.data) { // 更新服务实例编辑数据 var _p = getState(), - resourceDetail = _p.detail.resourceDetail, - selectedTab = _p.base.selectedTab; - + resourceDetail = _p.detail.resourceDetail, + selectedTab = _p.base.selectedTab; var basePro = { clusterId: (_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.query) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.clusterId, instanceName: (_e = (_d = (_c = record === null || record === void 0 ? void 0 : record.data) === null || _c === void 0 ? void 0 : _c.resource) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.name, @@ -6611,13 +5848,11 @@ var detailActions = { }; var instanceFormData = (_o = (_m = record === null || record === void 0 ? void 0 : record.data) === null || _m === void 0 ? void 0 : _m.instanceSchema) === null || _o === void 0 ? void 0 : _o.reduce(function (pre, cur) { var _a, _b; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = cur === null || cur === void 0 ? void 0 : cur.value, _a.unitMap = tslib.__assign(tslib.__assign({}, pre === null || pre === void 0 ? void 0 : pre.unitMap), (_b = {}, _b[cur === null || cur === void 0 ? void 0 : cur.name] = cur === null || cur === void 0 ? void 0 : cur.unit, _b)), _a)); }, basePro); var instanceEdit = { formData: instanceFormData }; - if (selectedTab === ResourceTypeEnum.ServiceResource) { dispatch(createActions.serviceInstanceEdit(instanceEdit)); } else { @@ -6632,54 +5867,32 @@ var detailActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var result; - var _a; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: - if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 - /*break*/ - , 5]; - if (!(((_a = query === null || query === void 0 ? void 0 : query.filter) === null || _a === void 0 ? void 0 : _a.resourceType) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource))) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { + if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 /*break*/, 5]; + if (!(((_a = query === null || query === void 0 ? void 0 : query.filter) === null || _a === void 0 ? void 0 : _a.resourceType) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource))) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { paging: query === null || query === void 0 ? void 0 : query.paging }))]; - case 1: result = _b.sent(); - return [3 - /*break*/ - , 4]; - + return [3 /*break*/, 4]; case 2: - return [4 - /*yield*/ - , fetchInstanceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { + return [4 /*yield*/, fetchInstanceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { paging: query === null || query === void 0 ? void 0 : query.paging }))]; - case 3: result = _b.sent(); _b.label = 4; - case 4: - return [3 - /*break*/ - , 6]; - + return [3 /*break*/, 6]; case 5: result.records = []; _b.label = 6; - case 6: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -6689,12 +5902,10 @@ var detailActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b, _c, _d, _e, _f; - - var instanceResource = getState().detail.instanceResource; //判断是否开启轮训 - + var instanceResource = getState().detail.instanceResource; + //判断是否开启轮训 if ((_b = (_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.some(function (item) { var _a; - return (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp; })) { dispatch((_c = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _c === void 0 ? void 0 : _c.polling({ @@ -6703,15 +5914,13 @@ var detailActions = { } else { dispatch((_d = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _d === void 0 ? void 0 : _d.clearPolling()); } - if ((_e = record === null || record === void 0 ? void 0 : record.data) === null || _e === void 0 ? void 0 : _e.recordCount) { var _g = (_f = instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.query) === null || _f === void 0 ? void 0 : _f.filter, - platform = _g.platform, - clusterId = _g.clusterId, - regionId = _g.regionId, - serviceName = _g.serviceName; // 查看实例关联的规格资源 - - + platform = _g.platform, + clusterId = _g.clusterId, + regionId = _g.regionId, + serviceName = _g.serviceName; + // 查看实例关联的规格资源 dispatch(listActions === null || listActions === void 0 ? void 0 : listActions.servicePlans.applyFilter({ platform: platform, clusterId: clusterId, @@ -6730,29 +5939,19 @@ var detailActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var filter, _a, platform, route, response; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: filter = query.filter; _a = (_b = getState()) === null || _b === void 0 ? void 0 : _b.base, platform = _a.platform, route = _a.route; - if (!filter) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , checkCosResource(filter)]; - + if (!filter) return [3 /*break*/, 2]; + return [4 /*yield*/, checkCosResource(filter)]; case 1: response = _c.sent(); _c.label = 2; - case 2: - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); @@ -6762,11 +5961,9 @@ var detailActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a; - if (record === null || record === void 0 ? void 0 : record.data) { var checkCosResource_1 = getState().detail.checkCosResource; var filter = (_a = checkCosResource_1 === null || checkCosResource_1 === void 0 ? void 0 : checkCosResource_1.query) === null || _a === void 0 ? void 0 : _a.filter; - if (filter) { dispatch(createActions.createResource.start([filter], filter === null || filter === void 0 ? void 0 : filter.regionId)); } @@ -6785,32 +5982,26 @@ var detailActions = { type: ActionType.Detail.SHOW_BACKUP_STRATEGY_DIALOG, payload: show }); - if (!show) { dispatch(detailActions.resetBackupStrategyEdit()); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + selectDetailResource: function selectDetailResource(resources) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, _b, platform, route, regionId, services, clusterId, resourceIns, namespace; - var _c, _d, _e, _f, _g, _h; - return tslib.__generator(this, function (_j) { _a = getState(), _b = _a.base, platform = _b.platform, route = _b.route, regionId = _b.regionId, services = _a.list.services; dispatch({ type: ActionType.Detail.SELECT_DETAIL_RESOURCE, payload: resources }); - if (resources === null || resources === void 0 ? void 0 : resources[0]) { clusterId = Util.getClusterId(platform, resources === null || resources === void 0 ? void 0 : resources[0], route); resourceIns = (_d = (_c = resources === null || resources === void 0 ? void 0 : resources[0]) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.name; @@ -6825,26 +6016,21 @@ var detailActions = { namespace: namespace })); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + initBackUpStrategy: function initBackUpStrategy(formData) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var newEdit; - var _a, _b; - return tslib.__generator(this, function (_c) { newEdit = { validator: (_a = Object.keys(formData)) === null || _a === void 0 ? void 0 : _a.reduce(function (pre, key) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[key] = { message: '', status: ffValidator.ValidatorStatusEnum === null || ffValidator.ValidatorStatusEnum === void 0 ? void 0 : ffValidator.ValidatorStatusEnum.Success @@ -6856,22 +6042,18 @@ var detailActions = { type: (_b = ActionType === null || ActionType === void 0 ? void 0 : ActionType.Detail) === null || _b === void 0 ? void 0 : _b.BACKUP_STRATEGY_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + updateBackUpStrategy: function updateBackUpStrategy(key, value) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b; - var _c, _d, _e; - return tslib.__generator(this, function (_f) { if (key) { _a = (_d = (_c = getState()) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.backupStrategyEdit, formData = _a.formData, validator = _a.validator; @@ -6884,33 +6066,24 @@ var detailActions = { payload: newEdit }); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + validateAll: function validateAll() { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var backupStrategyEdit, _a, formData, validator, newValidatorModel, newEdit; - var _b, _c, _d; - return tslib.__generator(this, function (_e) { switch (_e.label) { case 0: backupStrategyEdit = getState().detail.backupStrategyEdit; - if (!backupStrategyEdit) return [3 - /*break*/ - , 2]; + if (!backupStrategyEdit) return [3 /*break*/, 2]; _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.backupStrategyEdit, formData = _a.formData, validator = _a.validator; - return [4 - /*yield*/ - , Backup.getValidatorModel(backupStrategyEdit)]; - + return [4 /*yield*/, Backup.getValidatorModel(backupStrategyEdit)]; case 1: newValidatorModel = _e.sent(); newEdit = { @@ -6922,23 +6095,19 @@ var detailActions = { payload: newEdit }); _e.label = 2; - case 2: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); }; }, + resetBackupStrategyEdit: function resetBackupStrategyEdit() { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var backupStrategyEdit, newEdit; - var _a; - return tslib.__generator(this, function (_b) { backupStrategyEdit = getState().detail.backupStrategyEdit; newEdit = tslib.__assign({}, BackupStrategyEditInitValue); @@ -6946,43 +6115,37 @@ var detailActions = { type: (_a = ActionType === null || ActionType === void 0 ? void 0 : ActionType.Detail) === null || _a === void 0 ? void 0 : _a.BACKUP_STRATEGY_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + openInstanceConsole: ffRedux.generateWorkflowActionCreator({ - actionType: (_b$4 = ActionType.Detail) === null || _b$4 === void 0 ? void 0 : _b$4.OPEN_CONSOLE_WORKFLOW, + actionType: (_b$5 = ActionType.Detail) === null || _b$5 === void 0 ? void 0 : _b$5.OPEN_CONSOLE_WORKFLOW, workflowStateLocator: function workflowStateLocator(state) { var _a; - return (_a = state.detail) === null || _a === void 0 ? void 0 : _a.openConsoleWorkflow; }, operationExecutor: openInstanceConsole, - after: (_a$5 = {}, _a$5[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { + after: (_a$6 = {}, _a$6[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { var openConsoleWorkflow = getState().detail.openConsoleWorkflow; - if (ffRedux.isSuccessWorkflow(openConsoleWorkflow)) { dispatch(detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceDetail.fetch()); } - }, _a$5) + }, _a$6) }), showCreateResourceDialog: function showCreateResourceDialog(show) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, serviceInstanceSchema, route, _b, route_1, platform, regionId; - var _c, _d, _e, _f, _g, _h; - return tslib.__generator(this, function (_j) { _a = getState(), serviceInstanceSchema = _a.detail.serviceInstanceSchema, route = _a.base.route; dispatch({ type: ActionType.Detail.SHOW_CREATE_RESOURCE_DIALOG, payload: show }); - if (!show) { dispatch(detailActions === null || detailActions === void 0 ? void 0 : detailActions.initServiceBindingEdit((_e = (_d = (_c = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.bindingCreateParameterSchema) !== null && _e !== void 0 ? _e : [])); } else { @@ -6999,14 +6162,12 @@ var detailActions = { platform: platform })); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + // 命名空间资源 namespaces: ffRedux.createFFListActions({ actionName: ActionType.Detail.FETCH_NAMESPACES, @@ -7016,21 +6177,13 @@ var detailActions = { return tslib.__generator(this, function (_a) { switch (_a.label) { case 0: - if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchNamespaces(query === null || query === void 0 ? void 0 : query.filter)]; - + if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchNamespaces(query === null || query === void 0 ? void 0 : query.filter)]; case 1: result = _a.sent(); _a.label = 2; - case 2: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -7040,7 +6193,6 @@ var detailActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b; - if ((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a[0]) { dispatch(listActions.services.select((_b = record === null || record === void 0 ? void 0 : record.data) === null || _b === void 0 ? void 0 : _b[0])); } @@ -7053,11 +6205,8 @@ var detailActions = { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b, _c; - var _d, _e, _f; - return tslib.__generator(this, function (_g) { if (key) { _a = (_e = (_d = getState()) === null || _d === void 0 ? void 0 : _d.detail) === null || _e === void 0 ? void 0 : _e.serviceBindingEdit, formData = _a.formData, validator = _a.validator; @@ -7070,21 +6219,17 @@ var detailActions = { payload: newEdit }); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + initServiceBindingEdit: function initServiceBindingEdit(data) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, editData, newEdit; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.serviceBindingEdit, formData = _a.formData, validator = _a.validator; editData = ServiceBinding === null || ServiceBinding === void 0 ? void 0 : ServiceBinding.initServiceResourceEdit(data); @@ -7096,41 +6241,30 @@ var detailActions = { type: ActionType.Detail.SERVICE_BINDING_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + serviceInstanceSchema: ffRedux.createFFObjectActions({ actionName: ActionType.Detail.FETCH_SERVICE_INSTANCE_SCHEMA, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var filter, _a, platform, route, response; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: filter = query.filter; _a = (_b = getState()) === null || _b === void 0 ? void 0 : _b.base, platform = _a.platform, route = _a.route; - if (!filter) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchResourceSchemas(filter)]; - + if (!filter) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchResourceSchemas(filter)]; case 1: response = _c.sent(); _c.label = 2; - case 2: - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); @@ -7140,10 +6274,8 @@ var detailActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a; - if (record === null || record === void 0 ? void 0 : record.data) { var selectedDetailTab = getState().detail.selectedDetailTab; - if (selectedDetailTab === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding)) { dispatch(detailActions === null || detailActions === void 0 ? void 0 : detailActions.initServiceBindingEdit((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.bindingCreateParameterSchema)); } @@ -7155,21 +6287,15 @@ var detailActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var filter, _a, platform, route, result, response, cronArr; - var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; - return tslib.__generator(this, function (_o) { switch (_o.label) { case 0: filter = query.filter; _a = (_b = getState()) === null || _b === void 0 ? void 0 : _b.base, platform = _a.platform, route = _a.route; - return [4 - /*yield*/ - , fetchBackStrategy(filter)]; - + return [4 /*yield*/, fetchBackStrategy(filter)]; case 1: response = _o.sent(); - if (response) { cronArr = (_f = (_e = (_d = (_c = response === null || response === void 0 ? void 0 : response.spec) === null || _c === void 0 ? void 0 : _c.trigger) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.cron) === null || _f === void 0 ? void 0 : _f.split(' '); result = { @@ -7180,10 +6306,7 @@ var detailActions = { name: (_m = response === null || response === void 0 ? void 0 : response.metadata) === null || _m === void 0 ? void 0 : _m.name }; } - - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -7201,26 +6324,18 @@ var detailActions = { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, _b, editData, serviceInstanceSchema, _c, services, serviceResources, route, _d, formData, validator, instance, newValidatorModel, newEdit; - var _e, _f, _g, _h, _j, _k, _l, _m, _o; - return tslib.__generator(this, function (_p) { switch (_p.label) { case 0: _a = getState(), _b = _a.detail, editData = _b.serviceBindingEdit, serviceInstanceSchema = _b.serviceInstanceSchema, _c = _a.list, services = _c.services, serviceResources = _c.serviceResources, route = _a.base.route; - if (!editData) return [3 - /*break*/ - , 2]; + if (!editData) return [3 /*break*/, 2]; _d = (_f = (_e = getState()) === null || _e === void 0 ? void 0 : _e.detail) === null || _f === void 0 ? void 0 : _f.serviceBindingEdit, formData = _d.formData, validator = _d.validator; instance = (_j = (_h = (_g = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.records) === null || _j === void 0 ? void 0 : _j.find(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = route === null || route === void 0 ? void 0 : route.queries) === null || _b === void 0 ? void 0 : _b.instancename); }); - return [4 - /*yield*/ - , ServiceBinding._validateFormItem(editData, (_l = (_k = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.bindingCreateParameterSchema, (_m = services === null || services === void 0 ? void 0 : services.selection) === null || _m === void 0 ? void 0 : _m.name, instance)]; - + return [4 /*yield*/, ServiceBinding._validateFormItem(editData, (_l = (_k = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.bindingCreateParameterSchema, (_m = services === null || services === void 0 ? void 0 : services.selection) === null || _m === void 0 ? void 0 : _m.name, instance)]; case 1: newValidatorModel = _p.sent(); newEdit = { @@ -7232,11 +6347,8 @@ var detailActions = { payload: newEdit }); _p.label = 2; - case 2: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -7244,15 +6356,13 @@ var detailActions = { } }; -var _a$6, _b$5, _c$3; +var _a$7, _b$6, _c$3; var createActions = { updateInstanceEditSchema: function updateInstanceEditSchema(data) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, serviceInstanceEdit, newEdit; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.serviceInstanceEdit, formData = _a.formData, validator = _a.validator; serviceInstanceEdit = initServiceInstanceEdit(data); @@ -7264,20 +6374,17 @@ var createActions = { type: ActionType.Create.SERVICE_INSTANCE_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + serviceInstanceEdit: function serviceInstanceEdit(data) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.serviceInstanceEdit, formData = _a.formData, validator = _a.validator; newEdit = { @@ -7288,22 +6395,18 @@ var createActions = { type: ActionType.Create.SERVICE_INSTANCE_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + updateInstance: function updateInstance(key, value) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b; - var _c, _d; - return tslib.__generator(this, function (_e) { if (key) { _a = (_d = (_c = getState()) === null || _c === void 0 ? void 0 : _c.list) === null || _d === void 0 ? void 0 : _d.serviceInstanceEdit, formData = _a.formData, validator = _a.validator; @@ -7316,23 +6419,18 @@ var createActions = { payload: newEdit }); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + validateTimeBackup: function validateTimeBackup(key, message) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b; - var _c, _d; - return tslib.__generator(this, function (_e) { if (key) { _a = (_d = (_c = getState()) === null || _c === void 0 ? void 0 : _c.list) === null || _d === void 0 ? void 0 : _d.serviceInstanceEdit, formData = _a.formData, validator = _a.validator; @@ -7348,21 +6446,17 @@ var createActions = { payload: newEdit }); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + validateInstance: function validateInstance() { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, serviceInstanceEdit, servicesInstance, formData, instanceSchemas, vm; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = getState().list, serviceInstanceEdit = _a.serviceInstanceEdit, servicesInstance = _a.servicesInstance, formData = serviceInstanceEdit.formData; instanceSchemas = (_c = (_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.instanceCreateParameterSchema; @@ -7373,20 +6467,17 @@ var createActions = { validator: vm }) }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + updateServicePlanSchema: function updateServicePlanSchema(data) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, editData, newEdit; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.servicePlanEdit, formData = _a.formData, validator = _a.validator; editData = initServicePlanEdit(data); @@ -7398,20 +6489,17 @@ var createActions = { type: ActionType.Create.SERVICE_PLAN_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + servicePlanEdit: function servicePlanEdit(data) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b, _c; - return tslib.__generator(this, function (_d) { _a = (_c = (_b = getState()) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.servicePlanEdit, formData = _a.formData, validator = _a.validator; newEdit = { @@ -7422,22 +6510,18 @@ var createActions = { type: ActionType.Create.SERVICE_PLAN_EDIT, payload: newEdit }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + updatePlan: function updatePlan(key, value) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, formData, validator, newEdit; - var _b; - var _c, _d; - return tslib.__generator(this, function (_e) { if (key) { _a = (_d = (_c = getState()) === null || _c === void 0 ? void 0 : _c.list) === null || _d === void 0 ? void 0 : _d.servicePlanEdit, formData = _a.formData, validator = _a.validator; @@ -7450,14 +6534,12 @@ var createActions = { payload: newEdit }); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + validatePlan: function validatePlan(instanceSchemas) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { @@ -7471,30 +6553,25 @@ var createActions = { validator: vm }) }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + createResource: ffRedux.generateWorkflowActionCreator({ actionType: ActionType.Create.CREATE_SERVICE_RESOURCE, workflowStateLocator: function workflowStateLocator(state) { var _a; - return (_a = state.list) === null || _a === void 0 ? void 0 : _a.createResourceWorkflow; }, operationExecutor: createServiceResource, - after: (_a$6 = {}, _a$6[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { + after: (_a$7 = {}, _a$7[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { var _a, _b, _c, _d, _e, _f; - var _g = getState(), - route = _g.base.route, - createResourceWorkflow = _g.list.createResourceWorkflow; - + route = _g.base.route, + createResourceWorkflow = _g.list.createResourceWorkflow; var specificOperate = ((_a = createResourceWorkflow === null || createResourceWorkflow === void 0 ? void 0 : createResourceWorkflow.targets) === null || _a === void 0 ? void 0 : _a[0]).specificOperate; - if (ffRedux.isSuccessWorkflow(createResourceWorkflow)) { if ((_b = [CreateSpecificOperatorEnum.BackupNow, CreateSpecificOperatorEnum.BackupStrategy, CreateSpecificOperatorEnum === null || CreateSpecificOperatorEnum === void 0 ? void 0 : CreateSpecificOperatorEnum.CreateServiceBinding]) === null || _b === void 0 ? void 0 : _b.includes(specificOperate)) { dispatch((_c = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _c === void 0 ? void 0 : _c.fetch()); @@ -7510,35 +6587,29 @@ var createActions = { mode: "list" }); } - dispatch(createActions.createResource.reset()); } else { specificOperate === CreateSpecificOperatorEnum.BackupNow && dispatch(createActions.createResource.reset()); } - dispatch({ type: (_f = ActionType.Detail) === null || _f === void 0 ? void 0 : _f.BACKUP_RESOURCE_LOADING, payload: false }); - }, _a$6) + }, _a$7) }), updateResource: ffRedux.generateWorkflowActionCreator({ actionType: ActionType.Create.CREATE_SERVICE_RESOURCE, workflowStateLocator: function workflowStateLocator(state) { var _a; - return (_a = state.list) === null || _a === void 0 ? void 0 : _a.updateResourceWorkflow; }, operationExecutor: updateServiceResource, - after: (_b$5 = {}, _b$5[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { + after: (_b$6 = {}, _b$6[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { var _a, _b, _c; - var updateResourceWorkflow = getState().list.updateResourceWorkflow; - if (ffRedux.isSuccessWorkflow(updateResourceWorkflow)) { dispatch(createActions.updateResource.reset()); var specificOperate = ((_a = updateResourceWorkflow === null || updateResourceWorkflow === void 0 ? void 0 : updateResourceWorkflow.targets) === null || _a === void 0 ? void 0 : _a[0]).specificOperate; - if ((_b = [CreateSpecificOperatorEnum.BackupNow, CreateSpecificOperatorEnum.BackupStrategy, CreateSpecificOperatorEnum === null || CreateSpecificOperatorEnum === void 0 ? void 0 : CreateSpecificOperatorEnum.CreateServiceBinding]) === null || _b === void 0 ? void 0 : _b.includes(specificOperate)) { dispatch(detailActions === null || detailActions === void 0 ? void 0 : detailActions.showBackupDialog(false)); dispatch((_c = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _c === void 0 ? void 0 : _c.fetch()); @@ -7547,23 +6618,19 @@ var createActions = { dispatch(listActions.serviceResources.fetch()); } } - }, _b$5) + }, _b$6) }), backupResourceNow: function backupResourceNow(params) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var hubCluster, platform, clusterId, regionId, cosParam, result; - var _a, _b, _c; - return tslib.__generator(this, function (_d) { switch (_d.label) { case 0: hubCluster = getState().base.hubCluster; platform = params.platform, clusterId = params.clusterId, regionId = params.regionId; - if (!params) return [3 - /*break*/ - , 2]; + if (!params) return [3 /*break*/, 2]; cosParam = { platform: platform, clusterId: Util === null || Util === void 0 ? void 0 : Util.getCOSClusterId(platform, (_a = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.object) === null || _a === void 0 ? void 0 : _a.data), @@ -7573,13 +6640,9 @@ var createActions = { type: (_b = ActionType.Detail) === null || _b === void 0 ? void 0 : _b.BACKUP_RESOURCE_LOADING, payload: true }); - return [4 - /*yield*/ - , checkCosResource(cosParam)]; - + return [4 /*yield*/, checkCosResource(cosParam)]; case 1: result = _d.sent(); - if (result) { dispatch(createActions.createResource.start([params], regionId)); dispatch(createActions.createResource.perform()); @@ -7590,38 +6653,30 @@ var createActions = { }); bridge.tips.error(ErrorMsgEnum.COS_Resource_Not_Found); } - _d.label = 2; - case 2: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); }; }, + createServiceInstance: ffRedux.generateWorkflowActionCreator({ actionType: ActionType.Create.CREATE_SERVICE_INSTANCE, workflowStateLocator: function workflowStateLocator(state) { var _a; - return (_a = state.list) === null || _a === void 0 ? void 0 : _a.createServiceInstanceWorkflow; }, operationExecutor: function operationExecutor(targets, params, dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, instance, backupStrategy, result, error, response; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: _a = targets === null || targets === void 0 ? void 0 : targets[0], instance = _a.instance, backupStrategy = _a.backupStrategy; - return [4 - /*yield*/ - , Promise.all([createServiceResource(instance, params).then(function (response) { + return [4 /*yield*/, Promise.all([createServiceResource(instance, params).then(function (response) { return response; }, function (error) { return error; @@ -7630,39 +6685,31 @@ var createActions = { }, function (error) { return error; })])]; - case 1: result = _c.sent(); error = result === null || result === void 0 ? void 0 : result.find(function (item) { var _a; - return (_a = item === null || item === void 0 ? void 0 : item[0]) === null || _a === void 0 ? void 0 : _a.error; }); response = []; result === null || result === void 0 ? void 0 : result.forEach(function (item) { response.push(item === null || item === void 0 ? void 0 : item[0]); }); - if (!(error === null || error === void 0 ? void 0 : error.length)) { - return [2 - /*return*/ - , operationResult(targets, [], response)]; + return [2 /*return*/, operationResult(targets, [], response)]; } else { - return [2 - /*return*/ - , operationResult(targets, (_b = error === null || error === void 0 ? void 0 : error[0]) === null || _b === void 0 ? void 0 : _b.error)]; + return [2 /*return*/, operationResult(targets, (_b = error === null || error === void 0 ? void 0 : error[0]) === null || _b === void 0 ? void 0 : _b.error)]; } } }); }); }, + after: (_c$3 = {}, _c$3[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { var _a, _b, _c, _d, _e, _f; - var _g = getState(), - route = _g.base.route, - createServiceInstanceWorkflow = _g.list.createServiceInstanceWorkflow; - + route = _g.base.route, + createServiceInstanceWorkflow = _g.list.createServiceInstanceWorkflow; if ((_c = (_b = (_a = createServiceInstanceWorkflow === null || createServiceInstanceWorkflow === void 0 ? void 0 : createServiceInstanceWorkflow.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.every(function (item) { return item === null || item === void 0 ? void 0 : item.success; })) { @@ -7680,41 +6727,31 @@ var createActions = { }) }; -var _a$7; +var _a$8; var listActions = { resourceSchemas: ffRedux.createFFObjectActions({ actionName: ActionType.List.FETCH_CREATE_RESOURCE_SCHEMAS, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, regionId, serviceName, platform, response; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: _a = query.filter, clusterId = _a.clusterId, regionId = _a.regionId, serviceName = _a.serviceName; platform = ((_b = getState()) === null || _b === void 0 ? void 0 : _b.base).platform; - if (!(platform && clusterId && regionId && serviceName)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchResourceSchemas({ + if (!(platform && clusterId && regionId && serviceName)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchResourceSchemas({ clusterId: clusterId, regionId: regionId, serviceName: serviceName, platform: platform })]; - case 1: response = _c.sent(); _c.label = 2; - case 2: - return [2 - /*return*/ - , response]; + return [2 /*return*/, response]; } }); }); @@ -7724,10 +6761,8 @@ var listActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b; - if (record === null || record === void 0 ? void 0 : record.data) { var selectedTab = getState().base.selectedTab; - if (selectedTab === ResourceTypeEnum.ServiceResource) { dispatch(createActions.updateInstanceEditSchema((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.instanceCreateParameterSchema)); } else if (selectedTab === ResourceTypeEnum.ServicePlan) { @@ -7740,40 +6775,39 @@ var listActions = { actionName: ActionType.List.FETCH_EXTERNAL_CLUSTERS, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { - var _a, regionId, _b, _c, regional, platform, result; - - var _d, _e, _f; - + var _a, regionId, _b, _c, regional, _d, platform, services, result; + var _e, _f; return tslib.__generator(this, function (_g) { switch (_g.label) { case 0: _a = query.filter, regionId = _a.regionId, _b = _a.clusterIds, _c = _a.regional, regional = _c === void 0 ? false : _c; - platform = ((_d = getState()) === null || _d === void 0 ? void 0 : _d.base).platform; - if (!(platform && regionId)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchExternalClusters({ + _d = getState(), platform = _d.base.platform, services = _d.list.services; + if (!(platform && regionId)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchExternalClusters({ platform: platform, regionId: regionId })]; - case 1: result = _g.sent(); _g.label = 2; - case 2: // 过滤状态为运行状态的注册集群 result.records = (_e = result === null || result === void 0 ? void 0 : result.records) === null || _e === void 0 ? void 0 : _e.filter(function (item) { var _a; - return (item === null || item === void 0 ? void 0 : item.status) === ((_a = ExternalCluster === null || ExternalCluster === void 0 ? void 0 : ExternalCluster.StatusEnum) === null || _a === void 0 ? void 0 : _a.Running); }); + // // 集群排序 + // result.records = result.records?.sort((a,b) => { + // if(services.selection?.clusters?.includes(a?.clusterId)){ + // return -1 + // }else if(services.selection?.clusters?.includes(b?.clusterId)){ + // return 1 + // }else{ + // return 0 + // } + // }) result.recordCount = (_f = result === null || result === void 0 ? void 0 : result.records) === null || _f === void 0 ? void 0 : _f.length; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -7783,14 +6817,11 @@ var listActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b; - var services = getState().list.services; var openVendorClusters = (_b = (_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.filter(function (item) { var _a, _b; - return (_b = (_a = services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes(item === null || item === void 0 ? void 0 : item.clusterId); }); - if (!!(openVendorClusters === null || openVendorClusters === void 0 ? void 0 : openVendorClusters.length)) { dispatch(listActions.externalClusters.select(openVendorClusters === null || openVendorClusters === void 0 ? void 0 : openVendorClusters[0])); } @@ -7798,12 +6829,11 @@ var listActions = { onSelect: function onSelect(record, dispatch, getState) { if (record) { var _a = getState().base, - selectedTab = _a.selectedTab, - route = _a.route, - platform = _a.platform; + selectedTab = _a.selectedTab, + route = _a.route, + platform = _a.platform; var sub = (router === null || router === void 0 ? void 0 : router.resolve(route)).sub; var mode = (route === null || route === void 0 ? void 0 : route.queries).mode; - if (sub === 'create' || mode === 'create') { if (selectedTab === ResourceTypeEnum.ServiceResource) { dispatch(createActions.updateInstance('clusterId', record === null || record === void 0 ? void 0 : record.clusterId)); @@ -7819,9 +6849,7 @@ var listActions = { fetcher: function fetcher(query, getState, fetchOptions, dispatch) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, regionId, serviceName, _b, resourceType, search, paging, platform, result; - var _c; - return tslib.__generator(this, function (_d) { switch (_d.label) { case 0: @@ -7831,25 +6859,17 @@ var listActions = { recordCount: 0, records: [] }; - if (!(platform && clusterId && serviceName && resourceType)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { + if (!(platform && clusterId && serviceName && resourceType)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { search: search, paging: paging }))]; - case 1: result = _d.sent(); _d.label = 2; - case 2: result.recordCount = result === null || result === void 0 ? void 0 : result.recordCount; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -7859,50 +6879,39 @@ var listActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; - var _u = getState(), - route = _u.base.route, - _v = _u.list, - serviceResources = _v.serviceResources, - services = _v.services; - + route = _u.base.route, + _v = _u.list, + serviceResources = _v.serviceResources, + services = _v.services; var sub = (router === null || router === void 0 ? void 0 : router.resolve(route)).sub; - if ((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.recordCount) { var instancename_1 = (route === null || route === void 0 ? void 0 : route.queries).instancename; var resource = void 0; - if (instancename_1) { resource = (_c = (_b = record === null || record === void 0 ? void 0 : record.data) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.find(function (item) { var _a; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === instancename_1; }); } else { resource = (_e = (_d = record === null || record === void 0 ? void 0 : record.data) === null || _d === void 0 ? void 0 : _d.records) === null || _e === void 0 ? void 0 : _e[0]; } - if (resource) { dispatch((_f = listActions === null || listActions === void 0 ? void 0 : listActions.serviceResources) === null || _f === void 0 ? void 0 : _f.select(resource)); - } // 拉取规格列表关联的实例资源/拉取实例列表中关联的规格资源 - - + } + // 拉取规格列表关联的实例资源/拉取实例列表中关联的规格资源 var filter = tslib.__assign(tslib.__assign({}, (_g = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.query) === null || _g === void 0 ? void 0 : _g.filter), { resourceType: ((_j = (_h = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.query) === null || _h === void 0 ? void 0 : _h.filter) === null || _j === void 0 ? void 0 : _j.resourceType) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServicePlan) ? ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceResource : ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServicePlan }); - dispatch((_k = listActions === null || listActions === void 0 ? void 0 : listActions.serviceResourceList) === null || _k === void 0 ? void 0 : _k.clear()); dispatch((_l = listActions === null || listActions === void 0 ? void 0 : listActions.serviceResourceList) === null || _l === void 0 ? void 0 : _l.applyFilter(filter)); - } //判断是否开启轮训 - - + } + //判断是否开启轮训 if (((_m = ['', 'list']) === null || _m === void 0 ? void 0 : _m.includes(sub)) && ((_p = (_o = record === null || record === void 0 ? void 0 : record.data) === null || _o === void 0 ? void 0 : _o.records) === null || _p === void 0 ? void 0 : _p.some(function (item) { var _a; - return (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp; })) && ((_r = (_q = record === null || record === void 0 ? void 0 : record.data) === null || _q === void 0 ? void 0 : _q.records) === null || _r === void 0 ? void 0 : _r.every(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.serviceClass) === ((_b = services === null || services === void 0 ? void 0 : services.selection) === null || _b === void 0 ? void 0 : _b.name); }))) { dispatch((_s = listActions === null || listActions === void 0 ? void 0 : listActions.serviceResources) === null || _s === void 0 ? void 0 : _s.polling({ @@ -7918,33 +6927,23 @@ var listActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, regionId, platform, result; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: _a = query.filter, clusterId = _a.clusterId, regionId = _a.regionId; platform = ((_b = getState()) === null || _b === void 0 ? void 0 : _b.base).platform; - if (!(platform && clusterId)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchOpenedServices({ + if (!(platform && clusterId)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchOpenedServices({ platform: platform, clusterId: clusterId, regionId: regionId })]; - case 1: result = _c.sent(); _c.label = 2; - case 2: - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -7954,12 +6953,10 @@ var listActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b, _c, _d, _e, _f, _g; - if ((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.recordCount) { var route = getState().base.route; var service = void 0; var servicename_1 = ((_b = route === null || route === void 0 ? void 0 : route.queries) === null || _b === void 0 ? void 0 : _b.servicename) || ((_c = parseQueryString(location === null || location === void 0 ? void 0 : location.search)) === null || _c === void 0 ? void 0 : _c['servicename']); - if (servicename_1 && servicename_1 !== 'undefined') { service = (_e = (_d = record === null || record === void 0 ? void 0 : record.data) === null || _d === void 0 ? void 0 : _d.records) === null || _e === void 0 ? void 0 : _e.find(function (item) { return (item === null || item === void 0 ? void 0 : item.name) === servicename_1; @@ -7967,37 +6964,30 @@ var listActions = { } else { service = (_g = (_f = record === null || record === void 0 ? void 0 : record.data) === null || _f === void 0 ? void 0 : _f.records) === null || _g === void 0 ? void 0 : _g[0]; } - dispatch(listActions.services.select(service !== null && service !== void 0 ? service : {})); } }, onSelect: function onSelect(record, dispatch, getState) { var _a, _b, _c; - var _d = getState(), - route = _d.base.route, - services = _d.list.services; - + route = _d.base.route, + services = _d.list.services; var resourceType = (route === null || route === void 0 ? void 0 : route.queries).resourceType; var selectedTab; - if (resourceType) { selectedTab = resourceType; } else { selectedTab = (_a = serviceMngTabs === null || serviceMngTabs === void 0 ? void 0 : serviceMngTabs[0]) === null || _a === void 0 ? void 0 : _a.id; - } // 重置服务资源列表 - - + } + // 重置服务资源列表 dispatch(listActions.serviceResources.clear()); dispatch(listActions.serviceResources.clearPolling()); dispatch(baseActions.selectTab(selectedTab)); - var _e = (_b = services === null || services === void 0 ? void 0 : services.query) === null || _b === void 0 ? void 0 : _b.filter, - regionId = _e.regionId, - platform = _e.platform; - - var clusterId = (_c = route === null || route === void 0 ? void 0 : route.queries) === null || _c === void 0 ? void 0 : _c.clusterid; // 查询resourceSchema配置 - + regionId = _e.regionId, + platform = _e.platform; + var clusterId = (_c = route === null || route === void 0 ? void 0 : route.queries) === null || _c === void 0 ? void 0 : _c.clusterid; + // 查询resourceSchema配置 if (platform && record && regionId && clusterId) { dispatch(listActions === null || listActions === void 0 ? void 0 : listActions.resourceSchemas.applyFilter({ platform: platform, @@ -8013,41 +7003,29 @@ var listActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, clusterId, regionId, serviceName, result; - var _b, _c, _d; - return tslib.__generator(this, function (_e) { switch (_e.label) { case 0: _a = query.filter, clusterId = _a.clusterId, regionId = _a.regionId, serviceName = _a.serviceName; - if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchServiceResources(query === null || query === void 0 ? void 0 : query.filter)]; - + if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchServiceResources(query === null || query === void 0 ? void 0 : query.filter)]; case 1: result = _e.sent(); _e.label = 2; - case 2: // 过滤掉为空的规格数据 result.records = (_b = result === null || result === void 0 ? void 0 : result.records) === null || _b === void 0 ? void 0 : _b.filter(function (item) { var _a; - return !isEmpty((_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.metadata); - }); // 按照创建时间降序排列 - + }); + // 按照创建时间降序排列 result.records = (_c = result.records) === null || _c === void 0 ? void 0 : _c.sort(function (pre, cur) { var _a, _b, _c, _d; - return ((_b = new Date((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp)) === null || _b === void 0 ? void 0 : _b.getTime()) - ((_d = new Date((_c = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _c === void 0 ? void 0 : _c.creationTimestamp)) === null || _d === void 0 ? void 0 : _d.getTime()); }); result.recordCount = (_d = result === null || result === void 0 ? void 0 : result.records) === null || _d === void 0 ? void 0 : _d.length; - return [2 - /*return*/ - , result]; + return [2 /*return*/, result]; } }); }); @@ -8057,20 +7035,17 @@ var listActions = { }, onFinish: function onFinish(record, dispatch) { var _a, _b, _c; - if ((_a = record === null || record === void 0 ? void 0 : record.data) === null || _a === void 0 ? void 0 : _a.recordCount) { dispatch(listActions.servicePlans.select((_c = (_b = record === null || record === void 0 ? void 0 : record.data) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c[0])); } }, onSelect: function onSelect(record, dispatch, get) { var _a; - if (record) { dispatch(createActions.updateInstance('plan', (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name)); } } }), - /** * 实例资源列表 */ @@ -8079,39 +7054,28 @@ var listActions = { fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var search, paging, serviceResources, resources; - var _a, _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: search = query.search, paging = query.paging; serviceResources = getState().list.serviceResources; - if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { + if (!(query === null || query === void 0 ? void 0 : query.filter)) return [3 /*break*/, 2]; + return [4 /*yield*/, fetchServiceResources(tslib.__assign(tslib.__assign({}, query === null || query === void 0 ? void 0 : query.filter), { search: search, paging: paging }))]; - case 1: resources = _c.sent(); _c.label = 2; - case 2: // 按照创建时间降序排列 resources.records = (_a = resources.records) === null || _a === void 0 ? void 0 : _a.sort(function (pre, cur) { var _a, _b, _c, _d; - return ((_b = new Date((_a = cur === null || cur === void 0 ? void 0 : cur.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp)) === null || _b === void 0 ? void 0 : _b.getTime()) - ((_d = new Date((_c = pre === null || pre === void 0 ? void 0 : pre.metadata) === null || _c === void 0 ? void 0 : _c.creationTimestamp)) === null || _d === void 0 ? void 0 : _d.getTime()); }); resources.recordCount = (_b = resources === null || resources === void 0 ? void 0 : resources.records) === null || _b === void 0 ? void 0 : _b.length; - return [2 - /*return*/ - , resources]; + return [2 /*return*/, resources]; } }); }); @@ -8128,34 +7092,30 @@ var listActions = { type: ActionType.List.SELECT_DELETE_RESOURCE, payload: resources }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + showInstanceDialog: function showInstanceDialog(isShowInstanceDialog) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a; - return tslib.__generator(this, function (_b) { if (!isShowInstanceDialog) { dispatch((_a = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _a === void 0 ? void 0 : _a.clear()); } - dispatch({ type: ActionType.List.SHOW_INSTANCE_TABLE_DIALOG, payload: isShowInstanceDialog }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + showCreateResourceDialog: function showCreateResourceDialog(isShowDialog) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { @@ -8164,29 +7124,25 @@ var listActions = { type: ActionType.List.SHOW_CREATE_RESOURCE_DIALOG, payload: isShowDialog }); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + deleteResource: ffRedux.generateWorkflowActionCreator({ actionType: ActionType.List.DELETE_SERVICE_RESOURCE, workflowStateLocator: function workflowStateLocator(state) { return state.list.deleteResourceWorkflow; }, operationExecutor: deleteMulServiceResource, - after: (_a$7 = {}, _a$7[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { + after: (_a$8 = {}, _a$8[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { var _a, _b, _c, _d, _e, _f; - var deleteResourceWorkflow = getState().list.deleteResourceWorkflow; var resourceInfos = ((_a = deleteResourceWorkflow === null || deleteResourceWorkflow === void 0 ? void 0 : deleteResourceWorkflow.targets) === null || _a === void 0 ? void 0 : _a[0]).resourceInfos; - if (ffRedux.isSuccessWorkflow(deleteResourceWorkflow)) { dispatch(listActions.deleteResource.reset()); dispatch(listActions.selectDeleteResources([])); - if ((_b = [ResourceTypeEnum.ServiceResource, ResourceTypeEnum.ServicePlan]) === null || _b === void 0 ? void 0 : _b.includes((_c = resourceInfos === null || resourceInfos === void 0 ? void 0 : resourceInfos[0]) === null || _c === void 0 ? void 0 : _c.kind)) { dispatch((_d = listActions === null || listActions === void 0 ? void 0 : listActions.serviceResources) === null || _d === void 0 ? void 0 : _d.fetch()); } else { @@ -8194,12 +7150,12 @@ var listActions = { dispatch((_f = detailActions === null || detailActions === void 0 ? void 0 : detailActions.instanceResource) === null || _f === void 0 ? void 0 : _f.selects([])); } } - }, _a$7) + }, _a$8) }) }; +var _a$9; var routerSea$3 = seajs.require('router'); - var baseActions = { /** 国际版 */ toggleIsI18n: function toggleIsI18n(isI18n) { @@ -8212,16 +7168,14 @@ var baseActions = { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, route, platform; - var _b; - return tslib.__generator(this, function (_c) { dispatch({ type: ActionType.Base.FETCH_REGION, payload: regionId }); - _a = getState().base, route = _a.route, platform = _a.platform; // tdcc首先拉取hub集群,然后拉取已开通的服务列表;tkeStack同时拉取目标集群和拉取已开通的服务列表 - + _a = getState().base, route = _a.route, platform = _a.platform; + // tdcc首先拉取hub集群,然后拉取已开通的服务列表;tkeStack同时拉取目标集群和拉取已开通的服务列表 if (platform === (PlatformType === null || PlatformType === void 0 ? void 0 : PlatformType.TDCC)) { dispatch(baseActions.hubCluster.applyFilter({ regionId: regionId, @@ -8238,19 +7192,17 @@ var baseActions = { clusterIds: [], regionId: regionId })); - } //拉取用户信息 - - + } + //拉取用户信息 dispatch((_b = baseActions.userInfo) === null || _b === void 0 ? void 0 : _b.applyFilter({ platform: platform })); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + fetchPlatform: function fetchPlatform(platform, region) { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { @@ -8264,40 +7216,30 @@ var baseActions = { route = getState().base.route; regionId = region !== null && region !== void 0 ? region : HubCluster.DefaultRegion; dispatch(baseActions === null || baseActions === void 0 ? void 0 : baseActions.fetchRegion(regionId)); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + hubCluster: ffRedux.createFFObjectActions({ actionName: ActionType.Base.HubCluster, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, platform, route, response, data; - var _b; - return tslib.__generator(this, function (_c) { switch (_c.label) { case 0: _a = getState().base, platform = _a.platform, route = _a.route; - return [4 - /*yield*/ - , fetchHubCluster(query === null || query === void 0 ? void 0 : query.filter)]; - + return [4 /*yield*/, fetchHubCluster(query === null || query === void 0 ? void 0 : query.filter)]; case 1: response = _c.sent(); data = (_b = response === null || response === void 0 ? void 0 : response.records) === null || _b === void 0 ? void 0 : _b[0]; - if (data && !(data === null || data === void 0 ? void 0 : data.regionId)) { data.regionId = HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion; } - - return [2 - /*return*/ - , data]; + return [2 /*return*/, data]; } }); }); @@ -8307,16 +7249,14 @@ var baseActions = { }, onFinish: function onFinish(record, dispatch, getState) { var _a, _b, _c, _d, _e; - var _f = getState().base, - route = _f.route, - platform = _f.platform, - regionId = _f.regionId; + route = _f.route, + platform = _f.platform, + regionId = _f.regionId; dispatch({ type: ActionType.Base.ClusterVersion, payload: '1.18.4' }); - if (!record.data) { if (platform === PlatformType.TDCC) { routerSea$3.navigate('/tdcc/paasoverview/startup'); @@ -8344,9 +7284,7 @@ var baseActions = { return function (dispatch, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var _a, _b, platform, route, hubCluster, regionId, _c, serviceResources, services, filter; - var _d, _e; - return tslib.__generator(this, function (_f) { dispatch({ type: ActionType.Base.SELECT_TAB, @@ -8359,51 +7297,37 @@ var baseActions = { serviceName: (_e = services === null || services === void 0 ? void 0 : services.selection) === null || _e === void 0 ? void 0 : _e.name, resourceType: tabId, regionId: regionId - }; // 重新查询服务资源列表 - + }; + // 重新查询服务资源列表 dispatch(listActions.serviceResources.clear()); dispatch(listActions.serviceResources.applyFilter(filter)); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; }, + userInfo: ffRedux.createFFObjectActions({ actionName: ActionType.Base.FETCH_UserInfo, fetcher: function fetcher(query, getState) { return tslib.__awaiter(void 0, void 0, void 0, function () { var response; - - var _a, _b; - - return tslib.__generator(this, function (_c) { - switch (_c.label) { + var _a; + return tslib.__generator(this, function (_b) { + switch (_b.label) { case 0: - if (!(((_a = query === null || query === void 0 ? void 0 : query.filter) === null || _a === void 0 ? void 0 : _a.platform) === PlatformType.TDCC)) return [3 - /*break*/ - , 1]; + if (!(((_a = query === null || query === void 0 ? void 0 : query.filter) === null || _a === void 0 ? void 0 : _a.platform) === PlatformType.TDCC)) return [3 /*break*/, 1]; response = { - name: Util === null || Util === void 0 ? void 0 : Util.getUserName((_b = query === null || query === void 0 ? void 0 : query.filter) === null || _b === void 0 ? void 0 : _b.platform) + name: Util === null || Util === void 0 ? void 0 : Util.getUin() }; - return [3 - /*break*/ - , 3]; - + return [3 /*break*/, 3]; case 1: - return [4 - /*yield*/ - , fetchUserInfo(query === null || query === void 0 ? void 0 : query.filter)]; - + return [4 /*yield*/, fetchUserInfo(query === null || query === void 0 ? void 0 : query.filter)]; case 2: - response = _c.sent(); - _c.label = 3; - + response = _b.sent(); + _b.label = 3; case 3: - return [2 - /*return*/ - , response !== null && response !== void 0 ? response : {}]; + return [2 /*return*/, response !== null && response !== void 0 ? response : {}]; } }); }); @@ -8411,6 +7335,22 @@ var baseActions = { getRecord: function getRecord(getState) { return getState().base.userInfo; } + }), + // 获取集群Admin权限 + getClusterAdminRole: ffRedux.generateWorkflowActionCreator({ + actionType: ActionType.Base.GetClusterAdminRoleFlow, + workflowStateLocator: function workflowStateLocator(state) { + return state.base.getClusterAdminRoleFlow; + }, + operationExecutor: getClusterAdminRole, + after: (_a$9 = {}, _a$9[ffRedux.OperationTrigger.Done] = function (dispatch, getState) { + var getClusterAdminRoleFlow = getState().base.getClusterAdminRoleFlow; + if (ffRedux.isSuccessWorkflow(getClusterAdminRoleFlow)) { + dispatch(baseActions.getClusterAdminRole.reset()); + dispatch(listActions.servicePlans.fetch()); + dispatch(listActions.resourceSchemas.fetch()); + } + }, _a$9) }) }; @@ -8429,15 +7369,13 @@ var ResetStoreAction = 'ResetStore'; * 生成可重置的reducer,用于rootReducer简单包装 * @return 可重置的reducer,当接收到 ResetStoreAction 时重置之 */ - var generateResetableReducer = function generateResetableReducer(rootReducer) { return function (state, action) { - var newState = state; // 销毁页面 - + var newState = state; + // 销毁页面 if (action.type === ResetStoreAction) { newState = undefined; } - return rootReducer(newState, action); }; }; @@ -8454,15 +7392,17 @@ var TempReducer = redux.combineReducers({ clusterVersion: ffRedux.reduceToPayload(ActionType.Base.ClusterVersion, ''), userInfo: ffRedux.createFFObjectReducer({ actionName: ActionType.Base.FETCH_UserInfo + }), + getClusterAdminRoleFlow: ffRedux.generateWorkflowReducer({ + actionType: ActionType.Base.GetClusterAdminRoleFlow }) }); var baseReducer = function baseReducer(state, action) { - var newState = state; // 销毁页面 - + var newState = state; + // 销毁页面 if (action.type === ActionType.Base.Clear) { newState = undefined; } - return TempReducer(newState, action); }; @@ -8474,7 +7414,6 @@ var TempReducer$1 = redux.combineReducers({ instanceResource: ffRedux.createFFListReducer({ actionName: ActionType.Detail.FETCH_INSTANCE_RESOURCE }), - /**检测COS存储是否配置 */ checkCosResource: ffRedux.createFFObjectReducer({ actionName: ActionType.Detail.CHECK_COS @@ -8484,7 +7423,6 @@ var TempReducer$1 = redux.combineReducers({ showCreateResourceDialog: ffRedux.reduceToPayload(ActionType.Detail.SHOW_CREATE_RESOURCE_DIALOG, false), selectDetailResource: ffRedux.reduceToPayload(ActionType.Detail.SELECT_DETAIL_RESOURCE, []), backupStrategyEdit: ffRedux.reduceToPayload(ActionType.Detail.BACKUP_STRATEGY_EDIT, tslib.__assign({}, BackupStrategyEditInitValue)), - /** 开启/关闭控制台 */ openConsoleWorkflow: ffRedux.generateWorkflowReducer({ actionType: ActionType.Detail.OPEN_CONSOLE_WORKFLOW @@ -8501,12 +7439,11 @@ var TempReducer$1 = redux.combineReducers({ }) }); var detailReducer = function detailReducer(state, action) { - var newState = state; // 销毁页面 - + var newState = state; + // 销毁页面 if (action.type === ActionType.List.Clear) { newState = undefined; } - return TempReducer$1(newState, action); }; @@ -8545,22 +7482,18 @@ var TempReducer$2 = redux.combineReducers({ description: '' } }), - /** 新建资源工作流 */ createResourceWorkflow: ffRedux.generateWorkflowReducer({ actionType: ActionType.Create.CREATE_SERVICE_RESOURCE }), - /** 编辑资源工作流 */ updateResourceWorkflow: ffRedux.generateWorkflowReducer({ actionType: ActionType.Create.CREATE_SERVICE_RESOURCE }), - /** 创建备份策略工作流 */ createServiceInstanceWorkflow: ffRedux.generateWorkflowReducer({ actionType: ActionType.Create.CREATE_SERVICE_INSTANCE }), - /** 已关联的资源列表(实例或者规格) */ serviceResourceList: ffRedux.createFFListReducer({ actionName: ActionType.List.FETCH_SERVICE_RESOURCE_LIST @@ -8568,19 +7501,17 @@ var TempReducer$2 = redux.combineReducers({ deleteResourceSelection: ffRedux.reduceToPayload(ActionType.List.SELECT_DELETE_RESOURCE, []), showInstanceTableDialog: ffRedux.reduceToPayload(ActionType.List.SHOW_INSTANCE_TABLE_DIALOG, false), showCreateResourceDialog: ffRedux.reduceToPayload(ActionType.List.SHOW_CREATE_RESOURCE_DIALOG, false), - /** 删除资源工作流 */ deleteResourceWorkflow: ffRedux.generateWorkflowReducer({ actionType: ActionType.List.DELETE_SERVICE_RESOURCE }) }); var listReducer = function listReducer(state, action) { - var newState = state; // 销毁页面 - + var newState = state; + // 销毁页面 if (action.type === ActionType.List.Clear) { newState = undefined; } - return TempReducer$2(newState, action); }; @@ -8596,53 +7527,127 @@ var createStore = process.env.NODE_ENV === 'development' ? redux.applyMiddleware }))(redux.createStore) : redux.applyMiddleware(thunk)(redux.createStore); function configStore() { - var store = createStore(generateResetableReducer(RootReducer)); // hot reloading + var store = createStore(generateResetableReducer(RootReducer)); + // hot reloading // if (typeof module !== 'undefined' && (module as any).hot) { // (module as any).hot.accept('../reducers/RootReducer', () => { // store.replaceReducer(generateResetableReducer(require('../reducers/RootReducer').RootReducer)); // }); // } - return store; } -function ServiceInstanceCreatePanel(props) { - var _this = this; +var ErrorEnum; +(function (ErrorEnum) { + var Code; + (function (Code) { + Code["RBACForbidden"] = "FailedOperation.RBACForbidden"; + Code[Code["RBACForbidden403"] = 403] = "RBACForbidden403"; + })(Code = ErrorEnum.Code || (ErrorEnum.Code = {})); +})(ErrorEnum || (ErrorEnum = {})); - var _a, _b, _c, _d, _e, _f; +function GetRbacAdminDialog(props) { + var _a, _b, _c; + var actions = props.actions, + _d = props.base, + hubCluster = _d.hubCluster, + getClusterAdminRoleFlow = _d.getClusterAdminRoleFlow, + platform = _d.platform, + externalClusters = props.list.externalClusters, + clusterId = (_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _a === void 0 ? void 0 : _a.clusterId, + regionId = (_c = (_b = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.object) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.regionId; + var workflow = getClusterAdminRoleFlow; + var action = actions.base.getClusterAdminRole; + if (workflow.operationState === ffRedux.OperationState.Pending) { + return React__default.createElement("noscript", null); + } + var cancel = function cancel() { + if (workflow.operationState === ffRedux.OperationState.Done) { + action.reset(); + } else { + action.cancel(); + } + }; + var perform = function perform() { + // 提交操作 + var params = { + id: uuid(), + platform: platform, + clusterId: clusterId, + clusterType: ClusterType.External + }; + action.start([params], regionId); + action.perform(); + }; + var failed = workflow.operationState === ffRedux.OperationState.Done && !ffRedux.isSuccessWorkflow(workflow); + return React__default.createElement(ModalMain.Modal, { + visible: true, + caption: i18n.t('获取集群Admin角色'), + onClose: cancel, + disableEscape: true + }, React__default.createElement(ModalMain.Modal.Body, null, React__default.createElement(i18n.Trans, null, React__default.createElement(teaComponent.Text, { + theme: "text", + parent: "p" + }, "\u5B50\u8D26\u6237\u5728CAM\u62E5\u6709AcquireClusterAdminRole Action\u6743\u9650\u4E4B\u540E\u53EF\u4EE5\u901A\u8FC7\u6B64\u65B9\u5F0F\u83B7\u53D6\u96C6\u7FA4Kubernetes RBAC\u7684tke:admin\u89D2\u8272"), React__default.createElement(teaComponent.Text, { + theme: "text", + parent: "p" + }, "\u70B9\u51FB\u786E\u5B9A\u4E4B\u540E\uFF0C\u540E\u53F0\u4F1A\u4E3A\u60A8\u521B\u5EFAtke:admin\u89D2\u8272\u7684ClusterRolebinding\uFF0C\u4E4B\u540E\u60A8\u5C06\u62E5\u6709\u6B64\u96C6\u7FA4\u5185\u8D44\u6E90\u7684\u7BA1\u7406\u5458\u6743\u9650\u3002")), failed && (ffComponent.isCamRefused(workflow.results[0].error) ? React__default.createElement(ffComponent.CamBox, { + message: workflow.results[0].error.message + }) : React__default.createElement(TipInfo, { + isForm: true, + type: "error" + }, getWorkflowError(workflow)))), React__default.createElement(ModalMain.Modal.Footer, null, React__default.createElement(teaComponent.Button, { + type: "primary", + disabled: workflow.operationState === ffRedux.OperationState.Performing, + onClick: perform + }, failed ? i18n.t('重试') : i18n.t('确定')), React__default.createElement(teaComponent.Button, { + onClick: cancel + }, i18n.t('取消')))); +} +var mapDispatchToProps = function mapDispatchToProps(dispatch) { + return Object.assign({}, ffRedux.bindActionCreators({ + actions: allActions + }, dispatch), { + dispatch: dispatch + }); +}; +var ResourceGetRbacAdminDialog = reactRedux.connect(function (state) { + return state; +}, mapDispatchToProps)(GetRbacAdminDialog); +function ServiceInstanceCreatePanel(props) { + var _this = this; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; var actions = props.actions, - _g = props.base, - platform = _g.platform, - route = _g.route, - hubCluster = _g.hubCluster, - isI18n = _g.isI18n, - userInfo = _g.userInfo, - regionId = _g.regionId, - _h = props.list, - services = _h.services, - servicePlans = _h.servicePlans, - createResourceWorkflow = _h.createResourceWorkflow, - createServiceInstanceWorkflow = _h.createServiceInstanceWorkflow, - externalClusters = _h.externalClusters; + _q = props.base, + platform = _q.platform, + route = _q.route, + hubCluster = _q.hubCluster, + isI18n = _q.isI18n, + userInfo = _q.userInfo, + regionId = _q.regionId, + _r = props.list, + services = _r.services, + servicePlans = _r.servicePlans, + createResourceWorkflow = _r.createResourceWorkflow, + createServiceInstanceWorkflow = _r.createServiceInstanceWorkflow, + externalClusters = _r.externalClusters; var servicename = (route === null || route === void 0 ? void 0 : route.queries).servicename; var servicesInstance = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.servicesInstance; }); var servicesInstanceEdit = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.serviceInstanceEdit; }); - var isLoadingSchema = ((_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.fetchState) === ffRedux.FetchState.Fetching || !((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.fetched); + var isLoadingSchema = ((_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _a === void 0 ? void 0 : _a.fetched) && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) ? !((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.fetched) : !((_c = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _c === void 0 ? void 0 : _c.fetched); + var loadSchemaFailed = ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.fetched) && ((_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.error) && (!((_f = ['ResourceNotFound', 404]) === null || _f === void 0 ? void 0 : _f.includes((_h = (_g = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code)) || !((_l = (_k = (_j = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _j === void 0 ? void 0 : _j.error) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.includes('404'))); React.useEffect(function () { var _a; - var clusterId = (_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _a === void 0 ? void 0 : _a.clusterId; - if (actions.list.resourceSchemas && platform && servicename && clusterId) { + actions.list.resourceSchemas.reset(); actions.list.resourceSchemas.applyFilter({ platform: platform, serviceName: servicename, @@ -8653,10 +7658,9 @@ function ServiceInstanceCreatePanel(props) { }, [actions.list.resourceSchemas, regionId, platform, servicename, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); React.useEffect(function () { var _a; - var clusterId = (_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _a === void 0 ? void 0 : _a.clusterId; - if (actions.list.servicePlans && platform && servicename && clusterId) { + actions.list.servicePlans.reset(); actions.list.servicePlans.applyFilter({ platform: platform, serviceName: servicename, @@ -8668,7 +7672,6 @@ function ServiceInstanceCreatePanel(props) { }, [actions.list.servicePlans, platform, servicename, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); React.useEffect(function () { var _a, _b; - if (platform && ((_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.externalClusters) && (services === null || services === void 0 ? void 0 : services.selection)) { (_b = actions === null || actions === void 0 ? void 0 : actions.list) === null || _b === void 0 ? void 0 : _b.externalClusters.applyFilter({ platform: platform, @@ -8676,40 +7679,24 @@ function ServiceInstanceCreatePanel(props) { regionId: regionId }); } - }, [(_c = actions === null || actions === void 0 ? void 0 : actions.list) === null || _c === void 0 ? void 0 : _c.externalClusters, platform, services === null || services === void 0 ? void 0 : services.selection]); - var loadSchemaFailed = React__default === null || React__default === void 0 ? void 0 : React__default.useMemo(function () { - var _a, _b, _c, _d; - - return ((_a = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _a === void 0 ? void 0 : _a['isSetParams']) && ((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.fetched) && (((_c = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _c === void 0 ? void 0 : _c.error) || ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.fetchState) === ffRedux.FetchState.Failed); - }, [(_d = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _d === void 0 ? void 0 : _d['isSetParams'], servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object]); // 由于vendor在目标集群上开启为异步操作,因此若vendor在集群上执行了开启且schema加载resource not found,则认为vendor正在开启中 - + }, [(_m = actions === null || actions === void 0 ? void 0 : actions.list) === null || _m === void 0 ? void 0 : _m.externalClusters, platform, services === null || services === void 0 ? void 0 : services.selection]); + // 由于vendor在目标集群上开启为异步操作,因此若vendor在集群上执行了开启且schema加载resource not found,则认为vendor正在开启中 var openingVendor = React__default === null || React__default === void 0 ? void 0 : React__default.useMemo(function () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return ((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes((_c = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _c === void 0 ? void 0 : _c.clusterId)) && ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.fetched) && (((_f = (_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.code) === 'ResourceNotFound' || ((_h = (_g = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) === 404 || ((_l = (_k = (_j = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _j === void 0 ? void 0 : _j.error) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.includes('404'))); }, [servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object, services === null || services === void 0 ? void 0 : services.selection, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); - var showVisitForbidden = React__default === null || React__default === void 0 ? void 0 : React__default.useMemo(function () { - var _a, _b, _c, _d, _e, _f, _g; - - return ((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes((_c = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _c === void 0 ? void 0 : _c.clusterId)) && ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.fetched) && ((_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.error) && ((_g = (_f = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message.includes('forbidden')); - }, [servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object, services === null || services === void 0 ? void 0 : services.selection, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); - var createWorkflow = ((_e = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _e === void 0 ? void 0 : _e.timeBackup) ? createServiceInstanceWorkflow : createResourceWorkflow; - + var createWorkflow = ((_o = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _o === void 0 ? void 0 : _o.timeBackup) ? createServiceInstanceWorkflow : createResourceWorkflow; var reduceCreateServiceResourceDataJson = function reduceCreateServiceResourceDataJson(data) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - var _l = data === null || data === void 0 ? void 0 : data.formData, - instanceName = _l.instanceName, - plan = _l.plan, - timeBackup = _l.timeBackup, - clusterId = _l.clusterId; //拼接中间件实例参数部分属性值 - - + instanceName = _l.instanceName, + plan = _l.plan, + timeBackup = _l.timeBackup, + clusterId = _l.clusterId; + //拼接中间件实例参数部分属性值 var parameters = (_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceCreateParameterSchema) === null || _c === void 0 ? void 0 : _c.reduce(function (pre, cur) { var _a; - var _b, _c, _d, _e; - return Object.assign(pre, ((_b = data === null || data === void 0 ? void 0 : data.formData) === null || _b === void 0 ? void 0 : _b[cur === null || cur === void 0 ? void 0 : cur.name]) !== '' ? (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = formatPlanSchemaSubmitData(cur, (_c = data === null || data === void 0 ? void 0 : data.formData) === null || _c === void 0 ? void 0 : _c[cur === null || cur === void 0 ? void 0 : cur.name], (_e = (_d = data === null || data === void 0 ? void 0 : data.formData) === null || _d === void 0 ? void 0 : _d['unitMap']) === null || _e === void 0 ? void 0 : _e[cur === null || cur === void 0 ? void 0 : cur.name]), _a) : {}); }, {}); var json = { @@ -8729,16 +7716,15 @@ function ServiceInstanceCreatePanel(props) { servicePlan: plan, enableBackup: timeBackup, parameters: parameters, - externalID: DefaultNamespace + '-' + instanceName // ...backupParams, - + externalID: DefaultNamespace + '-' + instanceName + // ...backupParams, } }; + return JSON.stringify(json); }; - var _cancel = function _cancel() { var _a, _b, _c; - router === null || router === void 0 ? void 0 : router.navigate({ sub: 'list', tab: undefined @@ -8748,21 +7734,11 @@ function ServiceInstanceCreatePanel(props) { mode: "list" }); }; - var _submit = function _submit() { - var _a, _b, _c, _d, _e, _f, _g; - + var _a, _b, _c, _d; var formData = servicesInstanceEdit.formData; - - if ((formData === null || formData === void 0 ? void 0 : formData['isSetParams']) && !((_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceCreateParameterSchema) === null || _c === void 0 ? void 0 : _c.length)) { - teaComponent.message === null || teaComponent.message === void 0 ? void 0 : teaComponent.message.warning({ - content: i18n.t('Schema数据异常,请刷新重试') - }); - return; - } actions.create.validateInstance(); - - if (_validateInstance(servicesInstanceEdit, (_e = (_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.instanceCreateParameterSchema)) { + if (_validateInstance(servicesInstanceEdit, (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.instanceCreateParameterSchema)) { if (!(formData === null || formData === void 0 ? void 0 : formData.timeBackup)) { var params = { platform: platform, @@ -8793,7 +7769,7 @@ function ServiceInstanceCreatePanel(props) { backupReserveDay: formData === null || formData === void 0 ? void 0 : formData.backupReserveDay, instanceId: DefaultNamespace + '-' + (formData === null || formData === void 0 ? void 0 : formData.instanceName), instanceName: formData === null || formData === void 0 ? void 0 : formData.instanceName, - serviceName: ((_f = services === null || services === void 0 ? void 0 : services.selection) === null || _f === void 0 ? void 0 : _f.name) || ((_g = route === null || route === void 0 ? void 0 : route.queries) === null || _g === void 0 ? void 0 : _g.servicename) + serviceName: ((_c = services === null || services === void 0 ? void 0 : services.selection) === null || _c === void 0 ? void 0 : _c.name) || ((_d = route === null || route === void 0 ? void 0 : route.queries) === null || _d === void 0 ? void 0 : _d.servicename) }), resourceType: ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.Backup, namespace: SystemNamespace @@ -8807,10 +7783,8 @@ function ServiceInstanceCreatePanel(props) { } } }; - var renderContent = function renderContent(data) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22; - + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28; var versionFields = (_a = data === null || data === void 0 ? void 0 : data.instanceCreateParameterSchema) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return (item === null || item === void 0 ? void 0 : item.name) === 'version'; }); @@ -8835,6 +7809,12 @@ function ServiceInstanceCreatePanel(props) { }, React__default.createElement(ffComponent.FormPanel.Text, null, i18n.t('{{name}}', { name: (_f = route === null || route === void 0 ? void 0 : route.queries) === null || _f === void 0 ? void 0 : _f.servicename }))), React__default.createElement(ffComponent.FormPanel.Item, { + after: React__default.createElement(teaComponent.Button, { + icon: 'refresh', + onClick: function onClick() { + actions.list.externalClusters.fetch(); + } + }), label: React__default.createElement(teaComponent.Text, { style: { display: 'flex', @@ -8853,7 +7833,6 @@ function ServiceInstanceCreatePanel(props) { action: (_h = actions === null || actions === void 0 ? void 0 : actions.list) === null || _h === void 0 ? void 0 : _h.externalClusters, disabledField: function disabledField(record) { var _a, _b, _c; - var disabled = !((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes(record === null || record === void 0 ? void 0 : record.clusterId)); return { disabled: disabled, @@ -8863,12 +7842,17 @@ function ServiceInstanceCreatePanel(props) { }; } }, - message: React__default.createElement(React__default.Fragment, null, ((_j = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _j === void 0 ? void 0 : _j.fetched) && !((_l = (_k = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.recordCount) ? React__default.createElement(teaComponent.Text, null, i18n.t('无运行状态的目标集群,'), React__default.createElement(teaComponent.Button, { - type: 'link', - onClick: function onClick() { + message: React__default.createElement(React__default.Fragment, null, ((_j = services === null || services === void 0 ? void 0 : services.list) === null || _j === void 0 ? void 0 : _j.fetched) && !((_l = (_k = services.selection) === null || _k === void 0 ? void 0 : _k.clusters) === null || _l === void 0 ? void 0 : _l.length) ? React__default.createElement(RetryPanel, { + loadingText: i18n.t('集群列表尚无已开启vendor的集群'), + retryText: i18n.t('刷新重试'), + action: actions.list.services.fetch + }) : ((_m = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _m === void 0 ? void 0 : _m.fetched) && !((_p = (_o = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.recordCount) ? React__default.createElement(RetryPanel, { + loadingText: i18n.t('集群列表尚无运行状态的目标集群'), + retryText: i18n.t('前往确认'), + action: function action() { router.navigate({}, {}, '/tdcc/cluster'); } - }, i18n.t('前往确认'))) : null) + }) : null) }), React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -8881,17 +7865,22 @@ function ServiceInstanceCreatePanel(props) { style: { paddingTop: 0 }, - validator: (_m = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _m === void 0 ? void 0 : _m['instanceName'], + validator: (_q = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _q === void 0 ? void 0 : _q['instanceName'], input: { - value: (_o = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _o === void 0 ? void 0 : _o['instanceName'], + value: (_r = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _r === void 0 ? void 0 : _r['instanceName'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updateInstance('instanceName', e); }, onBlur: function onBlur() {} } }), React__default.createElement(ffComponent.FormPanel.Item, { + after: React__default.createElement(teaComponent.Button, { + icon: 'refresh', + onClick: function onClick() { + actions.list.servicePlans.fetch(); + } + }), key: 'plan', label: React__default.createElement(teaComponent.Text, { style: { @@ -8901,12 +7890,14 @@ function ServiceInstanceCreatePanel(props) { }, React__default.createElement(teaComponent.Text, null, i18n.t('规格')), React__default.createElement(teaComponent.Text, { className: 'text-danger tea-pt-1n' }, "*")), - validator: (_p = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _p === void 0 ? void 0 : _p['plan'], - message: React__default.createElement(React__default.Fragment, null, !openingVendor && ((_q = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _q === void 0 ? void 0 : _q.fetched) && !((_r = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _r === void 0 ? void 0 : _r.error) && !((_t = (_s = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.recordCount) ? React__default.createElement(teaComponent.Text, null, i18n.t('无可用规格,'), React__default.createElement(teaComponent.Button, { + validator: (_s = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _s === void 0 ? void 0 : _s['plan'], + message: React__default.createElement(React__default.Fragment, null, ((_t = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _t === void 0 ? void 0 : _t.error) ? React__default.createElement(RetryPanel, { + loadingText: "\u52A0\u8F7D\u89C4\u683C\u5931\u8D25", + action: actions.list.servicePlans + }) : ((_u = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _u === void 0 ? void 0 : _u.fetched) && !((_w = (_v = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.list) === null || _v === void 0 ? void 0 : _v.data) === null || _w === void 0 ? void 0 : _w.recordCount) ? React__default.createElement(teaComponent.Text, null, i18n.t('无可用规格,'), React__default.createElement(teaComponent.Button, { type: 'link', onClick: function onClick() { var _a, _b; - router.navigate({ sub: 'create', tab: ResourceTypeEnum.ServicePlan @@ -8922,52 +7913,42 @@ function ServiceInstanceCreatePanel(props) { title: '请选择规格' }), model: servicePlans, - action: (_u = actions === null || actions === void 0 ? void 0 : actions.list) === null || _u === void 0 ? void 0 : _u.servicePlans, + action: (_x = actions === null || actions === void 0 ? void 0 : actions.list) === null || _x === void 0 ? void 0 : _x.servicePlans, valueField: function valueField(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name; }, displayField: function displayField(record) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - return "".concat((_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name, "(cpu:").concat((_d = (_c = (_b = record === null || record === void 0 ? void 0 : record.spec) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.cpu) !== null && _d !== void 0 ? _d : '-', ",memory:").concat((_g = (_f = (_e = record === null || record === void 0 ? void 0 : record.spec) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.memory) !== null && _g !== void 0 ? _g : '-', ",storage:").concat((_k = (_j = (_h = record === null || record === void 0 ? void 0 : record.spec) === null || _h === void 0 ? void 0 : _h.metadata) === null || _j === void 0 ? void 0 : _j.storage) !== null && _k !== void 0 ? _k : '-', ")"); }, - value: (_w = (_v = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.selection) === null || _v === void 0 ? void 0 : _v.metadata) === null || _w === void 0 ? void 0 : _w.name + value: (_z = (_y = servicePlans === null || servicePlans === void 0 ? void 0 : servicePlans.selection) === null || _y === void 0 ? void 0 : _y.metadata) === null || _z === void 0 ? void 0 : _z.name })), showBackUpOperation && React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('定时备份'), required: false, - validator: (_x = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _x === void 0 ? void 0 : _x['timeBackup'], - message: ((_z = (_y = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _y === void 0 ? void 0 : _y['backupDate']) === null || _z === void 0 ? void 0 : _z.status) === 2 || ((_1 = (_0 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _0 === void 0 ? void 0 : _0['backupTime']) === null || _1 === void 0 ? void 0 : _1.status) === 2 ? React__default.createElement(teaComponent.Text, { + validator: (_0 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _0 === void 0 ? void 0 : _0['timeBackup'], + message: ((_2 = (_1 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _1 === void 0 ? void 0 : _1['backupDate']) === null || _2 === void 0 ? void 0 : _2.status) === 2 || ((_4 = (_3 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _3 === void 0 ? void 0 : _3['backupTime']) === null || _4 === void 0 ? void 0 : _4.status) === 2 ? React__default.createElement(teaComponent.Text, { className: 'text-danger' }, i18n.t('{{message}}', { - message: (_3 = (_2 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _2 === void 0 ? void 0 : _2['backupDate']) === null || _3 === void 0 ? void 0 : _3.message + message: (_6 = (_5 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _5 === void 0 ? void 0 : _5['backupDate']) === null || _6 === void 0 ? void 0 : _6.message })) : null }, React__default.createElement(teaComponent.Switch, { - value: (_4 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _4 === void 0 ? void 0 : _4['timeBackup'], + value: (_7 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _7 === void 0 ? void 0 : _7['timeBackup'], onChange: function onChange(value) { return tslib.__awaiter(_this, void 0, void 0, function () { var cosResource; - var _a; - return tslib.__generator(this, function (_b) { switch (_b.label) { case 0: - if (!value) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , checkCosResource({ + if (!value) return [3 /*break*/, 2]; + return [4 /*yield*/, checkCosResource({ platform: platform, clusterId: Util === null || Util === void 0 ? void 0 : Util.getCOSClusterId(platform, (_a = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.object) === null || _a === void 0 ? void 0 : _a.data), regionId: regionId })]; - case 1: cosResource = _b.sent(); - if (cosResource) { actions === null || actions === void 0 ? void 0 : actions.create.updateInstance('timeBackup', value); } else { @@ -8975,33 +7956,25 @@ function ServiceInstanceCreatePanel(props) { msg: ErrorMsgEnum.COS_Resource_Not_Found })); } - - return [3 - /*break*/ - , 3]; - + return [3 /*break*/, 3]; case 2: actions === null || actions === void 0 ? void 0 : actions.create.updateInstance('timeBackup', value); _b.label = 3; - case 3: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); } - })), showBackUpOperation && ((_5 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _5 === void 0 ? void 0 : _5['timeBackup']) ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ffComponent.FormPanel.Item, { + })), showBackUpOperation && ((_8 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _8 === void 0 ? void 0 : _8['timeBackup']) ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('备份日期') }, React__default.createElement(teaComponent.Checkbox.Group, { - value: (_6 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _6 === void 0 ? void 0 : _6.backupDate, + value: (_9 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _9 === void 0 ? void 0 : _9.backupDate, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updateInstance('backupDate', value); } - }, (_7 = Backup === null || Backup === void 0 ? void 0 : Backup.weekConfig) === null || _7 === void 0 ? void 0 : _7.map(function (item) { + }, (_10 = Backup === null || Backup === void 0 ? void 0 : Backup.weekConfig) === null || _10 === void 0 ? void 0 : _10.map(function (item) { return React__default.createElement(teaComponent.Checkbox, { key: item === null || item === void 0 ? void 0 : item.value, name: item === null || item === void 0 ? void 0 : item.value, @@ -9013,13 +7986,12 @@ function ServiceInstanceCreatePanel(props) { }))), React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('备份时间点') }, React__default.createElement(teaComponent.Checkbox.Group, { - value: (_8 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _8 === void 0 ? void 0 : _8.backupTime, + value: (_11 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _11 === void 0 ? void 0 : _11.backupTime, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updateInstance('backupTime', value); } - }, (_9 = Backup === null || Backup === void 0 ? void 0 : Backup.hourConfig) === null || _9 === void 0 ? void 0 : _9.map(function (item) { + }, (_12 = Backup === null || Backup === void 0 ? void 0 : Backup.hourConfig) === null || _12 === void 0 ? void 0 : _12.map(function (item) { return React__default.createElement(teaComponent.Checkbox, { key: item === null || item === void 0 ? void 0 : item.value, name: item === null || item === void 0 ? void 0 : item.value, @@ -9033,47 +8005,79 @@ function ServiceInstanceCreatePanel(props) { }, React__default.createElement(ffComponent.FormPanel.InputNumber, { min: Backup.minReserveDay, max: Backup.maxReserveDay, - value: (_10 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _10 === void 0 ? void 0 : _10.backupReserveDay, + value: (_13 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _13 === void 0 ? void 0 : _13.backupReserveDay, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updateInstance('backupReserveDay', value); } }), React__default.createElement(teaComponent.Text, null, i18n.t('天后自动删除')))) : null, React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('设置实例参数'), required: false, - validator: (_11 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _11 === void 0 ? void 0 : _11['isSetParams'] + validator: (_14 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _14 === void 0 ? void 0 : _14['isSetParams'] }, React__default.createElement(teaComponent.Switch, { - value: (_12 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _12 === void 0 ? void 0 : _12['isSetParams'], + value: (_15 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _15 === void 0 ? void 0 : _15['isSetParams'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updateInstance('isSetParams', e); } - })), isLoadingSchema && React__default.createElement(LoadingPanel, null), !isLoadingSchema && !openingVendor && loadSchemaFailed && React__default.createElement(RetryPanel, { + })), isLoadingSchema && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(LoadingPanel, null)), !isLoadingSchema && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) && loadSchemaFailed && ((_16 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _16 === void 0 ? void 0 : _16['isSetParams']) && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(i18n.Trans, null, React__default.createElement("div", { style: { - minWidth: 150, - width: 150 - }, - loadingText: i18n.t('Schema加载失败'), - action: (_14 = (_13 = actions === null || actions === void 0 ? void 0 : actions.list) === null || _13 === void 0 ? void 0 : _13.resourceSchemas) === null || _14 === void 0 ? void 0 : _14.fetch - }), !isLoadingSchema && openingVendor && React__default.createElement(RetryPanel, { + display: 'flex', + alignItems: 'center' + } + }, React__default.createElement(teaComponent.Text, { + theme: 'danger', + className: 'tea-mr-2n', style: { - minWidth: 170, - width: 170 + minWidth: 100 + } + }, "\u52A0\u8F7DSchema\u5931\u8D25:"), ((_17 = [ErrorEnum.Code.RBACForbidden, ErrorEnum.Code.RBACForbidden403]) === null || _17 === void 0 ? void 0 : _17.includes((_19 = (_18 = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _18 === void 0 ? void 0 : _18.error) === null || _19 === void 0 ? void 0 : _19.code)) ? React__default.createElement(React__default.Fragment, null, React__default.createElement(i18n.Trans, null, React__default.createElement(teaComponent.Text, { + verticalAlign: "middle", + theme: 'danger' + }, "\u6743\u9650\u4E0D\u8DB3\uFF0C\u8BF7\u8054\u7CFB\u96C6\u7FA4\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650\uFF1B\u82E5\u60A8\u672C\u8EAB\u662F\u96C6\u7FA4\u7BA1\u7406\u5458\uFF0C\u53EF\u76F4\u63A5"), React__default.createElement(teaComponent.Button, { + type: "link", + onClick: function onClick() { + actions.base.getClusterAdminRole.start([]); }, + className: 'tea-mr-2n' + }, "\u83B7\u53D6\u96C6\u7FA4admin\u89D2\u8272"), React__default.createElement(teaComponent.Button, { + type: "link", + onClick: function onClick() { + var _a, _b; + actions === null || actions === void 0 ? void 0 : actions.list.servicePlans.fetch(); + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + }, i18n.t('重试')))) : React__default.createElement(RetryPanel, { + loadingText: (_21 = (_20 = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _20 === void 0 ? void 0 : _20.error) === null || _21 === void 0 ? void 0 : _21.message, + action: function action() { + var _a, _b; + actions === null || actions === void 0 ? void 0 : actions.list.servicePlans.fetch(); + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + })))), !isLoadingSchema && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) && !loadSchemaFailed && React__default.createElement(React__default.Fragment, null, openingVendor && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(RetryPanel, { loadingText: i18n.t('{{text}}', { - text: "".concat((_15 = services === null || services === void 0 ? void 0 : services.selection) === null || _15 === void 0 ? void 0 : _15.name, "\u5F00\u542F\u4E2D...") + text: "".concat((_22 = services === null || services === void 0 ? void 0 : services.selection) === null || _22 === void 0 ? void 0 : _22.name, "\u5F00\u542F\u4E2D...") }), loadingTextTheme: 'text', - action: (_17 = (_16 = actions === null || actions === void 0 ? void 0 : actions.list) === null || _16 === void 0 ? void 0 : _16.resourceSchemas) === null || _17 === void 0 ? void 0 : _17.fetch - }), !isLoadingSchema && !loadSchemaFailed && !openingVendor && React__default.createElement(React__default.Fragment, null, versionFields === null || versionFields === void 0 ? void 0 : versionFields.map(function (item) { + action: function action() { + var _a, _b; + actions === null || actions === void 0 ? void 0 : actions.list.servicePlans.fetch(); + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + })), !openingVendor && React__default.createElement(React__default.Fragment, null, versionFields === null || versionFields === void 0 ? void 0 : versionFields.map(function (item) { var _a, _b, _c, _d, _e; - var _f = (_b = (_a = item.description) === null || _a === void 0 ? void 0 : _a.split('---')) !== null && _b !== void 0 ? _b : [], - english = _f[0], - chinese = _f[1]; - + english = _f[0], + chinese = _f[1]; return React__default.createElement(ffComponent.FormPanel.Item, { key: item === null || item === void 0 ? void 0 : item.name, label: React__default.createElement(teaComponent.Text, { @@ -9103,27 +8107,21 @@ function ServiceInstanceCreatePanel(props) { actions === null || actions === void 0 ? void 0 : actions.create.updateInstance(item === null || item === void 0 ? void 0 : item.name, e); } })); - }), ((_18 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _18 === void 0 ? void 0 : _18['isSetParams']) && (instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item, index) { + }), ((_23 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _23 === void 0 ? void 0 : _23['isSetParams']) && (instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item, index) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - var values = tslib.__assign({}, servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData); - if (item.enabledCondition && values) { var _m = item === null || item === void 0 ? void 0 : item.enabledCondition.split('=='), - conditionKey = _m[0], - conditionValue = _m[1]; - + conditionKey = _m[0], + conditionValue = _m[1]; var value = values[conditionKey]; - if (String(value) !== String(conditionValue)) { return null; } } - var _o = (_b = (_a = item.description) === null || _a === void 0 ? void 0 : _a.split('---')) !== null && _b !== void 0 ? _b : [], - english = _o[0], - chinese = _o[1]; - + english = _o[0], + chinese = _o[1]; return !hideSchema(item) ? React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -9185,10 +8183,9 @@ function ServiceInstanceCreatePanel(props) { plan: item, onChange: function onChange(_a) { var field = _a.field, - value = _a.value; + value = _a.value; actions === null || actions === void 0 ? void 0 : actions.create.updateInstance(item === null || item === void 0 ? void 0 : item.name, JSON.stringify(value === null || value === void 0 ? void 0 : value.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.key] = cur === null || cur === void 0 ? void 0 : cur.value, _a)); }, {}))); } @@ -9202,58 +8199,50 @@ function ServiceInstanceCreatePanel(props) { value: (_l = (_k = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _k === void 0 ? void 0 : _k['unitMap']) === null || _l === void 0 ? void 0 : _l[item === null || item === void 0 ? void 0 : item.name], onChange: function onChange(e) { var _a; - var _b; - actions === null || actions === void 0 ? void 0 : actions.create.updateInstance('unitMap', tslib.__assign(tslib.__assign({}, (_b = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _b === void 0 ? void 0 : _b['unitMap']), (_a = {}, _a[item === null || item === void 0 ? void 0 : item.name] = e, _a))); } })) : null; - }))), React__default.createElement(ffComponent.FormPanel.Footer, null, React__default.createElement(teaComponent.Button, { + })))), React__default.createElement(GetRbacAdminDialog, tslib.__assign({}, props)), React__default.createElement(ffComponent.FormPanel.Footer, null, React__default.createElement(teaComponent.Button, { type: 'primary', style: { marginRight: 10 }, onClick: _submit, loading: isSubmitting, - disabled: isSubmitting + disabled: isSubmitting || !(externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) || ((_24 = servicesInstanceEdit.formData) === null || _24 === void 0 ? void 0 : _24['isSetParams']) && loadSchemaFailed || openingVendor }, failed ? i18n.t('重试') : i18n.t('确定')), React__default.createElement(teaComponent.Button, { onClick: _cancel }, i18n.t('取消')), React__default.createElement(TipInfo, { isShow: failed, type: "error", isForm: true - }, !((_19 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _19 === void 0 ? void 0 : _19.timeBackup) ? getWorkflowError(createWorkflow) : (_22 = (_21 = (_20 = createWorkflow === null || createWorkflow === void 0 ? void 0 : createWorkflow.results) === null || _20 === void 0 ? void 0 : _20[0]) === null || _21 === void 0 ? void 0 : _21.error) === null || _22 === void 0 ? void 0 : _22.message))); + }, !((_25 = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _25 === void 0 ? void 0 : _25.timeBackup) ? getWorkflowError(createWorkflow) : (_28 = (_27 = (_26 = createWorkflow === null || createWorkflow === void 0 ? void 0 : createWorkflow.results) === null || _26 === void 0 ? void 0 : _26[0]) === null || _27 === void 0 ? void 0 : _27.error) === null || _28 === void 0 ? void 0 : _28.message))); }; - - return React__default.createElement(React__default.Fragment, null, renderContent((_f = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _f === void 0 ? void 0 : _f.data)); + return React__default.createElement(React__default.Fragment, null, renderContent((_p = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _p === void 0 ? void 0 : _p.data)); } function ServicePlanCreatePanel(props) { - var _a, _b, _c, _d, _e, _f; - + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; var actions = props.actions, - _g = props.base, - platform = _g.platform, - route = _g.route, - isI18n = _g.isI18n, - userInfo = _g.userInfo, - regionId = _g.regionId, - _h = props.list, - services = _h.services, - servicePlans = _h.servicePlans, - createResourceWorkflow = _h.createResourceWorkflow, - externalClusters = _h.externalClusters; + _p = props.base, + platform = _p.platform, + route = _p.route, + isI18n = _p.isI18n, + userInfo = _p.userInfo, + regionId = _p.regionId, + _q = props.list, + services = _q.services, + servicePlans = _q.servicePlans, + createResourceWorkflow = _q.createResourceWorkflow, + externalClusters = _q.externalClusters; var servicename = (route === null || route === void 0 ? void 0 : route.queries).servicename; - - var _j = React.useState({}), - planSchemaUnitMap = _j[0], - setPlanSchemaUnitMap = _j[1]; - + var _r = React.useState({}), + planSchemaUnitMap = _r[0], + setPlanSchemaUnitMap = _r[1]; React.useEffect(function () { var _a; - var clusterId = (_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _a === void 0 ? void 0 : _a.clusterId; - if (actions.list.resourceSchemas && platform && servicename && clusterId) { actions.list.resourceSchemas.applyFilter({ platform: platform, @@ -9265,7 +8254,6 @@ function ServicePlanCreatePanel(props) { }, [actions.list.resourceSchemas, regionId, platform, servicename, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); React.useEffect(function () { var _a, _b; - if (platform && ((_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.externalClusters) && (services === null || services === void 0 ? void 0 : services.selection)) { (_b = actions === null || actions === void 0 ? void 0 : actions.list) === null || _b === void 0 ? void 0 : _b.externalClusters.applyFilter({ platform: platform, @@ -9276,9 +8264,7 @@ function ServicePlanCreatePanel(props) { }, [(_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.externalClusters, platform, services === null || services === void 0 ? void 0 : services.selection]); React.useEffect(function () { var _a; - var clusterId = (_a = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _a === void 0 ? void 0 : _a.clusterId; - if (actions.list.servicePlans && platform && servicename && clusterId) { actions.list.servicePlans.applyFilter({ platform: platform, @@ -9291,37 +8277,29 @@ function ServicePlanCreatePanel(props) { }, [actions.list.servicePlans, regionId, platform, servicename, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); var servicesInstance = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.servicesInstance; }); var servicesInstanceEdit = reactRedux.useSelector(function (state) { var _a; - return (_a = state === null || state === void 0 ? void 0 : state.list) === null || _a === void 0 ? void 0 : _a.servicePlanEdit; }); - var isLoading = ((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.fetchState) === ffRedux.FetchState.Fetching || !((_c = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _c === void 0 ? void 0 : _c.fetched); - var loadSchemaFailed = ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.error) || ((_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.fetchState) === ffRedux.FetchState.Failed || (servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object.data) === undefined; + var isLoadingSchema = ((_b = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _b === void 0 ? void 0 : _b.fetched) && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) ? !((_c = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _c === void 0 ? void 0 : _c.fetched) : !((_d = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _d === void 0 ? void 0 : _d.fetched); + var loadSchemaFailed = ((_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.fetched) && ((_f = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _f === void 0 ? void 0 : _f.error) && (!((_g = ['ResourceNotFound', 404]) === null || _g === void 0 ? void 0 : _g.includes((_j = (_h = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _h === void 0 ? void 0 : _h.error) === null || _j === void 0 ? void 0 : _j.code)) || !((_m = (_l = (_k = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _k === void 0 ? void 0 : _k.error) === null || _l === void 0 ? void 0 : _l.message) === null || _m === void 0 ? void 0 : _m.includes('404'))); var openingVendor = React__default === null || React__default === void 0 ? void 0 : React__default.useMemo(function () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - return ((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes((_c = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) === null || _c === void 0 ? void 0 : _c.clusterId)) && ((_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.fetched) && (((_f = (_e = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.code) === 'ResourceNotFound' || ((_h = (_g = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) === 404 || ((_l = (_k = (_j = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _j === void 0 ? void 0 : _j.error) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.includes('404'))); }, [servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object, services === null || services === void 0 ? void 0 : services.selection, externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection]); - var reduceCreateServiceResourceDataJson = function reduceCreateServiceResourceDataJson(data) { var _a, _b, _c, _d, _e, _f, _g, _h; - var _j = data === null || data === void 0 ? void 0 : data.formData, - instanceName = _j.instanceName, - description = _j.description, - clusterId = _j.clusterId; //拼接中间件实例参数部分属性值 - - + instanceName = _j.instanceName, + description = _j.description, + clusterId = _j.clusterId; + //拼接中间件实例参数部分属性值 var parameters = (_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.planSchema) === null || _c === void 0 ? void 0 : _c.reduce(function (pre, cur) { var _a; - - var _b, _c, _d, _e; // return Object.assign(pre,!!data?.formData?.[cur?.name] ? {[cur?.name]:data?.formData?.[cur?.name] + (data?.formData?.['unitMap']?.[cur?.name] ?? '')} : {}); - - + var _b, _c, _d, _e; + // return Object.assign(pre,!!data?.formData?.[cur?.name] ? {[cur?.name]:data?.formData?.[cur?.name] + (data?.formData?.['unitMap']?.[cur?.name] ?? '')} : {}); return Object.assign(pre, ((_b = data === null || data === void 0 ? void 0 : data.formData) === null || _b === void 0 ? void 0 : _b[cur === null || cur === void 0 ? void 0 : cur.name]) !== '' ? (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = formatPlanSchemaSubmitData(cur, (_c = data === null || data === void 0 ? void 0 : data.formData) === null || _c === void 0 ? void 0 : _c[cur === null || cur === void 0 ? void 0 : cur.name], (_e = (_d = data === null || data === void 0 ? void 0 : data.formData) === null || _d === void 0 ? void 0 : _d['unitMap']) === null || _e === void 0 ? void 0 : _e[cur === null || cur === void 0 ? void 0 : cur.name]), _a) : {}); }, {}); var json = { @@ -9342,17 +8320,13 @@ function ServicePlanCreatePanel(props) { metadata: tslib.__assign({}, parameters) } }; - if (description) { json.spec['description'] = description; } - return JSON.stringify(json); }; - var _cancel = function _cancel() { var _a, _b; - router.navigate({ sub: 'list', tab: undefined @@ -9362,21 +8336,11 @@ function ServicePlanCreatePanel(props) { mode: "list" }); }; - var _submit = function _submit() { - var _a, _b, _c, _d, _e, _f, _g; - - if (!((_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.planSchema) === null || _c === void 0 ? void 0 : _c.length)) { - teaComponent.message === null || teaComponent.message === void 0 ? void 0 : teaComponent.message.warning({ - content: i18n.t('Schema数据异常,请刷新重试') - }); - return; - } - + var _a, _b, _c, _d; var formData = servicesInstanceEdit.formData; - actions.create.validatePlan((_e = (_d = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.planSchema); - - if (_validatePlan(servicesInstanceEdit, (_g = (_f = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.planSchema)) { + actions.create.validatePlan((_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.planSchema); + if (_validatePlan(servicesInstanceEdit, (_d = (_c = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.planSchema)) { var params = { platform: platform, regionId: HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion, @@ -9388,10 +8352,8 @@ function ServicePlanCreatePanel(props) { actions.create.createResource.perform(); } }; - var renderContent = function renderContent(data) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; - + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; var instanceParamsFields = data === null || data === void 0 ? void 0 : data.planSchema; var isSubmitting = (createResourceWorkflow === null || createResourceWorkflow === void 0 ? void 0 : createResourceWorkflow.operationState) === ffRedux.OperationState.Performing; var failed = createResourceWorkflow.operationState === ffRedux.OperationState.Done && !ffRedux.isSuccessWorkflow(createResourceWorkflow); @@ -9408,6 +8370,12 @@ function ServicePlanCreatePanel(props) { }, React__default.createElement(ffComponent.FormPanel.Text, null, i18n.t('{{name}}', { name: (_a = route === null || route === void 0 ? void 0 : route.queries) === null || _a === void 0 ? void 0 : _a.servicename }))), React__default.createElement(ffComponent.FormPanel.Item, { + after: React__default.createElement(teaComponent.Button, { + icon: 'refresh', + onClick: function onClick() { + actions.list.externalClusters.fetch(); + } + }), label: React__default.createElement(teaComponent.Text, { style: { display: 'flex', @@ -9426,7 +8394,6 @@ function ServicePlanCreatePanel(props) { action: (_c = actions === null || actions === void 0 ? void 0 : actions.list) === null || _c === void 0 ? void 0 : _c.externalClusters, disabledField: function disabledField(record) { var _a, _b, _c; - var disabled = !((_b = (_a = services === null || services === void 0 ? void 0 : services.selection) === null || _a === void 0 ? void 0 : _a.clusters) === null || _b === void 0 ? void 0 : _b.includes(record === null || record === void 0 ? void 0 : record.clusterId)); return { disabled: disabled, @@ -9436,12 +8403,17 @@ function ServicePlanCreatePanel(props) { }; } }, - message: React__default.createElement(React__default.Fragment, null, ((_d = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _d === void 0 ? void 0 : _d.fetched) && !((_f = (_e = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.recordCount) ? React__default.createElement(teaComponent.Text, null, i18n.t('无运行状态的目标集群,'), React__default.createElement(teaComponent.Button, { - type: 'link', - onClick: function onClick() { + message: React__default.createElement(React__default.Fragment, null, ((_d = services === null || services === void 0 ? void 0 : services.list) === null || _d === void 0 ? void 0 : _d.fetched) && !((_f = (_e = services.selection) === null || _e === void 0 ? void 0 : _e.clusters) === null || _f === void 0 ? void 0 : _f.length) ? React__default.createElement(RetryPanel, { + loadingText: i18n.t('集群列表尚无已开启vendor的集群'), + retryText: i18n.t('刷新重试'), + action: actions.list.services.fetch + }) : ((_g = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _g === void 0 ? void 0 : _g.fetched) && !((_j = (_h = externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.list) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.recordCount) ? React__default.createElement(RetryPanel, { + loadingText: i18n.t('集群列表尚无运行状态的目标集群'), + retryText: i18n.t('前往确认'), + action: function action() { router.navigate({}, {}, '/tdcc/cluster'); } - }, i18n.t('前往确认'))) : null) + }) : null) }), React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -9451,64 +8423,95 @@ function ServicePlanCreatePanel(props) { }, React__default.createElement(teaComponent.Text, null, i18n.t('规格名称')), React__default.createElement(teaComponent.Text, { className: 'text-danger tea-pt-1n' }, "*")), - validator: (_g = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _g === void 0 ? void 0 : _g['instanceName'], + validator: (_k = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _k === void 0 ? void 0 : _k['instanceName'], input: { - value: (_h = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _h === void 0 ? void 0 : _h['instanceName'], + value: (_l = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _l === void 0 ? void 0 : _l['instanceName'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updatePlan('instanceName', e); }, onBlur: function onBlur() {} } }), React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('描述'), - validator: (_j = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _j === void 0 ? void 0 : _j['description'], + validator: (_m = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.validator) === null || _m === void 0 ? void 0 : _m['description'], input: { - value: (_k = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _k === void 0 ? void 0 : _k['description'], + value: (_o = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _o === void 0 ? void 0 : _o['description'], onChange: function onChange(e) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.create) === null || _a === void 0 ? void 0 : _a.updatePlan('description', e); }, onBlur: function onBlur() {} } - }), isLoading && React__default.createElement(LoadingPanel, null), !isLoading && !openingVendor && loadSchemaFailed && React__default.createElement(RetryPanel, { + }), isLoadingSchema && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(LoadingPanel, null)), !isLoadingSchema && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) && loadSchemaFailed && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(i18n.Trans, null, React__default.createElement("div", { + style: { + display: 'flex', + alignItems: 'center' + } + }, React__default.createElement(teaComponent.Text, { + theme: 'danger', + className: 'tea-mr-2n', style: { - minWidth: 150 + minWidth: 100 + } + }, "\u52A0\u8F7DSchema\u5931\u8D25:"), ((_p = [ErrorEnum.Code.RBACForbidden, ErrorEnum.Code.RBACForbidden403]) === null || _p === void 0 ? void 0 : _p.includes((_r = (_q = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _q === void 0 ? void 0 : _q.error) === null || _r === void 0 ? void 0 : _r.code)) ? React__default.createElement(React__default.Fragment, null, React__default.createElement(i18n.Trans, null, React__default.createElement(teaComponent.Text, { + verticalAlign: "middle", + theme: 'danger' + }, "\u6743\u9650\u4E0D\u8DB3\uFF0C\u8BF7\u8054\u7CFB\u96C6\u7FA4\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650\uFF1B\u82E5\u60A8\u672C\u8EAB\u662F\u96C6\u7FA4\u7BA1\u7406\u5458\uFF0C\u53EF\u76F4\u63A5"), React__default.createElement(teaComponent.Button, { + type: "link", + onClick: function onClick() { + actions.base.getClusterAdminRole.start([]); }, - loadingText: i18n.t('Schema加载失败'), - action: (_m = (_l = actions === null || actions === void 0 ? void 0 : actions.list) === null || _l === void 0 ? void 0 : _l.resourceSchemas) === null || _m === void 0 ? void 0 : _m.fetch - }), !isLoading && openingVendor && React__default.createElement(RetryPanel, { + className: 'tea-mr-2n' + }, "\u83B7\u53D6\u96C6\u7FA4admin\u89D2\u8272"), React__default.createElement(teaComponent.Button, { + type: "link", + onClick: function onClick() { + var _a, _b; + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + }, i18n.t('重试')))) : React__default.createElement(RetryPanel, { + loadingText: (_t = (_s = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _s === void 0 ? void 0 : _s.error) === null || _t === void 0 ? void 0 : _t.message, + action: function action() { + var _a, _b; + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + })))), !isLoadingSchema && (externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) && !loadSchemaFailed && React__default.createElement(React__default.Fragment, null, openingVendor && React__default.createElement(ffComponent.FormPanel.Item, { + label: i18n.t(''), + text: true + }, React__default.createElement(RetryPanel, { style: { - minWidth: 170 + minWidth: 170, + width: 170 }, loadingText: i18n.t('{{text}}', { - text: "".concat((_o = services === null || services === void 0 ? void 0 : services.selection) === null || _o === void 0 ? void 0 : _o.name, "\u5F00\u542F\u4E2D...") + text: "".concat((_u = services === null || services === void 0 ? void 0 : services.selection) === null || _u === void 0 ? void 0 : _u.name, "\u5F00\u542F\u4E2D...") }), loadingTextTheme: 'text', - action: (_q = (_p = actions === null || actions === void 0 ? void 0 : actions.list) === null || _p === void 0 ? void 0 : _p.resourceSchemas) === null || _q === void 0 ? void 0 : _q.fetch - }), !isLoading && !loadSchemaFailed && !openingVendor && (instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item, index) { + action: function action() { + var _a, _b; + (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.resourceSchemas) === null || _b === void 0 ? void 0 : _b.fetch(); + } + })), !openingVendor && React__default.createElement(React__default.Fragment, null, instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item, index) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - var values = tslib.__assign({}, servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData); - if (item.enabledCondition && values) { var _m = item === null || item === void 0 ? void 0 : item.enabledCondition.split('=='), - conditionKey = _m[0], - conditionValue = _m[1]; - + conditionKey = _m[0], + conditionValue = _m[1]; var value = values[conditionKey]; - if (String(value) !== String(conditionValue)) { return null; } } - var _o = (_b = (_a = item.description) === null || _a === void 0 ? void 0 : _a.split('---')) !== null && _b !== void 0 ? _b : [], - english = _o[0], - chinese = _o[1]; - + english = _o[0], + chinese = _o[1]; return !hideSchema(item) ? React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -9570,10 +8573,9 @@ function ServicePlanCreatePanel(props) { plan: item, onChange: function onChange(_a) { var field = _a.field, - value = _a.value; + value = _a.value; actions === null || actions === void 0 ? void 0 : actions.create.updatePlan(item === null || item === void 0 ? void 0 : item.name, JSON.stringify(value === null || value === void 0 ? void 0 : value.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.key] = cur === null || cur === void 0 ? void 0 : cur.value, _a)); }, {}))); } @@ -9587,18 +8589,16 @@ function ServicePlanCreatePanel(props) { value: (_l = (_k = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _k === void 0 ? void 0 : _k['unitMap']) === null || _l === void 0 ? void 0 : _l[item === null || item === void 0 ? void 0 : item.name], onChange: function onChange(e) { var _a; - var _b; - actions === null || actions === void 0 ? void 0 : actions.create.updatePlan('unitMap', tslib.__assign(tslib.__assign({}, (_b = servicesInstanceEdit === null || servicesInstanceEdit === void 0 ? void 0 : servicesInstanceEdit.formData) === null || _b === void 0 ? void 0 : _b['unitMap']), (_a = {}, _a[item === null || item === void 0 ? void 0 : item.name] = e, _a))); } })) : null; - })), React__default.createElement(ffComponent.FormPanel.Footer, null, React__default.createElement(teaComponent.Button, { + }))), React__default.createElement(GetRbacAdminDialog, tslib.__assign({}, props)), React__default.createElement(ffComponent.FormPanel.Footer, null, React__default.createElement(teaComponent.Button, { type: 'primary', className: 'tea-mr-2n', onClick: _submit, loading: isSubmitting, - disabled: isSubmitting + disabled: isSubmitting || !(externalClusters === null || externalClusters === void 0 ? void 0 : externalClusters.selection) || loadSchemaFailed || openingVendor }, failed ? i18n.t('重试') : i18n.t('确定')), React__default.createElement(teaComponent.Button, { onClick: _cancel }, i18n.t('取消')), React__default.createElement(TipInfo, { @@ -9607,16 +8607,17 @@ function ServicePlanCreatePanel(props) { isForm: true }, getWorkflowError(createResourceWorkflow)))); }; - - return React__default.createElement(React__default.Fragment, null, renderContent((_f = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _f === void 0 ? void 0 : _f.data)); + return React__default.createElement(React__default.Fragment, null, renderContent((_o = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _o === void 0 ? void 0 : _o.data)); } function ServiceCreate(props) { - var selectedTab = props.base.selectedTab; - - if (selectedTab === ResourceTypeEnum.ServiceResource) { + var _a = props.base, + selectedTab = _a.selectedTab, + route = _a.route; + var tab = (router === null || router === void 0 ? void 0 : router.resolve(route)).tab; + if (tab === ResourceTypeEnum.ServiceResource) { return React__default.createElement(ServiceInstanceCreatePanel, tslib.__assign({}, props)); - } else if (selectedTab === ResourceTypeEnum.ServicePlan) { + } else if (tab === ResourceTypeEnum.ServicePlan) { return React__default.createElement(ServicePlanCreatePanel, tslib.__assign({}, props)); } else { return React__default.createElement(React__default.Fragment, null, React__default.createElement(LoadingPanel, null)); @@ -9625,32 +8626,26 @@ function ServiceCreate(props) { function ResourceDeleteDialog(props) { var _this = this; - var _a; - var _b = props.base, - platform = _b.platform, - route = _b.route, - regionId = _b.regionId, - _c = props.list, - deleteResourceSelection = _c.deleteResourceSelection, - deleteResourceWorkflow = _c.deleteResourceWorkflow, - serviceResources = _c.serviceResources, - actions = props.actions; + platform = _b.platform, + route = _b.route, + regionId = _b.regionId, + _c = props.list, + deleteResourceSelection = _c.deleteResourceSelection, + deleteResourceWorkflow = _c.deleteResourceWorkflow, + serviceResources = _c.serviceResources, + actions = props.actions; var finalResourceInfo = deleteResourceSelection === null || deleteResourceSelection === void 0 ? void 0 : deleteResourceSelection[0]; var loading = deleteResourceWorkflow.operationState === ffRedux.OperationState.Performing; var failed = deleteResourceWorkflow.operationState === ffRedux.OperationState.Done && !ffRedux.isSuccessWorkflow(deleteResourceWorkflow); - if (!(deleteResourceSelection === null || deleteResourceSelection === void 0 ? void 0 : deleteResourceSelection.length)) { return React__default.createElement("noscript", null); } - var _submit = function _submit() { return tslib.__awaiter(_this, void 0, void 0, function () { var basePrams, externalParams, resource; - var _a, _b, _c, _d; - return tslib.__generator(this, function (_e) { basePrams = { id: uuid(), @@ -9660,7 +8655,6 @@ function ResourceDeleteDialog(props) { clusterId: Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, finalResourceInfo, route) }; externalParams = {}; - if ((finalResourceInfo === null || finalResourceInfo === void 0 ? void 0 : finalResourceInfo.kind) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceOpsBackup)) { externalParams = ((_a = finalResourceInfo === null || finalResourceInfo === void 0 ? void 0 : finalResourceInfo.spec) === null || _a === void 0 ? void 0 : _a.trigger) === (BackupTypeNum === null || BackupTypeNum === void 0 ? void 0 : BackupTypeNum.Schedule) ? { resourceInfos: deleteResourceSelection @@ -9679,33 +8673,26 @@ function ResourceDeleteDialog(props) { namespace: (finalResourceInfo === null || finalResourceInfo === void 0 ? void 0 : finalResourceInfo.kind) !== (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding) ? DefaultNamespace : undefined }; } - resource = tslib.__assign(tslib.__assign({}, basePrams), externalParams); actions.list.deleteResource.start([resource], HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion); actions.list.deleteResource.perform(); - return [2 - /*return*/ - ]; + return [2 /*return*/]; }); }); }; var _cancel = function _cancel() { actions.list.selectDeleteResources([]); - if (deleteResourceWorkflow.operationState === ffRedux.OperationState.Done) { actions.list.deleteResource.reset(); } - if (deleteResourceWorkflow.operationState === ffRedux.OperationState.Started) { actions.list.deleteResource.cancel(); } }; - var caption = (finalResourceInfo === null || finalResourceInfo === void 0 ? void 0 : finalResourceInfo.kind) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding) ? i18n.t('解绑确认') : i18n.t('删除资源'); var resourceIns = (_a = deleteResourceSelection === null || deleteResourceSelection === void 0 ? void 0 : deleteResourceSelection.map(function (item) { var _a; - return (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name; })) === null || _a === void 0 ? void 0 : _a.join(','); var content = (finalResourceInfo === null || finalResourceInfo === void 0 ? void 0 : finalResourceInfo.kind) === (ResourceTypeEnum === null || ResourceTypeEnum === void 0 ? void 0 : ResourceTypeEnum.ServiceBinding) ? React__default.createElement(React__default.Fragment, null, i18n.t('您确定要解绑{{headTitle}}:', { @@ -9744,18 +8731,16 @@ function ResourceDeleteDialog(props) { } function InstanceBaseDetail(props) { - - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6; - - var _7 = props.base, - platform = _7.platform, - route = _7.route, - regionId = _7.regionId, - servicesInstance = props.list.servicesInstance, - _8 = props.detail, - resourceDetail = _8.resourceDetail, - openConsoleWorkflow = _8.openConsoleWorkflow, - actions = props.actions; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9; + var _10 = props.base, + platform = _10.platform, + route = _10.route, + regionId = _10.regionId, + servicesInstance = props.list.servicesInstance, + _11 = props.detail, + resourceDetail = _11.resourceDetail, + openConsoleWorkflow = _11.openConsoleWorkflow, + actions = props.actions; var isBaseLoading = !(resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object.fetched) || (resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object.loading); var resource = (_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.resource; var openConsoleLoading = (openConsoleWorkflow === null || openConsoleWorkflow === void 0 ? void 0 : openConsoleWorkflow.operationState) === ffRedux.OperationState.Performing; @@ -9763,8 +8748,11 @@ function InstanceBaseDetail(props) { var instanceParamsFields = (_d = (_c = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.instanceSchema; var domain = ((_f = (_e = resource === null || resource === void 0 ? void 0 : resource.status) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.host) || i18n.t('未设置'); var vip = ((_h = (_g = resource === null || resource === void 0 ? void 0 : resource.status) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.ip) || ((_k = (_j = resource === null || resource === void 0 ? void 0 : resource.status) === null || _j === void 0 ? void 0 : _j.metadata) === null || _k === void 0 ? void 0 : _k.port) ? "".concat((_m = (_l = resource === null || resource === void 0 ? void 0 : resource.status) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.ip, ":").concat((_p = (_o = resource === null || resource === void 0 ? void 0 : resource.status) === null || _o === void 0 ? void 0 : _o.metadata) === null || _p === void 0 ? void 0 : _p.port) : i18n.t('未设置'); - var rsIps = getRsIps((_q = resource === null || resource === void 0 ? void 0 : resource.status) === null || _q === void 0 ? void 0 : _q.deploy); // const _confirm = (isOpen:boolean) => { + var rsIps = getRsIps((_q = resource === null || resource === void 0 ? void 0 : resource.status) === null || _q === void 0 ? void 0 : _q.deploy); + var state = ((_r = resource === null || resource === void 0 ? void 0 : resource.status) === null || _r === void 0 ? void 0 : _r.state) || '-'; + var className = ServiceInstanceMap === null || ServiceInstanceMap === void 0 ? void 0 : ServiceInstanceMap[((_s = resource === null || resource === void 0 ? void 0 : resource.status) === null || _s === void 0 ? void 0 : _s.state) || (ServiceInstanceStatusEnum === null || ServiceInstanceStatusEnum === void 0 ? void 0 : ServiceInstanceStatusEnum.Unknown)].className; + var isDeleting = showResourceDeleteLoading(resource, [resource]); return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Row, { style: { width: '100%', @@ -9786,15 +8774,41 @@ function InstanceBaseDetail(props) { }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n', overflow: true - }, i18n.t('名称:')), React__default.createElement(teaComponent.Text, null, (_s = (_r = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _r === void 0 ? void 0 : _r.name) !== null && _s !== void 0 ? _s : '-')), React__default.createElement(teaComponent.Col, { + }, i18n.t('名称:')), React__default.createElement(teaComponent.Text, null, (_u = (_t = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _t === void 0 ? void 0 : _t.name) !== null && _u !== void 0 ? _u : '-')), React__default.createElement(teaComponent.Col, { + span: 6 + }, React__default.createElement(teaComponent.Text, { + className: 'tea-mr-2n' + }, i18n.t('ID:')), React__default.createElement(teaComponent.Text, null, (_w = (_v = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _v === void 0 ? void 0 : _v.externalID) !== null && _w !== void 0 ? _w : '-')), React__default.createElement(teaComponent.Col, { span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n' - }, i18n.t('ID:')), React__default.createElement(teaComponent.Text, null, (_u = (_t = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _t === void 0 ? void 0 : _t.externalID) !== null && _u !== void 0 ? _u : '-')), React__default.createElement(teaComponent.Col, { + }, i18n.t('状态:')), React__default.createElement(React__default.Fragment, null, isDeleting && React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Icon, { + type: 'loading' + }), i18n.t('删除中')), !isDeleting && React__default.createElement(teaComponent.Text, { + className: className + " tea-mr-1n" + }, state), !isDeleting && !!((_y = (_x = resource === null || resource === void 0 ? void 0 : resource.status) === null || _x === void 0 ? void 0 : _x.conditions) === null || _y === void 0 ? void 0 : _y.length) && React__default.createElement(teaComponent.Bubble, { + content: React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.List, { + type: "number", + style: { + width: '100%' + } + }, (_0 = (_z = resource === null || resource === void 0 ? void 0 : resource.status) === null || _z === void 0 ? void 0 : _z.conditions) === null || _0 === void 0 ? void 0 : _0.map(function (item) { + return React__default.createElement(teaComponent.List.Item, { + key: item === null || item === void 0 ? void 0 : item.type + }, React__default.createElement(teaComponent.Text, { + className: 'tea-mr-2n' + }, " ", "".concat(item === null || item === void 0 ? void 0 : item.type, " : ").concat((item === null || item === void 0 ? void 0 : item.reason) || (item === null || item === void 0 ? void 0 : item.message))), React__default.createElement(teaComponent.Icon, { + type: (item === null || item === void 0 ? void 0 : item.status) === 'True' ? 'success' : 'error' + })); + }))) + }, React__default.createElement(teaComponent.Icon, { + type: "info", + className: "tea-mr-2n" + })))), React__default.createElement(teaComponent.Col, { span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n' - }, i18n.t('版本:')), React__default.createElement(teaComponent.Text, null, (_x = (_w = (_v = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _v === void 0 ? void 0 : _v.parameters) === null || _w === void 0 ? void 0 : _w.version) !== null && _x !== void 0 ? _x : '-')), React__default.createElement(teaComponent.Col, { + }, i18n.t('版本:')), React__default.createElement(teaComponent.Text, null, (_3 = (_2 = (_1 = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _1 === void 0 ? void 0 : _1.parameters) === null || _2 === void 0 ? void 0 : _2.version) !== null && _3 !== void 0 ? _3 : '-'))), React__default.createElement(teaComponent.Row, null, React__default.createElement(teaComponent.Col, { span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n' @@ -9802,7 +8816,6 @@ function InstanceBaseDetail(props) { type: 'link', onClick: function onClick() { var _a; - router.navigate({ sub: 'list', tab: undefined @@ -9812,7 +8825,7 @@ function InstanceBaseDetail(props) { mode: 'list' }); } - }, (_z = (_y = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _y === void 0 ? void 0 : _y.servicePlan) !== null && _z !== void 0 ? _z : '-'))), React__default.createElement(teaComponent.Row, null, React__default.createElement(teaComponent.Col, { + }, (_5 = (_4 = resource === null || resource === void 0 ? void 0 : resource.spec) === null || _4 === void 0 ? void 0 : _4.servicePlan) !== null && _5 !== void 0 ? _5 : '-')), React__default.createElement(teaComponent.Col, { span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n', @@ -9820,18 +8833,18 @@ function InstanceBaseDetail(props) { }, i18n.t('创建人:')), React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true - }, (_2 = (_1 = (_0 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _0 === void 0 ? void 0 : _0.labels) === null || _1 === void 0 ? void 0 : _1['ssm.infra.tce.io/creator']) !== null && _2 !== void 0 ? _2 : '-')), React__default.createElement(teaComponent.Col, { + }, Util.getCreator(platform, resource))), React__default.createElement(teaComponent.Col, { span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n' }, i18n.t('命名空间:')), React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true - }, (_4 = (_3 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _3 === void 0 ? void 0 : _3.namespace) !== null && _4 !== void 0 ? _4 : '-')), React__default.createElement(teaComponent.Col, { - span: 12 + }, (_7 = (_6 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _6 === void 0 ? void 0 : _6.namespace) !== null && _7 !== void 0 ? _7 : '-')), React__default.createElement(teaComponent.Col, { + span: 6 }, React__default.createElement(teaComponent.Text, { className: 'tea-mr-2n' - }, i18n.t('创建时间:')), React__default.createElement(teaComponent.Text, null, ((_5 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _5 === void 0 ? void 0 : _5.creationTimestamp) ? dateFormatter(new Date((_6 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _6 === void 0 ? void 0 : _6.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') : '-'))))), React__default.createElement(ffComponent.FormPanel, { + }, i18n.t('创建时间:')), React__default.createElement(teaComponent.Text, null, ((_8 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _8 === void 0 ? void 0 : _8.creationTimestamp) ? dateFormatter(new Date((_9 = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _9 === void 0 ? void 0 : _9.creationTimestamp), 'YYYY-MM-DD HH:mm:ss') : '-'))))), React__default.createElement(ffComponent.FormPanel, { title: '服务入口', style: { width: '100%' @@ -9876,7 +8889,8 @@ function InstanceBaseDetail(props) { label: i18n.t('{{name}}', { name: (item === null || item === void 0 ? void 0 : item.label) + ':' }), - text: true + text: true, + key: item === null || item === void 0 ? void 0 : item.name }, React__default.createElement(teaComponent.Text, { style: { textAlign: 'right' @@ -9891,43 +8905,36 @@ function InstanceMonitorPanel() { function CreateServiceBindingDialog(props) { var _this = this; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; - var _r = props.detail, - showCreateResourceDialog = _r.showCreateResourceDialog, - serviceBindingEdit = _r.serviceBindingEdit, - namespaces = _r.namespaces, - serviceInstanceSchema = _r.serviceInstanceSchema, - resourceDetail = _r.resourceDetail, - _s = props.base, - platform = _s.platform, - route = _s.route, - isI18n = _s.isI18n, - _t = props.list, - createResourceWorkflow = _t.createResourceWorkflow, - serviceResources = _t.serviceResources, - services = _t.services, - actions = props.actions, - _u = props.mode; + showCreateResourceDialog = _r.showCreateResourceDialog, + serviceBindingEdit = _r.serviceBindingEdit, + namespaces = _r.namespaces, + serviceInstanceSchema = _r.serviceInstanceSchema, + resourceDetail = _r.resourceDetail, + _s = props.base, + platform = _s.platform, + route = _s.route, + isI18n = _s.isI18n, + _t = props.list, + createResourceWorkflow = _t.createResourceWorkflow, + serviceResources = _t.serviceResources, + services = _t.services, + actions = props.actions, + _u = props.mode; var loading = (createResourceWorkflow === null || createResourceWorkflow === void 0 ? void 0 : createResourceWorkflow.operationState) === ffRedux.OperationState.Performing; var failed = createResourceWorkflow.operationState === ffRedux.OperationState.Done && !ffRedux.isSuccessWorkflow(createResourceWorkflow); var instanceParamsFields = (_b = (_a = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.bindingCreateParameterSchema; var updateFormData = (_c = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _c === void 0 ? void 0 : _c.updateServiceBinding; - var reduceServiceBindingJson = function reduceServiceBindingJson(data) { var _a, _b, _c, _d, _e, _f; - var _g = data === null || data === void 0 ? void 0 : data.formData, - name = _g.name, - namespace = _g.namespace; //拼接中间件实例参数部分属性值 - - + name = _g.name, + namespace = _g.namespace; + //拼接中间件实例参数部分属性值 var parameters = (_c = (_b = (_a = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.bindingCreateParameterSchema) === null || _c === void 0 ? void 0 : _c.reduce(function (pre, cur) { var _a; - var _b, _c, _d, _e; - return Object.assign(pre, ((_b = data === null || data === void 0 ? void 0 : data.formData) === null || _b === void 0 ? void 0 : _b[cur === null || cur === void 0 ? void 0 : cur.name]) !== '' ? (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.name] = formatPlanSchemaSubmitData(cur, (_c = data === null || data === void 0 ? void 0 : data.formData) === null || _c === void 0 ? void 0 : _c[cur === null || cur === void 0 ? void 0 : cur.name], (_e = (_d = data === null || data === void 0 ? void 0 : data.formData) === null || _d === void 0 ? void 0 : _d['unitMap']) === null || _e === void 0 ? void 0 : _e[cur === null || cur === void 0 ? void 0 : cur.name]), _a) : {}); }, {}); var instancename = (route === null || route === void 0 ? void 0 : route.queries).instancename; @@ -9953,13 +8960,10 @@ function CreateServiceBindingDialog(props) { }; return JSON.stringify(jsonData); }; - var _submit = function _submit() { return tslib.__awaiter(_this, void 0, void 0, function () { var instance, result, regionId, params; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; - return tslib.__generator(this, function (_l) { switch (_l.label) { case 0: @@ -9967,37 +8971,17 @@ function CreateServiceBindingDialog(props) { teaComponent.message === null || teaComponent.message === void 0 ? void 0 : teaComponent.message.warning({ content: i18n.t('Schema数据异常,请刷新重试') }); - return [2 - /*return*/ - ]; - } // if(services?.selection?.name === 'rabbitmq' && - // serviceResources?.list?.data?.records?.find(item => item?.metadata?.name === route?.queries?.instancename)?.spec?.parameters?.adminUser === serviceBindingEdit?.formData?.['user'] - // ){ - // message?.warning({content:t('用户名不能和实例管理用户名相同')}); - // return; - // } - - - return [4 - /*yield*/ - , (_b = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _b === void 0 ? void 0 : _b.validateAllServiceBinding()]; + return [2 /*return*/]; + } + return [4 /*yield*/, (_b = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _b === void 0 ? void 0 : _b.validateAllServiceBinding()]; case 1: - // if(services?.selection?.name === 'rabbitmq' && - // serviceResources?.list?.data?.records?.find(item => item?.metadata?.name === route?.queries?.instancename)?.spec?.parameters?.adminUser === serviceBindingEdit?.formData?.['user'] - // ){ - // message?.warning({content:t('用户名不能和实例管理用户名相同')}); - // return; - // } _l.sent(); - instance = (_e = (_d = (_c = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.list) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records) === null || _e === void 0 ? void 0 : _e.find(function (item) { var _a, _b; - return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === ((_b = route === null || route === void 0 ? void 0 : route.queries) === null || _b === void 0 ? void 0 : _b.instancename); }); result = ServiceBinding === null || ServiceBinding === void 0 ? void 0 : ServiceBinding._validateAll(serviceBindingEdit, instanceParamsFields, (_f = services === null || services === void 0 ? void 0 : services.selection) === null || _f === void 0 ? void 0 : _f.name, instance); - if (result === null || result === void 0 ? void 0 : result.valid) { regionId = HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion; params = { @@ -10012,10 +8996,7 @@ function CreateServiceBindingDialog(props) { (_j = actions === null || actions === void 0 ? void 0 : actions.create) === null || _j === void 0 ? void 0 : _j.createResource.start([params], regionId); (_k = actions === null || actions === void 0 ? void 0 : actions.create) === null || _k === void 0 ? void 0 : _k.createResource.perform(); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -10023,11 +9004,9 @@ function CreateServiceBindingDialog(props) { var _cancel = function _cancel() { var _a; - actions.detail.showCreateResourceDialog(false); (_a = actions === null || actions === void 0 ? void 0 : actions.create.createResource) === null || _a === void 0 ? void 0 : _a.reset(); }; - var _renderButtons = function _renderButtons() { var buttons = [{ handleFunc: _submit, @@ -10048,7 +9027,6 @@ function CreateServiceBindingDialog(props) { }, item === null || item === void 0 ? void 0 : item.text); }); }; - var isLoadingSchema = !NotSupportBindingSchemaVendors.includes((_d = services === null || services === void 0 ? void 0 : services.selection) === null || _d === void 0 ? void 0 : _d.name) ? !((_e = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _e === void 0 ? void 0 : _e.fetched) || ((_f = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _f === void 0 ? void 0 : _f.fetchState) === (ffRedux.FetchState === null || ffRedux.FetchState === void 0 ? void 0 : ffRedux.FetchState.Fetching) : false; var loadSchemaFailed = !NotSupportBindingSchemaVendors.includes((_g = services === null || services === void 0 ? void 0 : services.selection) === null || _g === void 0 ? void 0 : _g.name) ? ((_h = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _h === void 0 ? void 0 : _h.error) || ((_j = serviceInstanceSchema === null || serviceInstanceSchema === void 0 ? void 0 : serviceInstanceSchema.object) === null || _j === void 0 ? void 0 : _j.fetchState) === (ffRedux.FetchState === null || ffRedux.FetchState === void 0 ? void 0 : ffRedux.FetchState.Failed) : false; return React__default.createElement(teaComponent.Modal, { @@ -10075,7 +9053,6 @@ function CreateServiceBindingDialog(props) { placeholder: i18n.t('请输入名称'), onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.updateServiceBinding('name', value); } } @@ -10094,17 +9071,14 @@ function CreateServiceBindingDialog(props) { action: (_o = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _o === void 0 ? void 0 : _o.namespaces, displayField: function displayField(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name; }, valueField: function valueField(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name; }, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.updateServiceBinding('namespace', value); } } @@ -10118,25 +9092,19 @@ function CreateServiceBindingDialog(props) { action: (_q = (_p = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _p === void 0 ? void 0 : _p.serviceInstanceSchema) === null || _q === void 0 ? void 0 : _q.fetch }), !isLoadingSchema && !loadSchemaFailed && (instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; - var values = tslib.__assign({}, serviceBindingEdit === null || serviceBindingEdit === void 0 ? void 0 : serviceBindingEdit.formData); - if (item.enabledCondition && values) { var _o = item === null || item === void 0 ? void 0 : item.enabledCondition.split('=='), - conditionKey = _o[0], - conditionValue = _o[1]; - + conditionKey = _o[0], + conditionValue = _o[1]; var value = values[conditionKey]; - if (String(value) !== String(conditionValue)) { return null; } } - var _p = (_b = (_a = item.description) === null || _a === void 0 ? void 0 : _a.split('---')) !== null && _b !== void 0 ? _b : [], - english = _p[0], - chinese = _p[1]; - + english = _p[0], + chinese = _p[1]; return !hideSchema(item) ? React__default.createElement(ffComponent.FormPanel.Item, { label: React__default.createElement(teaComponent.Text, { style: { @@ -10198,10 +9166,9 @@ function CreateServiceBindingDialog(props) { plan: item, onChange: function onChange(_a) { var field = _a.field, - value = _a.value; + value = _a.value; actions === null || actions === void 0 ? void 0 : actions.create.updateInstance(item === null || item === void 0 ? void 0 : item.name, JSON.stringify(value === null || value === void 0 ? void 0 : value.reduce(function (pre, cur) { var _a; - return tslib.__assign(tslib.__assign({}, pre), (_a = {}, _a[cur === null || cur === void 0 ? void 0 : cur.key] = cur === null || cur === void 0 ? void 0 : cur.value, _a)); }, {}))); } @@ -10215,9 +9182,7 @@ function CreateServiceBindingDialog(props) { value: (_m = (_l = serviceBindingEdit === null || serviceBindingEdit === void 0 ? void 0 : serviceBindingEdit.formData) === null || _l === void 0 ? void 0 : _l['unitMap']) === null || _m === void 0 ? void 0 : _m[item === null || item === void 0 ? void 0 : item.name], onChange: function onChange(e) { var _a; - var _b; - actions === null || actions === void 0 ? void 0 : actions.create.updateInstance('unitMap', tslib.__assign(tslib.__assign({}, (_b = serviceBindingEdit === null || serviceBindingEdit === void 0 ? void 0 : serviceBindingEdit.formData) === null || _b === void 0 ? void 0 : _b['unitMap']), (_a = {}, _a[item === null || item === void 0 ? void 0 : item.name] = e, _a))); } })) : null; @@ -10230,8 +9195,8 @@ function CreateServiceBindingDialog(props) { function CertificateField(props) { var _a = props.id, - id = _a === void 0 ? 0 : _a, - schema = props.schema; + id = _a === void 0 ? 0 : _a, + schema = props.schema; return schema ? React__default.createElement(ffComponent.FormPanel.Item, { text: true, label: schema === null || schema === void 0 ? void 0 : schema.name, @@ -10270,23 +9235,18 @@ function CertificateField(props) { function ResourceDetailPanel(props) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; - var _p = props.detail, - selectDetailResource = _p.selectDetailResource, - resourceDetail = _p.resourceDetail, - actions = props.actions; - + selectDetailResource = _p.selectDetailResource, + resourceDetail = _p.resourceDetail, + actions = props.actions; if (!(selectDetailResource === null || selectDetailResource === void 0 ? void 0 : selectDetailResource.length)) { return React__default.createElement("noscript", null); } - var _cancel = function _cancel() { var _a, _b, _c, _d, _e; - (_b = (_a = props === null || props === void 0 ? void 0 : props.actions) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.selectDetailResource([]); (_e = (_d = (_c = props === null || props === void 0 ? void 0 : props.actions) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.instanceResource) === null || _e === void 0 ? void 0 : _e.selects([]); }; - var resource = (_b = (_a = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.resource; var instanceParamsFields = (_d = (_c = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.instanceSchema; var loading = !((_e = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _e === void 0 ? void 0 : _e.fetched) || ((_f = resourceDetail === null || resourceDetail === void 0 ? void 0 : resourceDetail.object) === null || _f === void 0 ? void 0 : _f.fetchState) === (ffRedux.FetchState === null || ffRedux.FetchState === void 0 ? void 0 : ffRedux.FetchState.Fetching); @@ -10322,15 +9282,12 @@ function ResourceDetailPanel(props) { name: ((_o = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _o === void 0 ? void 0 : _o.namespace) || '-' })), instanceParamsFields === null || instanceParamsFields === void 0 ? void 0 : instanceParamsFields.map(function (item) { var _a, _b, _c, _d; - var value; - try { value = ((item === null || item === void 0 ? void 0 : item.type) === (SchemaType === null || SchemaType === void 0 ? void 0 : SchemaType.List) ? (_b = (_a = JSON === null || JSON === void 0 ? void 0 : JSON.parse(item === null || item === void 0 ? void 0 : item.value)) !== null && _a !== void 0 ? _a : []) === null || _b === void 0 ? void 0 : _b.join(',') : item === null || item === void 0 ? void 0 : item.value) || '-'; } catch (error) { value = '-'; } - return !((_c = ['ca_pem', 'client_pem', 'client_key_pem']) === null || _c === void 0 ? void 0 : _c.includes(item === null || item === void 0 ? void 0 : item.name)) ? React__default.createElement(ffComponent.FormPanel.Item, { label: i18n.t('{{name}}', { name: item === null || item === void 0 ? void 0 : item.label @@ -10347,18 +9304,16 @@ function ResourceDetailPanel(props) { } var Body = teaComponent.Layout.Body, - Content = teaComponent.Layout.Content; + Content = teaComponent.Layout.Content; function ServiceBindingPanel(props) { var _a, _b; - var instanceResource = props.detail.instanceResource, - actions = props.actions; + actions = props.actions; var columns = [{ key: "bindingId", header: "服务绑定ID", render: function render(item) { var _a, _b, _c; - return React__default.createElement("p", null, React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true @@ -10371,7 +9326,6 @@ function ServiceBindingPanel(props) { header: "服务绑定名称", render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true @@ -10382,7 +9336,6 @@ function ServiceBindingPanel(props) { header: "命名空间", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.namespace) !== null && _b !== void 0 ? _b : '-')); } }, { @@ -10390,7 +9343,6 @@ function ServiceBindingPanel(props) { header: "实例ID", render: function render(item) { var _a, _b, _c, _d; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, ((_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['clusternet.io/instanceId']) || ((_d = (_c = item === null || item === void 0 ? void 0 : item.metadata) === null || _c === void 0 ? void 0 : _c.labels) === null || _d === void 0 ? void 0 : _d['ssm.infra.tce.io/instance-id']) || '-')); } }, { @@ -10398,7 +9350,6 @@ function ServiceBindingPanel(props) { header: "绑定时间", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_b = dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp), 'YYYY-MM-DD HH:mm:ss')) !== null && _b !== void 0 ? _b : '-')); } }, { @@ -10406,7 +9357,6 @@ function ServiceBindingPanel(props) { header: "状态", render: function render(item) { var _a, _b, _c, _d, _e, _f, _g, _h; - var state = ((_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.state) || '-'; var className = ((_b = item === null || item === void 0 ? void 0 : item.status) === null || _b === void 0 ? void 0 : _b.state) === (ServiceBindingStatusNum === null || ServiceBindingStatusNum === void 0 ? void 0 : ServiceBindingStatusNum.Ready) ? 'text-success' : ''; var isDeleting = showResourceDeleteLoading(item, (_d = (_c = instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.list) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records); @@ -10437,13 +9387,11 @@ function ServiceBindingPanel(props) { header: "操作", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Button, { type: "link", disabled: !!((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp), onClick: function onClick() { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.selectDetailResource([item]); } }, i18n.t('详情')), React__default.createElement(teaComponent.Button, { @@ -10451,7 +9399,6 @@ function ServiceBindingPanel(props) { disabled: !!((_b = item === null || item === void 0 ? void 0 : item.metadata) === null || _b === void 0 ? void 0 : _b.deletionTimestamp), onClick: function onClick() { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.selectDeleteResources([item]); } }, i18n.t('解除绑定'))); @@ -10469,7 +9416,6 @@ function ServiceBindingPanel(props) { type: 'primary', onClick: function onClick() { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.list) === null || _a === void 0 ? void 0 : _a.selectDeleteResources(instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.selections); }, disabled: !((_a = instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.selections) === null || _a === void 0 ? void 0 : _a.length), @@ -10479,14 +9425,12 @@ function ServiceBindingPanel(props) { icon: "refresh", onClick: function onClick() { var _a, _b; - (_b = (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.instanceResource) === null || _b === void 0 ? void 0 : _b.fetch(); } })) })), React__default.createElement(teaComponent.Card, null, React__default.createElement(ffComponent.TablePanel, { recordKey: function recordKey(record) { var _a, _b; - return ((_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.name) + ((_b = record === null || record === void 0 ? void 0 : record.metadata) === null || _b === void 0 ? void 0 : _b.namespace); }, columns: columns, @@ -10496,15 +9440,12 @@ function ServiceBindingPanel(props) { selectable: { value: instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.selections.map(function (item) { var _a, _b; - return ((_a = item.metadata) === null || _a === void 0 ? void 0 : _a.name) + ((_b = item.metadata) === null || _b === void 0 ? void 0 : _b.namespace); }), onChange: function onChange(keys, context) { var _a, _b; - (_b = (_a = actions.detail) === null || _a === void 0 ? void 0 : _a.instanceResource) === null || _b === void 0 ? void 0 : _b.selects(instanceResource.list.data.records.filter(function (item) { var _a, _b; - return keys.includes(((_a = item.metadata) === null || _a === void 0 ? void 0 : _a.name) + ((_b = item.metadata) === null || _b === void 0 ? void 0 : _b.namespace) + ''); })); }, @@ -10512,7 +9453,6 @@ function ServiceBindingPanel(props) { }, rowDisabled: function rowDisabled(record) { var _a; - return !!((_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp); } })), React__default.createElement(CreateServiceBindingDialog, tslib.__assign({}, props)), React__default.createElement(ResourceDetailPanel, tslib.__assign({}, props))); @@ -10520,32 +9460,27 @@ function ServiceBindingPanel(props) { function BackUpStrategyDialog(props) { var _this = this; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - var _m = props.detail, - showBackupStrategyDialog = _m.showBackupStrategyDialog, - backupStrategyEdit = _m.backupStrategyEdit, - backupStrategy = _m.backupStrategy, - _o = props.base, - platform = _o.platform, - route = _o.route, - hubCluster = _o.hubCluster, - regionId = _o.regionId, - _p = props.list, - createResourceWorkflow = _p.createResourceWorkflow, - serviceResources = _p.serviceResources, - services = _p.services, - actions = props.actions, - _q = props.mode; - + showBackupStrategyDialog = _m.showBackupStrategyDialog, + backupStrategyEdit = _m.backupStrategyEdit, + backupStrategy = _m.backupStrategy, + _o = props.base, + platform = _o.platform, + route = _o.route, + hubCluster = _o.hubCluster, + regionId = _o.regionId, + _p = props.list, + createResourceWorkflow = _p.createResourceWorkflow, + serviceResources = _p.serviceResources, + services = _p.services, + actions = props.actions, + _q = props.mode; var _r = React.useState(''), - errorMsg = _r[0], - setErrorMsg = _r[1]; - + errorMsg = _r[0], + setErrorMsg = _r[1]; React.useEffect(function () { var _a, _b, _c, _d; - if (platform && regionId && (serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.selection) && showBackupStrategyDialog) { var clusterId = Util === null || Util === void 0 ? void 0 : Util.getClusterId(platform, serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.selection); var instanceId = (_b = (_a = serviceResources === null || serviceResources === void 0 ? void 0 : serviceResources.selection) === null || _a === void 0 ? void 0 : _a.spec) === null || _b === void 0 ? void 0 : _b.externalID; @@ -10562,46 +9497,32 @@ function BackUpStrategyDialog(props) { var backupStrategyFailed = (_c = backupStrategy === null || backupStrategy === void 0 ? void 0 : backupStrategy.object) === null || _c === void 0 ? void 0 : _c.error; var operateLoading = (createResourceWorkflow === null || createResourceWorkflow === void 0 ? void 0 : createResourceWorkflow.operationState) === ffRedux.OperationState.Performing; var failed = createResourceWorkflow.operationState === ffRedux.OperationState.Done && !ffRedux.isSuccessWorkflow(createResourceWorkflow); - var _submit = function _submit() { return tslib.__awaiter(_this, void 0, void 0, function () { var cosResource, result, formData, regionId_1, params; - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; - return tslib.__generator(this, function (_r) { switch (_r.label) { case 0: - return [4 - /*yield*/ - , checkCosResource({ + return [4 /*yield*/, checkCosResource({ platform: platform, clusterId: Util === null || Util === void 0 ? void 0 : Util.getCOSClusterId(platform, (_a = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.object) === null || _a === void 0 ? void 0 : _a.data), regionId: regionId })]; - case 1: cosResource = _r.sent(); - if (!cosResource) { setErrorMsg(i18n.t('{{msg}}', { msg: ErrorMsgEnum.COS_Resource_Not_Found })); - return [2 - /*return*/ - ]; + return [2 /*return*/]; } - return [4 - /*yield*/ - , (_b = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _b === void 0 ? void 0 : _b.validateAll()]; - + return [4 /*yield*/, (_b = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _b === void 0 ? void 0 : _b.validateAll()]; case 2: _r.sent(); - result = Backup === null || Backup === void 0 ? void 0 : Backup._validateAll(backupStrategyEdit); formData = backupStrategyEdit.formData; - if (result === null || result === void 0 ? void 0 : result.valid) { regionId_1 = HubCluster === null || HubCluster === void 0 ? void 0 : HubCluster.DefaultRegion; params = { @@ -10622,8 +9543,8 @@ function BackUpStrategyDialog(props) { resourceType: ResourceTypeEnum.Backup, instanceName: "backup-".concat((_k = route === null || route === void 0 ? void 0 : route.queries) === null || _k === void 0 ? void 0 : _k.instancename, "-").concat(new Date().getTime()), specificOperate: CreateSpecificOperatorEnum === null || CreateSpecificOperatorEnum === void 0 ? void 0 : CreateSpecificOperatorEnum.BackupStrategy - }; //若实例的备份策略已存在,则更新备份策略;若实例的备份策略不存在,则新建备份策略 - + }; + //若实例的备份策略已存在,则更新备份策略;若实例的备份策略不存在,则新建备份策略 if (!((_l = backupStrategy === null || backupStrategy === void 0 ? void 0 : backupStrategy.object) === null || _l === void 0 ? void 0 : _l.data)) { (_m = actions === null || actions === void 0 ? void 0 : actions.create) === null || _m === void 0 ? void 0 : _m.createResource.start([params], regionId_1); (_o = actions === null || actions === void 0 ? void 0 : actions.create) === null || _o === void 0 ? void 0 : _o.createResource.perform(); @@ -10637,10 +9558,7 @@ function BackUpStrategyDialog(props) { } else { bridge.tips.error(result === null || result === void 0 ? void 0 : result.message); } - - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -10648,11 +9566,9 @@ function BackUpStrategyDialog(props) { var _cancel = function _cancel() { var _a; - actions.detail.showBackupDialog(false); (_a = actions === null || actions === void 0 ? void 0 : actions.create.createResource) === null || _a === void 0 ? void 0 : _a.reset(); }; - var renderButtons = function renderButtons() { var buttons = [{ handleFunc: _submit, @@ -10673,7 +9589,6 @@ function BackUpStrategyDialog(props) { }, item === null || item === void 0 ? void 0 : item.text); }); }; - return React__default.createElement(teaComponent.Modal, { visible: showBackupStrategyDialog, caption: i18n.t('备份策略管理'), @@ -10697,26 +9612,18 @@ function BackUpStrategyDialog(props) { onChange: function onChange(value) { return tslib.__awaiter(_this, void 0, void 0, function () { var cosResource; - var _a, _b, _c; - return tslib.__generator(this, function (_d) { switch (_d.label) { case 0: - if (!value) return [3 - /*break*/ - , 2]; - return [4 - /*yield*/ - , checkCosResource({ + if (!value) return [3 /*break*/, 2]; + return [4 /*yield*/, checkCosResource({ platform: platform, clusterId: Util.getCOSClusterId(platform, (_a = hubCluster === null || hubCluster === void 0 ? void 0 : hubCluster.object) === null || _a === void 0 ? void 0 : _a.data), regionId: regionId })]; - case 1: cosResource = _d.sent(); - if (cosResource) { (_b = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _b === void 0 ? void 0 : _b.updateBackUpStrategy('enable', value); } else { @@ -10724,19 +9631,12 @@ function BackUpStrategyDialog(props) { msg: ErrorMsgEnum.COS_Resource_Not_Found })); } - - return [3 - /*break*/ - , 3]; - + return [3 /*break*/, 3]; case 2: (_c = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _c === void 0 ? void 0 : _c.updateBackUpStrategy('enable', value); _d.label = 3; - case 3: - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -10747,7 +9647,6 @@ function BackUpStrategyDialog(props) { value: (_g = backupStrategyEdit === null || backupStrategyEdit === void 0 ? void 0 : backupStrategyEdit.formData) === null || _g === void 0 ? void 0 : _g.backupDate, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.updateBackUpStrategy('backupDate', value); } }, (_h = Backup === null || Backup === void 0 ? void 0 : Backup.weekConfig) === null || _h === void 0 ? void 0 : _h.map(function (item) { @@ -10765,7 +9664,6 @@ function BackUpStrategyDialog(props) { value: (_j = backupStrategyEdit === null || backupStrategyEdit === void 0 ? void 0 : backupStrategyEdit.formData) === null || _j === void 0 ? void 0 : _j.backupTime, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.updateBackUpStrategy('backupTime', value); } }, (_k = Backup === null || Backup === void 0 ? void 0 : Backup.hourConfig) === null || _k === void 0 ? void 0 : _k.map(function (item) { @@ -10785,7 +9683,6 @@ function BackUpStrategyDialog(props) { value: (_l = backupStrategyEdit === null || backupStrategyEdit === void 0 ? void 0 : backupStrategyEdit.formData) === null || _l === void 0 ? void 0 : _l.backupReserveDay, onChange: function onChange(value) { var _a; - (_a = actions === null || actions === void 0 ? void 0 : actions.detail) === null || _a === void 0 ? void 0 : _a.updateBackUpStrategy('backupReserveDay', value); } }), React__default.createElement(teaComponent.Text, null, i18n.t('天后自动删除')))) : null)), React__default.createElement(teaComponent.Modal.Footer, null, renderButtons(), React__default.createElement(TipInfo, { @@ -10797,52 +9694,40 @@ function BackUpStrategyDialog(props) { function InstanceBackupPanel(props) { var _this = this; - var _a, _b, _c, _d; - var _e = props.detail, - instanceResource = _e.instanceResource, - backupResourceLoading = _e.backupResourceLoading, - _f = props.base, - platform = _f.platform, - route = _f.route, - userInfo = _f.userInfo, - regionId = _f.regionId, - _g = props.list, - serviceResources = _g.serviceResources, - services = _g.services, - servicesInstance = _g.servicesInstance, - actions = props.actions; - + instanceResource = _e.instanceResource, + backupResourceLoading = _e.backupResourceLoading, + _f = props.base, + platform = _f.platform, + route = _f.route, + userInfo = _f.userInfo, + regionId = _f.regionId, + _g = props.list, + serviceResources = _g.serviceResources, + services = _g.services, + servicesInstance = _g.servicesInstance, + actions = props.actions; var _h = route === null || route === void 0 ? void 0 : route.queries, - instancename = _h.instancename, - clusterid = _h.clusterid; - + instancename = _h.instancename, + clusterid = _h.clusterid; var _backupNow = function _backupNow() { return tslib.__awaiter(_this, void 0, void 0, function () { var result, params; - var _a, _b, _c, _d; - return tslib.__generator(this, function (_e) { switch (_e.label) { case 0: - return [4 - /*yield*/ - , teaComponent.Modal.confirm({ + return [4 /*yield*/, teaComponent.Modal.confirm({ message: i18n.t('确认备份资源'), okText: i18n.t('确定'), cancelText: i18n.t('取消'), description: i18n.t('根据备份数据大小,备份过程可能持续数分钟,请确保期间网络连接畅通,云上存储空间足够。') })]; - case 1: result = _e.sent(); - if (!result) { - return [2 - /*return*/ - ]; + return [2 /*return*/]; } params = { @@ -10879,9 +9764,7 @@ function InstanceBackupPanel(props) { namespace: SystemNamespace }; actions.create.backupResourceNow(params); - return [2 - /*return*/ - ]; + return [2 /*return*/]; } }); }); @@ -10892,7 +9775,6 @@ function InstanceBackupPanel(props) { header: "名称", render: function render(item) { var _a, _b, _c; - return React__default.createElement("p", null, React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true @@ -10905,18 +9787,15 @@ function InstanceBackupPanel(props) { header: "状态", render: function render(item) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; - var isFailed = ((_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.phase) && ![BackupStatusNum.Waiting, BackupStatusNum.Success].includes((_b = item === null || item === void 0 ? void 0 : item.status) === null || _b === void 0 ? void 0 : _b.phase); var state = isFailed ? BackupStatusNum === null || BackupStatusNum === void 0 ? void 0 : BackupStatusNum.Failed : !((_c = item === null || item === void 0 ? void 0 : item.status) === null || _c === void 0 ? void 0 : _c.phase) ? BackupStatusNum.Waiting : (_d = item === null || item === void 0 ? void 0 : item.status) === null || _d === void 0 ? void 0 : _d.phase; var isSuccess = ((_e = item === null || item === void 0 ? void 0 : item.status) === null || _e === void 0 ? void 0 : _e.phase) === BackupStatusNum.Success; var isDeleting = showResourceDeleteLoading(item, (_g = (_f = instanceResource === null || instanceResource === void 0 ? void 0 : instanceResource.list) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.records); - if (isDeleting) { return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Icon, { type: 'loading' }), i18n.t('删除中')); } - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, { className: ((_h = BackupStatusMap === null || BackupStatusMap === void 0 ? void 0 : BackupStatusMap[state]) === null || _h === void 0 ? void 0 : _h.className) + ' tea-mr-1n', overflow: true @@ -10972,7 +9851,6 @@ function InstanceBackupPanel(props) { header: "实例ID", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, { overflow: true, tooltip: true @@ -10983,7 +9861,6 @@ function InstanceBackupPanel(props) { header: "大小", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, Util === null || Util === void 0 ? void 0 : Util.getReadableFileSizeString((_b = (_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.results) === null || _b === void 0 ? void 0 : _b.BACKUP_FILE_SIZE))); } }, { @@ -10991,7 +9868,6 @@ function InstanceBackupPanel(props) { header: "备份类型", render: function render(item) { var _a, _b, _c, _d, _e, _f; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, { className: (_c = BackupTypeMap[(_b = (_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.trigger) !== null && _b !== void 0 ? _b : BackupTypeNum.Unknown]) === null || _c === void 0 ? void 0 : _c.className }, (_f = BackupTypeMap[(_e = (_d = item === null || item === void 0 ? void 0 : item.spec) === null || _d === void 0 ? void 0 : _d.trigger) !== null && _e !== void 0 ? _e : BackupTypeNum.Unknown]) === null || _f === void 0 ? void 0 : _f.text)); @@ -11001,7 +9877,6 @@ function InstanceBackupPanel(props) { header: "创建时间", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_b = dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.creationTimestamp), 'YYYY-MM-DD HH:mm:ss')) !== null && _b !== void 0 ? _b : '-')); } }, { @@ -11009,7 +9884,6 @@ function InstanceBackupPanel(props) { header: "保留时间", render: function render(item) { var _a, _b, _c; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, ((_a = item === null || item === void 0 ? void 0 : item.spec) === null || _a === void 0 ? void 0 : _a.trigger) === (BackupTypeNum === null || BackupTypeNum === void 0 ? void 0 : BackupTypeNum.Manual) ? i18n.t('永久保留') : (_c = dateFormatter(new Date((_b = item === null || item === void 0 ? void 0 : item.spec) === null || _b === void 0 ? void 0 : _b.retainTime), 'YYYY-MM-DD HH:mm:ss')) !== null && _c !== void 0 ? _c : '-')); } }, { @@ -11017,7 +9891,6 @@ function InstanceBackupPanel(props) { header: "删除时间", render: function render(item) { var _a, _b; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Text, null, (_b = dateFormatter(new Date((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp), 'YYYY-MM-DD HH:mm:ss')) !== null && _b !== void 0 ? _b : '-')); } }, { @@ -11025,7 +9898,6 @@ function InstanceBackupPanel(props) { header: "操作", render: function render(item) { var _a; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Button, { type: "link", disabled: !!((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp), @@ -11034,8 +9906,8 @@ function InstanceBackupPanel(props) { } }, i18n.t('删除'))); } - }]; // 是否支持备份功能 - + }]; + // 是否支持备份功能 var showBackUpOperation = (_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.supportedOperations) === null || _c === void 0 ? void 0 : _c.some(function (operation) { return (operation === null || operation === void 0 ? void 0 : operation.operation) === (SupportedOperationsEnum === null || SupportedOperationsEnum === void 0 ? void 0 : SupportedOperationsEnum.Backup); }); @@ -11062,7 +9934,6 @@ function InstanceBackupPanel(props) { })), React__default.createElement(ffComponent.TablePanel, { recordKey: function recordKey(record) { var _a; - return (_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.uid; }, columns: columns, @@ -11071,7 +9942,6 @@ function InstanceBackupPanel(props) { isNeedPagination: true, rowDisabled: function rowDisabled(record) { var _a; - return !!((_a = record === null || record === void 0 ? void 0 : record.metadata) === null || _a === void 0 ? void 0 : _a.deletionTimestamp); } }), React__default.createElement(BackUpStrategyDialog, tslib.__assign({}, props))); @@ -11079,31 +9949,27 @@ function InstanceBackupPanel(props) { function InstanceDetailContainer(props) { var _a, _b; - var actions = props.actions, - _c = props.detail, - selectedDetailTab = _c.selectedDetailTab, - serviceInstanceSchema = _c.serviceInstanceSchema, - _d = props.base, - route = _d.route, - platform = _d.platform, - regionId = _d.regionId, - servicesInstance = props.list.servicesInstance; + _c = props.detail, + selectedDetailTab = _c.selectedDetailTab, + serviceInstanceSchema = _c.serviceInstanceSchema, + _d = props.base, + route = _d.route, + platform = _d.platform, + regionId = _d.regionId, + servicesInstance = props.list.servicesInstance; var urlParams = router === null || router === void 0 ? void 0 : router.resolve(route); React.useEffect(function () { var _a; - if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'detail' && ((_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.fetched)) { actions.detail.selectDetailTab(DetailTabType.Detail); } }, [urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub, servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object]); var instanceDetailTabs = React.useMemo(function () { var _a, _b, _c; - if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'detail' && ((_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.fetched) && !((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.error)) { return detailTabs === null || detailTabs === void 0 ? void 0 : detailTabs.filter(function (item) { var _a, _b, _c; - if ((item === null || item === void 0 ? void 0 : item.id) === (DetailTabType === null || DetailTabType === void 0 ? void 0 : DetailTabType.BackUp)) { return (_c = (_b = (_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.supportedOperations) === null || _c === void 0 ? void 0 : _c.some(function (operation) { return (operation === null || operation === void 0 ? void 0 : operation.operation) === (SupportedOperationsEnum === null || SupportedOperationsEnum === void 0 ? void 0 : SupportedOperationsEnum.Backup); @@ -11119,10 +9985,8 @@ function InstanceDetailContainer(props) { } }, [urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub, servicesInstance]); var loadingDetailTabs = ((_a = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _a === void 0 ? void 0 : _a.loading) || !((_b = servicesInstance === null || servicesInstance === void 0 ? void 0 : servicesInstance.object) === null || _b === void 0 ? void 0 : _b.fetched); - var _renderTabContent = function _renderTabContent(tabId) { var content; - if (tabId === DetailTabType.Detail) { content = React__default.createElement(InstanceBaseDetail, tslib.__assign({}, props)); } else if (tabId === DetailTabType.BackUp) { @@ -11132,10 +9996,8 @@ function InstanceDetailContainer(props) { } else if (tabId === DetailTabType.ServiceBinding) { content = React__default.createElement(ServiceBindingPanel, tslib.__assign({}, props)); } - return content; }; - return React__default.createElement(React__default.Fragment, null, React__default.createElement(teaComponent.Layout, { style: { boxShadow: 'none' @@ -11175,76 +10037,57 @@ function InstanceDetailContainer(props) { var routerSea$4 = seajs === null || seajs === void 0 ? void 0 : seajs.require('router'); var store = configStore(); - -var MiddlewareAppContainer = -/** @class */ -function (_super) { +var MiddlewareAppContainer = /** @class */function (_super) { tslib.__extends(MiddlewareAppContainer, _super); - function MiddlewareAppContainer(props, context) { return _super.call(this, props, context) || this; - } // 页面离开时,清空store - - + } + // 页面离开时,清空store MiddlewareAppContainer.prototype.componentWillUnmount = function () { store.dispatch({ type: ResetStoreAction }); }; - MiddlewareAppContainer.prototype.render = function () { return React.createElement(reactRedux.Provider, { store: store }, React.createElement(MiddlewareApp, tslib.__assign({}, this.props))); }; - return MiddlewareAppContainer; }(React.Component); - -var mapDispatchToProps = function mapDispatchToProps(dispatch) { +var mapDispatchToProps$1 = function mapDispatchToProps(dispatch) { return Object.assign({}, ffRedux.bindActionCreators({ actions: allActions }, dispatch), { dispatch: dispatch }); }; - -var MiddlewareApp = -/** @class */ -function (_super) { +var MiddlewareApp = /** @class */function (_super) { tslib.__extends(MiddlewareApp, _super); - function MiddlewareApp(props, context) { return _super.call(this, props, context) || this; } - MiddlewareApp.prototype.componentDidMount = function () { var _a, _b, _c; - var _d = this.props, - actions = _d.actions, - platform = _d.platform, - isI18n = _d.base.isI18n; - + actions = _d.actions, + platform = _d.platform, + isI18n = _d.base.isI18n; if (window['VERSION'] === 'en' && !isI18n) { actions.base.toggleIsI18n(true); } - if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.platform) { (_b = actions === null || actions === void 0 ? void 0 : actions.base) === null || _b === void 0 ? void 0 : _b.fetchPlatform(platform, (_c = this === null || this === void 0 ? void 0 : this.props) === null || _c === void 0 ? void 0 : _c.regionId); } }; - MiddlewareApp.prototype.render = function () { var _a, _b; - var _c = this.props.base, - route = _c.route, - platform = _c.platform; + route = _c.route, + platform = _c.platform; var urlParams = router === null || router === void 0 ? void 0 : router.resolve(route); var queries = route === null || route === void 0 ? void 0 : route.queries; var content; - if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'detail' || ((_a = route === null || route === void 0 ? void 0 : route.queries) === null || _a === void 0 ? void 0 : _a.mode) === 'detail') { content = React.createElement(InstanceDetailContainer, tslib.__assign({}, this.props)); } else if ((urlParams === null || urlParams === void 0 ? void 0 : urlParams.sub) === 'create' || ((_b = route === null || route === void 0 ? void 0 : route.queries) === null || _b === void 0 ? void 0 : _b.mode) === 'create') { @@ -11252,7 +10095,6 @@ function (_super) { } else { content = React.createElement(PaasContent, tslib.__assign({}, this.props)); } - return React.createElement(teaComponent.Layout, { style: { marginTop: 0 @@ -11264,10 +10106,9 @@ function (_super) { full: true }, content, React.createElement(ResourceDeleteDialog, tslib.__assign({}, this.props)))); }; - MiddlewareApp = tslib.__decorate([reactRedux.connect(function (state) { return state; - }, mapDispatchToProps)], MiddlewareApp); + }, mapDispatchToProps$1)], MiddlewareApp); return MiddlewareApp; }(React.Component);