瀏覽代碼

[release] v0.12.0-unstable50

Yann Stepienik 1 年之前
父節點
當前提交
0faa1133fc
共有 2 個文件被更改,包括 9 次插入3 次删除
  1. 8 2
      client/src/pages/market/sources.jsx
  2. 1 1
      package.json

+ 8 - 2
client/src/pages/market/sources.jsx

@@ -55,7 +55,7 @@ const EditSourcesModal = ({ onSave }) => {
 
   const formik = useFormik({
     initialValues: {
-      sources: config ? config.MarketConfig.Sources : [],
+      sources: (config && config.MarketConfig.Sources) ? config.MarketConfig.Sources : [],
     },
     enableReinitialize: true, // This will reinitialize the form when `config` changes
     // validationSchema: AlertValidationSchema,
@@ -82,6 +82,10 @@ const EditSourcesModal = ({ onSave }) => {
       const errors = {};
 
       values.sources && values.sources.forEach((source, index) => {
+        if (source.removed) {
+          return;
+        }
+
         if (source.Name === '') {
           errors[`sources.${index}.Name`] = 'Name is required';
         }
@@ -89,10 +93,12 @@ const EditSourcesModal = ({ onSave }) => {
           errors[`sources.${index}.Url`] = 'URL is required';
         }
 
-        if (source.Name === 'cosmos-cloud' || values.sources.filter((s) => s.Name === source.Name).length > 1) {
+        if (source.Name === 'cosmos-cloud' || values.sources.filter((s) => s.Name === source.Name && !s.removed).length > 1) {
           errors[`sources.${index}.Name`] = 'Name must be unique';
         }
       });
+
+      console.log(errors)
   
       return errors;
     }

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "cosmos-server",
-  "version": "0.12.0-unstable49",
+  "version": "0.12.0-unstable50",
   "description": "",
   "main": "test-server.js",
   "bugs": {