diff --git a/CHANGELOG.md b/CHANGELOG.md index 340e11e..d5f0441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.19.0 +- Замена компонента App на компонент AdminBase из библиотеки +- Удален весь код, дублирующий компонент AdminBase ## 0.18.9 - Исправлены дополнительные параметры подключения в форме ## 0.18.8 diff --git a/package-lock.json b/package-lock.json index 770e47e..339c2ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,27 +1,19 @@ { "name": "isp-admin-ui", - "version": "0.18.8", + "version": "0.19.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "isp-admin-ui", - "version": "0.18.8", + "version": "0.19.0", "dependencies": { - "@apidevtools/json-schema-ref-parser": "^9.0.6", "@monaco-editor/react": "^4.6.0", "@reduxjs/toolkit": "^2.2.3", - "@rjsf/antd": "^5.21.2", - "@rjsf/core": "^5.21.2", - "@rjsf/validator-ajv8": "^5.21.2", "axios": "^1.7.7", - "clipboard": "^2.0.11", - "compare-versions": "^6.1.0", "dayjs": "^1.11.10", - "deep-equal": "^2.2.3", - "isp-ui-kit": "^0.10.1", - "json-schema-view-js": "^2.0.1", - "lodash.clonedeep": "^4.5.0", + "isp-admin-ui-kit": "^0.3.1", + "isp-ui-kit": "^0.12.3", "monaco-editor": "^0.52.0", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -3410,7 +3402,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -4034,14 +4025,6 @@ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz", "integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==" }, - "node_modules/@types/lodash-es": { - "version": "4.17.12", - "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", - "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", - "dependencies": { - "@types/lodash": "*" - } - }, "node_modules/@types/lodash.clonedeep": { "version": "4.5.9", "resolved": "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz", @@ -4726,12 +4709,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", - "license": "MIT" - }, "node_modules/asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", @@ -5672,15 +5649,6 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, - "node_modules/cross-fetch": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", - "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", - "license": "MIT", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -6943,36 +6911,6 @@ "reusify": "^1.0.4" } }, - "node_modules/fbemitter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fbemitter/-/fbemitter-3.0.0.tgz", - "integrity": "sha512-KWKaceCwKQU0+HPoop6gn4eOHk50bBv/VxjJtGMfwmJt3D29JpN4H4eisCtIPA+a8GVBam+ldMMpMjJUvpDyHw==", - "license": "BSD-3-Clause", - "dependencies": { - "fbjs": "^3.0.0" - } - }, - "node_modules/fbjs": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-3.0.5.tgz", - "integrity": "sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg==", - "license": "MIT", - "dependencies": { - "cross-fetch": "^3.1.5", - "fbjs-css-vars": "^1.0.0", - "loose-envify": "^1.0.0", - "object-assign": "^4.1.0", - "promise": "^7.1.1", - "setimmediate": "^1.0.5", - "ua-parser-js": "^1.0.35" - } - }, - "node_modules/fbjs-css-vars": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz", - "integrity": "sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ==", - "license": "MIT" - }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -7033,19 +6971,6 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, - "node_modules/flux": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/flux/-/flux-4.0.4.tgz", - "integrity": "sha512-NCj3XlayA2UsapRpM7va6wU1+9rE5FIL7qoMcmxWHRzbp0yujihMBm9BBHZ1MDIk5h5o2Bl6eGiCe8rYELAmYw==", - "license": "BSD-3-Clause", - "dependencies": { - "fbemitter": "^3.0.0", - "fbjs": "^3.0.1" - }, - "peerDependencies": { - "react": "^15.0.2 || ^16.0.0 || ^17.0.0" - } - }, "node_modules/follow-redirects": { "version": "1.15.6", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", @@ -8051,38 +7976,73 @@ "node": ">=10" } }, - "node_modules/isp-ui-kit": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.10.1.tgz", - "integrity": "sha512-WcDUtS9Gw0mRvLWjytuVT9EY7wZjTSOXKfP2krv4MgeG5Q9eTS36RJ9d2slqS86m5H4PHohMmAJNuomw+sf8Rw==", - "license": "MIT", + "node_modules/isp-admin-ui-kit": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/isp-admin-ui-kit/-/isp-admin-ui-kit-0.3.1.tgz", + "integrity": "sha512-Hm855/ivVV6KGgrNb2pqrKrA7FnG7bkf2vuOwNIBjZ9+qa5pzQMucQmQUZzV6OcuVM0TMvgr1AIwzaiXzebvnw==", "dependencies": { - "flux": "^4.0.4", - "react-base16-styling": "^0.10.0", - "react-lifecycles-compat": "^3.0.4", + "@apidevtools/json-schema-ref-parser": "^9.0.6", + "@rjsf/antd": "^5.21.2", + "@rjsf/core": "^5.21.2", + "@rjsf/validator-ajv8": "^5.21.2", + "clipboard": "^2.0.11", + "compare-versions": "^6.1.0", + "deep-equal": "^2.2.3", + "json-schema-view-js": "^2.0.1", + "lodash.clonedeep": "^4.5.0", "react-resizable": "^3.0.5", - "react-textarea-autosize": "^6.1.0", + "simplebar": "^6.2.5", "simplebar-react": "^3.2.4" }, + "optionalDependencies": { + "@rollup/rollup-linux-x64-gnu": "^4.32.1" + }, "peerDependencies": { "@monaco-editor/react": "^4.6.0", "antd": "^5.12.2", + "axios": "^1.7.7", + "dayjs": "^1.11.10", + "isp-ui-kit": "^0.12.3", "monaco-editor": "^0.52.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-hook-form": "^7.49.1" + "react": ">=18.2.0", + "react-dom": ">=18.2.0", + "react-hook-form": "^7.54.0", + "react-router-dom": "^6.22.3" } }, - "node_modules/isp-ui-kit/node_modules/react-textarea-autosize": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-6.1.0.tgz", - "integrity": "sha512-F6bI1dgib6fSvG8so1HuArPUv+iVEfPliuLWusLF+gAKz0FbB4jLrWUrTAeq1afnPT2c9toEZYUdz/y1uKMy4A==", - "license": "MIT", + "node_modules/isp-admin-ui-kit/node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.32.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.32.1.tgz", + "integrity": "sha512-WQFLZ9c42ECqEjwg/GHHsouij3pzLXkFdz0UxHa/0OM12LzvX7DzedlY0SIEly2v18YZLRhCRoHZDxbBSWoGYg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/isp-ui-kit": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/isp-ui-kit/-/isp-ui-kit-0.12.3.tgz", + "integrity": "sha512-7WK90Y43VvDNzEen6Ycd4vOEzoKjwVfqUJroPbBfTcv6cd5Z2TBTKqt8s4IGXMKXiX2CFxKGxHVhCIVzalSifQ==", "dependencies": { - "prop-types": "^15.6.0" + "react-base16-styling": "~0.10.0", + "react-lifecycles-compat": "~3.0.4", + "react-resizable": "^3.0.5", + "react-textarea-autosize": "~8.5.7", + "simplebar-react": "^3.3.0" + }, + "optionalDependencies": { + "@rollup/rollup-linux-x64-gnu": "^4.9.5" }, "peerDependencies": { - "react": ">=0.14.0 <17.0.0" + "@monaco-editor/react": "^4.6.0", + "antd": ">=5.12", + "monaco-editor": "^0.52.0", + "react": ">=18", + "react-dom": ">=18", + "react-hook-form": "^7.54.0" } }, "node_modules/iterator.prototype": { @@ -8542,26 +8502,6 @@ "tslib": "^2.0.3" } }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", @@ -9105,15 +9045,6 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, - "node_modules/promise": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", - "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "license": "MIT", - "dependencies": { - "asap": "~2.0.3" - } - }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -9855,18 +9786,18 @@ } }, "node_modules/react-hook-form": { - "version": "7.51.2", - "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.51.2.tgz", - "integrity": "sha512-y++lwaWjtzDt/XNnyGDQy6goHskFualmDlf+jzEZvjvz6KWDf7EboL7pUvRCzPTJd0EOPpdekYaQLEvvG6m6HA==", + "version": "7.54.2", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.54.2.tgz", + "integrity": "sha512-eHpAUgUjWbZocoQYUHposymRb4ZP6d0uwUnooL2uOybA9/3tPUvoAKqEWK1WaSiTxxOfTpffNZP7QwlnM3/gEg==", "engines": { - "node": ">=12.22.0" + "node": ">=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/react-hook-form" }, "peerDependencies": { - "react": "^16.8.0 || ^17 || ^18" + "react": "^16.8.0 || ^17 || ^18 || ^19" } }, "node_modules/react-is": { @@ -9957,6 +9888,22 @@ "react-dom": ">=16.8" } }, + "node_modules/react-textarea-autosize": { + "version": "8.5.7", + "resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.5.7.tgz", + "integrity": "sha512-2MqJ3p0Jh69yt9ktFIaZmORHXw4c4bxSIhCeWiFwmJ9EYKgLmuNII3e9c9b2UO+ijl4StnpZdqpxNIhTdHvqtQ==", + "dependencies": { + "@babel/runtime": "^7.20.13", + "use-composed-ref": "^1.3.0", + "use-latest": "^1.2.1" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -10479,7 +10426,8 @@ "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true }, "node_modules/sha.js": { "version": "2.4.11", @@ -10562,22 +10510,19 @@ } }, "node_modules/simplebar-core": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/simplebar-core/-/simplebar-core-1.2.4.tgz", - "integrity": "sha512-P+Sqshef4fq3++gQ82TgNYcgl3qZFSCP5jS2/8NMmw18oagXOijMzs1G+vm6RUY3oMvpwH3wGoqh9u6SyDjHfQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/simplebar-core/-/simplebar-core-1.3.0.tgz", + "integrity": "sha512-LpWl3w0caz0bl322E68qsrRPpIn+rWBGAaEJ0lUJA7Xpr2sw92AkIhg6VWj988IefLXYh50ILatfAnbNoCFrlA==", "dependencies": { - "@types/lodash-es": "^4.17.6", - "can-use-dom": "^0.1.0", - "lodash": "^4.17.21", - "lodash-es": "^4.17.21" + "lodash": "^4.17.21" } }, "node_modules/simplebar-react": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/simplebar-react/-/simplebar-react-3.2.4.tgz", - "integrity": "sha512-ogLN79e7JUm82wJChD7NSUB+4EHCFvDkjXpiu8hT1Alk7DnCekUWds61NXcsP9jC97KOgF5To/AVjYFbX0olgg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/simplebar-react/-/simplebar-react-3.3.0.tgz", + "integrity": "sha512-sxzy+xRuU41He4tT4QLGYutchtOuye/xxVeq7xhyOiwMiHNK1ZpvbOTyy+7P0i7gfpXLGTJ8Bep8+4Mhdgtz/g==", "dependencies": { - "simplebar-core": "^1.2.4" + "simplebar-core": "^1.3.0" }, "peerDependencies": { "react": ">=16.8.0" @@ -10970,12 +10915,6 @@ "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -11154,32 +11093,6 @@ "node": ">=14.17" } }, - "node_modules/ua-parser-js": { - "version": "1.0.39", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.39.tgz", - "integrity": "sha512-k24RCVWlEcjkdOxYmVJgeD/0a1TiSpqLg+ZalVGV9lsnr4yqu0w7tX/x2xX6G4zpkgQnRf89lxuZ1wsbjXM8lw==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/ua-parser-js" - }, - { - "type": "paypal", - "url": "https://paypal.me/faisalman" - }, - { - "type": "github", - "url": "https://github.com/sponsors/faisalman" - } - ], - "license": "MIT", - "bin": { - "ua-parser-js": "script/cli.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -11323,6 +11236,48 @@ "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true }, + "node_modules/use-composed-ref": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/use-composed-ref/-/use-composed-ref-1.4.0.tgz", + "integrity": "sha512-djviaxuOOh7wkj0paeO1Q/4wMZ8Zrnag5H6yBvzN7AKKe8beOaED9SF5/ByLqsku8NP4zQqsvM2u3ew/tJK8/w==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/use-isomorphic-layout-effect": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.2.0.tgz", + "integrity": "sha512-q6ayo8DWoPZT0VdG4u3D3uxcgONP3Mevx2i2b0434cwWBoL+aelL1DzkXI6w3PhTZzUeR2kaVlZn70iCiseP6w==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/use-latest": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/use-latest/-/use-latest-1.3.0.tgz", + "integrity": "sha512-mhg3xdm9NaM8q+gLT8KryJPnRFOz1/5XPBhmDEVZK1webPzDjrPk7f/mbpeLqTgB9msytYWANxgALOCJKnLvcQ==", + "dependencies": { + "use-isomorphic-layout-effect": "^1.1.1" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/use-sync-external-store": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", @@ -11583,22 +11538,6 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index a2b47c4..167c9e8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "isp-admin-ui", "private": true, - "version": "0.18.9", + "version": "0.19.0", "type": "module", "scripts": { "start": "vite", @@ -14,27 +14,19 @@ "prepare": "husky || true" }, "dependencies": { - "@apidevtools/json-schema-ref-parser": "^9.0.6", + "dayjs": "^1.11.10", + "isp-ui-kit": "^0.12.3", + "axios": "^1.7.7", + "react-router-dom": "^6.22.3", + "react-hook-form": "^7.51.2", + "react-dom": "^18.2.0", + "react": "^18.2.0", + "monaco-editor": "^0.52.0", "@monaco-editor/react": "^4.6.0", "@reduxjs/toolkit": "^2.2.3", - "@rjsf/antd": "^5.21.2", - "@rjsf/core": "^5.21.2", - "@rjsf/validator-ajv8": "^5.21.2", - "axios": "^1.7.7", - "clipboard": "^2.0.11", - "compare-versions": "^6.1.0", - "dayjs": "^1.11.10", - "deep-equal": "^2.2.3", - "isp-ui-kit": "^0.10.1", - "json-schema-view-js": "^2.0.1", - "lodash.clonedeep": "^4.5.0", - "monaco-editor": "^0.52.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-hook-form": "^7.51.2", + "isp-admin-ui-kit": "^0.3.1", "react-redux": "^9.1.0", "react-resizable": "^3.0.5", - "react-router-dom": "^6.22.3", "simplebar": "^6.2.5", "simplebar-react": "^3.2.4" }, diff --git a/src/assets/icon/default-user.svg b/src/assets/icon/default-user.svg deleted file mode 100644 index 67e0de6..0000000 --- a/src/assets/icon/default-user.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/assets/icon/search-icon.svg b/src/assets/icon/search-icon.svg deleted file mode 100644 index f5ce949..0000000 --- a/src/assets/icon/search-icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/assets/images/home-background.png b/src/assets/images/home-background.png deleted file mode 100644 index 54c4290..0000000 Binary files a/src/assets/images/home-background.png and /dev/null differ diff --git a/src/components/ActiveConfigurationsTable/active-configurations-table.scss b/src/components/ActiveConfigurationsTable/active-configurations-table.scss deleted file mode 100644 index 847545a..0000000 --- a/src/components/ActiveConfigurationsTable/active-configurations-table.scss +++ /dev/null @@ -1,47 +0,0 @@ -@import "src/constants/style/styleConst"; - - -.active-configurations-table { - &__title { - margin-bottom: $basic-margin*2; - font-size: 20px; - } - - &__table { - &__name-field { - input { - color: #606060; - border: none; - background-color: transparent; - width: 100%; - - &:focus-visible { - color: var(--ant-color-text); - padding: $basic-padding; - border-radius: 4px; - outline: 1px solid $blue-color; - } - } - - display: flex; - justify-content: space-between; - gap: $basic-margin; - - &__actions { - display: flex; - gap: $basic-margin - } - } - } - - .active-config { - tr { - background: var(--ant-color-info-bg); - } - } - - &__buttons { - display: flex; - justify-content: space-between; - } -} diff --git a/src/components/ActiveConfigurationsTable/active-configurations-table.type.ts b/src/components/ActiveConfigurationsTable/active-configurations-table.type.ts deleted file mode 100644 index 5669166..0000000 --- a/src/components/ActiveConfigurationsTable/active-configurations-table.type.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ConfigType, ModuleType } from '@pages/ModulesPage/module.type.ts' - -export interface ActiveConfigurationsTablePropsType { - isActiveTable?: boolean - data: ConfigType[] - handleShowConfig: (config: ConfigType) => void - handleShowCompareModal: (config: ConfigType) => void - currentModule?: ModuleType -} diff --git a/src/components/ActiveConfigurationsTable/index.tsx b/src/components/ActiveConfigurationsTable/index.tsx deleted file mode 100644 index cced20a..0000000 --- a/src/components/ActiveConfigurationsTable/index.tsx +++ /dev/null @@ -1,227 +0,0 @@ -import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons' -import { Button, message, Table, Tag, Tooltip } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { FC, useEffect, useRef, useState } from 'react' -import { useNavigate, useParams } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' - -import ActiveTableActionButtons from '@widgets/ActiveTableActionButtons' - -import { ActiveConfigurationsTablePropsType } from '@components/ActiveConfigurationsTable/active-configurations-table.type.ts' -import CanEdit from '@components/CanEdit' - -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -import configApi from '@services/configService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import './active-configurations-table.scss' - -const ActiveConfigurationsTable: FC = ({ - isActiveTable = false, - handleShowConfig, - handleShowCompareModal, - data, - currentModule = {} -}) => { - const [editKeyConfig, setEditKeyConfig] = useState('') - const [tempEditValues, setTempEditValues] = useState() - const inputRefs = useRef>({}) - const [createUpdateConfig] = configApi.useCreateUpdateConfigMutation() - const [markConfigAsActive] = configApi.useMarkConfigAsActiveMutation() - const [deleteConfig] = configApi.useDeleteConfigMutation() - const navigate = useNavigate() - const { id: moduleId } = useParams() - - useEffect(() => { - if (inputRefs.current[editKeyConfig]) { - inputRefs.current[editKeyConfig]?.focus() - } - }, [editKeyConfig]) - const handleEditStart = (record: ConfigType) => { - setEditKeyConfig(record.id) - setTempEditValues({ - ...tempEditValues, - [record.id]: record.name - } as ConfigType) - } - - const handleCancelEdit = (record: ConfigType) => { - setEditKeyConfig('') - setTempEditValues({ - ...tempEditValues, - [record.id]: record.name - } as ConfigType) - } - - const handleSaveEdit = (record: ConfigType) => { - const sendData = { ...record, name: tempEditValues[record.id] } - createUpdateConfig(sendData) - .unwrap() - .then(() => { - message.success('Элемент успешно сохранен') - setEditKeyConfig('') - }) - .catch(() => { - message.error('Не удалось сохранить элемент') - }) - } - const handleDeleteConfig = (record: ConfigType) => { - deleteConfig(record.id) - .unwrap() - .then(() => { - message.success('Элемент успешно удален') - setEditKeyConfig('') - }) - .catch(() => { - message.error('Не удалось удалить элемент') - }) - } - - const handleMarkConfigActive = (record: ConfigType) => { - markConfigAsActive(record.id) - .unwrap() - .then(() => { - message.success('Элемент успешно обновлен') - setEditKeyConfig('') - }) - .catch(() => { - message.error('Не удалось обновить элемент') - }) - } - - const renderNameField = (value: string, record: ConfigType) => { - const canEdit = editKeyConfig === record.id - const inputValue = canEdit ? tempEditValues[record.id] : value - - return ( -
- (inputRefs.current[record.id] = inputRef)} - onChange={(event) => { - const { value } = event.target - setTempEditValues({ ...tempEditValues, [record.id]: value }) - }} - disabled={!canEdit} - value={inputValue} - /> - {canEdit ? ( -
- -
- ) : ( - - -
- ) - } - - const columns: ColumnsType = [ - { - title: 'Наименование', - dataIndex: 'name', - key: 'name', - render: renderNameField, - align: 'center' - }, - { - title: 'Версия', - dataIndex: 'version', - key: 'version', - align: 'center' - }, - { - title: 'Статус', - dataIndex: 'valid', - key: 'version', - align: 'center', - render: (value: boolean) => { - if (value) { - return Корректная - } - return Некорректная - } - }, - { - title: 'Дата обновления', - dataIndex: 'updatedAt', - key: 'updatedAt', - align: 'center', - render: (value: string) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - title: 'Действия', - dataIndex: 'actions', - key: 'actions', - align: 'center', - render: (_: unknown, record: ConfigType) => ( - - ) - } - ] - const className = `active-configurations-table__table ${isActiveTable ? 'active-config' : ''}` - return ( -
-
-

- {isActiveTable ? 'Активная' : 'Остальные'} -

- {!isActiveTable && ( - - - - )} -
- record.id} - pagination={false} - columns={columns} - dataSource={data} - /> - - ) -} - -export default ActiveConfigurationsTable diff --git a/src/components/App.tsx b/src/components/App.tsx deleted file mode 100644 index 99831d4..0000000 --- a/src/components/App.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { ConfigProvider } from 'antd' -import ruRu from 'antd/locale/ru_RU' -import { useEffect, useState } from 'react' -import { useLocation } from 'react-router-dom' - -import { darkTheme, lightTheme } from '@constants/theme.ts' - -import { Context } from '@stores/index.tsx' - -import Routers from '@routes/Routers' -import { routePaths } from '@routes/routePaths.ts' - -import './app.scss' - -const App = () => { - const [themes, setTheme] = useState(lightTheme) - const [changeTheme, setChangeTheme] = useState( - localStorage.getItem('theme') - ? JSON.parse(localStorage.getItem('theme') || '') - : true - ) - - const location = useLocation() - - useEffect(() => { - const prevRoute = sessionStorage.getItem('prevRoute') - if ( - location.pathname !== routePaths.error && - location.pathname !== routePaths.login && - location.pathname !== prevRoute - ) { - sessionStorage.setItem('prevRoute', location.pathname) - } - }, [location]) - - useEffect(() => { - setTheme(() => (changeTheme ? darkTheme : lightTheme)) - }, [changeTheme]) - - return ( -
- - - - - -
- ) -} - -export default App diff --git a/src/components/AppAccessContent/app-access-content.scss b/src/components/AppAccessContent/app-access-content.scss deleted file mode 100644 index 86ded25..0000000 --- a/src/components/AppAccessContent/app-access-content.scss +++ /dev/null @@ -1,36 +0,0 @@ -@import 'src/constants/style/styleConst'; - -.app-access-content { - height: 100%; - width: 100%; - min-width: 760px; - - padding: $basic-padding * 1.8; - border: 1px solid $border-color; - - &__header { - display: flex; - justify-content: space-between; - margin-bottom: $basic-margin * 2; - - &__action-buttons { - display: flex; - gap: $basic-margin * 2; - } - } - - &__main { - display: grid; - grid-template-columns:1fr 1fr; - - - &__tree-search-input { - width: 350px; - margin-bottom: $basic-margin * 2; - } - } - - .unknown-label { - color: $error-red - } -} diff --git a/src/components/AppAccessContent/app-access-content.type.ts b/src/components/AppAccessContent/app-access-content.type.ts deleted file mode 100644 index 3eb7c73..0000000 --- a/src/components/AppAccessContent/app-access-content.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface AppAccessContentPropsType { - id: number - paramPrefix: string -} diff --git a/src/components/AppAccessContent/index.tsx b/src/components/AppAccessContent/index.tsx deleted file mode 100644 index 4efc947..0000000 --- a/src/components/AppAccessContent/index.tsx +++ /dev/null @@ -1,208 +0,0 @@ -import { SearchOutlined } from '@ant-design/icons' -import { Button, Input, message, Spin, TreeProps } from 'antd' -import { ChangeEvent, FC, memo, useEffect, useState } from 'react' -import { Navigate, useSearchParams } from 'react-router-dom' - -import AccessListTree from '@widgets/AccessListTree' -import SelectedAccessMethod from '@widgets/SelectedAccessMethod' - -import { AppAccessContentPropsType } from '@components/AppAccessContent/app-access-content.type.ts' - -import { setSearchValue } from '@utils/columnLayoutUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import accessListApi from '@services/accessListService.ts' -import routeApi from '@services/routeService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { AccessListMethodType, EndpointType } from '@type/accessList.type.ts' -import { PermissionKeysType } from '@type/roles.type.ts' - -import './app-access-content.scss' - -const unknownMethodKey = 'неизвестные методы' - -const AppAccessContent: FC = ({ - id, - paramPrefix -}) => { - const [messageApi, contextHolder] = message.useMessage() - const { hasPermission } = useRole() - - const canWrite = hasPermission(PermissionKeysType.write) - - const { - data: methods = [], - isLoading: isMethodsLoading, - isError: isMethodsError, - isSuccess: isMethodsSuccess - } = accessListApi.useGetByIdQuery({ id }) - const [setList] = accessListApi.useSetListMutation() - const [setOne] = accessListApi.useSetOneMutation() - - const { - data: routes = { - originalResponse: [], - moduleEndpoints: {}, - allRouteMap: {} - }, - isLoading: isRouteLoading, - isError: isRouteError, - isSuccess: isRouteSuccess - } = routeApi.useGetAllRoutesQuery() - const { moduleEndpoints, allRouteMap } = routes - const [defaultAllRoutes, setDefaultAllRoutes] = useState< - Record - >({}) - - const [searchParams, setSearchParams] = useSearchParams() - const searchValue = searchParams.get(paramPrefix) || '' - - const isLoading = isMethodsLoading || isRouteLoading - const isError = isMethodsError || isRouteError - const isSuccess = isMethodsSuccess && isRouteSuccess - - const openSuccessMessage = (body: string) => { - messageApi.success(body) - } - - const openErrorMessage = (body: string) => { - messageApi.error(body) - } - - const createAllMethodList = (status: boolean) => { - return Object.keys(allRouteMap).map((key) => { - return { - method: key, - value: status - } - }) - } - - const onCheck: TreeProps['onCheck'] = (_, info): void | never[] => { - const { node } = info - if (!node.children) { - const sendData = { - appId: id, - method: node.key as string, - value: !node.checked - } - setOne(sendData) - .then(() => { - openSuccessMessage('Статус метода успешно изменен') - }) - .catch(() => { - openErrorMessage('Не удалось изменить статус метода') - }) - return - } - - const newCheckedKeys = node.children.map((child) => ({ - method: child.key as string, - value: !node.checked - })) - setListMethods(newCheckedKeys) - } - - const onChange = (e: ChangeEvent) => { - const { value } = e.target - setSearchValue(value.trim().toLowerCase(), setSearchParams, paramPrefix) - } - - const setListMethods = (methods: AccessListMethodType[]) => { - setList({ - appId: id, - methods: methods - }) - .then(() => { - openSuccessMessage('Статус методов успешно изменен') - }) - .catch(() => { - openErrorMessage('Не удалось изменить статус методов') - }) - } - - const setAllMethods = (status: boolean) => { - const methods = createAllMethodList(status) - setListMethods(methods) - } - - const getAllRoutes = () => { - const missingRoute: EndpointType[] = [] - const copyAllRoutes = { ...moduleEndpoints } - - methods.forEach((item) => { - if (!allRouteMap[item.method]) { - missingRoute.push({ path: item.method } as EndpointType) - } - }) - - if (missingRoute.length) { - copyAllRoutes[unknownMethodKey] = missingRoute - } - return copyAllRoutes - } - - useEffect(() => { - const allRoutes = getAllRoutes() - setDefaultAllRoutes(allRoutes) - }, [isSuccess]) - - if (isLoading) { - return - } - - if (isError) { - return - } - return ( -
- {contextHolder} -
- } - allowClear - className="app-access-content__main__tree-search-input" - value={searchValue} - placeholder="Найти метод" - onChange={onChange} - /> -
- - -
-
-
- - -
-
- ) -} - -export default memo(AppAccessContent) diff --git a/src/components/AppGroupModal/app-group-modal.type.ts b/src/components/AppGroupModal/app-group-modal.type.ts deleted file mode 100644 index e1f8e87..0000000 --- a/src/components/AppGroupModal/app-group-modal.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ModalPropsType } from '@widgets/Modal/modal.type.ts' - -import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts' - -export type AppGroupModalType = Omit & { - appGroup?: ApplicationsGroupType - onOk: (data: ApplicationsGroupType) => void -} diff --git a/src/components/AppGroupModal/index.tsx b/src/components/AppGroupModal/index.tsx deleted file mode 100644 index e3d6aea..0000000 --- a/src/components/AppGroupModal/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FormComponents } from 'isp-ui-kit' -import { FC, useEffect } from 'react' -import { useForm } from 'react-hook-form' - -import { ValidationRules } from '@constants/form/validationRules.ts' - -import Modal from '@widgets/Modal' - -import { AppGroupModalType } from '@components/AppGroupModal/app-group-modal.type.ts' - -import { ApplicationsGroupType } from '@pages/ApplicationsPage/applications.type.ts' - -const { FormInput, FormTextArea } = FormComponents - -const AppGroupModal: FC = ({ - title, - onClose, - onOk, - open, - appGroup -}) => { - const { handleSubmit, control, reset } = useForm({ - mode: 'onChange', - defaultValues: appGroup - }) - - useEffect(() => { - reset(appGroup) - }, [open]) - - return ( - -
- - - -
- ) -} - -export default AppGroupModal diff --git a/src/components/AppModal/app-group-modal.type.ts b/src/components/AppModal/app-group-modal.type.ts deleted file mode 100644 index 1bf5c17..0000000 --- a/src/components/AppModal/app-group-modal.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ModalPropsType } from '@widgets/Modal/modal.type.ts' - -import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts' - -export type AppModalType = Omit & { - app?: ApplicationAppType - onOk: (data: ApplicationAppType) => void -} diff --git a/src/components/AppModal/index.tsx b/src/components/AppModal/index.tsx deleted file mode 100644 index 411ce8a..0000000 --- a/src/components/AppModal/index.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { FormComponents } from 'isp-ui-kit' -import { FC, useEffect } from 'react' -import { useForm } from 'react-hook-form' - -import { ValidationRules } from '@constants/form/validationRules.ts' - -import Modal from '@widgets/Modal' - -import { AppModalType } from '@components/AppModal/app-group-modal.type.ts' - -import { ApplicationAppType } from '@pages/ApplicationsPage/applications.type.ts' - -const { FormInput, FormTextArea } = FormComponents - -const AppModal: FC = ({ title, onOk, onClose, open, app }) => { - const { handleSubmit, control, reset } = useForm({ - mode: 'onChange', - defaultValues: app - }) - useEffect(() => { - reset(app) - }, [open]) - - return ( - -
- - - -
- ) -} - -export default AppModal diff --git a/src/components/ApplicationsContent/applications-content.scss b/src/components/ApplicationsContent/applications-content.scss deleted file mode 100644 index 64e8af8..0000000 --- a/src/components/ApplicationsContent/applications-content.scss +++ /dev/null @@ -1,39 +0,0 @@ -@import "src/constants/style/styleConst"; - -.applications-content { - height: 100%; - display: grid; - grid-template-columns:min-content 1fr; - width: 100%; - - .column-content { - margin-left: $basic-margin; - } - - &__add-btn { - display: flex; - max-width: 240px; - margin-left: auto; - margin-bottom: $basic-margin * 2; - } - - &__update-btn { - margin-right: $basic-margin; - } - - &__addToken-btn { - display: flex; - margin: 0 auto; - } - - .link-btn { - color: $blue-color; - - &:hover { - color: $text-color-blue; - } - } - .column { - border-left: 0; - } -} diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx deleted file mode 100644 index e443acf..0000000 --- a/src/components/ApplicationsContent/index.tsx +++ /dev/null @@ -1,237 +0,0 @@ -import { FileProtectOutlined } from '@ant-design/icons' -import { List, message, Spin, Tooltip } from 'antd' -import { Layout } from 'isp-ui-kit' -import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type' -import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react' -import { useNavigate, useParams, useSearchParams } from 'react-router-dom' - -import AppModal from '@components/AppModal' -import TokenContent from '@components/TokenContent' - -import { - ApplicationAppType, - ApplicationsServiceType, - NewApplicationAppType, - UpdateApplicationAppType -} from '@pages/ApplicationsPage/applications.type.ts' - -import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts' -import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts' - -import applicationsApi from '@services/applicationsService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import './applications-content.scss' - -const { EmptyData, Column } = Layout - -interface ApplicationsContentPropTypes { - selectedItemId: number - currentApplicationsApp: number - setCurrentApplicationsApp: Dispatch> -} - -const ApplicationsContent: FC = ({ - selectedItemId, - setCurrentApplicationsApp -}) => { - const { - data: applications = [], - isLoading: isLoadingApplicationsContent = [] - } = applicationsApi.useGetApplicationsByServiceIdQuery({ - id: selectedItemId - }) - - const [createApplicationService] = - applicationsApi.useCreateApplicationServiceMutation() - const [updateApplication] = - applicationsApi.useUpdateApplicationsServiceMutation() - const [removeApplicationsService] = - applicationsApi.useRemoveApplicationsServiceMutation() - const [showApplicationsModal, setShowApplicationsModal] = useState({ - addModal: false, - updateModal: false - }) - const [searchParams, setSearchParams] = useSearchParams('') - const searchAppValue = searchParams.get('appSearch') || '' - const navigate = useNavigate() - const { appId = '' } = useParams() - - const currentApp = useMemo(() => { - const element = applications.find( - (application) => application.app.id.toString() === appId - ) - return element ? element.app : undefined - }, [applications, appId]) - - const updateApplicationModal = () => { - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: true - }) - } - const addApplicationModal = () => { - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: true - }) - } - const renderTokenContent = () => { - if (!appId) { - return - } - - return - } - - const handleUpdateApplicationApp = (data: ApplicationAppType) => { - if (currentApp) { - const updateApplications: UpdateApplicationAppType = { - id: currentApp.id, - name: data.name, - description: data.description - ? data.description - : currentApp.description, - serviceId: selectedItemId, - type: 'SYSTEM' - } - updateApplication({ ...currentApp, ...updateApplications }) - .unwrap() - .then(() => { - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false - }) - message.success('Элемент сохранен') - }) - .catch(() => message.error('Ошибка обновления элемента')) - } - } - - const handleCreateApplicationApp = (data: ApplicationAppType) => { - const newApplicationApp: NewApplicationAppType = { - name: data.name, - description: data.description, - serviceId: selectedItemId, - type: 'SYSTEM' - } - - createApplicationService(newApplicationApp) - .unwrap() - .then(() => { - message.success('Элемент сохранен') - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - }) - }) - .catch(() => message.error('Ошибка добавления элемента')) - } - const handleRemoveApplicationApp = (id: number) => - removeApplicationsService([id]) - .unwrap() - .then(() => { - message.success('Элемент удален') - navigate( - `${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}` - ) - }) - .catch(() => message.error('Ошибка удаления элемента')) - - const renderColumnItems = (item: ColumnItem) => { - return ( - - - id: {item.id}} - /> -
{ - e.stopPropagation() - navigate(`/appAccess/${item.id}`) - }} - > - - - -
-
-
- ) - } - - if (!selectedItemId) { - return - } - if (selectedItemId) - if (isLoadingApplicationsContent) { - return - } - - return ( -
- handleRemoveApplicationApp(Number(appId))} - items={filterFirstColumnItems( - applications?.map((el) => { - return el.app - }) as unknown as ColumnItem[], - searchAppValue - )} - renderItems={renderColumnItems} - searchValue={searchAppValue} - selectedItemId={appId} - setSelectedItemId={(itemId: string) => { - setCurrentApplicationsApp(Number(itemId)) - setSelectedItemId( - `${routePaths.applicationsGroup}/${selectedItemId}/${routePaths.application}`, - itemId.toString(), - searchAppValue, - navigate - ) - }} - onChangeSearchValue={(value: string) => { - setSearchValue( - value.trim().toLowerCase(), - setSearchParams, - 'appSearch' - ) - }} - /> - {renderTokenContent()} - - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false - }) - } - /> - - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - }) - } - /> -
- ) -} - -export default ApplicationsContent diff --git a/src/components/CanEdit/index.tsx b/src/components/CanEdit/index.tsx deleted file mode 100644 index a2c9993..0000000 --- a/src/components/CanEdit/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { PropsWithChildren } from 'react' - -import { useRole } from '@hooks/useRole.tsx' - -import { PermissionKeysType } from '@type/roles.type.ts' - -const CanEdit = ({ children }: PropsWithChildren) => { - const { hasPermission } = useRole() - - if (hasPermission(PermissionKeysType.write)) { - return <>{children} - } - return null -} - -export default CanEdit diff --git a/src/components/ChangePasswordModal/change-password-modal.type.ts b/src/components/ChangePasswordModal/change-password-modal.type.ts deleted file mode 100644 index c2e212a..0000000 --- a/src/components/ChangePasswordModal/change-password-modal.type.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type ChangePasswordModalType = { - oldPassword: string - newPassword: string - confirmPassword: string -} - -export type ChangePasswordModalProps = { - open: boolean - onClose: () => void -} diff --git a/src/components/ChangePasswordModal/index.tsx b/src/components/ChangePasswordModal/index.tsx deleted file mode 100644 index 1452b36..0000000 --- a/src/components/ChangePasswordModal/index.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { message } from 'antd' -import { FormComponents } from 'isp-ui-kit' -import { FC, useEffect, useState } from 'react' -import { useForm } from 'react-hook-form' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import Modal from '@widgets/Modal' - -import { - ChangePasswordModalProps, - ChangePasswordModalType -} from '@components/ChangePasswordModal/change-password-modal.type.ts' - -import { ChangeProfilePassword } from '@pages/ProfilePage/profile-page.type.ts' - -import useLogout from '@hooks/useLogout.tsx' - -import { apiService } from '@services/apiService.ts' - -const { FormInputPassword } = FormComponents -const ChangePasswordModal: FC = ({ - open, - onClose -}) => { - const { - control, - handleSubmit, - setError, - clearErrors, - watch, - reset, - trigger - } = useForm({ - mode: 'onChange' - }) - const [loading, setLoading] = useState(false) - const { logoutUser } = useLogout() - - const onSubmit = async (formValue: ChangePasswordModalType) => { - setLoading(true) - try { - await apiService.post(apiPaths.changePassword, { - oldPassword: formValue.oldPassword, - newPassword: formValue.newPassword - }) - await logoutUser() - message.success('Пароль успешно изменен') - clearErrors('oldPassword') - onClose() - } catch (error: any) { - if (error.response.data.errorCode === 1001) { - setError('oldPassword', { - message: 'Не верный текущий пароль' - }) - } - } finally { - setLoading(false) - } - } - - const handleCloseModal = () => { - onClose() - reset() - } - - const confirmPassword = watch('confirmPassword') - const newPassword = watch('newPassword') - - useEffect(() => { - trigger('newPassword') - trigger('confirmPassword') - }, [newPassword, confirmPassword]) - - return ( - -
- - { - return value === confirmPassword || 'Пароли не совпадают' - } - }} - label="Новый пароль" - control={control} - name="newPassword" - /> - - { - if (value !== newPassword) return 'Пароли не совпадают' - if (!value) return 'Поле не может быть пустым' - return true - } - }} - label="Подтвердите пароль" - control={control} - name="confirmPassword" - /> - -
- ) -} -export default ChangePasswordModal diff --git a/src/components/CompareVersionModal/compare-version-modal.scss b/src/components/CompareVersionModal/compare-version-modal.scss deleted file mode 100644 index 38eed17..0000000 --- a/src/components/CompareVersionModal/compare-version-modal.scss +++ /dev/null @@ -1,37 +0,0 @@ -@import "src/constants/style/styleConst"; - -.compare-version-modal { - .modal__wrap { - width: 100%; - height: 100%; - justify-content: initial; - } - - .modal__content { - overflow: initial; - } - - &__header { - margin-top: $basic-margin; - display: flex; - justify-content: space-between; - margin-bottom: $basic-margin; - - } - - &__content { - .monaco-diff-editor { - overflow-y: scroll; - height: calc(90vh - 150px) !important; - } - - &__table { - overflow-y: auto; - height: calc(90vh - 50px); - - &__row { - cursor: pointer; - } - } - } -} diff --git a/src/components/CompareVersionModal/compare-version-modal.type.ts b/src/components/CompareVersionModal/compare-version-modal.type.ts deleted file mode 100644 index 278d74a..0000000 --- a/src/components/CompareVersionModal/compare-version-modal.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ModalPropsType } from '@widgets/Modal/modal.type.ts' - -export interface CompareVersionModalPropsType - extends Omit { - config: Record - currentConfigId: string -} diff --git a/src/components/CompareVersionModal/index.tsx b/src/components/CompareVersionModal/index.tsx deleted file mode 100644 index 590a1ac..0000000 --- a/src/components/CompareVersionModal/index.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { DiffEditor } from '@monaco-editor/react' -import { Button, Spin, Table } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { FC, memo, useContext, useState } from 'react' - -import { dateFormats } from '@constants/date.ts' - -import Modal from '@widgets/Modal' - -import { CompareVersionModalPropsType } from '@components/CompareVersionModal/compare-version-modal.type' - -import { sortObject } from '@utils/objectUtils.ts' - -import { useAppSelector } from '@hooks/redux.ts' - -import configServiceApi from '@services/configService.ts' -import userServiceApi from '@services/userService.ts' - -import { Context } from '@stores/index.tsx' - -import { VersionType } from '@type/version.type' - -import './compare-version-modal.scss' - -const CompareVersionModal: FC = ({ - open, - onClose, - config, - currentConfigId -}) => { - const [selectedItem, setSelectedItem] = useState() - const { data: versions = [], isLoading: isVersionLoading } = - configServiceApi.useGetAllVersionQuery(currentConfigId) - const { data: allUsers = [], isLoading: isUsersLoading } = - userServiceApi.useGetAllUsersQuery() - const { profile } = useAppSelector((state) => state.profileReducer) - const { changeTheme } = useContext(Context) - const isLoading = isVersionLoading || isUsersLoading - if (isLoading) { - return - } - - const columns: ColumnsType = [ - { - key: 'configVersion', - title: 'Версия', - dataIndex: 'configVersion' - }, - { - key: 'createdAt', - title: 'Создано', - dataIndex: 'createdAt', - render: (value: string) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - key: 'user', - title: 'Автор', - dataIndex: 'adminId', - render: (value: number) => { - const user = allUsers.find((user) => user.id === value) - if (user) { - return `${user.lastName} ${user.firstName}` - } - return `${profile.lastName} ${profile.firstName}` - } - } - ] - return ( -
- - {selectedItem ? ( -
- -
- Версия: {selectedItem.configVersion} - - {config?.version - ? `Текущая версия : ${config?.version}` - : `Версия: ${config?.configVersion}`} - -
- -
- ) : ( -
-
record.id} - onRow={(record) => { - return { - onClick: () => setSelectedItem(record) - } - }} - /> - - )} - - - ) -} - -export default memo(CompareVersionModal) diff --git a/src/components/ConfigSchemaModal/config-schema-moda.type.ts b/src/components/ConfigSchemaModal/config-schema-moda.type.ts deleted file mode 100644 index 496070d..0000000 --- a/src/components/ConfigSchemaModal/config-schema-moda.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ModalPropsType } from '@widgets/Modal/modal.type.ts' - -import { JSONSchema } from '@pages/ModulesPage/module.type.ts' - -export interface ConfigSchemaModalPropsType - extends Omit { - schema?: JSONSchema -} diff --git a/src/components/ConfigSchemaModal/config-schema-modal.scss b/src/components/ConfigSchemaModal/config-schema-modal.scss deleted file mode 100644 index dca2c0d..0000000 --- a/src/components/ConfigSchemaModal/config-schema-modal.scss +++ /dev/null @@ -1,11 +0,0 @@ -@import "src/constants/style/styleConst"; - -.config-schema-modal { - .modal__wrap { - min-width: 880px; - } - - .json-schema-view { - padding: $basic-padding - } -} diff --git a/src/components/ConfigSchemaModal/index.tsx b/src/components/ConfigSchemaModal/index.tsx deleted file mode 100644 index e116509..0000000 --- a/src/components/ConfigSchemaModal/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FC, memo } from 'react' - -import JsonSchemaViewer from '@widgets/JSONViewer' -import Modal from '@widgets/Modal' - -import { ConfigSchemaModalPropsType } from '@components/ConfigSchemaModal/config-schema-moda.type.ts' - -import './config-schema-modal.scss' - -const ConfigSchemaModal: FC = ({ - open, - onClose, - schema = {} -}) => { - return ( -
- - - -
- ) -} - -export default memo(ConfigSchemaModal) diff --git a/src/components/ConfigurationEditorCode/index.tsx b/src/components/ConfigurationEditorCode/index.tsx deleted file mode 100644 index e6611cd..0000000 --- a/src/components/ConfigurationEditorCode/index.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Editor from '@monaco-editor/react' -import { FC, useContext } from 'react' - -import { ConfigurationEditorPropsType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts' -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -import { Context } from '@stores/index.tsx' - -const ConfigurationEditorCode: FC = ({ - setDisableBtn = () => {}, - bufConfig, - setBufConfig -}) => { - const { changeTheme } = useContext(Context) - - const handleChange = (data: string | undefined) => { - if (data) { - try { - const newData = { - ...bufConfig, - data: { ...JSON.parse(data) } - } as ConfigType - setDisableBtn(false) - setBufConfig(newData) - } catch (error) { - setDisableBtn(true) - } - } - } - - const editorValue = JSON.stringify(bufConfig?.data, null, '\t') - - return ( -
- -
- ) -} - -export default ConfigurationEditorCode diff --git a/src/components/ConfigurationEditorForm/index.tsx b/src/components/ConfigurationEditorForm/index.tsx deleted file mode 100644 index 2b9bef1..0000000 --- a/src/components/ConfigurationEditorForm/index.tsx +++ /dev/null @@ -1,317 +0,0 @@ -import { DeleteOutlined, PlusOutlined } from '@ant-design/icons' -import { Theme as AntDTheme } from '@rjsf/antd' -import { withTheme } from '@rjsf/core' -import { UiSchema } from '@rjsf/utils' -import validator from '@rjsf/validator-ajv8' -import { - Badge, - Button, - Tabs, - Tooltip, - Collapse, - Typography, - Space -} from 'antd' -import equal from 'deep-equal' -import { createRef, FC, memo, useEffect, useState } from 'react' -import { useParams } from 'react-router-dom' - -import { - ArrayFieldTemplatePropsType, - ConfigurationEditorPropsType, - DescriptionPropsType, - ErrorsObjType, - ObjectFieldTemplatePropertyType, - ObjectFieldTemplatePropsType, - RemoveButtonProps, - SortPropType -} from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts' -import { ResponseSchemaType } from '@pages/ModulesPage/module.type.ts' - -import { cleanEmptyParamsObject } from '@utils/objectUtils.ts' - -const { Text: AntdText } = Typography - -const ConfigurationEditorForm: FC = ({ - bufConfig = {}, - jsonSchema = {}, - submitRef -}) => { - const Form = withTheme(AntDTheme) - const sortProps = (a: SortPropType, b: SortPropType) => - a.name.localeCompare(b.name) - - const [formState, setFormState] = useState(bufConfig.data) - const { id } = useParams() - const formRef = createRef() - - useEffect(() => { - if (!equal(formState, bufConfig.data)) { - setFormState(bufConfig.data) - } - }, [bufConfig.data]) - - const uiSchema: UiSchema = { - 'ui:submitButtonOptions': { - norender: true - } - } - - const onSubmit = (data: any) => { - if (!submitRef) return - if ( - !formRef.current.validateFormWithFormData(formRef.current.state.formData) - ) { - submitRef.current = data - } else { - submitRef.current = data.formData - } - } - - const forceSubmit = () => { - if (formRef.current) { - const formData = formRef.current.state.formData - - onSubmit(cleanEmptyParamsObject(formData)) - } - } - - const onFormChange = () => { - if (!formRef.current) return - if ( - formRef.current.validateFormWithFormData(formRef.current.state.formData) - ) { - formRef?.current?.submit() - } else { - forceSubmit() - } - } - - const Description: FC = ({ description }) => - description ? ( - -   - - - ) : null - - const getDepth = (id: string) => { - if (!id) { - return 0 - } - return id.split('_').length - } - - const ArrayFieldTemplate: FC = ({ - items, - onAddClick, - canAdd, - title, - idSchema - }) => { - return ( - - - - - {title} - - - - - {canAdd && ( - - - - - ) -} -export default ConfirmConfigModal diff --git a/src/components/ConfirmConfigModal/confirm-config-modal.scss b/src/components/ConfirmConfigModal/confirm-config-modal.scss deleted file mode 100644 index d095c9c..0000000 --- a/src/components/ConfirmConfigModal/confirm-config-modal.scss +++ /dev/null @@ -1,6 +0,0 @@ -.confirm-config-modal { - .modal__content { - display: flex; - gap: 10px; - } -} diff --git a/src/components/ErrorConfigModal/ErrorConfigModal.tsx b/src/components/ErrorConfigModal/ErrorConfigModal.tsx deleted file mode 100644 index 87ae4a4..0000000 --- a/src/components/ErrorConfigModal/ErrorConfigModal.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Table } from 'antd' -import { FC } from 'react' - -import Modal from '@widgets/Modal' -import { ModalPropsType } from '@widgets/Modal/modal.type.ts' - -interface ErrorConfigModalProps - extends Omit { - details?: { [key: string]: string } -} - -const ErrorConfigModal: FC = ({ - details = {}, - onClose, - open -}) => { - const columns = [ - { - dataIndex: 'key', - key: 'key', - render: (text: string) => {text} - }, - { - dataIndex: 'value', - key: 'value' - } - ] - - const data = Object.keys(details).map((key) => ({ - key, - value: details[key] - })) - - return ( - -
-
- - - ) -} - -export default ErrorConfigModal diff --git a/src/components/Icons/DefaultUser.tsx b/src/components/Icons/DefaultUser.tsx deleted file mode 100644 index 63153c7..0000000 --- a/src/components/Icons/DefaultUser.tsx +++ /dev/null @@ -1,35 +0,0 @@ -const DefaultUser = () => { - return ( - - - - - - - - - - - - ) -} - -export default DefaultUser diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx deleted file mode 100644 index 3746313..0000000 --- a/src/components/Layout/index.tsx +++ /dev/null @@ -1,241 +0,0 @@ -import { - AppstoreAddOutlined, - FileProtectOutlined, - ProductOutlined, - ProfileOutlined -} from '@ant-design/icons' -import type { MenuProps } from 'antd' -import { ConfigProvider, Layout, Menu, Spin } from 'antd' -import { useContext, useEffect, useState } from 'react' -import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom' - -import { localStorageKeys } from '@constants/localStorageKeys.ts' - -import Header from '@widgets/Header' - -import DefaultUser from '@components/Icons/DefaultUser.tsx' -import { - MenuItemKeysType, - MenuItemType, - menuKeys -} from '@components/Layout/layout.type.ts' - -import { LocalStorage } from '@utils/localStorageUtils.ts' - -import { useAppDispatch, useAppSelector } from '@hooks/redux.ts' -import useRole from '@hooks/useRole.tsx' - -import { fetchProfile, fetchUI } from '@stores/redusers/ActionCreators.ts' -import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import './layout.scss' - -const { Content, Sider } = Layout - -const LayoutComponent = () => { - const [collapsed, setCollapsed] = useState( - LocalStorage.get('menu') === null ? true : LocalStorage.get('menu') - ) - const [selectedMenuKeys, setSelectedMenuKeys] = useState( - [] - ) - const [openKeys, setOpenKeys] = useState([]) - const [loading, setLoading] = useState(true) - const dispatch = useAppDispatch() - const { - status, - profile: { firstName } - } = useAppSelector((state) => state.profileReducer) - const location = useLocation() - const navigate = useNavigate() - const { hasPermission } = useRole() - const { theme } = useContext(ConfigProvider.ConfigContext) - - const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN) - - const hideItem = (permission: PermissionKeysType | PermissionKeysType[]) => { - if (Array.isArray(permission)) { - const result = permission.reduce((acc, currentValue) => { - const hasPermissionFunc = hasPermission(currentValue) - return hasPermissionFunc || acc - }, false) - return result ? '' : 'hide-item' - } - return hasPermission(permission) ? '' : 'hide-item' - } - const menuItems: MenuItemType[] = [ - { - label: firstName || '', - key: 'profile', - className: 'user-item', - icon: - }, - { - label: 'Приложения', - key: 'applications_group', - className: hideItem([PermissionKeysType.read]), - icon: - }, - { - label: 'Доступы приложений', - key: 'appAccess', - className: hideItem([PermissionKeysType.read]), - icon: - }, - { - label: 'Модули', - key: 'modules', - className: hideItem(PermissionKeysType.read), - icon: - }, - { - label: 'Пользователи и роли', - key: 'sessionManagement', - className: hideItem([ - PermissionKeysType.user_view, - PermissionKeysType.session_view, - PermissionKeysType.role_view - ]), - icon: , - children: [ - { - label: 'Пользователи', - key: 'users', - className: hideItem(PermissionKeysType.user_view) - }, - { - label: 'Пользовательские сессии', - key: 'sessions', - className: hideItem(PermissionKeysType.session_view) - }, - { - label: 'Просмотр журналов ИБ', - key: 'securityLog', - className: hideItem(PermissionKeysType.security_log_view) - }, - { - label: 'Роли', - key: 'roles', - className: hideItem(PermissionKeysType.role_view) - } - ] - } - ] - - useEffect(() => { - ConfigProvider.config({ - holderRender: (children) => ( - - {children} - - ) - }) - }, [theme]) - useEffect(() => { - if (userToken && status === StateProfileStatus.notInit) { - dispatch(fetchProfile()) - dispatch(fetchUI()) - } - }, [userToken, status]) - - useEffect(() => { - if ( - status === StateProfileStatus.resolved || - status === StateProfileStatus.rejected - ) { - setLoading(false) - } - }, [status]) - - useEffect(() => { - const menuKey = location.pathname.split('/')[1] as MenuItemKeysType - const selectedKey = selectedMenuKeys[0] || '' - const menuItem = menuKeys[menuKey] - - if (menuItem && menuKey !== selectedKey) { - setSelectedMenuKeys([menuItem.key]) - if (selectedKey) { - setOpenKeys(menuItem.parent) - } - } - }, [location.pathname]) - - const handlerOnClickMenu: MenuProps['onClick'] = ({ key }): void => { - switch (key) { - case MenuItemKeysType.profile: { - navigate(routePaths.profile) - break - } - case MenuItemKeysType.users: - navigate(routePaths.users) - break - case MenuItemKeysType.sessions: - navigate(routePaths.sessions) - break - case MenuItemKeysType.securityLog: - navigate(routePaths.securityLog) - break - case MenuItemKeysType.appAccess: - navigate(routePaths.appAccess) - break - case MenuItemKeysType.roles: - navigate(routePaths.roles) - break - case MenuItemKeysType.modules: - navigate(routePaths.modules) - break - case MenuItemKeysType.applicationsGroup: - navigate(routePaths.applicationsGroup) - break - default: - } - } - - if (loading || status === StateProfileStatus.pending) { - return - } - - if (status === StateProfileStatus.rejected) { - return - } - - return ( -
- - { - LocalStorage.set('menu', value) - setCollapsed(value) - }} - > -
- setOpenKeys(keys)} - openKeys={openKeys} - selectedKeys={selectedMenuKeys} - onClick={handlerOnClickMenu} - theme="light" - mode="inline" - items={menuItems} - /> - - - - - - - -
- ) -} - -export default LayoutComponent diff --git a/src/components/Layout/layout.scss b/src/components/Layout/layout.scss deleted file mode 100644 index 19ddc9e..0000000 --- a/src/components/Layout/layout.scss +++ /dev/null @@ -1,52 +0,0 @@ -@import 'src/constants/style/styleConst'; - -.layout { - min-height: 100vh !important; - position: relative; - - .hide-item { - display: none !important; - } - - .ant-spin { - position: absolute; - top: 50%; - left: 50%; - } - - .ant-menu { - border-inline-end: none !important; - } - - .ant-menu-title-content { - padding-left: 10px - } -} - -.user-item { - padding-left: 21px !important; - & .ant-menu-submenu-arrow { - display: none !important; - } - - border-bottom: 1px solid var(--ant-color-border); - border-radius: 0 !important; - - & .ant-menu-title-content { - margin: 0 !important; - padding-left: 17px !important; - } -} - -.ant-menu-inline-collapsed { - & .user-item { - padding-left: 24px !important; - padding-top: 5px !important; - } -} - -.ant-menu-submenu { - .hide-item { - display: none !important; - } -} diff --git a/src/components/Layout/layout.type.ts b/src/components/Layout/layout.type.ts deleted file mode 100644 index ec02f84..0000000 --- a/src/components/Layout/layout.type.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { MenuProps } from 'antd' - -export enum MenuItemKeysType { - users = 'users', - sessions = 'sessions', - securityLog = 'securityLog', - appAccess = 'appAccess', - roles = 'roles', - logout = 'logout', - profile = 'profile', - modules = 'modules', - applicationsGroup = 'applications_group' -} -export enum MenuItemLabelsType { - users = 'Пользователи', - sessions = 'Пользовательские сессии', - securityLog = 'Просмотр журналов ИБ', - appAccess = 'Доступы приложений', - roles = 'Роли', - profile = 'Профиль', - modules = 'Модули', - logout = 'Выход', - applications_group = 'Группы приложений' -} - -interface MenuItem { - key: MenuItemKeysType - parent: string[] -} - -export const menuKeys: Record = { - [MenuItemKeysType.users]: { - key: MenuItemKeysType.users, - parent: ['users'] - }, - [MenuItemKeysType.sessions]: { - key: MenuItemKeysType.sessions, - parent: ['users'] - }, - [MenuItemKeysType.securityLog]: { - key: MenuItemKeysType.securityLog, - parent: ['users'] - }, - [MenuItemKeysType.appAccess]: { - key: MenuItemKeysType.appAccess, - parent: ['appAccess'] - }, - [MenuItemKeysType.roles]: { - key: MenuItemKeysType.roles, - parent: ['users'] - }, - [MenuItemKeysType.logout]: { - key: MenuItemKeysType.logout, - parent: [''] - }, - [MenuItemKeysType.profile]: { - key: MenuItemKeysType.profile, - parent: [''] - }, - [MenuItemKeysType.modules]: { - key: MenuItemKeysType.modules, - parent: ['modules'] - }, - [MenuItemKeysType.applicationsGroup]: { - key: MenuItemKeysType.applicationsGroup, - parent: ['applicationsGroup'] - } -} - -export type MenuItemType = Required['items'][number] diff --git a/src/components/ModuleTabs/index.tsx b/src/components/ModuleTabs/index.tsx deleted file mode 100644 index 8ab4bed..0000000 --- a/src/components/ModuleTabs/index.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Tabs } from 'antd' -import { memo } from 'react' -import { useNavigate, useParams } from 'react-router-dom' - -import ModuleTabContent from '@widgets/ModuleTabContent' - -import { ModuleTabsPropsType } from '@components/ModuleTabs/module-tabs.type.ts' - -const secondColumnItems = [ - { - key: 'configurations', - name: 'Конфигурации' - }, - { key: 'connections', name: 'Подключения' } -] - -const ModuleTabs = ({ - activeTab, - setActiveTab, - currentModule -}: ModuleTabsPropsType) => { - const navigate = useNavigate() - const { id: selectedItemId = '' } = useParams() - return ( - { - setActiveTab(activeKey) - const path = `${selectedItemId}/${activeKey}` - navigate(path) - }} - className="modules-page__tabs" - items={secondColumnItems.map((item) => { - return { - disabled: selectedItemId === '', - label: item.name, - key: item.key, - children: ( -
- -
- ) - } - })} - /> - ) -} - -export default memo(ModuleTabs) diff --git a/src/components/ModuleTabs/module-tabs.type.ts b/src/components/ModuleTabs/module-tabs.type.ts deleted file mode 100644 index 06f0aa8..0000000 --- a/src/components/ModuleTabs/module-tabs.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ModuleType } from '@pages/ModulesPage/module.type.ts' - -export interface ModuleTabsPropsType { - activeTab: string - setActiveTab: (key: string) => void - currentModule: ModuleType | undefined -} diff --git a/src/components/RoleList/index.tsx b/src/components/RoleList/index.tsx deleted file mode 100644 index 23e928e..0000000 --- a/src/components/RoleList/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { Descriptions, Spin } from 'antd' - -import { RoleListProps } from '@components/RoleList/role-list.type.ts' - -import roleApi from '@services/roleService.ts' - -import './role-list.scss' - -const RoleList = ({ userRoles }: RoleListProps) => { - const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery() - const roleIds = new Set(userRoles) - - if (isError) { - return null - } - - return ( - - - {isLoading ? ( - - ) : ( -
    - {roles.map((roleData) => { - if (roleIds.has(roleData.id) && roleData.name) { - return
  • {roleData.name}
  • - } - return null - })} -
- )} -
-
- ) -} - -export default RoleList diff --git a/src/components/RoleList/role-list.scss b/src/components/RoleList/role-list.scss deleted file mode 100644 index a233d42..0000000 --- a/src/components/RoleList/role-list.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import "src/constants/style/styleConst"; - -.role-list { - .ant-descriptions-item-label { - font-size: $text-size-header2; - } - - .spin { - position: initial; - } - - ul, li { - list-style-position: inside - } - - li { - font-size: $text-size - } -} diff --git a/src/components/RoleList/role-list.type.ts b/src/components/RoleList/role-list.type.ts deleted file mode 100644 index a4c2d36..0000000 --- a/src/components/RoleList/role-list.type.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type RoleListProps = { - userRoles: number[] -} diff --git a/src/components/RolesContent/index.tsx b/src/components/RolesContent/index.tsx deleted file mode 100644 index a81e23c..0000000 --- a/src/components/RolesContent/index.tsx +++ /dev/null @@ -1,163 +0,0 @@ -import { Divider, message, Table } from 'antd' -import { ColumnsType } from 'antd/es/table' -import { FormComponents } from 'isp-ui-kit' -import { useEffect, useState } from 'react' -import { Controller, useForm } from 'react-hook-form' -import { useParams } from 'react-router-dom' - -import { ValidationRules } from '@constants/form/validationRules.ts' - -import SaveButton from '@ui/SaveButton' - -import AgreementModal from '@widgets/AgreementModal' - -import { RolesContentPropsType } from '@components/RolesContent/roles-content.type.ts' - -import useRole from '@hooks/useRole.tsx' - -import { PermissionKeysType, RoleType } from '@type/roles.type.ts' - -import './roles-content.scss' - -const newRole: Partial = { - externalGroup: '', - name: '', - permissions: [] -} - -const columns: ColumnsType = [ - { - title: 'Действие', - dataIndex: 'name' - }, - { - title: 'Ключ в системе', - dataIndex: 'key' - } -] -const { FormInput } = FormComponents -const RolesContent = ({ - role, - permissions, - saveRole, - title = 'Редактировать', - immutable = false -}: RolesContentPropsType) => { - const { - control, - formState: { isDirty }, - setError, - getValues, - reset - } = useForm({ - defaultValues: role, - mode: 'onChange' - }) - const { hasPermission } = useRole() - const { id: selectedItemId } = useParams() - - const [openModal, setOpenModal] = useState(false) - const isUpdateRole = hasPermission(PermissionKeysType.role_update) - const isCreateRole = hasPermission(PermissionKeysType.role_add) - - const isSaveBtnAvailable = - selectedItemId === 'new' ? isCreateRole : isUpdateRole - - useEffect(() => { - if (!role) { - reset(newRole) - } else { - reset(role) - } - }, [role]) - - const handleSubmitForm = (changeMessage: string) => { - if (!changeMessage) { - message.error('Поле не может быть пустым') - return - } - const formValue = getValues() - formValue.changeMessage = changeMessage - saveRole(formValue, setError) - setOpenModal(false) - } - - const renderFormTable = () => ( - ( -
{ - onChange(selectedRowKeys) - }, - getCheckboxProps: () => ({ - disabled: immutable - }) - }} - /> - )} - /> - ) - - return ( - <> - {openModal && ( - setOpenModal(false)} - okText="Сохранить" - title="Для подтверждения изменений укажите причину" - description="Основание для измений" - onConfirm={handleSubmitForm} - /> - )} -
-
-

- {title} -

- setOpenModal(true)} - className="roles-content__header__save-button" - /> -
- -
- - -
- {renderFormTable()} - - - ) -} - -export default RolesContent diff --git a/src/components/RolesContent/roles-content.scss b/src/components/RolesContent/roles-content.scss deleted file mode 100644 index f0eb845..0000000 --- a/src/components/RolesContent/roles-content.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import "../../constants/style/styleConst"; - -.roles-content { - padding: $basic-padding*2 $basic-padding*3 0; - min-width: 400px; - height: 100%; - - &__header { - display: flex; - justify-content: space-between; - } - - &__wrap-input { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 10px; - } - - .ant-pagination { - margin: 8px 0 !important; - } - - .ant-divider-horizontal { - margin: 14px 0; - } - - .ant-form-item { - margin-bottom: 12px; - } -} diff --git a/src/components/RolesContent/roles-content.type.ts b/src/components/RolesContent/roles-content.type.ts deleted file mode 100644 index 8f4780d..0000000 --- a/src/components/RolesContent/roles-content.type.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { UseFormSetError } from 'react-hook-form' - -import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts' - -export interface RolesContentPropsType { - role?: Partial - title?: string - immutable?: boolean - permissions: PermissionType[] - saveRole: ( - formValue: RoleType | NewRoleType, - setError: UseFormSetError - ) => void -} diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx deleted file mode 100644 index e2bc8fb..0000000 --- a/src/components/TokenContent/index.tsx +++ /dev/null @@ -1,258 +0,0 @@ -import { CopyOutlined, DeleteOutlined } from '@ant-design/icons' -import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd' -import { ColumnsType } from 'antd/es/table' -import ClipboardJS from 'clipboard' -import dayjs from 'dayjs' -import 'dayjs/locale/ru' -import duration from 'dayjs/plugin/duration' -import relativeTime from 'dayjs/plugin/relativeTime' -import { FormComponents, Layout } from 'isp-ui-kit' -import { useEffect, useMemo, useState } from 'react' -import { useForm } from 'react-hook-form' - -import { dateFormats } from '@constants/date.ts' -import { ValidationRules } from '@constants/form/validationRules.ts' - -import Modal from '@widgets/Modal' - -import CanEdit from '@components/CanEdit' - -import { - ApplicationTokenType, - NewApplicationTokenType -} from '@pages/ApplicationsPage/applications.type.ts' - -import tokensApi from '@services/tokensService.ts' - -import './tokens.scss' - -const { FormSelect } = FormComponents -const { EmptyData } = Layout - -interface TokenPropTypes { - id: number -} - -// eslint-disable-next-line import/no-named-as-default-member -dayjs.locale('ru') -dayjs.extend(duration) -dayjs.extend(relativeTime) - -const TokenContent = ({ id }: TokenPropTypes) => { - const [showApplicationsModal, setShowApplicationsModal] = useState(false) - const { - handleSubmit: handleSubmitTokens, - control: controlTokens, - reset - } = useForm({ - mode: 'onChange' - }) - - const { data, isLoading } = tokensApi.useGetTokensByAppIdQuery({ id }) - const [createToken] = tokensApi.useCreateTokenMutation() - const [revokeToken] = tokensApi.useRevokeTokensMutation() - - useEffect(() => { - const clipboard = new ClipboardJS('.copy-btn') - clipboard.on('success', () => { - message.success('Токен скопирован в буфер обмена') - }) - clipboard.on('error', () => { - message.error('Ошибка копирования') - }) - - return () => { - clipboard.destroy() - } - }, []) - - const handleCreateToken = (data: any) => { - if (id) { - const newToken: NewApplicationTokenType = { - expireTimeMs: data.expireTime, - appId: Number(id) - } - - createToken(newToken) - .then(() => { - setShowApplicationsModal(false) - reset() - message.success('Элемент добавлен') - }) - .catch(() => { - message.error('Ошибка добавления элемента') - }) - } - } - - function shortenString(longString: string) { - if (longString.length <= 6) { - return {longString} - } else { - return ( - - {longString.slice(0, 3)}...{longString.slice(-3)} - - ) - } - } - - const handleRevokeToken = (elem: ApplicationTokenType) => { - const currentRemoveToken = { - appId: id, - tokens: [elem.token] - } - - revokeToken(currentRemoveToken) - .unwrap() - .then(() => message.success('Элемент удален')) - .catch(() => message.error('Ошибка удаления элемента')) - } - - const columns: ColumnsType = [ - { - title: 'Токен', - dataIndex: 'token', - key: 'token', - render: (value) =>
{shortenString(value)}
- }, - { - title: 'Дата/Время выпуска', - dataIndex: 'createdAt', - key: 'createdAt', - render: (value) => { - const formatTime = dayjs(value).format(dateFormats.fullFormat) - return
{formatTime}
- } - }, - { - title: 'Истекает', - dataIndex: 'expireTime', - key: 'expireTime', - render: (value, record) => { - if (value === -1) { - return Никогда - } - - const dateNow = dayjs() - const expireTime = dayjs(record.createdAt).add(value) - if (expireTime.isBefore(dateNow)) { - return Просрочен - } - - const formatTime = expireTime.format(dateFormats.fullFormat) - return {formatTime} - } - }, - { - title: 'Действия', - dataIndex: 'token', - key: 'actions', - render: (value, record) => { - return ( - - - - - -
-
record.createdAt} - pagination={false} - columns={columns} - dataSource={data} - /> - - setShowApplicationsModal(false)} - > -
- - -
- - - ) -} - -export default TokenContent diff --git a/src/components/TokenContent/tokens.scss b/src/components/TokenContent/tokens.scss deleted file mode 100644 index 1cdd454..0000000 --- a/src/components/TokenContent/tokens.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import "src/constants/style/styleConst"; - -.token-content { - overflow-x: scroll; - width: 100%; - - &__table { - overflow-x: scroll; - height: calc(100vh - 100px); - } - - &__wrap { - padding: $basic-padding*1.25 $basic-padding*3; - } - - &__header { - display: flex; - justify-content: space-between; - - h3 { - margin: 0; - padding: 0; - font-size: 19px; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - font-family: PT Sans, sans-serif; - font-weight: 500; - } - } - - .copy-btn { - cursor: pointer; - } -} diff --git a/src/components/app.scss b/src/components/app.scss deleted file mode 100644 index 8947f80..0000000 --- a/src/components/app.scss +++ /dev/null @@ -1,18 +0,0 @@ -@import "src/constants/style/styleConst"; - -*, html { - margin:0; - padding:0; - box-sizing: border-box; -} - -.app{ - overflow: hidden; - height: 100vh; - min-height: 0; - min-width: 500px; -} - -.ant-btn:focus-visible{ - outline: none !important; -} diff --git a/src/constants/api/apiPaths.ts b/src/constants/api/apiPaths.ts deleted file mode 100644 index 1a5fba4..0000000 --- a/src/constants/api/apiPaths.ts +++ /dev/null @@ -1,126 +0,0 @@ -type PathKeys = - | 'baseUrl' - | 'baseSystemUrl' - | 'baseConfigUrl' - | 'getAllRoles' - | 'createRole' - | 'updateRole' - | 'deleteRole' - | 'login' - | 'logout' - | 'getProfile' - | 'getUsers' - | 'createUser' - | 'updateUser' - | 'blockUser' - | 'deleteUser' - | 'getRoles' - | 'getAllPermissions' - | 'baseUserUrl' - | 'baseAdminUrl' - | 'getAllSession' - | 'revokeSession' - | 'getAllLogs' - | 'getLogEvents' - | 'setLogEvents' - | 'getSystemTree' - | 'getById' - | 'setList' - | 'setOne' - | 'getAllRoutes' - | 'getModules' - | 'deleteModule' - | 'createUpdateService' - | 'deleteService' - | 'getAllService' - | 'getServiceById' - | 'getServicesByDomainId' - | 'createUpdateApplication' - | 'deleteApplication' - | 'getApplicationById' - | 'getAllApplications' - | 'getApplicationsByServiceId' - | 'createToken' - | 'getTokensByAppId' - | 'revokeTokens' - | 'revokeTokensForApp' - | 'getConfigsByModuleId' - | 'getConfigById' - | 'getAllVersions' - | 'createUpdateConfig' - | 'deleteVersion' - | 'deleteConfig' - | 'markConfigAsActive' - | 'getUI' - | 'getByModuleId' - | 'changePassword' - -export const apiPaths: Record = { - baseUrl: '/api/kkd-configuration-service', - baseAdminUrl: '/api/admin', - baseUserUrl: '/api/admin/user', - baseSystemUrl: '/api/system', - baseConfigUrl: '/api/config', - // ======= ROLES ====== - getAllRoles: '/role/all', - createRole: '/role/create', - updateRole: '/role/update', - deleteRole: '/role/delete', - // ======= AUTH ====== - login: '/api/admin/auth/login', - logout: '/api/admin/auth/logout', - // ======= PROFILE ====== - getProfile: '/api/admin/user/get_profile', - getUI: '/api/admin/user/get_design', - changePassword: '/api/admin/user/change_password', - // ======= USERS ====== - getUsers: '/get_users', - createUser: '/create_user', - updateUser: '/update_user', - blockUser: '/block_user', - deleteUser: '/delete_user', - getRoles: '/get_roles', - getAllPermissions: '/get_permissions', - // ======= SESSIONS ====== - getAllSession: '/session/all', - revokeSession: '/session/revoke', - // ======= LOGS ====== - getAllLogs: '/log/all', - getLogEvents: '/log/events', - setLogEvents: '/log/set_events', - // ======= APPLICATIONS ====== - getSystemTree: '/application/get_system_tree', - getAllApplications: '/application/get_applications', - createUpdateApplication: '/application/create_update_application', - getApplicationsByServiceId: '/application/get_applications_by_service_id', - deleteApplication: '/application/delete_applications', - getApplicationById: '/application/get_application_by_id', - // ======= ACCESS_LIST ====== - getById: '/access_list/get_by_id', - setList: '/access_list/set_list', - setOne: '/access_list/set_one', - getAllRoutes: '/routing/get_routes', - // ======= MODULES ====== - getModules: '/module/get_modules_info', - deleteModule: '/module/delete_module', - getByModuleId: '/schema/get_by_module_id', - // ======= SERVICE ====== - getServiceById: '/service/get_service_by_id', - getAllService: '/service/get_service', - deleteService: '/service/delete_service', - createUpdateService: '/service/create_update_service', - getServicesByDomainId: '/service/get_services_by_domain_id', - // ======= TOKENS ====== - createToken: '/token/create_token', - getTokensByAppId: '/token/get_tokens_by_app_id', - revokeTokens: '/token/revoke_tokens', - revokeTokensForApp: '/token/revoke_tokens_for_app', - // ======= CONFIGS ====== - getConfigsByModuleId: '/config/get_configs_by_module_id', - getConfigById: '/config/get_config_by_id', - getAllVersions: '/config/get_all_version', - createUpdateConfig: '/config/create_update_config', - deleteVersion: '/config/delete_version', - deleteConfig: '/config/delete_config', - markConfigAsActive: '/config/mark_config_as_active' -} diff --git a/src/constants/date.ts b/src/constants/date.ts deleted file mode 100644 index 0dc331a..0000000 --- a/src/constants/date.ts +++ /dev/null @@ -1,5 +0,0 @@ -type FormattersKey = 'fullFormat' - -export const dateFormats: Record = { - fullFormat: 'DD.MM.YYYY HH:mm:ss' -} diff --git a/src/constants/form/validationRules.ts b/src/constants/form/validationRules.ts deleted file mode 100644 index c3edf39..0000000 --- a/src/constants/form/validationRules.ts +++ /dev/null @@ -1,5 +0,0 @@ -type ValidationRulesKeys = 'required' - -export const ValidationRules: Record = { - required: { value: true, message: 'Поле не может быть пустым' } -} diff --git a/src/constants/localStorageKeys.ts b/src/constants/localStorageKeys.ts deleted file mode 100644 index 37219da..0000000 --- a/src/constants/localStorageKeys.ts +++ /dev/null @@ -1,6 +0,0 @@ -type LocalStorageKeys = 'HEADER_NAME' | 'USER_TOKEN' - -export const localStorageKeys: Record = { - HEADER_NAME: 'HEADER_NAME', - USER_TOKEN: 'USER_TOKEN' -} diff --git a/src/constants/messages.ts b/src/constants/messages.ts deleted file mode 100644 index 9f1a579..0000000 --- a/src/constants/messages.ts +++ /dev/null @@ -1,6 +0,0 @@ -type MessagesKey = 'serverError' | 'loginError' - -export const messages: Record = { - serverError: 'Внутренняя ошибка сервиса', - loginError: 'Неверный логин или пароль' -} diff --git a/src/constants/statuses.ts b/src/constants/statuses.ts deleted file mode 100644 index 2720611..0000000 --- a/src/constants/statuses.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum SessionStatusKeysType { - allowed = 'ALLOWED', - revoked = 'REVOKED', - expired = 'EXPIRED' -} - -export const sessionStatuses: Record = { - [SessionStatusKeysType.allowed]: 'Активная', - [SessionStatusKeysType.revoked]: 'Отмененная', - [SessionStatusKeysType.expired]: 'Истекшая' -} diff --git a/src/constants/style/styleConst.scss b/src/constants/style/styleConst.scss deleted file mode 100644 index fc9fc71..0000000 --- a/src/constants/style/styleConst.scss +++ /dev/null @@ -1,18 +0,0 @@ -$basic-margin: 8px; -$basic-padding: 8px; - -$text-size: 1rem; -$text-size-header1: 1.7rem; -$text-size-header2: 1.25rem; - -$text-color-gray: var(--ant-layout-header-color); -$background-color: var(--ant-layout-light-sider-bg); -$grey: #606060; -$border-color: var(--ant-color-border); -$error-red: #cf1322; - -$blue-color: #40A9FF; -$blue-light: #E6F7FF; -$text-color-blue: #1890FF; - -$blue-color-2: #bae0ff; diff --git a/src/constants/theme.ts b/src/constants/theme.ts deleted file mode 100644 index 6e883f5..0000000 --- a/src/constants/theme.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { theme } from 'antd' - -export const darkTheme = { - algorithm: theme.darkAlgorithm, - cssVar: true, - token: { - colorBgLayout: '#000000' - } -} - -export const lightTheme = { - algorithm: theme.defaultAlgorithm, - cssVar: true, - token: { - colorBgLayout: '#FFFFFF' - } -} diff --git a/src/hooks/redux.ts b/src/hooks/redux.ts deleted file mode 100644 index 82d8f2b..0000000 --- a/src/hooks/redux.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' - -import { AppDispatch, RootState } from '../stores' - -export const useAppDispatch = () => useDispatch() -export const useAppSelector: TypedUseSelectorHook = useSelector diff --git a/src/hooks/useLogout.tsx b/src/hooks/useLogout.tsx deleted file mode 100644 index 2b49bcd..0000000 --- a/src/hooks/useLogout.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { useAuth } from 'isp-ui-kit' -import { useNavigate } from 'react-router-dom' - -import { apiPaths } from '@constants/api/apiPaths.ts' -import { localStorageKeys } from '@constants/localStorageKeys.ts' - -import { getConfigProperty } from '@utils/configUtils.ts' -import { LocalStorage } from '@utils/localStorageUtils.ts' - -import { routePaths } from '@routes/routePaths.ts' - -const useLogout = () => { - const { logout, isLoading } = useAuth() - const navigate = useNavigate() - const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME) - - const logoutUser = () => - logout(apiPaths.logout, { - 'X-APPLICATION-TOKEN': getConfigProperty( - 'APP_TOKEN', - import.meta.env.VITE_APP_TOKEN - ), - [headerName]: LocalStorage.get(localStorageKeys.USER_TOKEN) - }) - .then(() => { - LocalStorage.remove(localStorageKeys.USER_TOKEN) - LocalStorage.remove(localStorageKeys.HEADER_NAME) - navigate(routePaths.login, { replace: true }) - }) - .catch(() => {}) - return { isLoading, logoutUser } -} - -export default useLogout diff --git a/src/hooks/useRole.tsx b/src/hooks/useRole.tsx deleted file mode 100644 index da69254..0000000 --- a/src/hooks/useRole.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { useMemo } from 'react' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import { useAppSelector } from './redux.ts' - -export const useRole = () => { - const { profile } = useAppSelector((state: any) => state.profileReducer) - const role: string = useMemo(() => profile && profile.role, [profile]) - - const hasPermission = (permission: PermissionKeysType) => { - const userPermission = profile.permissions || [] - return userPermission.includes(permission) - } - - return { role, hasPermission } -} - -export default useRole diff --git a/src/index.tsx b/src/index.tsx index 58f33d7..9b0e246 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -10,12 +10,10 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' import { createRoot } from 'react-dom/client' import { Provider } from 'react-redux' import { BrowserRouter } from 'react-router-dom' +import { AdminBase, baseSetupStore } from 'isp-admin-ui-kit' -import App from './components/App.tsx' import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' -import { setupStore } from './stores' - import 'react-resizable/css/styles.css' import 'simplebar-react/dist/simplebar.min.css' @@ -42,14 +40,14 @@ loader.config({ monaco }) loader.init().then() dayjs.locale('ru') -const store = setupStore() +const store = baseSetupStore() setupListeners(store.dispatch) const root = createRoot(document.getElementById('root') as HTMLElement) root.render( - + ) diff --git a/src/pages/AllVersionsPage/all-versions-page.scss b/src/pages/AllVersionsPage/all-versions-page.scss deleted file mode 100644 index 051ff51..0000000 --- a/src/pages/AllVersionsPage/all-versions-page.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import "src/constants/style/styleConst"; - -.all-version-page { - padding: $basic-padding*2 0; - - &__back-btn { - margin-bottom: $basic-margin*2; - } - - &__table { - overflow: auto; - height: calc(100vh - 150px); - } - - &__actions-field { - display: flex; - gap: $basic-margin - } -} diff --git a/src/pages/AllVersionsPage/index.tsx b/src/pages/AllVersionsPage/index.tsx deleted file mode 100644 index 950db2b..0000000 --- a/src/pages/AllVersionsPage/index.tsx +++ /dev/null @@ -1,221 +0,0 @@ -import { - DeleteOutlined, - EyeOutlined, - ReloadOutlined, - SwapOutlined -} from '@ant-design/icons' -import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { useEffect, useState } from 'react' -import { Navigate, useNavigate, useParams } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' - -import CanEdit from '@components/CanEdit' -import CompareVersionModal from '@components/CompareVersionModal' -import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal' - -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -import { useAppSelector } from '@hooks/redux.ts' -import useRole from '@hooks/useRole.tsx' - -import configServiceApi from '@services/configService.ts' -import userServiceApi from '@services/userService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' -import { VersionType } from '@type/version.type.ts' - -import './all-versions-page.scss' - -const AllVersionsPage = () => { - const [showCompareModal, setShowCompareModal] = useState(false) - const [showPreviewModal, setShowPreviewModal] = useState(false) - - const [currentClickVersion, setCurrentClickVersion] = useState( - {} as VersionType - ) - const navigate = useNavigate() - const { id = '', configId = '' } = useParams() - const { - data: versions = [], - isLoading: isVersionLoading, - isError: isVersionError - } = configServiceApi.useGetAllVersionQuery(configId) - const { - data: currentConfig, - isLoading: isCurrentConfigLoading, - isError: isCurrentConfigError - } = configServiceApi.useGetConfigByIdQuery(configId) - const [deleteVersion] = configServiceApi.useDeleteVersionMutation() - const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation() - - const { - data: allUsers = [], - isLoading: isUsersLoading, - isError: isUsersError - } = userServiceApi.useGetAllUsersQuery() - const { profile } = useAppSelector((state) => state.profileReducer) - - const { role, hasPermission } = useRole() - - const isLoading = isVersionLoading || isCurrentConfigLoading || isUsersLoading - const isError = isVersionError || isCurrentConfigError || isUsersError - const isPageAvailable = hasPermission(PermissionKeysType.read) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - if (isLoading) { - return - } - if (isError) { - return - } - - const handeRemoveVersion = (versionId: string) => { - deleteVersion(versionId) - .unwrap() - .then(() => { - message.success('Элемент успешно удален') - }) - .catch(() => { - message.error('Не удалось удалить элемент') - }) - } - const handleRevertVersion = (newData: Record) => { - const sendData = { ...currentConfig, data: newData } as ConfigType - createUpdateConfig(sendData) - .unwrap() - .then(() => { - message.success('Версия успешно восстановлена') - }) - .catch(() => { - message.error('Не удалось восстановить версию') - }) - } - const renderActionsField = (_: unknown, record: VersionType) => { - return ( -
- - - - handleRevertVersion(record.data)} - > -
- ) - } - const columns: ColumnsType = [ - { - key: 'configVersion', - title: 'Версия', - dataIndex: 'configVersion' - }, - { - key: 'createdAt', - title: 'Создано', - dataIndex: 'createdAt', - render: (value: string) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - key: 'user', - title: 'Автор', - dataIndex: 'adminId', - render: (value: number) => { - const user = allUsers.find((user) => user.id === value) - if (user) { - return `${user.lastName} ${user.firstName}` - } - return `${profile.lastName} ${profile.firstName}` - } - }, - { - key: 'actions', - title: 'Действия', - dataIndex: 'actions', - render: renderActionsField - } - ] - return ( -
- {showPreviewModal && ( - setShowPreviewModal(false)} - /> - )} - {showCompareModal && ( - setShowCompareModal(false)} - /> - )} - -
-
record.id} - /> - - - ) -} - -export default AllVersionsPage diff --git a/src/pages/AppAccessPage/app-access-page.scss b/src/pages/AppAccessPage/app-access-page.scss deleted file mode 100644 index 92e4686..0000000 --- a/src/pages/AppAccessPage/app-access-page.scss +++ /dev/null @@ -1,15 +0,0 @@ -@import "src/constants/style/styleConst"; - -.app-access-page { - display: flex; - height: 100%; - - .ant-tree { - background: none; - } - - &__content-wrap { - width: 100%; - overflow-x: scroll; - } -} diff --git a/src/pages/AppAccessPage/app-access-page.type.ts b/src/pages/AppAccessPage/app-access-page.type.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/AppAccessPage/index.tsx b/src/pages/AppAccessPage/index.tsx deleted file mode 100644 index 79d951b..0000000 --- a/src/pages/AppAccessPage/index.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import { Spin } from 'antd' -import { Layout } from 'isp-ui-kit' -import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type' -import { memo, useEffect } from 'react' -import { - createSearchParams, - Navigate, - useNavigate, - useParams, - useSearchParams -} from 'react-router-dom' - -import ListItem from '@widgets/ListItem' - -import AppAccessContent from '@components/AppAccessContent' - -import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts' -import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import appApi from '@services/appService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { SystemTreeAppType } from '@type/app.type.ts' -import { PermissionKeysType } from '@type/roles.type.ts' - -import './app-access-page.scss' - -const { Column, EmptyData } = Layout - -const firstColumnSearchParam = 'search' -const findMethodParam = 'method' - -const AppAccessPage = () => { - const { - data = { originalResponse: [], appList: [] }, - isLoading, - isError - } = appApi.useGetSystemTreeQuery() - - const { appList } = data - const navigate = useNavigate() - const { hasPermission } = useRole() - - const { id: selectedItemId = '' } = useParams() - const [searchParams, setSearchParams] = useSearchParams() - const searchValue = searchParams.get(firstColumnSearchParam) || '' - const canRead = hasPermission(PermissionKeysType.read) - - useEffect(() => { - if (!canRead) { - navigate(routePaths.home) - } - }, [canRead]) - - const handleOnChangeSearchValue = (value: string): void => { - setSearchValue(value, setSearchParams) - } - - const onSelectedItemId = (id: string): void => { - setSearchValue('', setSearchParams, findMethodParam) - setSelectedItemId( - routePaths.appAccess, - id, - createSearchParams(searchParams).toString(), - navigate - ) - } - - if (isLoading) { - return - } - - if (isError) { - return - } - - return ( -
- , - searchValue - )} - renderItems={(item) => } - searchValue={searchValue} - selectedItemId={selectedItemId} - setSelectedItemId={onSelectedItemId} - onChangeSearchValue={handleOnChangeSearchValue} - /> -
- {selectedItemId ? ( - - ) : ( - - )} -
-
- ) -} - -export default memo(AppAccessPage) diff --git a/src/pages/ApplicationsPage/applications-page.scss b/src/pages/ApplicationsPage/applications-page.scss deleted file mode 100644 index c951766..0000000 --- a/src/pages/ApplicationsPage/applications-page.scss +++ /dev/null @@ -1,26 +0,0 @@ -@import "src/constants/style/styleConst"; - -.applications-page { - height: 100%; - display: flex; - - &__list { - .ant-list-item { - flex-direction: column; - align-items: self-start; - - .applications-page__list__desc { - width: auto !important; - font-size: 12px; - } - } - } - - .column-content { - max-height: 100vh; - } - - .modal__wrap{ - min-width: 380px; - } -} diff --git a/src/pages/ApplicationsPage/applications.type.ts b/src/pages/ApplicationsPage/applications.type.ts deleted file mode 100644 index 2198ac3..0000000 --- a/src/pages/ApplicationsPage/applications.type.ts +++ /dev/null @@ -1,57 +0,0 @@ -export interface ApplicationsGroupType { - createdAt: string - description: string - domainId: number - id: number - name: string - updatedAt: string -} - -export type NewApplicationsGroupType = Omit< - ApplicationsGroupType, - 'id' | 'createdAt' | 'updatedAt' -> -export type UpdateApplicationsGroupType = Omit< - ApplicationsGroupType, - 'createdAt' | 'updatedAt' -> - -export interface ApplicationsServiceType { - app: ApplicationAppType - tokens: ApplicationTokenType[] -} - -export type NewApplicationTokenType = { - appId: number - expireTimeMs: number -} - -export interface ApplicationAppType { - createdAt: string - description: string - id: number - name: string - serviceId: number - type: string - updatedAt: string -} - -export type UpdateApplicationAppType = Omit< - ApplicationAppType, - 'createdAt' | 'updatedAt' -> -export type NewApplicationAppType = Omit< - ApplicationAppType, - 'id' | 'createdAt' | 'updatedAt' -> -export type RevokeTokenType = { - appId: number - tokens: string[] -} - -export interface ApplicationTokenType { - appId: number - createdAt: string - expireTime: number - token: string -} diff --git a/src/pages/ApplicationsPage/index.tsx b/src/pages/ApplicationsPage/index.tsx deleted file mode 100644 index c7dc146..0000000 --- a/src/pages/ApplicationsPage/index.tsx +++ /dev/null @@ -1,223 +0,0 @@ -import { message, Spin } from 'antd' -import { Layout } from 'isp-ui-kit' -import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type' -import { useEffect, useMemo, useState } from 'react' -import { useNavigate, useParams, useSearchParams } from 'react-router-dom' - -import ListItem from '@widgets/ListItem' - -import ApplicationsContent from '@components/ApplicationsContent' - -import { - ApplicationsGroupType, - NewApplicationsGroupType, - UpdateApplicationsGroupType -} from '@pages/ApplicationsPage/applications.type.ts' - -import { setSearchValue, setSelectedItemId } from '@utils/columnLayoutUtils.ts' -import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import applicationsGroupApi from '@services/applicationsGroupService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import AppGroupModal from 'src/components/AppGroupModal' - -import './applications-page.scss' - -const { Column, EmptyData } = Layout - -const ApplicationsPage = () => { - const navigate = useNavigate() - const { id: selectedItemId = '' } = useParams() - const [searchParams, setSearchParams] = useSearchParams('') - const { hasPermission } = useRole() - const [currentApplicationsApp, setCurrentApplicationsApp] = useState(0) - - const { - data: applicationsGroup = [], - isError: isErrorApplicationsGroup, - isLoading: isLoadingApplicationsGroup - } = applicationsGroupApi.useGetApplicationsGroupByDomainIdQuery({ id: 1 }) - - const [createApplicationsGroup] = - applicationsGroupApi.useCreateApplicationsGroupMutation() - const [updateApplicationsGroup] = - applicationsGroupApi.useUpdateApplicationsGroupMutation() - - const [deleteApplicationsGroup] = - applicationsGroupApi.useRemoveApplicationsGroupMutation() - - const isPageAvailable = hasPermission(PermissionKeysType.read) - // const hasRevokePermission = hasPermission(PermissionKeysType.write) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - - const [showApplicationsModal, setShowApplicationsModal] = useState({ - addModal: false, - updateModal: false - }) - const searchValue = searchParams.get('search') || '' - - const currentAppGroup = useMemo( - () => - applicationsGroup.find((group) => group.id.toString() === selectedItemId), - [applicationsGroup, selectedItemId] - ) - - if (isErrorApplicationsGroup) { - return - } - - if (isLoadingApplicationsGroup) { - return - } - - const addApplicationModal = () => { - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: true - }) - } - - const updateApplicationModal = () => { - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: true - }) - } - - const handleAddApplicationGroup = (data: ApplicationsGroupType) => { - const newService: NewApplicationsGroupType = { - name: data.name, - description: data.description, - domainId: 1 - } - createApplicationsGroup(newService) - .unwrap() - .then((res) => { - setSelectedItemId( - `${routePaths.applicationsGroup}`, - res.id.toString(), - searchValue, - navigate - ) - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - }) - message.success('Группа приложений успешно создана') - }) - .catch(() => message.error('Не удалось создать группу приложений')) - } - - const handleUpdateApplicationsGroup = (data: ApplicationsGroupType) => { - const updateService: UpdateApplicationsGroupType = { - name: data.name, - description: data.description, - domainId: 1, - id: Number(selectedItemId) - } - - updateApplicationsGroup(updateService) - .unwrap() - .then(() => { - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false - }) - message.success('Группа приложений успешно отредактирована') - }) - .catch(() => - message.error('Не удалось отредактировать группу приложений') - ) - } - - const handleRemoveApplicationsGtoup = () => { - deleteApplicationsGroup([Number(selectedItemId)]) - .unwrap() - .then(() => { - message.success('Элемент удален') - navigate(routePaths.applicationsGroup) - }) - .catch(() => message.error('Ошибка удаления элемента')) - } - - const renderMainContent = () => { - if (!selectedItemId) { - return - } - - return ( - - ) - } - - return ( -
- [], - searchValue - )} - renderItems={(item) => } - searchValue={searchValue} - selectedItemId={selectedItemId} - setSelectedItemId={(itemId) => { - setCurrentApplicationsApp(0) - setSelectedItemId( - `${routePaths.applicationsGroup}`, - itemId, - searchValue, - navigate - ) - }} - onChangeSearchValue={(value) => setSearchValue(value, setSearchParams)} - /> - {renderMainContent()} - - setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - }) - } - /> - - setShowApplicationsModal({ - ...showApplicationsModal, - updateModal: false - }) - } - /> -
- ) -} - -export default ApplicationsPage diff --git a/src/pages/ConfigurationEditorPage/ConfigurationEditor.type.ts b/src/pages/ConfigurationEditorPage/ConfigurationEditor.type.ts deleted file mode 100644 index ed99fae..0000000 --- a/src/pages/ConfigurationEditorPage/ConfigurationEditor.type.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { - ComponentType, - Dispatch, - MutableRefObject, - ReactNode, - SetStateAction -} from 'react' -import { ButtonProps } from 'antd' - -import { - ConfigType, - ResponseSchemaType -} from '@pages/ModulesPage/module.type.ts' - -export interface ConfigurationEditorPropsType { - jsonSchema?: ResponseSchemaType - bufConfig: ConfigType - setBufConfig: Dispatch> - isCurrentConfigLoading: boolean - setDisableBtn?: Dispatch> - submitRef?: MutableRefObject -} - -export interface DescriptionPropsType { - description?: string -} - -export interface Schema { - type: string - dynamic?: boolean -} - -export interface FieldTemplatePropsType { - id: string - classNames?: string - label?: string - rawHelp?: string - required?: boolean - rawDescription?: string - rawErrors?: string[] - children: ReactNode - displayLabel?: boolean - schema: Schema -} - -export interface ArrayFieldTemplatePropsType { - items: { - index: number - children: ReactNode - onDropIndexClick: (index: number) => () => void - }[] - onAddClick: (event: MouseEvent) => void - canAdd: boolean - title: string - titleField?: ComponentType - idSchema: { $id: string } - schema: { description?: string } -} - -export interface ObjectFieldTemplatePropertyType { - name: string - content: ReactNode -} - -export interface SchemaPropertiesType { - [key: string]: { - type?: string - title?: string - } -} - -export interface ObjectFieldTemplatePropsType { - properties: ObjectFieldTemplatePropertyType[] - idSchema: { - $id: string - } - schema: { - properties: SchemaPropertiesType, - additionalProperties: boolean | {type: string} - }, - onAddClick: (schema: any) => () => void, - title: string, - activeTabKey: string - handleTabsChange: (key: string) => void -} - -export interface RemoveButtonProps extends ButtonProps { - icon?: ReactNode; - iconType?: string; -} - -export interface ErrorsObjType { - message: string - name: string - params: { - missingProperty?: string - } - property: string - schemaPath: string - stack: string -} - -export interface SortPropType { - name: string -} diff --git a/src/pages/ConfigurationEditorPage/configuration-editor-page.scss b/src/pages/ConfigurationEditorPage/configuration-editor-page.scss deleted file mode 100644 index 9082f98..0000000 --- a/src/pages/ConfigurationEditorPage/configuration-editor-page.scss +++ /dev/null @@ -1,209 +0,0 @@ -@import "../../constants/style/styleConst"; - -.configuration-editor-page { - display: flex; - flex-direction: column; - -ms-overflow-style: none; /* IE и Edge */ - scrollbar-width: none; - border-left: 1px solid $border-color; - height: 100vh; - overflow: scroll; - padding-bottom: 80px; - - .ant-tabs-nav { - width: 250px; - - .ant-tabs-tab-btn { - text-align: left; - white-space: normal; - } - } - - &::-webkit-scrollbar { - display: none; - } - - .react-json-view { - margin: $basic-margin *3 0 $basic-margin *2 0; - } - - &__header { - display: flex; - justify-content: space-between; - align-items: center; - padding: $basic-padding *2 $basic-padding; - border-bottom: 1px solid $border-color; - } - - &__controll { - display: flex; - } - - &__save-btn { - width: auto; - margin-left: $basic-margin; - } - - &__content { - padding: $basic-padding * 3 $basic-padding; - } - - .rjsf { - display: flex; - - .form-group { - width: 100%; - } - - .ant-form-item-label { - text-align: start; - max-width: 100%; - text-overflow: ellipsis; - - label { - display: inline; - } - } - - .ant-tabs-right { - width: 100%; - justify-content: space-between; - } - - .ant-col-8 .ant-form-item-label { - margin-right: $basic-margin *2; - } - - .ant-form-item-row { - flex-direction: column; - } - - .collapseArray_item_content { - width: 100%; - - .ant-btn { - position: relative; - top: 10px; - } - } - - .ant-collapse-header { - align-items: center; - padding: 4px 11px; - - .ant-collapse-header-text { - display: inline; - max-width: 100%; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - - .ant-btn { - top: 0; - } - } - } - - .collapseArray_item { - display: flex; - width: 100%; - margin-bottom: 24px; - - .ant-form-item { - height: 100%; - align-items: baseline; - align-content: end; - margin: 0; - } - - .anticon-delete { - margin-left: auto; - padding-left: 8px; - } - } - - .ant-col-sm-16 { - max-width: 100%; - } - - .ant-col .ant-form-item-control { - max-width: 100%; - } - - .ant-form-item-control-input-content { - width: 100%; - max-width: 100%; - flex: auto; - - .ant-collapse { - border-radius: 6px; - } - } - - .flex-space-between { - display: flex; - flex-direction: row !important; - justify-content: space-between; - - &__plus { - margin-left: 8px; - } - } - .collapseArray_item { - align-items: center; - } - } - - .collapse { - .configEditor_collapseObject { - border-radius: 6px; - .ant-row { - display: grid; - - grid-template-columns: minmax(0, 30%) minmax(0, 70%) auto; - .ant-col { - height: 100%; - align-content: center; - padding-bottom: 5px; - - .ant-form-item { - height: 100%; - align-items: baseline; - align-content: end; - margin: 0; - } - } - } - .ant-form-item-row { - display: flex; - } - } - } - - .ant-btn-group { - margin-top: 40px; - } - - .ant-row .ant-row-end { - width: 60px; - margin: 0 0 $basic-margin auto !important; - } - - &__form { - padding: $basic-padding; - } - - .modal__wrap { - min-height: 110px; - } - - .confirm-btn { - width: auto; - min-width: 190px; - } - - .error-data { - color: red; - font-size: 16px; - } -} \ No newline at end of file diff --git a/src/pages/ConfigurationEditorPage/index.tsx b/src/pages/ConfigurationEditorPage/index.tsx deleted file mode 100644 index baa5d26..0000000 --- a/src/pages/ConfigurationEditorPage/index.tsx +++ /dev/null @@ -1,222 +0,0 @@ -import { RollbackOutlined } from '@ant-design/icons' -import { Button, Dropdown, MenuProps, message, Radio, RadioChangeEvent, Spin } from 'antd' -import { FC, useEffect, useRef, useState} from 'react' -import { useLocation, useNavigate, useParams } from 'react-router-dom' - -import ConfigurationEditorCode from '@components/ConfigurationEditorCode' -import ConfigurationEditorJson from '@components/ConfigurationEditorJson' - -import configServiceApi from '@services/configService.ts' -import modulesServiceApi from '@services/modulesService.ts' - -import './configuration-editor-page.scss' -import ConfigSchemaModal from '@components/ConfigSchemaModal' -import { cleanEmptyParamsObject, sortObject } from '@utils/objectUtils.ts' -import { ConfigType } from '@pages/ModulesPage/module.type.ts' -import ConfirmConfigModal from '@components/ConfirmConfigModal/ConfirmConfigModal.tsx' -import ErrorConfigModal from '@components/ErrorConfigModal/ErrorConfigModal.tsx' -import ConfigurationEditorForm from '@components/ConfigurationEditorForm' - - - -const ConfigurationEditorPage: FC = () => { - const navigate = useNavigate() - const { moduleId = '' } = useParams() - const { id = '' } = useParams() - const isNew = id === 'new' - const { data: jsonSchema, isLoading: isLoadingJsonSchema } = - modulesServiceApi.useGetByModuleIdQuery(moduleId) - const { - data: currentConfig, - isLoading: isCurrentConfigLoading, - } = configServiceApi.useGetConfigByIdQuery(id) - const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation() - const { state } = useLocation() - const [showConfirmModal, setShowConfirmModal] = useState(false) - const [showSchemeModal, setShowSchemeModal] = useState(false) - const [radioValue, setRadioValue] = useState('json') - const [bufConfig, setBufConfig] = useState() - const [detailsErrors, setDetailsError] = useState({ details: {}, isOpenDetailsErrorModal: false }) - const [disableBtn, setDisableBtn] = useState(false) - const submitRef = useRef(null) - - const formRadio = 'form' - const codeRadio = 'code' - const jsonRadio = 'json' - - useEffect(() => { - setBufConfig(isNew ? {} : sortObject(currentConfig)) - }, [isCurrentConfigLoading]) - - const itemsSaveBtn = [ - { - key: 'save', - label: 'Сохранить' - }, - { - key: 'unsafe', - label: 'Сохранить небезопасно' - } - ] - - const onSaveBtn: MenuProps['onClick'] = (e, upVersion = undefined) => { - const isUnsafe = e.key === 'unsafe' - handleSaveClick(upVersion, isUnsafe, false) - - } - - const onRadioChange = (e: RadioChangeEvent) => { - if (!bufConfig) return - if (submitRef.current && radioValue === formRadio) { - setBufConfig({ ...bufConfig, data: { ...submitRef.current } }) - } - setRadioValue(e.target.value) - } - - const handleSaveClick = (upVersion?: number, unsafe?: boolean, isGoBack?: boolean) => { - let newData = {} - const sentData = - radioValue === formRadio - ? { ...bufConfig, data: { ...submitRef.current } } - : { ...bufConfig } - if (bufConfig) { - if (isNew) { - newData = { - name: state.name, - moduleId: moduleId, - id: '', - version: 0, - data: sentData.data, - unsafe: unsafe - } as ConfigType - } - if (currentConfig) { - newData = { - ...sentData, - version: upVersion ? upVersion : currentConfig.version, - unsafe: unsafe - } as ConfigType - } - } - createUpdateConfig(cleanEmptyParamsObject(newData)) - .unwrap() - .then(({ id }) => { - isNew && navigate(`/${moduleId}/configEditor/${id}`) - isGoBack && navigate(`/modules/${moduleId}/configurations`) - message.success('Конфигурация успешно сохранена') - }) - .catch((e) => { - if (e.data.errorCode === 2004) { - setShowConfirmModal(true) - } - if (e.data.errorCode === 2003) { - setDetailsError({ details: e.data.details, isOpenDetailsErrorModal: true }) - } - if (e.data.errorCode === 400) { - message.error('Невалидный JSON объект') - } - message.error('Ошибка обновления элемента') - }) - } - if (isLoadingJsonSchema || isCurrentConfigLoading) { - return - } - - - const renderContent = () => { - - switch (radioValue) { - case formRadio: - return ( - - ) - case jsonRadio: - return ( - - ) - case codeRadio: - return ( - - ) - } - } - - - return ( -
-
- -

{bufConfig?.name}

-
- - handleSaveClick(undefined, undefined, true)} - disabled={disableBtn} - type="primary" - className="configuration-editor-page__save-btn" - menu={{ items: itemsSaveBtn, onClick: onSaveBtn }} - > - Сохранить и выйти - -
- -
-
- - Форма - - JSON - - Редактор кода - - - {renderContent()} -
- - - setShowSchemeModal(false)} - /> - - setShowConfirmModal(false)} /> - - setDetailsError({details: {}, isOpenDetailsErrorModal: false })} /> - -
- ) -} - -export default ConfigurationEditorPage diff --git a/src/pages/ConfigurationsPage/configurations.scss b/src/pages/ConfigurationsPage/configurations.scss deleted file mode 100644 index a819b65..0000000 --- a/src/pages/ConfigurationsPage/configurations.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import "../../constants/style/styleConst"; - -.configurations { - height: calc(100vh - 80px); - width: 100%; - overflow-y: auto; - min-width: 700px; - - &__buttons { - display: flex; - justify-content: space-between; - margin-bottom: $basic-margin*2; - - } - - .active-configurations-table:last-child { - margin-top: $basic-margin*3; - } -} diff --git a/src/pages/ConfigurationsPage/index.tsx b/src/pages/ConfigurationsPage/index.tsx deleted file mode 100644 index 4d36b18..0000000 --- a/src/pages/ConfigurationsPage/index.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import { Button, Spin } from 'antd' -import { memo, useEffect, useMemo, useState } from 'react' -import { Outlet, useNavigate, useParams } from 'react-router-dom' - -import ActiveConfigurationsTable from '@components/ActiveConfigurationsTable' -import CompareVersionModal from '@components/CompareVersionModal' -import ConfigSchemaModal from '@components/ConfigSchemaModal' -import ConfigurationPreviewModal from '@components/ConfigurationPreviewModal' - -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -import useRole from '@hooks/useRole.tsx' - -import configServiceApi from '@services/configService.ts' -import modulesServiceApi from '@services/modulesService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import './configurations.scss' - -const Configurations = () => { - const { - data: modulesList = [], - isLoading: isModulesLoading, - isError: isModulesError - } = modulesServiceApi.useGetModulesQuery('configurations') - const { id: selectedItemId = '', configId = '' } = useParams() - const { - data = { originalResponse: [], activeConfigs: [], inactiveConfigs: [] }, - isLoading: isConfigsLoading, - isError: isConfigsError - } = configServiceApi.useGetConfigsByModuleIdQuery(selectedItemId) - - const { role, hasPermission } = useRole() - const navigate = useNavigate() - const [isModalOpen, setIsModalOpen] = useState(false) - const [isShowModalOpen, setisShowModalOpen] = useState(false) - const [isCompareModalOpen, setIsCompareModalOpen] = useState(false) - - const [currentConfig, setCurrentConfig] = useState( - {} as ConfigType - ) - const { activeConfigs, inactiveConfigs } = data - const currentModule = useMemo( - () => modulesList.find((module) => module.id === selectedItemId), - [selectedItemId, modulesList] - ) - const isLoading = isModulesLoading || isConfigsLoading - const isError = isModulesError || isConfigsError - const isPageAvailable = hasPermission(PermissionKeysType.read) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - if (isLoading) { - return - } - - if (configId) { - return - } - - return ( -
- setisShowModalOpen(false)} - /> - setIsModalOpen(false)} - /> - {isCompareModalOpen && ( - setIsCompareModalOpen(false)} - /> - )} -
- -
- { - setCurrentConfig(config) - setisShowModalOpen(true) - }} - handleShowCompareModal={(config) => { - setCurrentConfig(config) - setIsCompareModalOpen(true) - }} - /> - { - setCurrentConfig(config) - setisShowModalOpen(true) - }} - handleShowCompareModal={(config) => { - setCurrentConfig(config) - setIsCompareModalOpen(true) - }} - /> -
- ) -} - -export default memo(Configurations) diff --git a/src/pages/ConnectionsPage/connections.scss b/src/pages/ConnectionsPage/connections.scss deleted file mode 100644 index 1ff4bcd..0000000 --- a/src/pages/ConnectionsPage/connections.scss +++ /dev/null @@ -1,48 +0,0 @@ -@import "../../constants/style/styleConst"; - -.connection-page { - &__content { - width: 100%; - - &__wrap-table { - overflow-x: scroll; - height: calc(100vh - 70px); - } - } - - &__endpoint-list { - &__item { - height: 25px; - display: flex; - } - - &__inner-marker { - font-size: 11px; - border: 1px solid var(--ant-color-border); - border-radius: 12px; - padding: 0 4px; - margin: 4px - } - } - - &__no-data { - user-select: none; - display: flex; - flex: 1; - align-items: center; - justify-content: center; - width: 100%; - height: 100%; - font-size: 1.5em; - overflow: hidden; - font-family: PT Sans, sans-serif; - font-weight: 500; - padding: 8px; - text-overflow: ellipsis; - white-space: nowrap; - color: rgba(0, 0, 0, 0.45); - } - &__inner-tag{ - margin-left: $basic-margin !important; - } -} diff --git a/src/pages/ConnectionsPage/index.tsx b/src/pages/ConnectionsPage/index.tsx deleted file mode 100644 index 3106df1..0000000 --- a/src/pages/ConnectionsPage/index.tsx +++ /dev/null @@ -1,156 +0,0 @@ -import { Spin, Table, Tag, Tooltip } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import relativeTime from 'dayjs/plugin/relativeTime' -import { memo, useEffect, useState } from 'react' -import { useNavigate, useParams } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' - -import { - AddressType, - EndpointType, - ModuleStatusType, - ModuleType -} from '@pages/ModulesPage/module.type.ts' - -import useRole from '@hooks/useRole.tsx' - -import modulesServiceApi from '@services/modulesService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import './connections.scss' - -const Connections = () => { - const { data: ConnectionsList = [], isLoading: isModulesLoading } = - modulesServiceApi.useGetModulesQuery('modules') - const { role, hasPermission } = useRole() - const navigate = useNavigate() - const { id } = useParams() - const [obj, setObj] = useState([]) - - const isLoading = isModulesLoading - const isPageAvailable = hasPermission(PermissionKeysType.read) - - useEffect(() => { - const filterId = ConnectionsList.find((item: ModuleType) => item.id === id) - if (filterId && filterId.status) { - setObj(filterId.status) - } - }, [ConnectionsList, id]) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - if (isLoading) { - return - } - - const formatFullDate = (obj: string) => - dayjs(obj).format(dateFormats.fullFormat) - - const renderEndpoints = ({ endpoints }: ModuleStatusType) => { - if (endpoints && endpoints.length) { - return ( -
    - {endpoints.map(({ path, inner }) => ( -
  • - {path} - {inner && ( - - Внутренний - - )} -
  • - ))} -
- ) - } - - return ( -
Нет реализованных методов
- ) - } - - const columns: ColumnsType = [ - { - title: '#', - dataIndex: '', - key: 'num', - render: ( - _val: ModuleStatusType, - _record: ModuleStatusType, - index: number - ) => index + 1 - }, - { - title: 'Версия', - dataIndex: 'version', - key: 'version' - }, - { - title: 'Версия библиотеки', - dataIndex: 'libVersion', - key: 'libVersion' - }, - { - title: 'Адрес', - dataIndex: 'address', - key: 'address', - render: (value: AddressType) => `${value.ip}:${value.port}` - }, - { - title: 'Соединение установлено', - dataIndex: 'establishedAt', - key: 'establishedAt', - render: (val: string) => { - dayjs.extend(relativeTime) - - return ( - {dayjs(val).fromNow()} - ) - } - }, - { - title: 'Реализованные методы', - dataIndex: 'endpoints', - key: 'endpoints', - render: (value: EndpointType[]) => (value && value.length) || '0' - } - ] - - return ( -
-
-
-
record.id} - pagination={false} - dataSource={obj} - columns={columns} - expandable={{ - expandedRowRender: (i) => renderEndpoints(i) - }} - /> - - - - ) -} - -export default memo(Connections) diff --git a/src/pages/ErrorWrapperPage/index.tsx b/src/pages/ErrorWrapperPage/index.tsx deleted file mode 100644 index 69347e0..0000000 --- a/src/pages/ErrorWrapperPage/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Button } from 'antd' -import { Layout } from 'isp-ui-kit' -import { useNavigate } from 'react-router-dom' - -import { routePaths } from '@routes/routePaths.ts' - -const { ErrorPage } = Layout - -const ErrorWrapperPage = () => { - const navigate = useNavigate() - - return ( - - - - ) -} - -export default ErrorWrapperPage diff --git a/src/pages/HomePage/home-page.scss b/src/pages/HomePage/home-page.scss deleted file mode 100644 index 800dd35..0000000 --- a/src/pages/HomePage/home-page.scss +++ /dev/null @@ -1,13 +0,0 @@ -.home-page { - height: 100%; - display: flex; - justify-content: center; - align-items: center; - - background-image: url("/src/assets/images/home-background.png"); - font-size: calc(1.5vw + 1.5vh); - font-family: 'Roboto',sans-serif; - font-style: normal; - font-weight: 400; - line-height: 56px; -} diff --git a/src/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx deleted file mode 100644 index 7943ce5..0000000 --- a/src/pages/HomePage/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import './home-page.scss' - -const HomePage = () => { - return
Добро пожаловать!
-} - -export default HomePage diff --git a/src/pages/LoginPage/index.tsx b/src/pages/LoginPage/index.tsx deleted file mode 100644 index 7004f4f..0000000 --- a/src/pages/LoginPage/index.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { LockOutlined, UserOutlined } from '@ant-design/icons' -import { Button, Divider, Layout } from 'antd' -import { AxiosError } from 'axios' -import { FormComponents, useAuth } from 'isp-ui-kit' -import { useForm } from 'react-hook-form' -import { useNavigate } from 'react-router-dom' - -import { apiPaths } from '@constants/api/apiPaths.ts' -import { ValidationRules } from '@constants/form/validationRules.ts' -import { localStorageKeys } from '@constants/localStorageKeys.ts' -import { messages } from '@constants/messages.ts' - -import { getConfigProperty } from '@utils/configUtils.ts' -import { LocalStorage } from '@utils/localStorageUtils.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { MSPError } from '@type/index.ts' -import { LoginRequest } from '@type/login.type.ts' - -import './login-page.scss' - -const passwordLoginEnabled = getConfigProperty('ENABLE_PASSWORD_LOGIN', true) - -const LoginPage = () => { - const { login, isLoading } = useAuth() - const { handleSubmit, control, setError } = useForm({ - mode: 'onChange' - }) - const navigate = useNavigate() - - const setFormError = (statusText: string, message: string): void => { - setError('email', {}) - setError('password', { - message, - type: statusText - }) - } - - const handleError = (err: AxiosError): void => { - const { response, status } = err - if (response && status === 401) { - setFormError(response.statusText, messages.loginError) - } else { - setFormError('serverError', messages.serverError) - } - } - - const handleSubmitForm = (data: LoginRequest): void => { - login(apiPaths.login, data, { - 'X-APPLICATION-TOKEN': getConfigProperty( - 'APP_TOKEN', - import.meta.env.VITE_APP_TOKEN - ) - }) - .then((response) => { - LocalStorage.set(localStorageKeys.HEADER_NAME, response.headerName) - LocalStorage.set(localStorageKeys.USER_TOKEN, response.token) - const redirectUrl = - sessionStorage.getItem('prevRoute') || routePaths.home - navigate(redirectUrl, { replace: true }) - }) - .catch((err: AxiosError) => handleError(err)) - } - - const renderInternalAuthForm = () => { - if (!passwordLoginEnabled) { - return null - } - - return ( - <> - } - placeholder="Логин" - rules={{ required: ValidationRules.required }} - /> - } - type="password" - placeholder="Пароль" - rules={{ required: ValidationRules.required }} - /> - - - ) - } - - return ( - -
-
-

- Вход в систему -

- - {renderInternalAuthForm()} - -
-
- ) -} - -export default LoginPage diff --git a/src/pages/LoginPage/login-page.scss b/src/pages/LoginPage/login-page.scss deleted file mode 100644 index 71f043a..0000000 --- a/src/pages/LoginPage/login-page.scss +++ /dev/null @@ -1,53 +0,0 @@ -@import "src/constants/style/styleConst"; - -.login-page { - height: 100vh; - background: $background-color; - - display: flex; - - .ant-input { - width: 300px; - text-align: center; - } - - .ant-divider-horizontal { - margin-top: $basic-margin !important; - } - - .ant-form-item-explain-error { - margin-bottom: $basic-margin; - } - - .color { - color: $text-color-gray; - } - - &__content { - max-width: 360px; - margin: auto; - display: flex; - flex-direction: column; - - &__title { - text-align: center; - font-family: 'Roboto', sans-serif; - font-size: $text-size; - line-height: 20px; - color: $text-color-gray; - } - - &__submit-sudir-btn { - background: #0000000f; - margin-top: 4 * $basic-margin; - - &:hover { - background: rgba(0, 0, 0, 0.09) !important; - } - } - } - - .requiredInput::after { - content: ""; - } -} diff --git a/src/pages/ModulesPage/index.tsx b/src/pages/ModulesPage/index.tsx deleted file mode 100644 index f51df34..0000000 --- a/src/pages/ModulesPage/index.tsx +++ /dev/null @@ -1,214 +0,0 @@ -import { ExclamationCircleOutlined } from '@ant-design/icons' -import { Badge, List, message, Spin, Tag, Tooltip } from 'antd' -import { compareVersions } from 'compare-versions' -import { Layout } from 'isp-ui-kit' -import { useEffect, useState } from 'react' -import { - createSearchParams, - useLocation, - useNavigate, - useParams, - useSearchParams -} from 'react-router-dom' - -import ModuleTabs from '@components/ModuleTabs' - -import { ModuleType } from '@pages/ModulesPage/module.type.ts' - -import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import modulesServiceApi from '@services/modulesService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' - -import './modules-page.scss' - -const { Column } = Layout - -const ModulesPage = () => { - const [activeTab, setActiveTab] = useState('configurations') - const { id: selectedItemId = '' } = useParams() - const navigate = useNavigate() - const { role, hasPermission } = useRole() - const [searchParams, setSearchParams] = useSearchParams() - const { data: ModulesList = [], isLoading: isModulesLoading } = - modulesServiceApi.useGetModulesQuery('modules', { - pollingInterval: 5000, - skipPollingIfUnfocused: true - }) - const [removeModule] = modulesServiceApi.useRemoveModuleMutation() - const location = useLocation() - - const searchValue = searchParams.get('search') || '' - const isPageAvailable = hasPermission(PermissionKeysType.read) - const isRemoveModule = hasPermission(PermissionKeysType.write) - const isLoading = isModulesLoading - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.profile) - message.error('Страница не найдена') - } - }, [isPageAvailable]) - - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - useEffect(() => { - const url = location.pathname.substring( - location.pathname.lastIndexOf('/') + 1 - ) - switch (url) { - case 'configurations': - return setActiveTab('configurations') - case 'connections': - return setActiveTab('connections') - } - }, [location]) - - const setSelectedItemId = (id: string): void => { - if (id) { - navigate( - { - pathname: `${routePaths.modules}/${id}/${activeTab}`, - search: createSearchParams(searchParams).toString() - }, - { replace: true } - ) - } - } - - const handleOnChangeSearchValue = (value: string): void => { - setSearchParams((prev) => { - if (!value) { - prev.delete('search') - } else { - prev.set('search', value) - } - return prev - }) - } - - const handleRemoveModule = (id: string) => { - removeModule(id) - .unwrap() - .then(() => { - navigate(routePaths.modules) - message.success('Модуль успешно удален').then() - setSelectedItemId('') - }) - .catch(() => message.error('Не удалось удалить модуль')) - } - - const versionCompare = (versions: string[]) => { - const sorted = (versions || ['']).sort(compareVersions) - const firstVersion = sorted[0] - for (let i = 1; i < sorted.length; i++) { - if (compareVersions(firstVersion, sorted[i]) !== 0) { - return false - } - } - return true - } - - const getLastVersion = (versions: string[]) => { - const sorted = (versions || ['']).sort(compareVersions) - return sorted[sorted.length - 1] - } - - if (isLoading) { - return - } - - const currentModule = ModulesList.find( - (item: ModuleType) => item.id.toString() === selectedItemId - ) - - const renderItems = (item: ModuleType) => { - const isSame = versionCompare(item?.status?.map((i) => i.version)) - const textTooltip = isSame - ? 'Активны экземпляры одинаковых версий' - : 'Активны экземпляры разных версий' - const lastVersion = getLastVersion(item.status?.map((i) => i.version)) - - const renderVersion = () => { - if (!isSame && lastVersion) { - return ( - } color="warning"> - {lastVersion} - - ) - } - if (isSame && lastVersion) { - return {lastVersion} - } - return '' - } - - return ( - - - - {item.name} - - {renderVersion()} - - - } - description={ -
- - активные экземпляры: - - -
- } - /> -
-
- ) - } - - return ( -
- - -
- ) -} - -export default ModulesPage diff --git a/src/pages/ModulesPage/module.type.ts b/src/pages/ModulesPage/module.type.ts deleted file mode 100644 index 35782f7..0000000 --- a/src/pages/ModulesPage/module.type.ts +++ /dev/null @@ -1,104 +0,0 @@ -export interface RequiredModuleType { - id: string - name: string - required: boolean -} - -export interface AddressType { - ip: string - port: string -} - -export interface EndpointType { - extra: Record - inner: boolean - path: string - userAuthRequired: boolean -} - -export interface ModuleStatusType { - establishedAt: string - libVersion: string - version: string - address: AddressType - endpoints: EndpointType[] -} - -export interface ConfigType { - active: boolean - commonConfigs: string[] - createdAt: string - data: Record - description: string - id: string - moduleId: string - name: string - updatedAt: string - valid: boolean - version: number - unsafe?: boolean -} - -export interface JSONSchema { - $ref?: string - $schema?: string - additionalItems?: boolean | JSONSchema - additionalProperties?: boolean | JSONSchema - allOf?: JSONSchema[] - anyOf?: JSONSchema[] - default?: any - definitions?: Record - dependencies?: Record - description?: string - enum?: any[] - exclusiveMaximum?: boolean - exclusiveMinimum?: boolean - format?: string - items?: JSONSchema | JSONSchema[] - maxItems?: number - maxLength?: number - maxProperties?: number - maximum?: number - media?: JSONSchema - minItems?: number - minLength?: number - minProperties?: number - minimum?: number - multipleOf?: number - not?: JSONSchema - oneOf?: JSONSchema[] - pattern?: string - patternProperties?: Record - properties?: Record - required?: string[] - title?: string - type?: string | string[] - uniqueItems?: boolean -} - -export interface ModuleType { - active: boolean - configs: ConfigType[] - createdAt: string - id: string - lastConnectedAt: string - lastDisconnectedAt: string - name: string - requiredModules: RequiredModuleType[] - status: ModuleStatusType[] - configSchema: JSONSchema -} - -export interface ResponseSchemaType { - createdAt: string - id: string - moduleId: string - schema: JSONSchema - updatedAt: string - version: string -} -export interface ConfigResponse { - originalResponse: ConfigType[] - activeConfigs: ConfigType[] - inactiveConfigs: ConfigType[] -} diff --git a/src/pages/ModulesPage/modules-page.scss b/src/pages/ModulesPage/modules-page.scss deleted file mode 100644 index c3ad172..0000000 --- a/src/pages/ModulesPage/modules-page.scss +++ /dev/null @@ -1,47 +0,0 @@ -@import "../../constants/style/styleConst"; - -.modules-page { - height: 100%; - display: flex; - &__tabs { - padding: 0 $basic-padding*2; - width: 100%; - overflow-x: scroll; - } - - .ant-tag { - height: 22px; - margin: 0; - } - - .module-item { - width: 100%; - - &__name { - display: flex; - padding-bottom: 5px; - justify-content: space-between; - width: 100%; - } - - &__content { - display: flex; - justify-content: space-between; - align-items: center; - - &__description { - color: $grey; - display: inline-block; - } - } - } - - &__content { - overflow-x: scroll; - width: 100%; - } - - .column .column__items__item span { - width: fit-content !important; - } -} diff --git a/src/pages/NotFound/index.tsx b/src/pages/NotFound/index.tsx deleted file mode 100644 index 33b6070..0000000 --- a/src/pages/NotFound/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Button } from 'antd' -import { Layout } from 'isp-ui-kit' -import { useNavigate } from 'react-router-dom' - -import { routePaths } from '@routes/routePaths.ts' - -const { NotFoundPage } = Layout - -const NotFound = () => { - const navigate = useNavigate() - return ( - - - - ) -} - -export default NotFound diff --git a/src/pages/ProfilePage/index.tsx b/src/pages/ProfilePage/index.tsx deleted file mode 100644 index 96c212f..0000000 --- a/src/pages/ProfilePage/index.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { Button, Descriptions, Popconfirm } from 'antd' -import { useContext, useEffect, useState } from 'react' - -import PermissionList from '@widgets/PermissionList' - -import ChangePasswordModal from '@components/ChangePasswordModal' -import RoleList from '@components/RoleList' - -import { useAppSelector } from '@hooks/redux.ts' -import useLogout from '@hooks/useLogout.tsx' - -import { Context } from '@stores/index.tsx' - -import './profile-page.scss' - -const ProfilePage = () => { - const [isModalOpen, setIsModalOpen] = useState(false) - const { profile } = useAppSelector((state) => state.profileReducer) - const { logoutUser, isLoading } = useLogout() - const { changeTheme, setChangeTheme } = useContext(Context) - - const onChangeTheme = () => { - setChangeTheme((prev: any) => !prev) - } - - useEffect(() => { - localStorage.setItem('theme', JSON.stringify(changeTheme)) - }, [changeTheme]) - - return ( -
- setIsModalOpen(false)} - open={isModalOpen} - /> -
-

{`${profile.lastName} ${profile.firstName}`}

- -
-
-
- - {profile.email} - -
-
- - -
- - - - -
-
- ) -} - -export default ProfilePage diff --git a/src/pages/ProfilePage/profile-page.scss b/src/pages/ProfilePage/profile-page.scss deleted file mode 100644 index 99fa3af..0000000 --- a/src/pages/ProfilePage/profile-page.scss +++ /dev/null @@ -1,34 +0,0 @@ -@import '../../constants/style/styleConst'; - -.profile-page { - height: 100vh; - overflow: auto; - border: 1px solid var(--ant-color-border); - padding: $basic-padding * 2; - display: flex; - flex-direction: column; - align-items: start; - - &__header { - display: flex; - justify-content: space-between; - width: 100%; - } - - &__title { - font-size: $text-size-header1; - } - - &__user-info { - margin-top: $basic-padding; - - span { - font-size: $text-size !important; - } - } - - &__actions { - display: flex; - gap: $basic-margin - } -} diff --git a/src/pages/ProfilePage/profile-page.type.ts b/src/pages/ProfilePage/profile-page.type.ts deleted file mode 100644 index c1e8d39..0000000 --- a/src/pages/ProfilePage/profile-page.type.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts' - -export type ProfileDataType = { - email: string - firstName: string - lastName: string - role: string - roles: number[] - permissions: string[] - idleTimeoutMs: number -} - -export type ProfileType = { - profile: ProfileDataType - status: StateProfileStatus - error: string -} - -export type ChangeProfilePassword = { - oldPassword: string - newPassword: string -} - -export type UIDataType = { - name: string - primaryColor: string -} - -export type UIType = { - ui: UIDataType - status: StateProfileStatus - error: string -} diff --git a/src/pages/RolesPage/index.tsx b/src/pages/RolesPage/index.tsx deleted file mode 100644 index 6b5a33f..0000000 --- a/src/pages/RolesPage/index.tsx +++ /dev/null @@ -1,218 +0,0 @@ -import { List, message, Spin, Tooltip } from 'antd' -import { Layout } from 'isp-ui-kit' -import { useEffect } from 'react' -import { UseFormSetError } from 'react-hook-form' -import { - createSearchParams, - useLocation, - useNavigate, - useParams, - useSearchParams -} from 'react-router-dom' - -import RolesContent from '@components/RolesContent' - -import { filterFirstColumnItems } from '@utils/firstColumnUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import roleApi from '@services/roleService.ts' -import userServiceApi from '@services/userService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { NewRoleType, PermissionKeysType, RoleType } from '@type/roles.type.ts' - -import './roles-page.scss' -import { useAppDispatch } from '@hooks/redux.ts' -import { fetchProfile } from '@stores/redusers/ActionCreators.ts' - -const { Column, EmptyData, NoData } = Layout - -const RolesPage = () => { - const { id: selectedItemId = '' } = useParams() - const navigate = useNavigate() - const location = useLocation() - const fromApp = location.state?.fromApp || false - const { role, hasPermission } = useRole() - const [searchParams, setSearchParams] = useSearchParams() - const dispatch = useAppDispatch() - const searchValue = searchParams.get('search') || '' - const { data: permissionList = [], isLoading: isPermissionLoading } = - userServiceApi.useGetAllPermissionsQuery() - const { data = [], isLoading: isRolesLoading } = roleApi.useGetAllRolesQuery() - const [createRole] = roleApi.useCreateRoleMutation() - const [updateRole] = roleApi.useUpdateRoleMutation() - const [removeRole] = roleApi.useRemoveRoleMutation() - - const isPageAvailable = hasPermission(PermissionKeysType.role_view) - const isAddRolePermissions = hasPermission(PermissionKeysType.role_add) - const isRemoveRolePermissions = hasPermission(PermissionKeysType.role_delete) - const isLoading = isPermissionLoading || isRolesLoading - - const isNew = selectedItemId === 'new' - - useEffect(() => { - if (!fromApp) { - navigate(routePaths.roles) - } - }, [fromApp]) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - const setSelectedItemId = (id: string): void => { - navigate( - { - pathname: `${routePaths.roles}/${id}`, - search: createSearchParams(searchParams).toString() - }, - { replace: true, state: { fromApp: true } } - ) - } - - const handleOnChangeSearchValue = (value: string): void => { - setSearchParams((prev) => { - if (!value) { - prev.delete('search') - } else { - prev.set('search', value) - } - return prev - }) - } - - const handeOnAddItem = () => setSelectedItemId('new') - - const handleUpdateRole = ( - formValue: RoleType | NewRoleType, - setError: UseFormSetError - ) => { - updateRole(formValue as RoleType) - .unwrap() - .then(() => { - dispatch(fetchProfile()) - message.success('Элемент успешно добавлен').then() - }) - .catch((error) => { - const { status } = error - if (status === 409) { - setError('name', { - message: 'Роль с таким названием уже существует' - }) - } - message.error('Не удалось сохранить роль') - }) - } - - const handleCreateRole = ( - formValue: NewRoleType, - setError: UseFormSetError - ) => { - createRole(formValue) - .unwrap() - .then((res) => { - message.success('Элемент успешно добавлен').then() - setSelectedItemId(res.id.toString()) - }) - .catch((error) => { - const { status } = error - if (status === 409) { - setError('name', { - message: 'Роль с таким названием уже существует' - }) - } - message.error('Не удалось добавить роль').then() - }) - } - - const handleRemoveRole = (id: string) => { - const idAsNumber = parseInt(id, 10) - removeRole(idAsNumber) - .unwrap() - .then(() => { - message.success('Элемент успешно удален').then() - setSelectedItemId('') - }) - .catch(() => message.error('Не удалось удалить роль')) - } - - if (isLoading) { - return - } - - const currentRole = data - ? data.find((item) => item.id.toString() === selectedItemId) - : null - const renderItems = (item: RoleType) => ( - - - id: {item.id}} - /> - - - ) - - const renderMainContent = () => { - if (isNew) { - return ( - - ) - } - - if (!selectedItemId) { - return - } - - if (!currentRole) { - return - } - - return ( - - ) - } - - return ( -
- -
{renderMainContent()}
-
- ) -} - -export default RolesPage diff --git a/src/pages/RolesPage/roles-page.scss b/src/pages/RolesPage/roles-page.scss deleted file mode 100644 index 2b64e23..0000000 --- a/src/pages/RolesPage/roles-page.scss +++ /dev/null @@ -1,17 +0,0 @@ -@import "../../constants/style/styleConst"; - -.roles-page { - height: 100%; - display: flex; - - .role-item { - &__id { - color: $grey; - } - } - - &__content { - overflow-x: scroll; - width: 100% - } -} diff --git a/src/pages/SecurityLogPage/index.tsx b/src/pages/SecurityLogPage/index.tsx deleted file mode 100644 index 39e68ca..0000000 --- a/src/pages/SecurityLogPage/index.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { Pagination, Spin, Table } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { useEffect, useState } from 'react' -import { useNavigate } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' - -import { getUserFullName } from '@utils/userUtils/getFullNameUtil' - -import useRole from '@hooks/useRole' - -import securityLogServiceApi from '@services/securityLogService' -import userServiceApi from '@services/userService' - -import { routePaths } from '@routes/routePaths.ts' - -import { LogType } from '@type/log.type' -import { PermissionKeysType } from '@type/roles.type' - -import './security-log-page.scss' - -const limit = 10 - -const SecurityLogPage = () => { - const [getAllLogs, { data, isLoading: isLoadingLogs }] = - securityLogServiceApi.useGetAllLogsMutation() - - const { data: allUsers = [], isLoading: isUsersLoading } = - userServiceApi.useGetAllUsersQuery() - const { role, hasPermission } = useRole() - const navigate = useNavigate() - - const [currentPage, setCurrentPage] = useState(1) - - const isLoading = isUsersLoading || isLoadingLogs - const isPageAvailable = hasPermission(PermissionKeysType.security_log_view) - - useEffect(() => { - getAllLogs({ limit, offset: 0 }) - }, []) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - const handleChangePagination = (page: number) => { - setCurrentPage(page) - getAllLogs({ limit, offset: (page - 1) * limit }) - } - - if (isLoading || !data) { - return - } - - const columns: ColumnsType = [ - { - title: 'Пользователь', - dataIndex: 'userId', - key: 'userId', - render: (value) => { - const user = allUsers.find((el) => el.id === value) - if (user) { - return getUserFullName(user) - } - } - }, - { - title: 'Время события', - dataIndex: 'createdAt', - key: 'createdAt', - render: (value) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - title: 'Действие', - dataIndex: 'message', - key: 'message', - render: (value: string) => - value.split('\n').map((line) =>

{line}

) - } - ] - - const { totalCount, items } = data - - return ( -
-
- - Просмотр журналов ИБ - -
-
-
-
record.id} - pagination={false} - dataSource={items} - columns={columns} - /> - -
- -
- - - ) -} - -export default SecurityLogPage diff --git a/src/pages/SecurityLogPage/security-log-page.scss b/src/pages/SecurityLogPage/security-log-page.scss deleted file mode 100644 index d66bfb5..0000000 --- a/src/pages/SecurityLogPage/security-log-page.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import "src/constants/style/styleConst"; - -.security-log-page { - height: 100%; - border: 1px solid $border-color; - - &__header { - border-bottom: 1px solid $border-color; - padding: 0 3 * $basic-padding; - - &__title { - padding: 3 * $basic-padding 0; - display: inline-block; - font-weight: 500; - font-size: 20px; - line-height: 28px; - } - } - - &__content { - padding: 2 * $basic-padding 3 * $basic-padding; - - &__wrap-table { - overflow-x: scroll; - height: calc(100vh - 160px); - } - - &__pagination { - margin-top: 20px; - display: flex; - justify-content: flex-end; - } - - } -} diff --git a/src/pages/SessionsPage/index.tsx b/src/pages/SessionsPage/index.tsx deleted file mode 100644 index 29a3dc0..0000000 --- a/src/pages/SessionsPage/index.tsx +++ /dev/null @@ -1,180 +0,0 @@ -import { LogoutOutlined } from '@ant-design/icons' -import { - Button, - Popconfirm, - Spin, - Table, - message, - Pagination, - Tooltip -} from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { useEffect, useState } from 'react' -import { useNavigate } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' -import { SessionStatusKeysType, sessionStatuses } from '@constants/statuses' - -import { getUserFullName } from '@utils/userUtils/getFullNameUtil' - -import useRole from '@hooks/useRole' - -import sessionServiceApi from '@services/sessionService' -import userServiceApi from '@services/userService' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' -import { SessionType } from '@type/session.type' - -import './sessions-page.scss' - -const limit = 10 - -const SessionsPage = () => { - const [offset, setOffset] = useState(0) - const { data, isLoading: isLoadingSession } = - sessionServiceApi.useGetAllSessionsQuery({ limit, offset }) - const [revokeSession] = sessionServiceApi.useRevokeSessionMutation() - const { data: allUsers = [], isLoading: isUsersLoading } = - userServiceApi.useGetAllUsersQuery() - const { role, hasPermission } = useRole() - const navigate = useNavigate() - const [currentPage, setCurrentPage] = useState(1) - - const isLoading = isUsersLoading || isLoadingSession - - const isPageAvailable = hasPermission(PermissionKeysType.session_view) - const hasRevokePermission = hasPermission(PermissionKeysType.session_revoke) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - const handleChangePagination = (page: number) => { - setCurrentPage(page) - const currentOffset = (page - 1) * limit - setOffset(currentOffset) - } - - const handleRevokeSessions = (id: number) => { - revokeSession(id) - .unwrap() - .then(() => message.success('Сессия успешно завершена')) - .catch(() => message.error('Не удалось завершить сессию')) - } - - if (isLoading || !data) { - return - } - - const columns: ColumnsType = [ - { - title: 'Пользователь', - dataIndex: 'userId', - key: 'userId', - render: (value) => { - const user = allUsers.find((el) => el.id === value) - return user && getUserFullName(user) - } - }, - { - title: 'Идентификатор', - dataIndex: 'id', - key: 'id' - }, - { - title: 'Дата начала сессии', - dataIndex: 'createdAt', - key: 'createdAt', - render: (value) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - title: 'Дата окончания сессии', - dataIndex: 'expiredAt', - key: 'expiredAt', - render: (value) => { - return dayjs(value).format(dateFormats.fullFormat) - } - }, - { - title: 'Статус', - dataIndex: 'status', - key: 'status', - render: (value: SessionStatusKeysType) => sessionStatuses[value] - }, - { - dataIndex: 'actions', - key: 'actions', - render: (_, record) => { - if (record.status !== SessionStatusKeysType.allowed) { - return null - } - return ( - <> - {hasRevokePermission && ( - handleRevokeSessions(record.id)} - > - -
record.id} - pagination={false} - dataSource={items} - columns={columns} - /> - -
- -
- - - ) -} - -export default SessionsPage diff --git a/src/pages/SessionsPage/sessions-page.scss b/src/pages/SessionsPage/sessions-page.scss deleted file mode 100644 index 05e47a9..0000000 --- a/src/pages/SessionsPage/sessions-page.scss +++ /dev/null @@ -1,41 +0,0 @@ -@import "src/constants/style/styleConst"; - -.sessions-page { - height: 100%; - border: 1px solid $border-color; - - &__header { - border-bottom: 1px solid $border-color; - padding: 0 3 * $basic-padding; - - &__title { - padding: 3 * $basic-padding 0; - display: inline-block; - font-weight: 500; - font-size: 20px; - line-height: 28px; - } - } - - &__content { - padding: 2 * $basic-padding 3 * $basic-padding; - - &__wrap-table { - overflow-x: scroll; - height: calc(100vh - 160px); - } - - &__table { - &__logout-btn { - color: $blue-color; - background: $blue-light; - } - } - - &__pagination { - margin-top: 20px; - display: flex; - justify-content: flex-end; - } - } -} diff --git a/src/pages/UserEditor/index.tsx b/src/pages/UserEditor/index.tsx deleted file mode 100644 index 198e76b..0000000 --- a/src/pages/UserEditor/index.tsx +++ /dev/null @@ -1,253 +0,0 @@ -import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons' -import { Button, message, Spin } from 'antd' -import dayjs from 'dayjs' -import { FormComponents } from 'isp-ui-kit' -import { useEffect } from 'react' -import { useForm } from 'react-hook-form' -import { useLocation, useNavigate } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' -import { ValidationRules } from '@constants/form/validationRules.ts' - -import { findExclusiveRole } from '@utils/roleUtils.ts' - -import useRole from '@hooks/useRole.tsx' - -import roleApi from '@services/roleService.ts' -import userServiceApi from '@services/userService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType, RoleType } from '@type/roles.type.ts' -import { UserType } from '@type/user.type.ts' - -import { LabelItem } from 'isp-ui-kit/dist/FormComponents/formTypes' - -import './user-editor.scss' - -const UserEditor = () => { - const location = useLocation() - const navigate = useNavigate() - const state = location.state as UserType - const isNew = location.pathname.includes('new') - const fromApp = location.state?.fromApp || false - const { hasPermission } = useRole() - - const hasCreateUserPermission = hasPermission(PermissionKeysType.write) - const hasUpdateUserPermission = hasPermission(PermissionKeysType.write) - - const [createUser] = userServiceApi.useCreateUserMutation() - const { data: roles = [], isLoading } = roleApi.useGetAllRolesQuery() - - const [updateUser] = userServiceApi.useUpdateUserMutation() - - const isSaveBtnAvailable = isNew - ? hasCreateUserPermission - : hasUpdateUserPermission - - const { - control, - formState: { isDirty }, - getValues, - setValue, - watch, - setError - } = useForm({ - defaultValues: isNew - ? { - description: '', - email: '', - firstName: '', - password: '', - roles: [] - } - : state, - mode: 'onChange' - }) - - useEffect(() => { - if (isNew && !fromApp) { - navigate(routePaths.users) - } - }, [fromApp]) - - useEffect(() => { - const subscription = watch((value, { name, type }) => { - if (name === 'roles' && type === 'change') { - const exclusiveRole = findExclusiveRole(roles, value.roles as number[]) - if (exclusiveRole) { - if (value.roles && value.roles.length > 1) { - message.error( - <> - Роль: {exclusiveRole.name} несовместима с - другими ролями - - ) - } - setValue('roles', [exclusiveRole.id]) - } - } - }) - return () => subscription.unsubscribe() - }, [watch]) - - const sendForm = () => { - if (isNew) { - const newUser = { - email: getValues().email, - password: getValues().password, - description: getValues().description, - firstName: getValues().firstName, - lastName: getValues().lastName, - roles: getValues().roles - } - createUser(newUser) - .unwrap() - .then(() => { - message.success('Пользователь успешно создан') - navigate(routePaths.users) - }) - .catch((error) => { - const { status } = error - if (status === 409) { - setError('email', { - message: 'Пользователь с таким Email уже существует' - }) - } - message.error('Произошла ошибка создания пользователя') - }) - } else { - const formData = getValues() - delete formData.lastSessionCreatedAt - updateUser(formData) - .unwrap() - .then(() => { - message.success('Пользователь успешно изменен') - navigate(routePaths.users) - }) - .catch((error) => { - const { status } = error - if (status === 409) { - setError('email', { - message: 'Пользователь с таким Email уже существует' - }) - } - message.error('Произошла ошибка обновления пользователя') - }) - } - } - const createSelectOptions = (role: RoleType[]) => { - const options: LabelItem[] = role.map((r) => ({ - value: r.id, - label: r.name - })) - return options - } - if (isLoading) { - return - } - return ( -
-
-
- -
- - {isNew ? ( - '' - ) : ( - - {state.lastSessionCreatedAt && ( - <> - Последняя сессия   - {dayjs(state.lastSessionCreatedAt).format( - dateFormats.fullFormat - )} - - )} - - )} -
- -
-
-
- -
-
- -
-
- -
- - {isNew && ( -
- -
- )} -
- -
-
- -
-
- -
- ) -} -export default UserEditor diff --git a/src/pages/UserEditor/user-editor.scss b/src/pages/UserEditor/user-editor.scss deleted file mode 100644 index 9356347..0000000 --- a/src/pages/UserEditor/user-editor.scss +++ /dev/null @@ -1,65 +0,0 @@ -@import "../../constants/style/styleConst"; - -.user-editor { - height: 100%; - border: 1px solid $border-color; - - &__header { - border-bottom: 1px solid $border-color; - padding: 22px 24px 0; - - &__nav { - display: flex; - align-items: center; - margin-bottom: $basic-margin* 2.5; - - &__backBtn { - margin-left: -$basic-margin; - margin-right: $basic-margin; - } - } - - &__name { - font-family: 'Roboto', sans-serif; - font-style: normal; - font-weight: 500; - font-size: 20px; - line-height: 28px; - color: #000; - - } - - &__btn { - margin-left: auto; - } - } - - &__status { - font-family: 'Roboto', sans-serif; - font-size: 16px; - line-height: 24px; - } - - &__content { - &__wrap { - overflow-x: scroll; - height: calc(100vh - 80px); - } - - .ant-form-item { - margin: 0; - } - - &__name, &__description, &__email, &__roles, &__password { - padding: $basic-padding*1.5 $basic-padding*3; - - h3 { - padding-bottom: $basic-padding*1; - font-family: 'Roboto', sans-serif; - font-weight: 400; - font-size: 14px; - line-height: 22px - } - } - } -} diff --git a/src/pages/UsersPage/index.tsx b/src/pages/UsersPage/index.tsx deleted file mode 100644 index ed0c688..0000000 --- a/src/pages/UsersPage/index.tsx +++ /dev/null @@ -1,249 +0,0 @@ -import { - DeleteOutlined, - EditOutlined, - LockOutlined, - PlusSquareOutlined, - UnlockOutlined -} from '@ant-design/icons' -import { Button, message, Popconfirm, Spin, Table, Tag, Tooltip } from 'antd' -import { ColumnsType } from 'antd/es/table' -import dayjs from 'dayjs' -import { useEffect } from 'react' -import { useNavigate } from 'react-router-dom' - -import { dateFormats } from '@constants/date.ts' - -import { getUserFullName } from '@utils/userUtils/getFullNameUtil.ts' - -import useRole from '@hooks/useRole.tsx' - -import roleApi from '@services/roleService.ts' -import userServiceApi from '@services/userService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { PermissionKeysType } from '@type/roles.type.ts' -import { UserType } from '@type/user.type.ts' - -import './users-page.scss' - -const UsersPage = () => { - const { data: allUsers = [], isLoading: isUsersLoading } = - userServiceApi.useGetAllUsersQuery() - const { data: roles, isLoading: isRolesLoading } = - roleApi.useGetAllRolesQuery() - const [blockUser] = userServiceApi.useBlockUserMutation() - const [deleteUser] = userServiceApi.useDeleteUserMutation() - const { role, hasPermission } = useRole() - const navigate = useNavigate() - - const isLoading = isRolesLoading || isUsersLoading - - const isPageAvailable = hasPermission(PermissionKeysType.user_view) - const hasBlockUserPermission = hasPermission(PermissionKeysType.user_block) - const hasDeleteUserPermission = hasPermission(PermissionKeysType.user_delete) - const hasUpdateUserPermission = hasPermission(PermissionKeysType.user_update) - const hasCreateUserPermission = hasPermission(PermissionKeysType.user_create) - - useEffect(() => { - if (!isPageAvailable) { - navigate(routePaths.home) - } - }, [isPageAvailable]) - - useEffect(() => { - if (!role) { - navigate(routePaths.error) - } - }, [role]) - - const handleDeleteUser = (userId: number) => { - deleteUser(userId) - .unwrap() - .then(() => message.success('Пользователь успешно удален')) - .catch(() => message.error('Не удалось удалить пользователя')) - } - - const handleBlockUser = (userId: number) => { - const currentUser = allUsers.find((el) => el.id === userId) - const successMessage = currentUser?.blocked - ? `Пользователь ${currentUser.lastName} ${currentUser.firstName} успешно разблокирован` - : `Пользователь ${currentUser?.lastName} ${currentUser?.firstName} успешно заблокирован` - const errorMessage = currentUser?.blocked - ? `Не удалось разблокировать пользователя ${currentUser.lastName} ${currentUser.firstName}` - : `Не удалось заблокировать пользователя ${currentUser?.lastName} ${currentUser?.firstName}` - blockUser(userId) - .unwrap() - .then(() => message.success(successMessage)) - .catch(() => message.error(<>{errorMessage})) - } - - const renderBlockButton = (userData: UserType) => { - const { blocked, id } = userData - - const popConfirmTitle = blocked - ? 'Вы действительно хотите разблокировать этого пользователя?' - : 'Вы действительно хотите заблокировать этого пользователя?' - - const tooltipTitle = blocked - ? 'Разблокировать пользователя' - : 'Заблокировать пользователя' - - const icon = blocked ? : - - return ( - handleBlockUser(id)}> - - - -
-
-
record.id} - pagination={false} - dataSource={allUsers} - columns={columns} - /> - - - - ) -} - -export default UsersPage diff --git a/src/pages/UsersPage/users-page.scss b/src/pages/UsersPage/users-page.scss deleted file mode 100644 index 5be148b..0000000 --- a/src/pages/UsersPage/users-page.scss +++ /dev/null @@ -1,46 +0,0 @@ -@import "src/constants/style/styleConst"; - -.users-page { - height: 100%; - border: 1px solid $border-color; - .ant-btn-group >.ant-btn:first-child { - z-index: 2; - } - &__header { - border-bottom: 1px solid $border-color; - padding: 0 3 * $basic-padding; - display: flex; - justify-content: space-between; - align-items: center; - - &__title { - padding: 3 * $basic-padding 0; - display: inline-block; - font-weight: 500; - font-size: 20px; - line-height: 28px; - } - } - - &__content { - padding: 2 * $basic-padding 3 * $basic-padding; - overflow-x: scroll; - - &__wrap-table { - overflow-x: scroll; - height: calc(100vh - 110px); - } - - &__table { - &__actions { - justify-content: flex-end; - display: flex; - gap: $basic-margin; - } - } - - &__pagination { - margin-top: 20px; - } - } -} diff --git a/src/routes/PrivateRoute/index.tsx b/src/routes/PrivateRoute/index.tsx deleted file mode 100644 index 4a2161c..0000000 --- a/src/routes/PrivateRoute/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Navigate, Outlet, useLocation } from 'react-router-dom' - -import { localStorageKeys } from '@constants/localStorageKeys.ts' - -import { LocalStorage } from '@utils/localStorageUtils.ts' - -import { routePaths } from '@routes/routePaths.ts' - -const PrivateRoute = () => { - const location = useLocation() - const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN) - - if (!userToken) { - LocalStorage.set('redirectUrl', location.pathname) - return - } - - return -} - -export default PrivateRoute diff --git a/src/routes/Routers/index.tsx b/src/routes/Routers/index.tsx deleted file mode 100644 index b9bbdd7..0000000 --- a/src/routes/Routers/index.tsx +++ /dev/null @@ -1,228 +0,0 @@ -import { Spin } from 'antd' -import { lazy, Suspense } from 'react' -import { Navigate, Route, Routes } from 'react-router-dom' - -import LayoutComponent from '@components/Layout' - -// Составная часть основной страницы, поэтому без lazy -import Configurations from '@pages/ConfigurationsPage' -import Connections from '@pages/ConnectionsPage' -import ErrorWrapperPage from '@pages/ErrorWrapperPage' - -import PrivateRoute from '@routes/PrivateRoute' -import { routePaths } from '@routes/routePaths.ts' - -const LoginPage = lazy(() => import('@pages/LoginPage')) -const ProfilePage = lazy(() => import('@pages/ProfilePage')) -const UsersPage = lazy(() => import('@pages/UsersPage')) -const RolesPage = lazy(() => import('@pages/RolesPage')) -const UserEditor = lazy(() => import('src/pages/UserEditor')) -const SessionsPage = lazy(() => import('@pages/SessionsPage')) -const SecurityLogPage = lazy(() => import('@pages/SecurityLogPage')) -const AppAccessPage = lazy(() => import('@pages/AppAccessPage')) -const ModulesPage = lazy(() => import('@pages/ModulesPage')) -const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage')) -const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage')) -const ConfigurationEditorPage = lazy( - () => import('@pages/ConfigurationEditorPage') -) -const NotFound = lazy(() => import('@pages/NotFound')) - -const Routers = () => { - return ( - - }> - }> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - }> - - - } - > - }> - - - } - /> - - }> - - - } - > - }> - - - } - > - }> - - - } - > - }> - - - } - /> - - - - - }> - - - } - /> - }> - - - } - /> - }> - - - } - > - }> - - - } - /> - - }> - - - } - > - }> - - - } - > - - }> - - - } - > - }> - - - } - /> - - }> - - - } - /> - - - - - }> - - - } - /> - }> - - - } - /> - }> - - - } - /> - - ) -} - -export default Routers diff --git a/src/routes/routePaths.ts b/src/routes/routePaths.ts deleted file mode 100644 index 241d468..0000000 --- a/src/routes/routePaths.ts +++ /dev/null @@ -1,40 +0,0 @@ -type RoutePaths = - | 'home' - | 'notFound' - | 'error' - | 'login' - | 'profile' - | 'users' - | 'sessions' - | 'securityLog' - | 'roles' - | 'appAccess' - | 'applicationsGroup' - | 'configuration' - | 'modules' - | 'application' - | 'connections' - | 'configurations' - | 'allVersions' - | 'configEditor' - -export const routePaths: Record = { - home: '/', - error: '/error', - notFound: '*', - login: '/login', - profile: '/profile', - users: '/users', - sessions: '/sessions', - securityLog: '/securityLog', - roles: '/roles', - appAccess: '/appAccess', - applicationsGroup: '/applications_group', - configuration: '/configuration', - modules: '/modules', - application: 'application', - connections: 'connections', - configurations: 'configurations', - allVersions: ':configId/all_versions', - configEditor: 'configEditor' -} diff --git a/src/services/accessListService.ts b/src/services/accessListService.ts deleted file mode 100644 index fab02f2..0000000 --- a/src/services/accessListService.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { - AccessListMethodType, - AccessListSetListRequestType, - AccessListSetListSetOneRequestType -} from '@type/accessList.type.ts' - -const accessListApi = createApi({ - reducerPath: 'accessListApi', - refetchOnFocus: true, - tagTypes: ['AccessItems'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), - endpoints: (builder) => ({ - getById: builder.query({ - query: ({ id }) => ({ url: apiPaths.getById, data: { id } }), - providesTags: () => ['AccessItems'] - }), - setList: builder.mutation< - AccessListMethodType[], - AccessListSetListRequestType - >({ - query: (data) => ({ url: apiPaths.setList, data }), - invalidatesTags: () => ['AccessItems'] - }), - setOne: builder.mutation({ - query: (data) => ({ url: apiPaths.setOne, data }), - invalidatesTags: () => ['AccessItems'] - }) - }) -}) - -export default accessListApi diff --git a/src/services/apiService.ts b/src/services/apiService.ts deleted file mode 100644 index 1caf4e5..0000000 --- a/src/services/apiService.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { message } from 'antd' -import axios, { AxiosError } from 'axios' - -import { localStorageKeys } from '@constants/localStorageKeys.ts' - -import { getConfigProperty } from '@utils/configUtils.ts' -import { LocalStorage } from '@utils/localStorageUtils.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { MSPError } from '@type/index.ts' - -export const apiService = axios.create({ - timeout: 15000, - data: {} -}) - -apiService.defaults.headers.post['X-APPLICATION-TOKEN'] = getConfigProperty( - 'APP_TOKEN', - import.meta.env.VITE_APP_TOKEN -) - -apiService.interceptors.request.use( - async (config: any) => { - const headerName = LocalStorage.get(localStorageKeys.HEADER_NAME) - config.headers[headerName] = LocalStorage.get(localStorageKeys.USER_TOKEN) - - return config - }, - (error: AxiosError) => Promise.reject(error) -) - -const localClear = () => { - LocalStorage.remove(localStorageKeys.USER_TOKEN) - LocalStorage.remove(localStorageKeys.HEADER_NAME) -} - -apiService.interceptors.response.use( - async (response: any) => response, - (error: AxiosError) => { - console.error(error) - if (error.response && error.response.status === 401) { - localClear() - const prevRoute = sessionStorage.getItem('prevRoute') || '' - message.error('Ваша сессия истекла"').then() - sessionStorage.setItem('prevRoute', prevRoute) - window.location.href = routePaths.login - } - - if (error.response && error.response.status >= 500) { - message - .error('Внутренняя ошибка сервиса, попробуйте повторить запрос') - .then() - } - - return Promise.reject(error) - } -) diff --git a/src/services/appService.ts b/src/services/appService.ts deleted file mode 100644 index cbb585f..0000000 --- a/src/services/appService.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { AppApiResponseType, DomainType } from '@type/app.type.ts' - -const appApi = createApi({ - reducerPath: 'appService', - refetchOnFocus: true, - tagTypes: ['SystemTreeApps', 'Application'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), - endpoints: (builder) => ({ - getSystemTree: builder.query({ - query: () => ({ url: apiPaths.getSystemTree }), - transformResponse: (response: DomainType[]) => { - const apps = response.flatMap(({ services }) => - services.flatMap(({ apps }) => apps) - ) - - return { - originalResponse: response, - appList: apps - } - }, - providesTags: () => ['SystemTreeApps'] - }) - }) -}) - -export default appApi diff --git a/src/services/applicationsGroupService.ts b/src/services/applicationsGroupService.ts deleted file mode 100644 index 85dd8e6..0000000 --- a/src/services/applicationsGroupService.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { - ApplicationsGroupType, - NewApplicationsGroupType, - UpdateApplicationsGroupType -} from '@pages/ApplicationsPage/applications.type.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -const applicationsGroupApi = createApi({ - reducerPath: 'applicationsGroupApi', - refetchOnFocus: true, - tagTypes: ['ApplicationsGroup'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), - endpoints: (builder) => ({ - getApplicationsGroupByDomainId: builder.query< - ApplicationsGroupType[], - { id: number } - >({ - query: (id) => ({ - url: apiPaths.getServicesByDomainId, - data: id - }), - providesTags: () => ['ApplicationsGroup'] - }), - - getApplicationsGroupByServiceId: builder.query< - ApplicationsGroupType[], - { id: number } - >({ - query: (id) => ({ - url: apiPaths.getServiceById, - data: id - }), - providesTags: () => ['ApplicationsGroup'] - }), - - getAllApplicationsGroup: builder.query< - ApplicationsGroupType[], - { id: string } - >({ - query: () => ({ url: apiPaths.getAllService }), - providesTags: () => ['ApplicationsGroup'] - }), - - createApplicationsGroup: builder.mutation< - ApplicationsGroupType, - NewApplicationsGroupType - >({ - query: (newApplicationsGroup) => ({ - url: apiPaths.createUpdateService, - data: newApplicationsGroup - }), - invalidatesTags: ['ApplicationsGroup'] - }), - - updateApplicationsGroup: builder.mutation< - void, - UpdateApplicationsGroupType - >({ - query: (updateApplicationsGroup) => ({ - url: apiPaths.createUpdateService, - data: updateApplicationsGroup - }), - invalidatesTags: ['ApplicationsGroup'] - }), - - removeApplicationsGroup: builder.mutation({ - query: ([id]) => ({ - url: apiPaths.deleteService, - data: [id] - }), - invalidatesTags: ['ApplicationsGroup'] - }) - }) -}) - -export default applicationsGroupApi diff --git a/src/services/applicationsService.ts b/src/services/applicationsService.ts deleted file mode 100644 index bcafb4c..0000000 --- a/src/services/applicationsService.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { - ApplicationAppType, - ApplicationsServiceType, - NewApplicationAppType, - UpdateApplicationAppType -} from '@pages/ApplicationsPage/applications.type.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -const applicationsApi = createApi({ - reducerPath: 'applicationsApi', - refetchOnFocus: true, - tagTypes: ['Applications'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), - endpoints: (builder) => ({ - getAllApplicationsService: builder.query< - ApplicationsServiceType[], - { id: string } - >({ - query: () => ({ url: apiPaths.getAllApplications }), - providesTags: () => ['Applications'] - }), - - createApplicationService: builder.mutation< - ApplicationAppType, - NewApplicationAppType - >({ - query: (NewApplicationsService) => ({ - url: apiPaths.createUpdateApplication, - data: NewApplicationsService - }), - invalidatesTags: ['Applications'] - }), - - getApplicationsServiceById: builder.query< - ApplicationsServiceType, - { id: number } - >({ - query: (id) => ({ - url: apiPaths.getApplicationById, - data: id - }), - providesTags: () => ['Applications'] - }), - - getApplicationsByServiceId: builder.query< - ApplicationsServiceType[], - { id: number } - >({ - query: (id) => ({ - url: apiPaths.getApplicationsByServiceId, - data: id - }), - providesTags: () => ['Applications'] - }), - - updateApplicationsService: builder.mutation( - { - query: (updateApplications) => ({ - url: apiPaths.createUpdateApplication, - data: updateApplications - }), - invalidatesTags: ['Applications'] - } - ), - - removeApplicationsService: builder.mutation({ - query: ([id]) => ({ - url: apiPaths.deleteApplication, - data: [id] - }), - invalidatesTags: ['Applications'] - }) - }) -}) - -export default applicationsApi diff --git a/src/services/configService.ts b/src/services/configService.ts deleted file mode 100644 index 401ab62..0000000 --- a/src/services/configService.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { ConfigResponse, ConfigType } from '@pages/ModulesPage/module.type.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { VersionType } from '@type/version.type.ts' - -const configServiceApi = createApi({ - reducerPath: 'configApi', - tagTypes: ['configs', 'versions', 'config'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }), - endpoints: (builder) => ({ - getConfigsByModuleId: builder.query({ - query: (moduleId) => ({ - url: apiPaths.getConfigsByModuleId, - data: { moduleId } - }), - transformResponse: (response: ConfigType[]): ConfigResponse => { - const activeObjects: ConfigType[] = [] - const inactiveObjects: ConfigType[] = [] - response.forEach((obj) => { - if (obj.active) { - activeObjects.push(obj) - } else { - inactiveObjects.push(obj) - } - }) - return { - originalResponse: response, - activeConfigs: activeObjects, - inactiveConfigs: inactiveObjects - } - }, - providesTags: () => ['configs'] - }), - getConfigById: builder.query({ - query: (id) => ({ - url: apiPaths.getConfigById, - data: { id } - }), - providesTags: () => ['config'] - }), - getAllVersion: builder.query({ - query: (id) => ({ - url: apiPaths.getAllVersions, - data: { id } - }), - transformResponse: (response: VersionType[]) => { - return response.sort((a, b) => b.configVersion - a.configVersion) - }, - providesTags: () => ['versions'] - }), - createUpdateConfig: builder.mutation({ - query: (data) => ({ url: apiPaths.createUpdateConfig, data }), - invalidatesTags: () => ['configs', 'versions', 'config'] - }), - deleteVersion: builder.mutation({ - query: (id) => ({ url: apiPaths.deleteVersion, data: { id } }), - invalidatesTags: () => ['versions'] - }), - deleteConfig: builder.mutation({ - query: (id) => ({ url: apiPaths.deleteConfig, data: [id] }), - invalidatesTags: () => ['configs'] - }), - markConfigAsActive: builder.mutation({ - query: (id) => ({ url: apiPaths.markConfigAsActive, data: { id } }), - invalidatesTags: () => ['configs'] - }) - }) -}) - -export default configServiceApi diff --git a/src/services/modulesService.ts b/src/services/modulesService.ts deleted file mode 100644 index 4a10bb1..0000000 --- a/src/services/modulesService.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { - ModuleType, - ResponseSchemaType -} from '@pages/ModulesPage/module.type.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -const modulesServiceApi = createApi({ - reducerPath: 'modulesServiceApi', - refetchOnFocus: false, - tagTypes: ['modules', 'schema'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }), - endpoints: (builder) => ({ - getModules: builder.query({ - query: () => ({ url: apiPaths.getModules, data: { limit: 1000 } }), - providesTags: () => ['modules'] - }), - removeModule: builder.mutation({ - query: (id) => ({ - url: apiPaths.deleteModule, - data: [id] - }), - invalidatesTags: ['modules'] - }), - getByModuleId: builder.query({ - query: (moduleId) => ({ - url: apiPaths.getByModuleId, - data: { moduleId } - }), - providesTags: () => ['schema'] - }) - }) -}) - -export default modulesServiceApi diff --git a/src/services/roleService.ts b/src/services/roleService.ts deleted file mode 100644 index 9c13f32..0000000 --- a/src/services/roleService.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { NewRoleType, RoleType } from '@type/roles.type.ts' - -const roleApi = createApi({ - reducerPath: 'roleApi', - refetchOnFocus: true, - tagTypes: ['Roles'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseAdminUrl }), - endpoints: (builder) => ({ - getAllRoles: builder.query({ - query: () => ({ url: apiPaths.getAllRoles }), - providesTags: () => ['Roles'] - }), - createRole: builder.mutation({ - query: (newRole) => ({ - url: apiPaths.createRole, - data: newRole - }), - invalidatesTags: ['Roles'] - }), - updateRole: builder.mutation({ - query: (role) => ({ - url: apiPaths.updateRole, - data: role - }), - invalidatesTags: ['Roles'] - }), - removeRole: builder.mutation({ - query: (id) => ({ - url: apiPaths.deleteRole, - data: { id } - }), - invalidatesTags: ['Roles'] - }) - }) -}) - -export default roleApi diff --git a/src/services/routeService.ts b/src/services/routeService.ts deleted file mode 100644 index 3b740b0..0000000 --- a/src/services/routeService.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { - EndpointType, - RouteApiResponseType, - RouteType -} from '@type/accessList.type.ts' - -const routeApi = createApi({ - reducerPath: 'routeApi', - refetchOnFocus: true, - tagTypes: ['Routes'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }), - endpoints: (builder) => ({ - getAllRoutes: builder.query({ - query: () => ({ url: apiPaths.getAllRoutes }), - transformResponse: (response: RouteType[]) => { - const moduleEndpoints: Record = {} - const allRouteMap: Record = {} - - response.forEach((route) => { - if (route.endpoints && route.endpoints.length) { - moduleEndpoints[route.moduleName] = route.endpoints - } - }) - Object.keys(moduleEndpoints) - .sort() - .forEach((groupName) => { - moduleEndpoints[groupName].forEach((method) => { - allRouteMap[method.path] = method - }) - }) - - return { - originalResponse: response, - moduleEndpoints: moduleEndpoints, - allRouteMap: allRouteMap - } - }, - providesTags: () => ['Routes'] - }) - }) -}) - -export default routeApi diff --git a/src/services/securityLogService.ts b/src/services/securityLogService.ts deleted file mode 100644 index 8f25bbe..0000000 --- a/src/services/securityLogService.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths' - -import { axiosBaseQuery } from '@utils/apiUtils' - -import { LimitOffsetRequestType } from '@type/index.ts' -import { LogEventType, LogResponseType, SetEventType } from '@type/log.type' - -const securityLogServiceApi = createApi({ - reducerPath: 'securityLogService', - refetchOnFocus: true, - tagTypes: ['logs', 'events'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseAdminUrl }), - endpoints: (builder) => ({ - getAllLogs: builder.mutation({ - query: (request) => ({ url: apiPaths.getAllLogs, data: request }), - invalidatesTags: () => ['logs'] - }), - getLogEvents: builder.query({ - query: () => ({ url: apiPaths.getLogEvents }), - providesTags: () => ['events'] - }), - setLogEvents: builder.mutation({ - query: (request) => ({ url: apiPaths.setLogEvents, data: request }), - invalidatesTags: () => ['events'] - }) - }) -}) - -export default securityLogServiceApi diff --git a/src/services/sessionService.ts b/src/services/sessionService.ts deleted file mode 100644 index cece62e..0000000 --- a/src/services/sessionService.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths' - -import { axiosBaseQuery } from '@utils/apiUtils' - -import { LimitOffsetRequestType } from '@type/index.ts' -import { SessionResponseType } from '@type/session.type' - -const sessionServiceApi = createApi({ - reducerPath: 'sessionService', - refetchOnFocus: true, - tagTypes: ['sessions'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseAdminUrl }), - endpoints: (builder) => ({ - getAllSessions: builder.query({ - query: (request) => ({ url: apiPaths.getAllSession, data: request }), - providesTags: () => ['sessions'] - }), - revokeSession: builder.mutation({ - query: (id) => ({ url: apiPaths.revokeSession, data: { id } }), - invalidatesTags: () => ['sessions'] - }) - }) -}) - -export default sessionServiceApi diff --git a/src/services/tokensService.ts b/src/services/tokensService.ts deleted file mode 100644 index 6d4a497..0000000 --- a/src/services/tokensService.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { - ApplicationTokenType, - NewApplicationTokenType, - RevokeTokenType -} from '@pages/ApplicationsPage/applications.type.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -const tokensApi = createApi({ - reducerPath: 'tokensApi', - refetchOnFocus: true, - tagTypes: ['Tokens'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), - endpoints: (builder) => ({ - createToken: builder.mutation< - ApplicationTokenType, - NewApplicationTokenType - >({ - query: (NewApplicationTokenType) => ({ - url: apiPaths.createToken, - data: NewApplicationTokenType - }), - invalidatesTags: ['Tokens'] - }), - - getTokensByAppId: builder.query({ - query: (id) => ({ - url: apiPaths.getTokensByAppId, - data: id - }), - providesTags: ['Tokens'] - }), - revokeTokens: builder.mutation({ - query: (el) => ({ - url: apiPaths.revokeTokens, - data: el - }), - invalidatesTags: ['Tokens'] - }) - }) -}) - -export default tokensApi diff --git a/src/services/userService.ts b/src/services/userService.ts deleted file mode 100644 index 9f69730..0000000 --- a/src/services/userService.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { createApi } from '@reduxjs/toolkit/query/react' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { axiosBaseQuery } from '@utils/apiUtils.ts' - -import { PermissionType } from '@type/roles.type.ts' -import { NewUserType, UserResponseType, UserType } from '@type/user.type.ts' - -const userServiceApi = createApi({ - reducerPath: 'userServiceApi', - refetchOnFocus: true, - tagTypes: ['users', 'permissions'], - baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseUserUrl }), - endpoints: (builder) => ({ - getAllUsers: builder.query({ - query: () => ({ url: apiPaths.getUsers, data: { limit: 1000 } }), - transformResponse: (response: UserResponseType) => response.items, - providesTags: () => ['users'] - }), - getAllPermissions: builder.query({ - query: () => ({ url: apiPaths.getAllPermissions, data: {} }), - providesTags: () => ['permissions'] - }), - blockUser: builder.mutation({ - query: (userId) => ({ url: apiPaths.blockUser, data: { userId } }), - invalidatesTags: () => ['users'] - }), - deleteUser: builder.mutation({ - query: (userId) => ({ - url: apiPaths.deleteUser, - data: { ids: [userId] } - }), - invalidatesTags: () => ['users'] - }), - createUser: builder.mutation({ - query: (newUser) => ({ - url: apiPaths.createUser, - data: newUser - }), - invalidatesTags: ['users'] - }), - - updateUser: builder.mutation>({ - query: (user) => ({ - url: apiPaths.updateUser, - data: user - }), - invalidatesTags: ['users'] - }) - }) -}) - -export default userServiceApi diff --git a/src/stores/index.tsx b/src/stores/index.tsx deleted file mode 100644 index ceffc60..0000000 --- a/src/stores/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { combineReducers, configureStore } from '@reduxjs/toolkit' -import { theme } from 'antd' -import { MapToken, SeedToken } from 'antd/es/theme/interface' -import { createContext, Dispatch, SetStateAction } from 'react' - -import accessListApi from '@services/accessListService.ts' -import appApi from '@services/appService.ts' -import applicationsGroupApi from '@services/applicationsGroupService.ts' -import applicationsApi from '@services/applicationsService.ts' -import configServiceApi from '@services/configService.ts' -import modulesServiceApi from '@services/modulesService.ts' -import roleApi from '@services/roleService.ts' -import routeApi from '@services/routeService.ts' -import securityLogServiceApi from '@services/securityLogService.ts' -import sessionServiceApi from '@services/sessionService.ts' -import tokensApi from '@services/tokensService.ts' -import userServiceApi from '@services/userService.ts' - -import profileReducer from './redusers/ProfileSlice.ts' -import UIReducer from './redusers/UISlice.ts' - -export interface ContextProps { - setTheme: Dispatch< - SetStateAction<{ - algorithm: (token: SeedToken) => MapToken - cssVar: boolean - token: { colorBgLayout: string } - }> - > - changeTheme: boolean - setChangeTheme: Dispatch> -} - -export const Context = createContext({ - changeTheme: false, - setChangeTheme: () => false, - setTheme: () => theme.defaultAlgorithm -}) - -const rootReducer = combineReducers({ - profileReducer, - UIReducer, - [roleApi.reducerPath]: roleApi.reducer, - [userServiceApi.reducerPath]: userServiceApi.reducer, - [sessionServiceApi.reducerPath]: sessionServiceApi.reducer, - [securityLogServiceApi.reducerPath]: securityLogServiceApi.reducer, - [appApi.reducerPath]: appApi.reducer, - [accessListApi.reducerPath]: accessListApi.reducer, - [routeApi.reducerPath]: routeApi.reducer, - [modulesServiceApi.reducerPath]: modulesServiceApi.reducer, - [applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer, - [applicationsApi.reducerPath]: applicationsApi.reducer, - [configServiceApi.reducerPath]: configServiceApi.reducer, - [tokensApi.reducerPath]: tokensApi.reducer -}) - -export const setupStore = () => - configureStore({ - reducer: rootReducer, - middleware: (getDefaultMiddleware) => - getDefaultMiddleware().concat( - roleApi.middleware, - userServiceApi.middleware, - securityLogServiceApi.middleware, - appApi.middleware, - accessListApi.middleware, - routeApi.middleware, - userServiceApi.middleware, - sessionServiceApi.middleware, - modulesServiceApi.middleware, - applicationsGroupApi.middleware, - applicationsApi.middleware, - tokensApi.middleware, - configServiceApi.middleware - ) - }) - -export type RootState = ReturnType -export type AppStore = ReturnType -export type AppDispatch = AppStore['dispatch'] diff --git a/src/stores/redusers/ActionCreators.ts b/src/stores/redusers/ActionCreators.ts deleted file mode 100644 index e2547cf..0000000 --- a/src/stores/redusers/ActionCreators.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { createAsyncThunk } from '@reduxjs/toolkit' - -import { apiPaths } from '@constants/api/apiPaths.ts' - -import { - ProfileDataType, - UIDataType -} from '@pages/ProfilePage/profile-page.type.ts' - -import { initUI } from '@utils/UIUtiles.tsx' - -import { apiService } from '@services/apiService.ts' - -export const fetchProfile = createAsyncThunk( - 'profile/fetchProfile', - async (_, { rejectWithValue }) => { - try { - const response = await apiService.post( - apiPaths.getProfile - ) - return response.data - } catch (error) { - return rejectWithValue(error) - } - } -) -export const fetchUI = createAsyncThunk( - 'ui/fetchUI', - async (_, { rejectWithValue }) => { - try { - const response = await apiService.post(apiPaths.getUI) - initUI(response.data) - return response.data - } catch (error) { - return rejectWithValue(error) - } - } -) diff --git a/src/stores/redusers/ProfileSlice.ts b/src/stores/redusers/ProfileSlice.ts deleted file mode 100644 index 090ba5e..0000000 --- a/src/stores/redusers/ProfileSlice.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { - ActionReducerMapBuilder, - createSlice, - PayloadAction -} from '@reduxjs/toolkit' - -import { - ProfileDataType, - ProfileType -} from '@pages/ProfilePage/profile-page.type.ts' - -import { fetchProfile } from './ActionCreators.ts' - -export enum StateProfileStatus { - resolved = 'resolved', - pending = 'pending', - rejected = 'rejected', - notInit = 'notInit' -} - -export const initialState: ProfileType = { - profile: { - email: '', - firstName: '', - lastName: '', - role: '', - roles: [], - permissions: [], - idleTimeoutMs: 0 - }, - status: StateProfileStatus.notInit, - error: '' -} - -export const profileSlice = createSlice({ - name: 'profile', - initialState, - reducers: { - clearProfile(state) { - state.profile = initialState.profile - } - }, - extraReducers: (builder: ActionReducerMapBuilder) => { - builder - .addCase( - fetchProfile.fulfilled, - (state, action: PayloadAction) => { - state.status = StateProfileStatus.resolved - state.profile = { ...action.payload } - } - ) - .addCase(fetchProfile.pending, (state) => { - state.status = StateProfileStatus.pending - }) - .addCase(fetchProfile.rejected, (state, action: any) => { - state.status = StateProfileStatus.rejected - state.error = action.payload - }) - } -}) - -export default profileSlice.reducer diff --git a/src/stores/redusers/UISlice.ts b/src/stores/redusers/UISlice.ts deleted file mode 100644 index 196594c..0000000 --- a/src/stores/redusers/UISlice.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - ActionReducerMapBuilder, - createSlice, - PayloadAction -} from '@reduxjs/toolkit' - -import { UIDataType, UIType } from '@pages/ProfilePage/profile-page.type.ts' - -import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts' - -import { fetchUI } from './ActionCreators.ts' - -export const initialState: UIType = { - ui: { - name: '', - primaryColor: '' - }, - status: StateProfileStatus.notInit, - error: '' -} - -export const UISlice = createSlice({ - name: 'ui', - initialState, - reducers: { - clearUI(state) { - state.ui = initialState.ui - } - }, - extraReducers: (builder: ActionReducerMapBuilder) => { - builder - .addCase( - fetchUI.fulfilled, - (state, action: PayloadAction) => { - state.status = StateProfileStatus.resolved - state.ui = { ...action.payload } - } - ) - .addCase(fetchUI.pending, (state) => { - state.status = StateProfileStatus.pending - }) - .addCase(fetchUI.rejected, (state, action: any) => { - state.status = StateProfileStatus.rejected - state.error = action.payload - }) - } -}) - -export default UISlice.reducer diff --git a/src/type/accessList.type.ts b/src/type/accessList.type.ts deleted file mode 100644 index 8295f19..0000000 --- a/src/type/accessList.type.ts +++ /dev/null @@ -1,48 +0,0 @@ -export interface AccessListMethodType { - method: string - value: boolean -} - -export interface AccessListSetListRequestType { - appId: number - methods: AccessListMethodType[] - removeOld?: boolean -} - -export interface AccessListSetListSetOneRequestType { - appId: number - method: string - value: boolean -} - -export interface EndpointType { - extra: Record - inner: boolean - path: string - userAuthRequired: boolean -} - -export type AddressType = { - ip: string - port: string -} - -export type RequiredModuleType = { - name: string - required: boolean -} - -export type RouteType = { - address: AddressType - endpoints: EndpointType[] - libVersion: string - moduleName: string - requiredModules: RequiredModuleType[] - version: string -} - -export interface RouteApiResponseType { - originalResponse: RouteType[] - moduleEndpoints: Record - allRouteMap: Record -} diff --git a/src/type/app.type.ts b/src/type/app.type.ts deleted file mode 100644 index 138ddeb..0000000 --- a/src/type/app.type.ts +++ /dev/null @@ -1,33 +0,0 @@ -interface TokenType { - appId: boolean - createdAt: string - expireTime: boolean - token: string -} - -export interface SystemTreeAppType { - description: string - id: boolean - name: string - tokens: TokenType[] - type: string -} - -interface SystemServiceType { - apps: SystemTreeAppType[] - description: string - id: boolean - name: string -} - -export interface DomainType { - description: string - id: boolean - name: string - services: SystemServiceType[] -} - -export interface AppApiResponseType { - originalResponse: DomainType[] - appList: SystemTreeAppType[] -} diff --git a/src/type/index.ts b/src/type/index.ts deleted file mode 100644 index 1acd4ac..0000000 --- a/src/type/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface MSPError { - details: Array - errorCode: string - errorMessage: string -} - -export interface LimitOffsetRequestType { - limit: number - offset: number -} diff --git a/src/type/log.type.ts b/src/type/log.type.ts deleted file mode 100644 index 568bf04..0000000 --- a/src/type/log.type.ts +++ /dev/null @@ -1,25 +0,0 @@ -export interface LogResponseType { - totalCount: number - items: LogType[] -} - -export interface LogType { - id: string - userId: string - createdAt: string - message: string -} - -export type LogEventKeyType = - | 'login_logout' - | 'role_changed' - | 'user_changed' - | 'user_blocked' - -export interface LogEventType { - event: LogEventKeyType - name: string - enabled: boolean -} - -export type SetEventType = Omit diff --git a/src/type/login.type.ts b/src/type/login.type.ts deleted file mode 100644 index 017e375..0000000 --- a/src/type/login.type.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface LoginRequest { - email: string - password: string -} -export interface LoginResponse { - expired: string - headerName: string - token: string -} diff --git a/src/type/roles.type.ts b/src/type/roles.type.ts deleted file mode 100644 index 1b363f8..0000000 --- a/src/type/roles.type.ts +++ /dev/null @@ -1,36 +0,0 @@ -export enum PermissionKeysType { - read = 'read', // Просмотр страниц - write = 'write', // Редактирование страниц - user_view = 'user_view', // Просмотр списка пользователей - user_block = 'user_block', // Блокировка пользователя - user_create = 'user_create', // Создать пользователя - user_update = 'user_update', // Обновить пользователя - user_delete = 'user_delete', // Удаление пользователя - session_view = 'session_view', // Просмотр списка пользовательских сессий - session_revoke = 'session_revoke', // Отзыв сессии - role_view = 'role_view', // Просмотр экрана ролей - role_add = 'role_add', // Создание роли - role_update = 'role_update', // Обновление роли - role_delete = 'role_delete', // Удаление роли - security_log_view = 'security_log_view' // Просмотр журналов ИБ -} - -export interface RoleType { - changeMessage?: string - createdAt: string - description: string - externalGroup: string - id: number - name: string - permissions: PermissionKeysType[] - updatedAt: string - immutable: boolean - exclusive: boolean -} - -export type NewRoleType = Omit - -export interface PermissionType { - key: PermissionKeysType - name: string -} diff --git a/src/type/session.type.ts b/src/type/session.type.ts deleted file mode 100644 index 4cab19e..0000000 --- a/src/type/session.type.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { SessionStatusKeysType } from '@constants/statuses' - -export interface SessionType { - userId: string - createdAt: string - expiredAt: string - id: number - status: SessionStatusKeysType -} - -export interface SessionResponseType { - totalCount: number - items: SessionType[] -} diff --git a/src/type/user.type.ts b/src/type/user.type.ts deleted file mode 100644 index 64c8c1c..0000000 --- a/src/type/user.type.ts +++ /dev/null @@ -1,28 +0,0 @@ -export interface UserType { - id: number - blocked: boolean - createdAt: string - email: string - password: string - firstName: string - lastName: string - roleId: number - roleName: string - roles: number[] - updatedAt: string - description: string - lastSessionCreatedAt?: string -} - -export interface UserResponseType { - items: UserType[] -} - -export interface NewUserType { - description: string - email: string - firstName: string - lastName: string - password: string - roles: number[] -} diff --git a/src/type/version.type.ts b/src/type/version.type.ts deleted file mode 100644 index 8f46dc3..0000000 --- a/src/type/version.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface VersionType { - id: string - configId: string - configVersion: number - createdAt: string - data: Record -} diff --git a/src/ui/CloseBtn/close-btn.scss b/src/ui/CloseBtn/close-btn.scss deleted file mode 100644 index 479dd32..0000000 --- a/src/ui/CloseBtn/close-btn.scss +++ /dev/null @@ -1,15 +0,0 @@ -.close-btn { - border: none; - background: transparent; - box-shadow: none; - padding: 5px !important; - position: absolute; - top: 8px; - right: 8px; - - svg { - path { - fill: var(--ant-color-text) !important; - } - } -} diff --git a/src/ui/CloseBtn/index.tsx b/src/ui/CloseBtn/index.tsx deleted file mode 100644 index 7cfef8a..0000000 --- a/src/ui/CloseBtn/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Button } from 'antd' - -import './close-btn.scss' - -interface CloseBtnPropsType { - ariaLabel?: string - onClick: () => void -} -const CloseBtn = ({ onClick, ariaLabel }: CloseBtnPropsType) => { - return ( - - ) -} - -export default CloseBtn diff --git a/src/ui/SaveButton/index.tsx b/src/ui/SaveButton/index.tsx deleted file mode 100644 index d3bc673..0000000 --- a/src/ui/SaveButton/index.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Button, ButtonProps } from 'antd' - -import './save-button.scss' - -const SaveButton = ({ className, icon, ...rest }: ButtonProps) => { - return ( - - ) -} - -export default SaveButton diff --git a/src/ui/SaveButton/save-button.scss b/src/ui/SaveButton/save-button.scss deleted file mode 100644 index 68c5f22..0000000 --- a/src/ui/SaveButton/save-button.scss +++ /dev/null @@ -1,4 +0,0 @@ -.save-button { - width: 150px; - min-width: 100px; -} diff --git a/src/utils/UIUtiles.tsx b/src/utils/UIUtiles.tsx deleted file mode 100644 index 1cd7e3d..0000000 --- a/src/utils/UIUtiles.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { UIDataType } from '@pages/ProfilePage/profile-page.type.ts' - -const drawSVG = (color: string) => - `` - -export const createSVG = (color: string) => { - const svgString = drawSVG(color) - return btoa(svgString) // base64 -} - -export const initSVG = (color: string) => { - const favicon = document.createElement('link') - favicon.id = 'favicon' - favicon.rel = 'shortcut icon' - favicon.type = 'image/x-icon' - favicon.href = `data:image/svg+xml;base64,${createSVG(color)}` - return favicon -} - -export const initUI = (ui: UIDataType) => { - let favicon = document.getElementById('favicon') - favicon = initSVG(ui.primaryColor) - const titles = document.getElementsByTagName('title') - document.head.insertBefore(favicon, titles[0]) - document.title = ui.name -} diff --git a/src/utils/apiUtils.ts b/src/utils/apiUtils.ts deleted file mode 100644 index dd5f6ee..0000000 --- a/src/utils/apiUtils.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { BaseQueryFn, retry } from '@reduxjs/toolkit/query/react' -import { AxiosError, AxiosRequestConfig } from 'axios' - -import { apiService } from '@services/apiService.ts' - -import { MSPError } from '@type/index.ts' - -export const axiosBaseQuery = - ( - { baseUrl }: { baseUrl: string } = { baseUrl: '' } - ): BaseQueryFn< - { - url: string - method?: AxiosRequestConfig['method'] - data?: AxiosRequestConfig['data'] - params?: AxiosRequestConfig['params'] - }, - unknown, - unknown - > => - async ({ url, method = 'post', data, params }) => { - try { - const result = await apiService({ - url: baseUrl + url, - method, - data, - params - }) - return { data: result.data } - } catch (axiosError) { - const err = axiosError as AxiosError - return { - error: { ...err.response } - } - } - } - -export const staggeredBaseQueryWithBailOut = (baseUrl: string) => - retry( - async (args: string | AxiosRequestConfig['data'], api, extraOptions) => { - const result = await axiosBaseQuery({ baseUrl })(args, api, extraOptions) - const error = result.error as AxiosError - if (error && error?.status === 400) { - retry.fail(result.error) - } - - return result - }, - { - maxRetries: 5 - } - ) diff --git a/src/utils/columnLayoutUtils.ts b/src/utils/columnLayoutUtils.ts deleted file mode 100644 index 0161c8e..0000000 --- a/src/utils/columnLayoutUtils.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NavigateFunction, SetURLSearchParams } from 'react-router-dom' - -export const setSelectedItemId = ( - path: string, - id: string, - searchParams: string, - navigate: NavigateFunction -): void => { - navigate( - { - pathname: `${path}/${id}`, - search: searchParams - }, - { replace: true } - ) -} - -export const setSearchValue = ( - value: string, - setSearchParams: SetURLSearchParams, - prefix: string = 'search' -) => { - setSearchParams((prev) => { - if (!value) { - prev.delete(prefix) - } else { - prev.set(prefix, value) - } - return prev - }) -} diff --git a/src/utils/configUtils.ts b/src/utils/configUtils.ts deleted file mode 100644 index 3cfd16c..0000000 --- a/src/utils/configUtils.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare global { - interface Window { - config: { [key: string]: any } - } -} - -export const getConfigProperty = (property: string, defaultValue: any) => { - if ( - window.config && - Object.prototype.hasOwnProperty.call(window.config, property) - ) { - return window.config[property] - } - return defaultValue -} diff --git a/src/utils/firstColumnUtils.ts b/src/utils/firstColumnUtils.ts deleted file mode 100644 index 445b1c2..0000000 --- a/src/utils/firstColumnUtils.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type' - -export const filterFirstColumnItems = >( - listItems: ColumnItem[], - searchValue: string -): ColumnItem[] => { - const normalizedSearchValue = searchValue.toLowerCase().trim() - return listItems - ? listItems.filter((el) => { - const normalizedName = el.name.toLowerCase().trim() - const normalizedId = el.id.toString().toLowerCase().trim() - return ( - normalizedName.includes(normalizedSearchValue) || - normalizedId.includes(normalizedSearchValue) - ) - }) - : [] -} diff --git a/src/utils/localStorageUtils.ts b/src/utils/localStorageUtils.ts deleted file mode 100644 index 0352b9d..0000000 --- a/src/utils/localStorageUtils.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const LocalStorage = { - set(key: string, value: any): void { - const item = typeof value === 'string' ? value : JSON.stringify(value) - localStorage.setItem(key, item) - }, - get(key: string): any | null { - const value = localStorage.getItem(key) - try { - return value ? JSON.parse(value) : null - } catch (error) { - return value - } - }, - remove(key: string): void { - localStorage.removeItem(key) - }, - clear(): void { - localStorage.clear() - } -} diff --git a/src/utils/objectUtils.ts b/src/utils/objectUtils.ts deleted file mode 100644 index f86923b..0000000 --- a/src/utils/objectUtils.ts +++ /dev/null @@ -1,56 +0,0 @@ -const sortObject = (obj: any): any => { - if (typeof obj !== 'object' || obj === null) { - return obj - } - - if (Array.isArray(obj)) { - return obj.map(sortObject) - } - - const sorted: any = {} - Object.keys(obj) - .sort() - .forEach((key) => { - sorted[key] = sortObject(obj[key]) - }) - return sorted -} - -function isEmpty(value: unknown): boolean { - return ( - value === undefined || - value === null || - (typeof value === 'string' && value.trim() === '') || // Пустые строки - (Array.isArray(value) && value.length === 0) || - (typeof value === 'object' && - true && - !Array.isArray(value) && - Object.keys(value).length === 0) - ) -} - -function cleanEmptyParamsObject(obj: any): any { - if (typeof obj !== 'object' || obj === null) { - return obj - } - - if (Array.isArray(obj)) { - return obj.map(cleanEmptyParamsObject).filter((item) => !isEmpty(item)) // Удаление пустых элементов в массиве - } - - return Object.keys(obj).reduce( - (acc, key) => { - const value = cleanEmptyParamsObject(obj[key]) // Рекурсивная обработка объектов - - if (!isEmpty(value)) { - // Проверяем пустоту значения после рекурсивной обработки - acc[key] = value // Сохраняем только непустые значения - } - - return acc - }, - {} as Record - ) -} - -export { sortObject, cleanEmptyParamsObject } diff --git a/src/utils/roleUtils.ts b/src/utils/roleUtils.ts deleted file mode 100644 index e785958..0000000 --- a/src/utils/roleUtils.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { RoleType } from '@type/roles.type.ts' - -export const findExclusiveRole = ( - roles: RoleType[], - watchRoles: number[] = [] -) => { - let firstExclusiveElement = null - for (let i = 0; i < roles.length; i++) { - const item = roles[i] - if (item.exclusive === true && watchRoles.includes(item.id)) { - firstExclusiveElement = item - break - } - } - return firstExclusiveElement -} diff --git a/src/utils/userUtils/getFullNameUtil.ts b/src/utils/userUtils/getFullNameUtil.ts deleted file mode 100644 index e7f5f71..0000000 --- a/src/utils/userUtils/getFullNameUtil.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { UserType } from '@type/user.type.ts' - -export const getUserFullName = (user: UserType): string => - user ? `${user.lastName} ${user.firstName}` : '' diff --git a/src/widgets/AccessListTree/access-list-tree.scss b/src/widgets/AccessListTree/access-list-tree.scss deleted file mode 100644 index 1d5669e..0000000 --- a/src/widgets/AccessListTree/access-list-tree.scss +++ /dev/null @@ -1,9 +0,0 @@ -@import "../../constants/style/styleConst"; - -.access-list-tree{ - overflow-y: scroll; - height: calc(100vh - 100px); - &__inner-tag{ - margin-left: $basic-margin; - } -} diff --git a/src/widgets/AccessListTree/access-list-tree.type.ts b/src/widgets/AccessListTree/access-list-tree.type.ts deleted file mode 100644 index 3c639cc..0000000 --- a/src/widgets/AccessListTree/access-list-tree.type.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { TreeProps } from 'antd' - -import { AccessListMethodType, EndpointType } from '@type/accessList.type.ts' - -export interface AccessListTreePropsType { - searchValue: string - defaultAllRoutes: Record - methods: AccessListMethodType[] - onCheck: TreeProps['onCheck'] -} diff --git a/src/widgets/AccessListTree/index.tsx b/src/widgets/AccessListTree/index.tsx deleted file mode 100644 index 818e90c..0000000 --- a/src/widgets/AccessListTree/index.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { WarningOutlined } from '@ant-design/icons' -import { Tag, Tree, TreeProps } from 'antd' -import { FC, memo, useCallback, useEffect, useState } from 'react' - -import { AccessListTreePropsType } from '@widgets/AccessListTree/access-list-tree.type.ts' - -import useRole from '@hooks/useRole.tsx' - -import { EndpointType } from '@type/accessList.type.ts' -import { PermissionKeysType } from '@type/roles.type.ts' - -import './access-list-tree.scss' - -const unknownMethodKey = 'неизвестные методы' - -const AccessListTree: FC = ({ - searchValue, - defaultAllRoutes, - methods, - onCheck = [] -}) => { - const { hasPermission } = useRole() - const [checkedKeys, setCheckedKeys] = useState([]) - const [expandedKeys, setExpandedKeys] = useState([]) - - const createTreeData = (data: Record) => { - return Object.keys(data) - .sort() - .map((routeKey) => { - if (routeKey === unknownMethodKey) { - return { - title: ( - - {routeKey} - - ), - key: routeKey, - children: data[routeKey].map((route) => createTreeNode(route, true)) - } - } - return { - title: routeKey, - key: routeKey, - children: data[routeKey].map((route) => createTreeNode(route)) - } - }) - } - - const createTreeNode = useCallback((obj: EndpointType, unknown = false) => { - return { - title: ( - - {obj.path} - {obj.inner ? ( - - Внутренний - - ) : null} - - ), - key: obj.path - } - }, []) - - const filteredRoute = () => { - if (!searchValue) { - return defaultAllRoutes - } - const filteredRoute: Record = {} - Object.keys(defaultAllRoutes).forEach((groupName) => { - const filterArray = defaultAllRoutes[groupName].filter(({ path }) => - path.toLowerCase().includes(searchValue) - ) - if (filterArray.length) { - filteredRoute[groupName] = filterArray - } - }) - return filteredRoute - } - - const treeData = createTreeData(filteredRoute()) - - const filteredCheckedKeys = () => { - const isStringPresent = (string: string) => { - for (const service of treeData) { - for (const endpoint of service.children) { - if (endpoint.key === string) { - return true - } - } - } - return false - } - - return checkedKeys.filter((string) => isStringPresent(string)) - } - - const filteredKeys = filteredCheckedKeys() - - useEffect(() => { - const checkedKeys = new Set() - methods.forEach(({ method, value }) => { - if (value) { - checkedKeys.add(method) - } - }) - - const arrayCheckedKeys = Array.from(checkedKeys) - setCheckedKeys(arrayCheckedKeys) - }, [methods]) - - useEffect(() => { - if (!searchValue) { - setExpandedKeys([]) - return - } - const keys = Object.values(treeData).map((node) => node.key) - setExpandedKeys(keys) - }, [searchValue, defaultAllRoutes]) - - return ( -
- setExpandedKeys(keys as string[])} - onCheck={onCheck as TreeProps['onCheck']} - treeData={treeData} - /> -
- ) -} - -export default memo(AccessListTree) diff --git a/src/widgets/ActiveTableActionButtons/active-table-action-buttons.scss b/src/widgets/ActiveTableActionButtons/active-table-action-buttons.scss deleted file mode 100644 index 6fef769..0000000 --- a/src/widgets/ActiveTableActionButtons/active-table-action-buttons.scss +++ /dev/null @@ -1,12 +0,0 @@ -@import "src/constants/style/styleConst"; - - -.active-configurations-table-actions-field { - display: flex; - gap: $basic-margin; -} - -.dropdown { - display: flex; - gap: $basic-margin; -} diff --git a/src/widgets/ActiveTableActionButtons/active-table-action-buttons.type.ts b/src/widgets/ActiveTableActionButtons/active-table-action-buttons.type.ts deleted file mode 100644 index 43a4109..0000000 --- a/src/widgets/ActiveTableActionButtons/active-table-action-buttons.type.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -export interface ActiveTableActionButtonsPropsType { - isActive: boolean - record: ConfigType - handleShowConfig: (record: ConfigType) => void - handleShowCompareModal: (record: ConfigType) => void - handleDeleteConfig: (record: ConfigType) => void - handleMarkConfigActive: (record: ConfigType) => void -} diff --git a/src/widgets/ActiveTableActionButtons/index.tsx b/src/widgets/ActiveTableActionButtons/index.tsx deleted file mode 100644 index 10fb1a2..0000000 --- a/src/widgets/ActiveTableActionButtons/index.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import { - AlertOutlined, - DeleteOutlined, - FormOutlined, - EyeOutlined, - HistoryOutlined, - SwapOutlined, - EllipsisOutlined, - CopyOutlined -} from '@ant-design/icons' -import { Button, Dropdown, message, Popconfirm, Tooltip } from 'antd' -import { FC } from 'react' -import { useNavigate } from 'react-router-dom' - -import CanEdit from '@components/CanEdit' - -import { ConfigType } from '@pages/ModulesPage/module.type.ts' - -import configServiceApi from '@services/configService.ts' - -import { routePaths } from '@routes/routePaths.ts' - -import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons.type.ts' - -import './active-table-action-buttons.scss' - -const ActiveTableActionButtons: FC = ({ - isActive, - record, - handleShowCompareModal, - handleShowConfig, - handleDeleteConfig, - handleMarkConfigActive -}) => { - const navigate = useNavigate() - const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation() - - const navigateToAllVersion = () => navigate(`${record.id}/all_versions`) - - const copyConfig = () => { - const newConfig = { - name: `${record.name} (copy)`, - moduleId: record.moduleId, - id: '', - version: 0, - data: record.data - } as ConfigType - createUpdateConfig(newConfig) - .unwrap() - .then(() => message.success('Конфиг успешно скопирован')) - .catch(() => message.error('Не удалось скопировать конфиг')) - } - - const renderDropDownNoActive = (record: any) => { - return ( -
- -
- ) - } - - const renderDropDownActive = (record: any) => { - return ( -
- -
- ) - } - - const renderAdditionalButtons = () => { - if (isActive) { - return ( - renderDropDownActive(record)}> -