F #5422: Add user inputs to instantiate dialog (#1874)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2022-03-25 10:46:01 +01:00
1 parent 93556d5e61
commit f13f7622b5
24 files changed
+492 -435

No files matched your search

+161 -138
View File
@@ -52,7 +52,7 @@
"http": "0.0.1-security",
"http-proxy-middleware": "1.0.5",
"https": "1.0.0",
"iconoir-react": "2.1.0",
"iconoir-react": "4.7.1",
"immutable": "4.0.0-rc.12",
"intersection-observer": "0.11.0",
"jsonschema": "1.2.7",
@@ -535,9 +535,9 @@
}
},
"node_modules/@babel/helpers": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.7.tgz",
"integrity": "sha512-TKsj9NkjJfTBxM7Phfy7kv6yYc4ZcOo+AaWGqQOKTPDOmcGkIFb5xNA746eKisQkm4yavUYh4InYM9S+VnO01w==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.8.tgz",
"integrity": "sha512-QcL86FGxpfSJwGtAvv4iG93UL6bmqBdmoVY0CMCU2g+oD2ezQse3PT5Pa+jiD6LJndBQi0EDlpzOWNlLuhz5gw==",
"dependencies": {
"@babel/template": "^7.16.7",
"@babel/traverse": "^7.17.3",
@@ -583,9 +583,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.7.tgz",
"integrity": "sha512-bm3AQf45vR4gKggRfvJdYJ0gFLoCbsPxiFLSH6hTVYABptNHY6l9NrhnucVjQ/X+SPtLANT9lc0fFhikj+VBRA==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.8.tgz",
"integrity": "sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ==",
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -1278,12 +1278,12 @@
}
},
"node_modules/@babel/plugin-transform-modules-systemjs": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.7.tgz",
"integrity": "sha512-DuK5E3k+QQmnOqBR9UkusByy5WZWGRxfzV529s9nPra1GE7olmxfqO2FHobEOYSPIjPBTr4p66YDcjQnt8cBmw==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.17.8.tgz",
"integrity": "sha512-39reIkMTUVagzgA5x88zDYXPCMT6lcaRKs1+S9K6NKBPErbgO/w/kP8GlNQTC87b412ZTlmNgr3k2JrWgHH+Bw==",
"dependencies": {
"@babel/helper-hoist-variables": "^7.16.7",
"@babel/helper-module-transforms": "^7.16.7",
"@babel/helper-module-transforms": "^7.17.7",
"@babel/helper-plugin-utils": "^7.16.7",
"@babel/helper-validator-identifier": "^7.16.7",
"babel-plugin-dynamic-import-node": "^2.3.3"
@@ -1709,9 +1709,9 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.7.tgz",
"integrity": "sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.8.tgz",
"integrity": "sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA==",
"dependencies": {
"regenerator-runtime": "^0.13.4"
},
@@ -1720,9 +1720,9 @@
}
},
"node_modules/@babel/runtime-corejs3": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.7.tgz",
"integrity": "sha512-TvliGJjhxis5m7xIMvlXH/xG8Oa/LK0SCUCyfKD6nLi42n5fB4WibDJ0g9trmmBB6hwpMNx+Lzbxy9/4gpMaVw==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.8.tgz",
"integrity": "sha512-ZbYSUvoSF6dXZmMl/CYTMOvzIFnbGfv4W3SEHYgMvNsFTeLaF2gkGAF4K2ddmtSK4Emej+0aYcnSC6N5dPCXUQ==",
"dev": true,
"dependencies": {
"core-js-pure": "^3.20.2",
@@ -2306,13 +2306,13 @@
}
},
"node_modules/@mui/lab/node_modules/@mui/system": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.5.1.tgz",
"integrity": "sha512-2hynI4hN8304hOCT8sc4knJviwUUYJ7XK3mXwQ0nagVGOPnWSOad/nYADm7K0vdlCeUXLIbDbe7oNN3Kaiu2kA==",
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.5.2.tgz",
"integrity": "sha512-OATYFI36nliud8xh0u+ZNqDo0jWjxpO0vZLlzqNB+ZtkR5Q/+1X3GgboA9ruiB8Rq+udnJlMBQNGW0qqjvAOHQ==",
"dependencies": {
"@babel/runtime": "^7.17.2",
"@mui/private-theming": "^5.4.4",
"@mui/styled-engine": "^5.4.4",
"@mui/styled-engine": "^5.5.2",
"@mui/types": "^7.1.3",
"@mui/utils": "^5.4.4",
"clsx": "^1.1.1",
@@ -2455,9 +2455,9 @@
}
},
"node_modules/@mui/styled-engine": {
"version": "5.4.4",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.4.4.tgz",
"integrity": "sha512-AKx3rSgB6dmt5f7iP4K18mLFlE5/9EfJe/5EH9Pyqez8J/CPkTgYhJ/Va6qtlrcunzpui+uG/vfuf04yAZekSg==",
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.5.2.tgz",
"integrity": "sha512-jkz5AHHbA43akBo5L3y1X1/X0f+RvXvCp3eXKt+iOf3qnKSAausbtlVz7gBbC4xIWDnP1Jb/6T+t/0/7gObRYA==",
"dependencies": {
"@babel/runtime": "^7.17.2",
"@emotion/cache": "^11.7.1",
@@ -3065,9 +3065,9 @@
"integrity": "sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g=="
},
"node_modules/@types/node": {
"version": "17.0.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
"version": "17.0.23",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz",
"integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw=="
},
"node_modules/@types/parse-json": {
"version": "4.0.0",
@@ -3080,9 +3080,9 @@
"integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ=="
},
"node_modules/@types/react": {
"version": "17.0.40",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.40.tgz",
"integrity": "sha512-UrXhD/JyLH+W70nNSufXqMZNuUD2cXHu6UjCllC6pmOQgBX4SGXOH8fjRka0O0Ee0HrFxapDD8Bwn81Kmiz6jQ==",
"version": "17.0.42",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.42.tgz",
"integrity": "sha512-nuab3x3CpJ7VFeNA+3HTUuEkvClYHXqWtWd7Ud6AZYW7Z3NH9WKtgU+tFB0ZLcHq+niB/HnzLcaZPqMJ95+k5Q==",
"dependencies": {
"@types/prop-types": "*",
"@types/scheduler": "*",
@@ -4257,13 +4257,19 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001317",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz",
"integrity": "sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
}
"version": "1.0.30001320",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz",
"integrity": "sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
}
]
},
"node_modules/caseless": {
"version": "0.12.0",
@@ -4986,9 +4992,9 @@
}
},
"node_modules/debug": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
"integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==",
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dependencies": {
"ms": "2.1.2"
},
@@ -5201,9 +5207,9 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"node_modules/electron-to-chromium": {
"version": "1.4.85",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz",
"integrity": "sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg=="
"version": "1.4.92",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.92.tgz",
"integrity": "sha512-YAVbvQIcDE/IJ/vzDMjD484/hsRbFPW2qXJPaYTfOhtligmfYEYOep+5QojpaEU9kq6bMvNeC2aG7arYvTHYsA=="
},
"node_modules/elliptic": {
"version": "6.5.4",
@@ -6793,6 +6799,19 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -7324,9 +7343,9 @@
"integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ=="
},
"node_modules/iconoir-react": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/iconoir-react/-/iconoir-react-2.1.0.tgz",
"integrity": "sha512-PMrSTrTI4iksFrZvPnlQraQdDOE5yEe/Z4O0+v5O7mNbwLFDqCVgtDp6fyR9EDVeIyiPY9/YDfq++eII+DH4rw==",
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/iconoir-react/-/iconoir-react-4.7.1.tgz",
"integrity": "sha512-4QJr7qL4zU5Z7/wBSS0hUy/ThMRVqIuxInz79lPc1yIIdwsegqAKvPVfCeg1bHoFhgi5LbWB7pyx8/t/O9KHRQ==",
"peerDependencies": {
"react": "^16.8.6 || ^17"
}
@@ -7945,12 +7964,9 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"node_modules/json5": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
"integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==",
"dependencies": {
"minimist": "^1.2.5"
},
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"bin": {
"json5": "lib/cli.js"
},
@@ -8570,16 +8586,16 @@
}
},
"node_modules/minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
},
"node_modules/mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dependencies": {
"minimist": "^1.2.5"
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
@@ -9073,7 +9089,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/opennebula-guacamole/-/opennebula-guacamole-1.0.0.tgz",
"integrity": "sha512-zoLOv55wlVQvjIG0BVCOAh5OpLWNRN37268oIz1mQYC8AlBzoNflO1lCnA3PfQ06LriU0a32sqYV+nF7PTg6Dg==",
"license": "Apache-2.0",
"dependencies": {
"deep-extend": "0.6.0",
"luxon": "1.25.0",
@@ -11148,6 +11163,11 @@
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
},
"bin": {
"sshpk-conv": "bin/sshpk-conv",
"sshpk-sign": "bin/sshpk-sign",
"sshpk-verify": "bin/sshpk-verify"
},
"engines": {
"node": ">=0.10.0"
}
@@ -11299,18 +11319,18 @@
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"node_modules/string.prototype.matchall": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.6.tgz",
"integrity": "sha512-6WgDX8HmQqvEd7J+G6VtAahhsQIssiZ8zl7zKh1VDMFyL3hRTJP4FTNA3RbIp2TOQ9AYNDcc7e3fH0Qbup+DBg==",
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz",
"integrity": "sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.1",
"get-intrinsic": "^1.1.1",
"has-symbols": "^1.0.2",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"regexp.prototype.flags": "^1.3.1",
"regexp.prototype.flags": "^1.4.1",
"side-channel": "^1.0.4"
},
"funding": {
@@ -11440,9 +11460,9 @@
}
},
"node_modules/table/node_modules/ajv": {
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz",
"integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==",
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz",
"integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==",
"dev": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
@@ -11694,14 +11714,14 @@
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
},
"node_modules/tsconfig-paths": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz",
"integrity": "sha512-cg/1jAZoL57R39+wiw4u/SCC6Ic9Q5NqjBOb+9xISedOYurfog9ZNmKJSxAnb2m/5Bq4lE9lhUcau33Ml8DM0g==",
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
"integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==",
"dev": true,
"dependencies": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"minimist": "^1.2.0",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
},
@@ -12852,9 +12872,9 @@
}
},
"@babel/helpers": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.7.tgz",
"integrity": "sha512-TKsj9NkjJfTBxM7Phfy7kv6yYc4ZcOo+AaWGqQOKTPDOmcGkIFb5xNA746eKisQkm4yavUYh4InYM9S+VnO01w==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.8.tgz",
"integrity": "sha512-QcL86FGxpfSJwGtAvv4iG93UL6bmqBdmoVY0CMCU2g+oD2ezQse3PT5Pa+jiD6LJndBQi0EDlpzOWNlLuhz5gw==",
"requires": {
"@babel/template": "^7.16.7",
"@babel/traverse": "^7.17.3",
@@ -12885,9 +12905,9 @@
}
},
"@babel/parser": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.7.tgz",
"integrity": "sha512-bm3AQf45vR4gKggRfvJdYJ0gFLoCbsPxiFLSH6hTVYABptNHY6l9NrhnucVjQ/X+SPtLANT9lc0fFhikj+VBRA=="
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.8.tgz",
"integrity": "sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ=="
},
"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": {
"version": "7.16.7",
@@ -13321,12 +13341,12 @@
}
},
"@babel/plugin-transform-modules-systemjs": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.7.tgz",
"integrity": "sha512-DuK5E3k+QQmnOqBR9UkusByy5WZWGRxfzV529s9nPra1GE7olmxfqO2FHobEOYSPIjPBTr4p66YDcjQnt8cBmw==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.17.8.tgz",
"integrity": "sha512-39reIkMTUVagzgA5x88zDYXPCMT6lcaRKs1+S9K6NKBPErbgO/w/kP8GlNQTC87b412ZTlmNgr3k2JrWgHH+Bw==",
"requires": {
"@babel/helper-hoist-variables": "^7.16.7",
"@babel/helper-module-transforms": "^7.16.7",
"@babel/helper-module-transforms": "^7.17.7",
"@babel/helper-plugin-utils": "^7.16.7",
"@babel/helper-validator-identifier": "^7.16.7",
"babel-plugin-dynamic-import-node": "^2.3.3"
@@ -13611,17 +13631,17 @@
}
},
"@babel/runtime": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.7.tgz",
"integrity": "sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.8.tgz",
"integrity": "sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA==",
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"@babel/runtime-corejs3": {
"version": "7.17.7",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.7.tgz",
"integrity": "sha512-TvliGJjhxis5m7xIMvlXH/xG8Oa/LK0SCUCyfKD6nLi42n5fB4WibDJ0g9trmmBB6hwpMNx+Lzbxy9/4gpMaVw==",
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.8.tgz",
"integrity": "sha512-ZbYSUvoSF6dXZmMl/CYTMOvzIFnbGfv4W3SEHYgMvNsFTeLaF2gkGAF4K2ddmtSK4Emej+0aYcnSC6N5dPCXUQ==",
"dev": true,
"requires": {
"core-js-pure": "^3.20.2",
@@ -14005,13 +14025,13 @@
},
"dependencies": {
"@mui/system": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.5.1.tgz",
"integrity": "sha512-2hynI4hN8304hOCT8sc4knJviwUUYJ7XK3mXwQ0nagVGOPnWSOad/nYADm7K0vdlCeUXLIbDbe7oNN3Kaiu2kA==",
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.5.2.tgz",
"integrity": "sha512-OATYFI36nliud8xh0u+ZNqDo0jWjxpO0vZLlzqNB+ZtkR5Q/+1X3GgboA9ruiB8Rq+udnJlMBQNGW0qqjvAOHQ==",
"requires": {
"@babel/runtime": "^7.17.2",
"@mui/private-theming": "^5.4.4",
"@mui/styled-engine": "^5.4.4",
"@mui/styled-engine": "^5.5.2",
"@mui/types": "^7.1.3",
"@mui/utils": "^5.4.4",
"clsx": "^1.1.1",
@@ -14085,9 +14105,9 @@
}
},
"@mui/styled-engine": {
"version": "5.4.4",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.4.4.tgz",
"integrity": "sha512-AKx3rSgB6dmt5f7iP4K18mLFlE5/9EfJe/5EH9Pyqez8J/CPkTgYhJ/Va6qtlrcunzpui+uG/vfuf04yAZekSg==",
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.5.2.tgz",
"integrity": "sha512-jkz5AHHbA43akBo5L3y1X1/X0f+RvXvCp3eXKt+iOf3qnKSAausbtlVz7gBbC4xIWDnP1Jb/6T+t/0/7gObRYA==",
"requires": {
"@babel/runtime": "^7.17.2",
"@emotion/cache": "^11.7.1",
@@ -14558,9 +14578,9 @@
"integrity": "sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g=="
},
"@types/node": {
"version": "17.0.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
"version": "17.0.23",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz",
"integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw=="
},
"@types/parse-json": {
"version": "4.0.0",
@@ -14573,9 +14593,9 @@
"integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ=="
},
"@types/react": {
"version": "17.0.40",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.40.tgz",
"integrity": "sha512-UrXhD/JyLH+W70nNSufXqMZNuUD2cXHu6UjCllC6pmOQgBX4SGXOH8fjRka0O0Ee0HrFxapDD8Bwn81Kmiz6jQ==",
"version": "17.0.42",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.42.tgz",
"integrity": "sha512-nuab3x3CpJ7VFeNA+3HTUuEkvClYHXqWtWd7Ud6AZYW7Z3NH9WKtgU+tFB0ZLcHq+niB/HnzLcaZPqMJ95+k5Q==",
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
@@ -15535,9 +15555,9 @@
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
},
"caniuse-lite": {
"version": "1.0.30001317",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz",
"integrity": "sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ=="
"version": "1.0.30001320",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz",
"integrity": "sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA=="
},
"caseless": {
"version": "0.12.0",
@@ -16139,9 +16159,9 @@
}
},
"debug": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
"integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==",
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"requires": {
"ms": "2.1.2"
}
@@ -16311,9 +16331,9 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"electron-to-chromium": {
"version": "1.4.85",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz",
"integrity": "sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg=="
"version": "1.4.92",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.92.tgz",
"integrity": "sha512-YAVbvQIcDE/IJ/vzDMjD484/hsRbFPW2qXJPaYTfOhtligmfYEYOep+5QojpaEU9kq6bMvNeC2aG7arYvTHYsA=="
},
"elliptic": {
"version": "6.5.4",
@@ -17530,6 +17550,12 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"optional": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -17939,9 +17965,9 @@
"integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ=="
},
"iconoir-react": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/iconoir-react/-/iconoir-react-2.1.0.tgz",
"integrity": "sha512-PMrSTrTI4iksFrZvPnlQraQdDOE5yEe/Z4O0+v5O7mNbwLFDqCVgtDp6fyR9EDVeIyiPY9/YDfq++eII+DH4rw==",
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/iconoir-react/-/iconoir-react-4.7.1.tgz",
"integrity": "sha512-4QJr7qL4zU5Z7/wBSS0hUy/ThMRVqIuxInz79lPc1yIIdwsegqAKvPVfCeg1bHoFhgi5LbWB7pyx8/t/O9KHRQ==",
"requires": {}
},
"iconv-lite": {
@@ -18371,12 +18397,9 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"json5": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
"integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==",
"requires": {
"minimist": "^1.2.5"
}
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA=="
},
"jsonfile": {
"version": "6.1.0",
@@ -18885,16 +18908,16 @@
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"requires": {
"minimist": "^1.2.5"
"minimist": "^1.2.6"
}
},
"mkdirp-classic": {
@@ -21004,18 +21027,18 @@
}
},
"string.prototype.matchall": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.6.tgz",
"integrity": "sha512-6WgDX8HmQqvEd7J+G6VtAahhsQIssiZ8zl7zKh1VDMFyL3hRTJP4FTNA3RbIp2TOQ9AYNDcc7e3fH0Qbup+DBg==",
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz",
"integrity": "sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.1",
"get-intrinsic": "^1.1.1",
"has-symbols": "^1.0.2",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"regexp.prototype.flags": "^1.3.1",
"regexp.prototype.flags": "^1.4.1",
"side-channel": "^1.0.4"
}
},
@@ -21100,9 +21123,9 @@
},
"dependencies": {
"ajv": {
"version": "8.10.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz",
"integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==",
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz",
"integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
@@ -21303,14 +21326,14 @@
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
},
"tsconfig-paths": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz",
"integrity": "sha512-cg/1jAZoL57R39+wiw4u/SCC6Ic9Q5NqjBOb+9xISedOYurfog9ZNmKJSxAnb2m/5Bq4lE9lhUcau33Ml8DM0g==",
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
"integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==",
"dev": true,
"requires": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"minimist": "^1.2.0",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
},
"dependencies": {
+1 -1
View File
@@ -86,7 +86,7 @@
"http": "0.0.1-security",
"http-proxy-middleware": "1.0.5",
"https": "1.0.0",
"iconoir-react": "2.1.0",
"iconoir-react": "4.7.1",
"immutable": "4.0.0-rc.12",
"intersection-observer": "0.11.0",
"jsonschema": "1.2.7",
+25 -15
View File
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
import loadable from '@loadable/component'
import {
ReportColumns as DashboardIcon,
Settings as SettingsIcon,
Activity as WebMKSIcon,
} from 'iconoir-react'
import loadable from '@loadable/component'
const Dashboard = loadable(
() => import('client/containers/Dashboard/Sunstone'),
{ ssr: false }
@@ -97,25 +96,36 @@ export const getEndpointsByView = (views, endpoints = []) => {
* @param {string} [route.path] - Pathname route
* @returns {boolean | object} If user view yaml contains the route, return it
*/
const hasRoutePermission = (route) =>
views?.some(({ resource_name: name = '', actions: bulkActions = [] }) => {
// eg: '/vm-template/instantiate' => ['vm-template', 'instantiate']
const paths = route?.path
?.toLowerCase?.()
?.split?.('/')
?.filter?.(Boolean)
const hasRoutePermission = (route) => {
// Eg: '/vm-template/instantiate' => ['vm-template', 'instantiate']
const splittedPath = String(route?.path)
?.toLowerCase()
?.split('/')
?.filter(Boolean)
const [resource, dialogName] = paths
const [resource, ...restOfParams] = splittedPath ?? []
const hasParams = !!restOfParams.length
return dialogName && !dialogName.includes(':') // filter params. eg: '/vm/:id'
? bulkActions[`${dialogName}_dialog`]
: resource === name.toLowerCase()
}) && route
const view = views?.find((v) => resource === v.resource_name?.toLowerCase())
// view file not exists or not match the `resource_name`
if (!view) return false
return (
// match exactly. Eg: /vm
!hasParams ||
// allow routes with params. Eg: /vm/:id
restOfParams.some((p) => p.includes(':')) ||
// first param is dialog name. Eg: /vm/create or /vm-template/instantiate
// allow action if exists on bulk actions list
view?.actions[`${restOfParams[0]}_dialog`]
)
}
return endpoints
.map(({ routes: subRoutes, ...restOfProps }) => {
if (Array.isArray(subRoutes)) {
const routes = subRoutes.map(hasRoutePermission).filter(Boolean)
const routes = subRoutes.filter(hasRoutePermission)
return !!routes.length && { ...restOfProps, routes }
}
@@ -201,7 +201,6 @@ export const PATH = {
const ENDPOINTS = [
{
label: 'Instances',
sidebar: true,
icon: InstancesIcons,
routes: [
{
@@ -227,7 +226,6 @@ const ENDPOINTS = [
},
{
label: 'Templates',
sidebar: true,
icon: TemplatesIcon,
routes: [
{
@@ -251,7 +249,6 @@ const ENDPOINTS = [
},
{
label: 'Storage',
sidebar: true,
icon: StorageIcon,
routes: [
{
@@ -291,7 +288,6 @@ const ENDPOINTS = [
},
{
label: 'Networks',
sidebar: true,
icon: NetworksIcon,
routes: [
{
@@ -312,7 +308,6 @@ const ENDPOINTS = [
},
{
label: 'Infrastructure',
sidebar: true,
icon: InfrastructureIcon,
routes: [
{
@@ -350,7 +345,6 @@ const ENDPOINTS = [
},
{
label: 'System',
sidebar: true,
icon: SystemIcon,
routes: [
{
@@ -28,7 +28,11 @@ const ErrorTypo = styled(Typography)(({ theme }) => ({
}))
const ErrorHelper = memo(({ label, ...rest }) => {
const translateProps = label?.word ? { ...label } : { word: label }
const ensuredLabel = Array.isArray(label) ? label[0] : label
const translateProps = ensuredLabel?.word
? { ...ensuredLabel }
: { word: ensuredLabel }
return (
<Stack
@@ -16,16 +16,10 @@
import { memo } from 'react'
import PropTypes from 'prop-types'
import {
Typography,
TextField,
Slider,
FormHelperText,
Grid,
} from '@mui/material'
import { TextField, Slider, FormHelperText, Stack } from '@mui/material'
import { useController } from 'react-hook-form'
import { ErrorHelper } from 'client/components/FormControl'
import { ErrorHelper, Tooltip } from 'client/components/FormControl'
import { Tr, labelCanBeTranslated } from 'client/components/HOC'
import { generateKey } from 'client/utils'
@@ -35,6 +29,7 @@ const SliderController = memo(
cy = `slider-${generateKey()}`,
name = '',
label = '',
tooltip,
fieldProps = {},
}) => {
const {
@@ -47,41 +42,45 @@ const SliderController = memo(
return (
<>
<Typography id={sliderId} gutterBottom>
{labelCanBeTranslated(label) ? Tr(label) : label}
</Typography>
<Grid container spacing={2} alignItems="center">
<Grid item xs>
<Slider
color="secondary"
value={typeof value === 'number' ? value : 0}
aria-labelledby={sliderId}
valueLabelDisplay="auto"
data-cy={sliderId}
onChange={(_, val) => onChange(val)}
{...fieldProps}
/>
</Grid>
<Grid item>
<TextField
{...inputProps}
fullWidth
value={value}
error={Boolean(error)}
type="number"
inputProps={{
'data-cy': inputId,
'aria-labelledby': sliderId,
...fieldProps,
}}
onChange={(evt) =>
onChange(
evt.target.value === '' ? '0' : Number(evt.target.value)
)
<Stack direction="row" mt="0.5rem" spacing={2} alignItems="center">
<Slider
color="secondary"
value={typeof value === 'number' ? value : 0}
aria-labelledby={sliderId}
valueLabelDisplay="auto"
data-cy={sliderId}
onChange={(_, val) => onChange(val)}
{...fieldProps}
/>
<TextField
{...inputProps}
fullWidth
value={value}
type="number"
error={Boolean(error)}
label={labelCanBeTranslated(label) ? Tr(label) : label}
InputProps={{
endAdornment: tooltip && <Tooltip title={tooltip} />,
}}
inputProps={{
'data-cy': inputId,
'aria-labelledby': sliderId,
...fieldProps,
}}
onChange={(evt) =>
onChange(!evt.target.value ? '0' : Number(evt.target.value))
}
onBlur={() => {
const { min, max } = fieldProps ?? {}
if (min && value < min) {
onChange(min)
} else if (max && value > max) {
onChange(max)
}
/>
</Grid>
</Grid>
}}
/>
</Stack>
{Boolean(error) && (
<FormHelperText data-cy={`${cy}-error`}>
<ErrorHelper label={error?.message} />
@@ -98,8 +97,6 @@ SliderController.propTypes = {
name: PropTypes.string.isRequired,
label: PropTypes.any,
tooltip: PropTypes.any,
multiple: PropTypes.bool,
values: PropTypes.arrayOf(PropTypes.object).isRequired,
fieldProps: PropTypes.object,
}
@@ -23,7 +23,7 @@ import {
NavArrowRight as NextIcon,
} from 'iconoir-react'
import { Tr, Translate, labelCanBeTranslated } from 'client/components/HOC'
import { Translate, labelCanBeTranslated } from 'client/components/HOC'
import { T } from 'client/constants'
const useStyles = makeStyles((theme) => ({
@@ -64,9 +64,7 @@ const CustomMobileStepper = ({
</Typography>
{Boolean(errors[id]) && (
<Typography className={classes.error} variant="caption" color="error">
{labelCanBeTranslated(label)
? Tr(errors[id]?.message)
: errors[id]?.message}
<Translate word={errors[id]?.message} />
</Typography>
)}
</Box>
@@ -28,7 +28,7 @@ import StepConnector, {
import { styled } from '@mui/styles'
import { SubmitButton } from 'client/components/FormControl'
import { Tr, Translate, labelCanBeTranslated } from 'client/components/HOC'
import { Translate } from 'client/components/HOC'
import { T, SCHEMES } from 'client/constants'
const StepperStyled = styled(Stepper)(({ theme }) => ({
@@ -101,9 +101,7 @@ const CustomStepper = ({
optional={
errors[id] && (
<Typography variant="caption" color="error">
{labelCanBeTranslated(errors[id]?.message)
? Tr(errors[id]?.message)
: errors[id]?.message}
<Translate word={errors[id]?.message} />
</Typography>
)
}
@@ -112,7 +110,7 @@ const CustomStepper = ({
StepIconComponent={StepIconStyled}
error={Boolean(errors[id]?.message)}
>
{labelCanBeTranslated(label) ? Tr(label) : label}
<Translate word={label} />
</StepLabel>
</StepButton>
</Step>
@@ -31,21 +31,19 @@ export const FORM_FIELDS = (inputs) =>
min_value: min,
max_value: max,
options,
}) => {
const optionsValue = options ?? `${min}..${max}`
return {
}) => ({
name,
label: `${description ?? name} *`,
...schemaUserInput({
mandatory: true,
name,
label: `${description ?? name} *`,
...schemaUserInput({
mandatory: true,
name,
type,
options: optionsValue,
default: defaultValue,
}),
}
}
type,
min,
max,
options,
default: defaultValue,
}),
})
)
/**
@@ -64,7 +64,7 @@ const SECTIONS = (hypervisor) => [
]
/** @type {Field} Boot order field */
const BOOT_ORDER = {
const BOOT_ORDER_FIELD = {
name: 'OS.BOOT',
validation: string()
.trim()
@@ -77,7 +77,7 @@ const BOOT_ORDER = {
* @returns {Field[]} All 'OS & CPU' fields
*/
const FIELDS = (hypervisor) => [
BOOT_ORDER,
BOOT_ORDER_FIELD,
...SECTIONS(hypervisor)
.map(({ fields }) => fields)
.flat(),
@@ -89,4 +89,4 @@ const FIELDS = (hypervisor) => [
*/
const SCHEMA = (hypervisor) => getObjectSchemaFromFields(FIELDS(hypervisor))
export { SECTIONS, FIELDS, SCHEMA }
export { SECTIONS, FIELDS, BOOT_ORDER_FIELD, SCHEMA }
@@ -217,6 +217,6 @@ export const USER_INPUTS_SCHEMA = object({
.afterSubmit((_, { context }) => {
const userInputs = context?.extra?.USER_INPUTS
return userInputs?.map(({ name }) => name).join(',')
return userInputs?.map(({ name }) => String(name).toUpperCase()).join(',')
}),
})
@@ -18,7 +18,7 @@ import { array, object, ObjectSchema } from 'yup'
import { HYPERVISORS } from 'client/constants'
import { getObjectSchemaFromFields } from 'client/utils'
import { FIELDS as PLACEMENT_FIELDS } from './placement/schema'
import { FIELDS as OS_FIELDS } from './booting/schema'
import { FIELDS as OS_FIELDS, BOOT_ORDER_FIELD } from './booting/schema'
import { FIELDS as NUMA_FIELDS } from './numa/schema'
import { SCHEMA as IO_SCHEMA } from './inputOutput/schema'
import { SCHEMA as CONTEXT_SCHEMA } from './context/schema'
@@ -31,7 +31,7 @@ import { SCHEMA as NETWORK_SCHEMA } from './networking/schema'
* @param {string} prefixName - Prefix to add in name
* @returns {object[]} Resource object
*/
export const mapNameByIndex = (prefixName) => (resource, idx) => ({
const mapNameByIndex = (prefixName) => (resource, idx) => ({
...resource,
NAME:
resource?.NAME?.startsWith(prefixName) || !resource?.NAME
@@ -39,7 +39,7 @@ export const mapNameByIndex = (prefixName) => (resource, idx) => ({
: resource?.NAME,
})
export const SCHED_ACTION_SCHEMA = object({
const SCHED_ACTION_SCHEMA = object({
SCHED_ACTION: array()
.ensure()
.transform((actions) => actions.map(mapNameByIndex('SCHED_ACTION'))),
@@ -63,3 +63,16 @@ export const SCHEMA = (hypervisor) =>
...NUMA_FIELDS(hypervisor),
])
)
export {
mapNameByIndex,
SCHED_ACTION_SCHEMA,
STORAGE_SCHEMA,
NETWORK_SCHEMA,
IO_SCHEMA,
CONTEXT_SCHEMA,
PLACEMENT_FIELDS,
OS_FIELDS,
BOOT_ORDER_FIELD,
NUMA_FIELDS,
}
@@ -27,10 +27,10 @@ import { createSteps, isBase64 } from 'client/utils'
const Steps = createSteps([General, ExtraConfiguration, CustomVariables], {
transformInitialValue: (vmTemplate, schema) => {
const inputsOrder = vmTemplate?.TEMPLATE?.INPUTS_ORDER?.split(',') ?? []
const userInputs = userInputsToArray(
vmTemplate?.TEMPLATE?.USER_INPUTS
).sort((a, b) => inputsOrder.indexOf(a.name) - inputsOrder.indexOf(b.name))
vmTemplate?.TEMPLATE?.USER_INPUTS,
vmTemplate?.TEMPLATE?.INPUTS_ORDER
)
const knownTemplate = schema.cast(
{
@@ -13,31 +13,27 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
import { useMemo } from 'react'
import { useFormContext } from 'react-hook-form'
import PropTypes from 'prop-types'
import { useViews } from 'client/features/Auth'
import FormWithSchema from 'client/components/Forms/FormWithSchema'
import useStyles from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/styles'
import { STEP_ID as TEMPLATE_ID } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/VmTemplatesTable'
import {
SCHEMA,
FIELDS,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/schema'
import { getActionsAvailable as getSectionsAvailable } from 'client/models/Helper'
import { T, RESOURCE_NAMES } from 'client/constants'
import { T, RESOURCE_NAMES, VmTemplate } from 'client/constants'
export const STEP_ID = 'configuration'
const Content = () => {
const Content = ({ hypervisor }) => {
const classes = useStyles()
const { view, getResourceView } = useViews()
const { watch } = useFormContext()
const sections = useMemo(() => {
const hypervisor = watch(`${TEMPLATE_ID}[0].TEMPLATE.HYPERVISOR`)
const resource = RESOURCE_NAMES.VM_TEMPLATE
const dialog = getResourceView(resource)?.dialogs?.instantiate_dialog
const sectionsAvailable = getSectionsAvailable(dialog, hypervisor)
@@ -61,21 +57,26 @@ const Content = () => {
)
}
const BasicConfiguration = (initialValues) => {
const initialHypervisor = initialValues?.TEMPLATE?.HYPERVISOR
/**
* Basic configuration about VM Template.
*
* @param {VmTemplate} vmTemplate - VM Template
* @returns {object} Basic configuration step
*/
const BasicConfiguration = (vmTemplate) => {
const hypervisor = vmTemplate?.TEMPLATE?.HYPERVISOR
return {
id: STEP_ID,
label: T.Configuration,
resolver: (formData) => {
const hypervisor =
formData?.[TEMPLATE_ID]?.[0]?.TEMPLATE?.HYPERVISOR ?? initialHypervisor
return SCHEMA(hypervisor)
},
resolver: () => SCHEMA(hypervisor),
optionsValidate: { abortEarly: false },
content: Content,
content: (props) => Content({ ...props, hypervisor }),
}
}
Content.propTypes = {
hypervisor: PropTypes.string,
}
export default BasicConfiguration
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
import { useMemo } from 'react'
import PropTypes from 'prop-types'
import { useFormContext } from 'react-hook-form'
@@ -30,10 +29,9 @@ import Placement from 'client/components/Forms/VmTemplate/CreateForm/Steps/Extra
import Scheduling from 'client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/scheduleAction'
import BootOrder from 'client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/booting/bootOrder'
import { STEP_ID as TEMPLATE_ID } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/VmTemplatesTable'
import { SCHEMA } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/ExtraConfiguration/schema'
import { getActionsAvailable as getSectionsAvailable } from 'client/models/Helper'
import { T, RESOURCE_NAMES } from 'client/constants'
import { T, RESOURCE_NAMES, VmTemplate } from 'client/constants'
export const STEP_ID = 'extra'
@@ -52,16 +50,13 @@ export const TABS = [
},
]
const Content = ({ data, setFormData }) => {
const Content = ({ data, setFormData, hypervisor }) => {
const {
watch,
formState: { errors },
control,
} = useFormContext()
const { view, getResourceView } = useViews()
const hypervisor = useMemo(() => watch(`${TEMPLATE_ID}.0.HYPERVISOR`), [])
const sectionsAvailable = useMemo(() => {
const resource = RESOURCE_NAMES.VM_TEMPLATE
const dialog = getResourceView(resource)?.dialogs?.instantiate_dialog
@@ -78,7 +73,6 @@ const Content = ({ data, setFormData }) => {
...section,
name,
label: <Translate word={name} />,
// eslint-disable-next-line react/display-name
renderContent: () => (
<TabContent {...{ data, setFormData, hypervisor, control }} />
),
@@ -91,26 +85,28 @@ const Content = ({ data, setFormData }) => {
return <Tabs tabs={tabs} />
}
const ExtraConfiguration = (initialValues) => {
const initialHypervisor = initialValues?.TEMPLATE?.HYPERVISOR
/**
* Optional configuration about VM Template.
*
* @param {VmTemplate} vmTemplate - VM Template
* @returns {object} Optional configuration step
*/
const ExtraConfiguration = (vmTemplate) => {
const hypervisor = vmTemplate?.TEMPLATE?.HYPERVISOR
return {
id: STEP_ID,
label: T.AdvancedOptions,
resolver: (formData) => {
const hypervisor =
formData?.[TEMPLATE_ID]?.[0]?.TEMPLATE?.HYPERVISOR ?? initialHypervisor
return SCHEMA(hypervisor)
},
resolver: SCHEMA,
optionsValidate: { abortEarly: false },
content: Content,
content: (props) => Content({ ...props, hypervisor }),
}
}
Content.propTypes = {
data: PropTypes.any,
setFormData: PropTypes.func,
hypervisor: PropTypes.string,
}
export default ExtraConfiguration
@@ -13,16 +13,25 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
import { ObjectSchema } from 'yup'
import { ObjectSchema, object } from 'yup'
// get schemas from VmTemplate/CreateForm
import { SCHEMA as CREATE_EXTRA_SCHEMA } from 'client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/schema'
import { HYPERVISORS } from 'client/constants'
import {
SCHED_ACTION_SCHEMA,
STORAGE_SCHEMA,
NETWORK_SCHEMA,
PLACEMENT_FIELDS,
BOOT_ORDER_FIELD,
} from 'client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/schema'
import { getObjectSchemaFromFields } from 'client/utils'
import { UserInputObject } from 'client/constants'
/**
* @param {HYPERVISORS} hypervisor - VM hypervisor
* @param {UserInputObject[]} userInputs - User inputs
* @returns {ObjectSchema} Extra configuration schema
*/
export const SCHEMA = (hypervisor) =>
CREATE_EXTRA_SCHEMA(hypervisor).noUnknown(false)
export const SCHEMA = object()
.concat(SCHED_ACTION_SCHEMA)
.concat(NETWORK_SCHEMA)
.concat(STORAGE_SCHEMA)
.concat(getObjectSchemaFromFields([...PLACEMENT_FIELDS, BOOT_ORDER_FIELD]))
@@ -0,0 +1,65 @@
/* ------------------------------------------------------------------------- *
* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain *
* a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
import { useMemo } from 'react'
import PropTypes from 'prop-types'
import {
FIELDS,
SCHEMA,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/UserInputs/schema'
import { userInputsToArray } from 'client/models/Helper'
import { T, VmTemplate } from 'client/constants'
import { FormWithSchema } from 'client/components/Forms'
export const STEP_ID = 'user_inputs'
const Content = ({ userInputs }) => (
<FormWithSchema
cy="user-inputs"
id={STEP_ID}
fields={useMemo(() => FIELDS(userInputs), [])}
/>
)
Content.propTypes = {
data: PropTypes.any,
userInputs: PropTypes.object,
}
/**
* User inputs step.
*
* @param {VmTemplate} vmTemplate - VM Template
* @returns {object} User inputs step
*/
const UserInputsStep = (vmTemplate) => {
const userInputs = userInputsToArray(
vmTemplate?.TEMPLATE?.USER_INPUTS,
vmTemplate?.TEMPLATE?.INPUTS_ORDER
)
console.log({ userInputs, order: vmTemplate?.TEMPLATE?.INPUTS_ORDER })
return {
id: STEP_ID,
label: T.UserInputs,
optionsValidate: { abortEarly: false },
resolver: () => SCHEMA(userInputs),
content: (props) => Content({ ...props, userInputs }),
}
}
export default UserInputsStep
@@ -13,21 +13,28 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
import { array, object, string } from 'yup'
import { ObjectSchema } from 'yup'
const TEMPLATE_SCHEMA = object({
ID: string(),
NAME: string(),
TEMPLATE: object({
DISK: array().ensure(),
NIC: array().ensure(),
SCHED_ACTION: array().ensure(),
HYPERVISOR: string(),
}),
})
import { getObjectSchemaFromFields, schemaUserInput } from 'client/utils'
import { Field, UserInputObject } from 'client/constants'
export const SCHEMA = array(TEMPLATE_SCHEMA)
.min(1, 'Select VM Template')
.max(1, 'Max. one template selected')
.required('Template field is required')
.default(undefined)
/**
* @param {UserInputObject[]} userInputs - User inputs
* @returns {Field[]} User inputs in Field format
*/
const FIELDS = (userInputs = []) =>
userInputs.map(({ name, description, ...restOfUserInput }) => ({
name,
label: name,
...(description && { tooltip: description }),
...schemaUserInput(restOfUserInput),
}))
/**
* @param {UserInputObject[]} userInputs - User inputs
* @returns {ObjectSchema} User inputs schema
*/
const SCHEMA = (userInputs = []) =>
getObjectSchemaFromFields(FIELDS(userInputs))
export { FIELDS, SCHEMA }
@@ -1,98 +0,0 @@
/* ------------------------------------------------------------------------- *
* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain *
* a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
import PropTypes from 'prop-types'
import makeStyles from '@mui/styles/makeStyles'
import { useListForm } from 'client/hooks'
import { useLazyGetTemplateQuery } from 'client/features/OneApi/vmTemplate'
import { VmTemplatesTable } from 'client/components/Tables'
import { SCHEMA } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/VmTemplatesTable/schema'
import { STEP_ID as CONFIGURATION_ID } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration'
import { SCHEMA as CONFIGURATION_SCHEMA } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/schema'
import { STEP_ID as EXTRA_ID } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/ExtraConfiguration'
import { SCHEMA as EXTRA_SCHEMA } from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/ExtraConfiguration/schema'
import { T } from 'client/constants'
export const STEP_ID = 'template'
const useStyles = makeStyles({
body: {
gridTemplateColumns: 'repeat(auto-fill, minmax(400px, 1fr))',
},
})
const Content = ({ data, setFormData }) => {
const classes = useStyles()
const selectedTemplate = data?.[0]
const [getVmTemplate] = useLazyGetTemplateQuery()
const { handleSelect, handleClear } = useListForm({
key: STEP_ID,
setList: setFormData,
})
const handleSelectedRows = async (rows) => {
const { original: templateSelected } = rows?.[0] ?? {}
const { ID: id } = templateSelected ?? {}
if (!id) return handleClear()
const extendedTemplate = id
? await getVmTemplate({ id, extended: true }).unwrap()
: {}
setFormData((prev) => ({
...prev,
// needs hypervisor to strip unknown attributes
[CONFIGURATION_ID]: CONFIGURATION_SCHEMA?.({
[STEP_ID]: [extendedTemplate],
}).cast(extendedTemplate?.TEMPLATE, { stripUnknown: true }),
[EXTRA_ID]: EXTRA_SCHEMA(extendedTemplate?.TEMPLATE?.HYPERVISOR).cast(
extendedTemplate?.TEMPLATE,
{ stripUnknown: true }
),
}))
handleSelect(extendedTemplate)
}
return (
<VmTemplatesTable
singleSelect
onlyGlobalSearch
onlyGlobalSelectedRows
classes={classes}
initialState={{ selectedRowIds: { [selectedTemplate?.ID]: true } }}
onSelectedRowsChange={handleSelectedRows}
/>
)
}
Content.propTypes = {
data: PropTypes.any,
setFormData: PropTypes.func,
}
const VmTemplateStep = () => ({
id: STEP_ID,
label: T.SelectVmTemplate,
resolver: SCHEMA,
content: Content,
})
export default VmTemplateStep
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
import VmTemplatesTable, {
STEP_ID as TEMPLATE_ID,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/VmTemplatesTable'
import BasicConfiguration, {
STEP_ID as BASIC_ID,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration'
import UserInputs, {
STEP_ID as USER_INPUTS_ID,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/UserInputs'
import ExtraConfiguration, {
STEP_ID as EXTRA_ID,
} from 'client/components/Forms/VmTemplate/InstantiateForm/Steps/ExtraConfiguration'
@@ -28,39 +28,36 @@ import { createSteps } from 'client/utils'
const Steps = createSteps(
(vmTemplate) =>
[
!vmTemplate?.ID && VmTemplatesTable,
BasicConfiguration,
vmTemplate?.TEMPLATE?.USER_INPUTS && UserInputs,
ExtraConfiguration,
].filter(Boolean),
{
transformInitialValue: (vmTemplate, schema) => ({
...schema.cast(
transformInitialValue: (vmTemplate, schema) => {
const initialValue = schema.cast(
{
[TEMPLATE_ID]: [vmTemplate],
[BASIC_ID]: vmTemplate?.TEMPLATE,
[EXTRA_ID]: vmTemplate?.TEMPLATE,
},
{ stripUnknown: true }
),
}),
)
return initialValue
},
transformBeforeSubmit: (formData, vmTemplate) => {
const {
[TEMPLATE_ID]: [templateSelected] = [],
[BASIC_ID]: { name, instances, hold, persistent, ...restOfConfig } = {},
[EXTRA_ID]: {
TOPOLOGY: { ENABLE_NUMA, ...restOfTopology },
...extraTemplate
} = {},
[USER_INPUTS_ID]: userInputs,
[EXTRA_ID]: extraTemplate = {},
} = formData ?? {}
const topology = ENABLE_NUMA ? { TOPOLOGY: restOfTopology } : {}
// merge with template disks to get TYPE attribute
const templateXML = jsonToXml({
...userInputs,
...extraTemplate,
...topology,
...restOfConfig,
})
const data = { instances, hold, persistent, template: templateXML }
const templates = [...new Array(instances)].map((_, idx) => ({
@@ -68,7 +65,7 @@ const Steps = createSteps(
...data,
}))
return [templateSelected ?? vmTemplate, templates]
return [vmTemplate, templates]
},
}
)
@@ -56,7 +56,10 @@ const Sidebar = ({ endpoints }) => {
const SidebarEndpoints = useMemo(
() =>
endpoints
?.filter(({ sidebar = false }) => sidebar)
?.filter(
({ sidebar = false, routes = [] }) =>
sidebar || routes.some((subRoute) => subRoute?.sidebar)
)
?.sort(({ position: posA = 1 }, { position: posB = 1 }) => posB - posA)
?.map((endpoint, index) =>
endpoint.routes ? (
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
import { ReactElement } from 'react'
import PropTypes from 'prop-types'
import { Accordion, AccordionDetails } from '@mui/material'
import { Box, Accordion, AccordionDetails } from '@mui/material'
import { useGetTemplateQuery } from 'client/features/OneApi/vmTemplate'
@@ -27,17 +27,19 @@ import { useGetTemplateQuery } from 'client/features/OneApi/vmTemplate'
* @returns {ReactElement} Template tab
*/
const TemplateTab = ({ id }) => {
const { data: template = {} } = useGetTemplateQuery({ id })
const { TEMPLATE } = template
const { data: vmTemplate = {} } = useGetTemplateQuery({ id })
return (
<Accordion expanded TransitionProps={{ unmountOnExit: true }}>
<AccordionDetails>
<pre>
<code style={{ whiteSpace: 'break-spaces' }}>
{JSON.stringify(TEMPLATE, null, 2)}
</code>
</pre>
<Box component="pre">
<Box
component="code"
sx={{ whiteSpace: 'break-spaces', wordBreak: 'break-all' }}
>
{JSON.stringify(vmTemplate?.TEMPLATE ?? {}, null, 2)}
</Box>
</Box>
</AccordionDetails>
</Accordion>
)
+35 -5
View File
@@ -352,13 +352,43 @@ export const getUserInputString = (userInput) => {
* Get list of user inputs defined in OpenNebula template.
*
* @param {object} userInputs - List of user inputs in string format
* @param {string} [inputsOrder] - List separated by comma of input names
* @example
* const userInputs = {
* "INPUT-1": "O|text|Description1| |text1",
* "INPUT-2": "M|text|Description2| |text2"
* }
*
* const inputsOrder = "INPUT-2,INPUT-1"
*
* => userInputsToArray(userInputs, inputsOrder) => [{
* name: 'INPUT-1',
* mandatory: false,
* type: 'text',
* description: 'Description1',
* default: 'text1',
* },
* {
* name: 'INPUT-2',
* mandatory: true,
* type: 'text',
* description: 'Description2',
* default: 'text2',
* }]
* @returns {UserInputObject[]} User input object
*/
export const userInputsToArray = (userInputs = {}) =>
Object.entries(userInputs).map(([name, ui]) => ({
name,
...getUserInputParams(ui),
}))
export const userInputsToArray = (userInputs = {}, inputsOrder) => {
const orderedList = inputsOrder?.split(',') ?? []
return Object.entries(userInputs)
.map(([name, ui]) => ({ name, ...getUserInputParams(ui) }))
.sort((a, b) => {
const upperAName = a.name?.toUpperCase?.()
const upperBName = b.name?.toUpperCase?.()
return orderedList.indexOf(upperAName) - orderedList.indexOf(upperBName)
})
}
/**
* Get list of user inputs in format valid to forms.
+21 -11
View File
@@ -41,6 +41,7 @@ import {
INPUT_TYPES,
USER_INPUT_TYPES,
} from 'client/constants'
import { stringToBoolean } from 'client/models/Helper'
// ----------------------------------------------------------
// Types
@@ -202,8 +203,7 @@ const SEMICOLON_CHAR = ';'
const requiredSchema = (mandatory, schema) =>
mandatory ? schema.required() : schema.notRequired().nullable()
const getRange = (options) =>
options?.split('..').map((option) => parseFloat(option))
const getRange = (options) => options?.split?.('..').map(parseFloat)
const getValuesFromArray = (options, separator = SEMICOLON_CHAR) =>
options?.split(separator)
@@ -241,6 +241,8 @@ const parseUserInputValue = (value) => {
export const schemaUserInput = ({
mandatory,
type,
min,
max,
options,
default: defaultValue,
}) => {
@@ -250,35 +252,43 @@ export const schemaUserInput = ({
case USER_INPUT_TYPES.password:
return {
type: INPUT_TYPES.TEXT,
htmlType: type === 'password' ? 'password' : 'text',
htmlType: type === USER_INPUT_TYPES.password ? 'password' : 'text',
validation: string()
.trim()
.concat(requiredSchema(mandatory, string()))
.default(defaultValue || undefined),
}
case USER_INPUT_TYPES.number:
case USER_INPUT_TYPES.numberFloat:
case USER_INPUT_TYPES.numberFloat: {
const ensuredValue = parseFloat(defaultValue)
return {
type: INPUT_TYPES.TEXT,
htmlType: 'number',
validation: number()
.concat(requiredSchema(mandatory, number()))
.transform((value) => (!isNaN(value) ? value : null))
.default(() => parseFloat(defaultValue) ?? undefined),
.default(isNaN(ensuredValue) ? undefined : ensuredValue),
}
}
case USER_INPUT_TYPES.range:
case USER_INPUT_TYPES.rangeFloat: {
const [min, max] = getRange(options)
const [minimum, maximum] = getRange(options) ?? [min, max].map(parseFloat)
const ensuredValue = parseFloat(defaultValue)
return {
type: INPUT_TYPES.SLIDER,
validation: number()
.concat(requiredSchema(mandatory, number()))
.min(min)
.max(max)
.min(minimum)
.max(maximum)
.transform((value) => (!isNaN(value) ? value : undefined))
.default(parseFloat(defaultValue) ?? undefined),
fieldProps: { min, max, step: type === 'range-float' ? 0.01 : 1 },
.default(isNaN(ensuredValue) ? undefined : ensuredValue),
fieldProps: {
min: minimum,
max: maximum,
step: type === USER_INPUT_TYPES.rangeFloat ? 0.1 : 1,
},
}
}
case USER_INPUT_TYPES.boolean:
@@ -286,7 +296,7 @@ export const schemaUserInput = ({
type: INPUT_TYPES.CHECKBOX,
validation: boolean()
.concat(requiredSchema(mandatory, boolean()))
.default(defaultValue === 'YES' ?? false)
.default(() => stringToBoolean(defaultValue))
.yesOrNo(),
}
case USER_INPUT_TYPES.list: {