cx-chat 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
- package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
- package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
- package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
- package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
- package/.docker/Dockerfile +7 -0
- package/.env +9 -0
- package/.env.development +7 -0
- package/.env.production +7 -0
- package/.gitlab-ci/docker-build.yaml +28 -0
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
- package/.gitlab-ci/npm-build.yaml +17 -0
- package/.gitlab-ci.yml +8 -0
- package/.k8s/0-namespace.yaml +6 -0
- package/.k8s/1-configmap-web.yaml +7 -0
- package/.k8s/1-nginx-conf-dev.yaml +110 -0
- package/.k8s/2-deployment.yaml +27 -0
- package/.k8s/3-service.yaml +16 -0
- package/.k8s/4-ingress-dev.yaml +30 -0
- package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
- package/.nginx/nginx.conf +52 -0
- package/.prettierrc +9 -0
- package/README.md +1 -0
- package/eslint.config.js +32 -0
- package/index.html +13 -0
- package/package.json +67 -0
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +96 -0
- package/src/_doc/0.docs-overview.md +28 -0
- package/src/_doc/cx-ui/0.docs-overview.md +30 -0
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
- package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
- package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
- package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
- package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
- package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
- package/src/_doc/meta/0.docs-overview.md +24 -0
- package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
- package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
- package/src/_doc/router/0.docs-overview.md +14 -0
- package/src/_doc/router/guide.1.menu-component-config.md +181 -0
- package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
- package/src/_doc/table-view/0.docs-overview.md +30 -0
- package/src/_doc/table-view/comp.1.table-view.md +542 -0
- package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
- package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
- package/src/api/_mock/README.md +340 -0
- package/src/api/_mock/api.ts +1642 -0
- package/src/api/_mock/bundle-shim.ts +16 -0
- package/src/api/_mock/handler-shim.ts +6 -0
- package/src/api/_mock/handler.ts +458 -0
- package/src/api/_mock/index.ts +711 -0
- package/src/api/_mock/interceptor.ts +15 -0
- package/src/api/_mock/mod.ts +12 -0
- package/src/api/_mock/utils.ts +65 -0
- package/src/api/base/memory.js +24 -0
- package/src/api/chat.js +210 -0
- package/src/api/common/auth.js +70 -0
- package/src/api/menus/business-rules.js +76 -0
- package/src/api/menus/feedback.js +102 -0
- package/src/api/menus/knowledge.js +159 -0
- package/src/api/menus/model-metadata/manage.js +70 -0
- package/src/api/menus/model-metadata/role.js +50 -0
- package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
- package/src/api/menus/model-metadata/training.js +28 -0
- package/src/api/menus/skill.js +40 -0
- package/src/api/system/agent-config.js +16 -0
- package/src/api/system/department.js +94 -0
- package/src/api/system/dict.js +86 -0
- package/src/api/system/menu.js +37 -0
- package/src/api/system/permission.js +26 -0
- package/src/api/system/role.js +34 -0
- package/src/api/system/sys-config.js +16 -0
- package/src/api/system/sys-log.js +17 -0
- package/src/api/system/user.js +75 -0
- package/src/api/upload.js +39 -0
- package/src/assets/react.svg +1 -0
- package/src/components/auth/current-user-avatar.tsx +77 -0
- package/src/components/common/code-view.tsx +149 -0
- package/src/components/common/detail-link.tsx +67 -0
- package/src/components/common/error-boundary.tsx +98 -0
- package/src/components/common/language-switcher.tsx +91 -0
- package/src/components/common/lite-table/index.tsx +135 -0
- package/src/components/common/md-editor.tsx +126 -0
- package/src/components/common/modal/confirm-dialog.tsx +113 -0
- package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
- package/src/components/common/modal/dep-user-select.tsx +249 -0
- package/src/components/common/modal/user-select-multi.tsx +266 -0
- package/src/components/common/pagination.tsx +472 -0
- package/src/components/common/path.tsx +175 -0
- package/src/components/common/system-logo-mark.tsx +48 -0
- package/src/components/cx-ui/button/index.less +208 -0
- package/src/components/cx-ui/button/index.tsx +611 -0
- package/src/components/cx-ui/checkbox/index.tsx +78 -0
- package/src/components/cx-ui/date-picker/index.less +17 -0
- package/src/components/cx-ui/date-picker/index.tsx +193 -0
- package/src/components/cx-ui/drawer/index.tsx +47 -0
- package/src/components/cx-ui/empty-state/index.tsx +20 -0
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
- package/src/components/cx-ui/form/CxForm.tsx +15 -0
- package/src/components/cx-ui/form/index.tsx +20 -0
- package/src/components/cx-ui/form-item/index.less +26 -0
- package/src/components/cx-ui/form-item/index.tsx +36 -0
- package/src/components/cx-ui/index.ts +70 -0
- package/src/components/cx-ui/input/auto-complete.tsx +134 -0
- package/src/components/cx-ui/input/index.tsx +259 -0
- package/src/components/cx-ui/input-number/index.jsx +66 -0
- package/src/components/cx-ui/modal/index.jsx +212 -0
- package/src/components/cx-ui/modal/index.less +144 -0
- package/src/components/cx-ui/modal/useCxModal.ts +125 -0
- package/src/components/cx-ui/multi-select/index.jsx +74 -0
- package/src/components/cx-ui/multi-select/index.less +40 -0
- package/src/components/cx-ui/multi-select/index2.tsx +361 -0
- package/src/components/cx-ui/radio/index.tsx +33 -0
- package/src/components/cx-ui/range-picker/index.less +65 -0
- package/src/components/cx-ui/range-picker/index.tsx +219 -0
- package/src/components/cx-ui/select/index.less +34 -0
- package/src/components/cx-ui/select/index.tsx +196 -0
- package/src/components/cx-ui/skeleton/index.tsx +12 -0
- package/src/components/cx-ui/steps/index.tsx +14 -0
- package/src/components/cx-ui/styles/_tokens.less +79 -0
- package/src/components/cx-ui/styles/index.less +246 -0
- package/src/components/cx-ui/switch/index.less +106 -0
- package/src/components/cx-ui/switch/index.tsx +120 -0
- package/src/components/cx-ui/table/index.less +160 -0
- package/src/components/cx-ui/table/index.tsx +152 -0
- package/src/components/cx-ui/tabs/index.less +15 -0
- package/src/components/cx-ui/tabs/index.tsx +34 -0
- package/src/components/cx-ui/tag/index.less +51 -0
- package/src/components/cx-ui/tag/index.tsx +140 -0
- package/src/components/cx-ui/timeline/index.tsx +14 -0
- package/src/components/cx-ui/tooltip/index.tsx +67 -0
- package/src/components/cx-ui/tree/index.tsx +193 -0
- package/src/components/cx-ui/tree-select/index.jsx +91 -0
- package/src/components/cx-ui/tree-select/index.less +27 -0
- package/src/components/cx-ui/upload-file/index.less +223 -0
- package/src/components/cx-ui/upload-file/index.tsx +640 -0
- package/src/components/cx-ui/upload-img/index.tsx +291 -0
- package/src/components/layout/components/Header.tsx +216 -0
- package/src/components/layout/components/Sidebar.tsx +717 -0
- package/src/components/layout/index.tsx +95 -0
- package/src/components/table-view/components/search-area.tsx +411 -0
- package/src/components/table-view/components/table-view-config.tsx +528 -0
- package/src/components/table-view/components/table-view.types.ts +478 -0
- package/src/components/table-view/components/tree-api-normalize.ts +38 -0
- package/src/components/table-view/components/tree-data-annotate.ts +31 -0
- package/src/components/table-view/components/tree-sidebar.tsx +74 -0
- package/src/components/table-view/index.tsx +61 -0
- package/src/components/table-view/list-page-view.tsx +1049 -0
- package/src/components/table-view/select-table-view.tsx +1094 -0
- package/src/components/table-view/styles/select-table-view.less +51 -0
- package/src/config/default-system-name.ts +9 -0
- package/src/config/system.ts +165 -0
- package/src/constants/countryCodes.ts +3 -0
- package/src/contexts/AuthContext.tsx +256 -0
- package/src/contexts/ChatContext.tsx +839 -0
- package/src/contexts/MenuContext.tsx +62 -0
- package/src/contexts/ToastContext.tsx +181 -0
- package/src/hooks/useCopyToClipboard.ts +47 -0
- package/src/hooks/useModalSubmit.ts +104 -0
- package/src/hooks/useRouter.ts +240 -0
- package/src/hooks/useStepForm.ts +46 -0
- package/src/hooks/useStickyHeader.ts +42 -0
- package/src/hooks/useThreadActions.ts +105 -0
- package/src/hooks/useUserPreferences.ts +101 -0
- package/src/http/axios.js +372 -0
- package/src/http/mock.interceptor.ts +9 -0
- package/src/http/obfuscationKey.ts +41 -0
- package/src/i18n.ts +60 -0
- package/src/index.js +1 -0
- package/src/index.less +169 -0
- package/src/locales/en/auth.ts +70 -0
- package/src/locales/en/base/memory.ts +28 -0
- package/src/locales/en/base/settings.ts +41 -0
- package/src/locales/en/chat.ts +40 -0
- package/src/locales/en/common.ts +173 -0
- package/src/locales/en/enum.ts +27 -0
- package/src/locales/en/menus/business-rules.ts +48 -0
- package/src/locales/en/menus/feedback.ts +62 -0
- package/src/locales/en/menus/knowledge.ts +120 -0
- package/src/locales/en/menus/model-metadata/index.ts +10 -0
- package/src/locales/en/menus/model-metadata/manage.ts +151 -0
- package/src/locales/en/menus/model-metadata/role.ts +48 -0
- package/src/locales/en/menus/model-metadata/training.ts +65 -0
- package/src/locales/en/menus/skill.ts +34 -0
- package/src/locales/en/system/agent-config.ts +34 -0
- package/src/locales/en/system/department.ts +68 -0
- package/src/locales/en/system/dict.ts +44 -0
- package/src/locales/en/system/menu.ts +45 -0
- package/src/locales/en/system/permission.ts +89 -0
- package/src/locales/en/system/role.ts +25 -0
- package/src/locales/en/system/sys-config.ts +33 -0
- package/src/locales/en/system/sys-log.ts +38 -0
- package/src/locales/en/system/user.ts +113 -0
- package/src/locales/en.ts +68 -0
- package/src/locales/zh/auth.ts +70 -0
- package/src/locales/zh/base/memory.ts +29 -0
- package/src/locales/zh/base/settings.ts +41 -0
- package/src/locales/zh/chat.ts +47 -0
- package/src/locales/zh/common.ts +178 -0
- package/src/locales/zh/enum.ts +28 -0
- package/src/locales/zh/menus/business-rules.ts +47 -0
- package/src/locales/zh/menus/feedback.ts +62 -0
- package/src/locales/zh/menus/knowledge.ts +117 -0
- package/src/locales/zh/menus/model-metadata/index.ts +10 -0
- package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
- package/src/locales/zh/menus/model-metadata/role.ts +47 -0
- package/src/locales/zh/menus/model-metadata/training.ts +64 -0
- package/src/locales/zh/menus/skill.ts +34 -0
- package/src/locales/zh/system/agent-config.ts +33 -0
- package/src/locales/zh/system/department.ts +69 -0
- package/src/locales/zh/system/dict.ts +44 -0
- package/src/locales/zh/system/menu.ts +47 -0
- package/src/locales/zh/system/permission.ts +94 -0
- package/src/locales/zh/system/role.ts +25 -0
- package/src/locales/zh/system/sys-config.ts +32 -0
- package/src/locales/zh/system/sys-log.ts +38 -0
- package/src/locales/zh/system/user.ts +114 -0
- package/src/locales/zh.ts +67 -0
- package/src/main.tsx +50 -0
- package/src/meta/const/index.ts +40 -0
- package/src/meta/index-dict.ts +56 -0
- package/src/meta/index-enum.ts +95 -0
- package/src/meta/index.ts +14 -0
- package/src/meta/module/dict-data/runtime.ts +199 -0
- package/src/meta/module/dict-data/types.ts +17 -0
- package/src/meta/module/enum-data/runtime.ts +75 -0
- package/src/meta/module/enum-data/types.ts +18 -0
- package/src/router/index.tsx +312 -0
- package/src/styles/AntdThemeProvider.tsx +40 -0
- package/src/styles/antd-theme.ts +20 -0
- package/src/styles/global.less +107 -0
- package/src/styles/variable.less +103 -0
- package/src/types/feedback.ts +43 -0
- package/src/types/index.ts +85 -0
- package/src/types/menu.ts +43 -0
- package/src/utils/aesUtil.ts +123 -0
- package/src/utils/chatUtils.ts +524 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/crypto.ts +164 -0
- package/src/utils/date.ts +72 -0
- package/src/utils/file-icons.tsx +79 -0
- package/src/utils/index.ts +168 -0
- package/src/utils/markdown-math-plugins.ts +21 -0
- package/src/utils/menuI18n.ts +305 -0
- package/src/utils/menuRouteRegistry.ts +78 -0
- package/src/utils/permission-crud.ts +147 -0
- package/src/utils/routeConfig.ts +350 -0
- package/src/utils/storage.ts +135 -0
- package/src/utils/toastBridge.ts +26 -0
- package/src/utils/url.ts +38 -0
- package/src/utils/validation.ts +16 -0
- package/src/views/auth/auth-code/index.less +169 -0
- package/src/views/auth/auth-code/index.module.less +174 -0
- package/src/views/auth/auth-code/index.tsx +233 -0
- package/src/views/auth/login.tsx +498 -0
- package/src/views/auth/register.tsx +388 -0
- package/src/views/base/memory/index.tsx +136 -0
- package/src/views/base/memory/modal/detail-modal.tsx +89 -0
- package/src/views/base/memory/modal/submit-modal.tsx +134 -0
- package/src/views/base/settings/index.tsx +657 -0
- package/src/views/chat/chat.less +323 -0
- package/src/views/chat/components/chat-input.tsx +298 -0
- package/src/views/chat/components/header-thread-title.tsx +210 -0
- package/src/views/chat/components/message-list/content-answer.tsx +100 -0
- package/src/views/chat/components/message-list/content-question.tsx +18 -0
- package/src/views/chat/components/message-list/index.tsx +520 -0
- package/src/views/chat/components/message-list/message-item.tsx +199 -0
- package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
- package/src/views/chat/components/message-list/toolbar.tsx +224 -0
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/chat/components/references-knowledge/context.tsx +57 -0
- package/src/views/chat/components/references-knowledge/index.ts +9 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
- package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
- package/src/views/chat/hooks/use-chat-common.ts +19 -0
- package/src/views/chat/index-session.tsx +647 -0
- package/src/views/chat/index.tsx +127 -0
- package/src/views/page-error/401.tsx +56 -0
- package/src/views/page-error/404.tsx +56 -0
- package/src/views/page-menus/business-rules/index.tsx +376 -0
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
- package/src/views/page-menus/feedback/index.tsx +166 -0
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
- package/src/views/page-menus/knowledge/detail.tsx +600 -0
- package/src/views/page-menus/knowledge/index.tsx +337 -0
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
- package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
- package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
- package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
- package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
- package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
- package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
- package/src/views/page-menus/skill/index.tsx +201 -0
- package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
- package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
- package/src/views/page-system/agent-config/index.tsx +370 -0
- package/src/views/page-system/department/departmentFormShared.ts +36 -0
- package/src/views/page-system/department/index.tsx +541 -0
- package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
- package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
- package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
- package/src/views/page-system/dict/index.tsx +440 -0
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
- package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
- package/src/views/page-system/logs/components/index.ts +3 -0
- package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
- package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
- package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
- package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
- package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/page-system/logs/components/message-modal.tsx +239 -0
- package/src/views/page-system/logs/index.tsx +132 -0
- package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
- package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
- package/src/views/page-system/menu/index.less +12 -0
- package/src/views/page-system/menu/index.tsx +410 -0
- package/src/views/page-system/menu/modal/icon-modal.less +51 -0
- package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
- package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
- package/src/views/page-system/permission/index.tsx +562 -0
- package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
- package/src/views/page-system/permission/modal/submit-modal.less +146 -0
- package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
- package/src/views/page-system/role/index.tsx +163 -0
- package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
- package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
- package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
- package/src/views/page-system/sys-config/index.tsx +294 -0
- package/src/views/page-system/user/components/user-role-column.tsx +87 -0
- package/src/views/page-system/user/index.tsx +439 -0
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
- package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
- package/src/views/page-system/user/userFormShared.ts +51 -0
- package/tailwind.config.js +17 -0
- package/tsconfig.app.json +48 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +264 -0
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
import { getUserMenuListAPI } from '@/api/common/auth'
|
|
2
|
+
import { getPermissionListAPI } from '@/api/system/permission'
|
|
3
|
+
import { getRoleDetailAPI } from '@/api/system/role'
|
|
4
|
+
import { useToast } from '@/contexts/ToastContext'
|
|
5
|
+
import { CxCheckbox } from '@cx-ui'
|
|
6
|
+
import { conductCheck } from '@rc-component/tree/lib/utils/conductUtil'
|
|
7
|
+
import { convertDataToEntities } from '@rc-component/tree/lib/utils/treeUtil'
|
|
8
|
+
import { Tree } from 'antd'
|
|
9
|
+
import type { DataNode, TreeProps } from 'antd/es/tree'
|
|
10
|
+
import clsx from 'clsx'
|
|
11
|
+
import {
|
|
12
|
+
forwardRef,
|
|
13
|
+
useCallback,
|
|
14
|
+
useEffect,
|
|
15
|
+
useImperativeHandle,
|
|
16
|
+
useMemo,
|
|
17
|
+
useRef,
|
|
18
|
+
useState,
|
|
19
|
+
} from 'react'
|
|
20
|
+
import { useTranslation } from 'react-i18next'
|
|
21
|
+
import {
|
|
22
|
+
augmentInitialMenuBasePermissionCodes,
|
|
23
|
+
buildRolePermissionCreateDTO,
|
|
24
|
+
codesForRowsInMenuSubtree,
|
|
25
|
+
collectSubtreeMenuIds,
|
|
26
|
+
comparePermissionRowsForAssign,
|
|
27
|
+
computePermissionAssignSection,
|
|
28
|
+
dedupePermissionRows,
|
|
29
|
+
findFirstLeafId,
|
|
30
|
+
flattenPermissionsFromMenuTree,
|
|
31
|
+
getMenuPathFromRoot,
|
|
32
|
+
inferStrictMenuCheckFromMergedMenuIds,
|
|
33
|
+
isAssignPermissionChecked,
|
|
34
|
+
isPermissionRowBuiltin,
|
|
35
|
+
isPermissionRowMenuLockedBase,
|
|
36
|
+
mapMenusToTreeData,
|
|
37
|
+
mapPermissionListResponseToRows,
|
|
38
|
+
menuPreorderIndexMap,
|
|
39
|
+
mergeRolePermissionAssignPayloadCodes,
|
|
40
|
+
nextPermissionCodesForMenuSubtree,
|
|
41
|
+
normalizeRoleApiListSnapshot,
|
|
42
|
+
normalizeRoleMenuSnapshot,
|
|
43
|
+
resolveScrollAnchorForMenuClick,
|
|
44
|
+
splitPermissionCodeParts,
|
|
45
|
+
swaggerHttpMethodLeftAccentClass,
|
|
46
|
+
unwrapMenuTreeResponse,
|
|
47
|
+
type MenuPermissionSection,
|
|
48
|
+
type PermissionRow,
|
|
49
|
+
type RolePermissionAssignPayload,
|
|
50
|
+
} from './role-permission-assign-shared'
|
|
51
|
+
|
|
52
|
+
export type RolePermissionAssignPanelHandle = {
|
|
53
|
+
getPayload: () => RolePermissionAssignPayload
|
|
54
|
+
reset: () => void
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type Props = {
|
|
58
|
+
/** 为 false 时不加载、不渲染(用于新增弹窗未勾选「配置权限」) */
|
|
59
|
+
active: boolean
|
|
60
|
+
/** 已有角色 id;不传则视为新建,仅从菜单树构建可选权限、选中为空 */
|
|
61
|
+
roleId?: string | number | null
|
|
62
|
+
/**
|
|
63
|
+
* 外层每次打开「新增」弹窗递增;弹窗已打开时再次点「新增」时 `active` 不变,
|
|
64
|
+
* 仅靠此 key 变化触发重新 bootstrap(避免 reset 后无请求、树空白)。
|
|
65
|
+
*/
|
|
66
|
+
bootstrapKey?: number
|
|
67
|
+
/**
|
|
68
|
+
* 在 `cx-modal-role-assign`(容器固定视口高度)内传入
|
|
69
|
+
* `h-full min-h-0 w-full flex-1 overflow-hidden`,根与左右列才能撑满并内部滚动。
|
|
70
|
+
*/
|
|
71
|
+
maxHeightClass?: string
|
|
72
|
+
/** 只读模式:禁用所有 checkbox 和交互 */
|
|
73
|
+
readOnly?: boolean
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 卡片底色/边框:0 内置、1 基础、2/缺省 扩展 */
|
|
77
|
+
function assignCardShellTone(
|
|
78
|
+
apiType: number | undefined,
|
|
79
|
+
selected: boolean,
|
|
80
|
+
): string {
|
|
81
|
+
const t = apiType ?? 2
|
|
82
|
+
if (t === 0) {
|
|
83
|
+
return selected
|
|
84
|
+
? 'border border-dashed border-gray-300/95 bg-gray-100/90 text-gray-600 ring-1 ring-gray-200/90 dark:border-gray-600 dark:bg-gray-900/50 dark:text-gray-400 dark:ring-gray-800/80'
|
|
85
|
+
: 'border border-dashed border-gray-300/85 bg-gray-50/90 text-gray-600 hover:bg-gray-100/95 dark:border-gray-600 dark:bg-gray-900/40 dark:text-gray-400 dark:hover:bg-gray-900/55'
|
|
86
|
+
}
|
|
87
|
+
if (t === 1) {
|
|
88
|
+
// apiType=1 基础类型:使用更明显的背景色
|
|
89
|
+
return selected
|
|
90
|
+
? 'border-indigo-300 bg-indigo-100 ring-1 ring-indigo-200 dark:border-indigo-600 dark:bg-indigo-950/50 dark:ring-indigo-800/60'
|
|
91
|
+
: 'border-indigo-200 bg-indigo-50/80 hover:bg-indigo-100/90 dark:border-indigo-700 dark:bg-indigo-950/35 dark:hover:bg-indigo-950/50'
|
|
92
|
+
}
|
|
93
|
+
return selected
|
|
94
|
+
? 'border-blue-200 bg-blue-50 ring-1 ring-blue-100 dark:border-blue-800 dark:bg-blue-900/30 dark:ring-blue-900/50'
|
|
95
|
+
: 'border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700/50'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function assignCodeTitleHoverClass(apiType: number | undefined): string {
|
|
99
|
+
const t = apiType ?? 2
|
|
100
|
+
if (t === 0) {
|
|
101
|
+
return 'text-gray-500 transition-colors dark:text-gray-400'
|
|
102
|
+
}
|
|
103
|
+
if (t === 1) {
|
|
104
|
+
return 'text-gray-900 transition-colors group-hover:text-indigo-700 dark:text-gray-100 dark:group-hover:text-indigo-300'
|
|
105
|
+
}
|
|
106
|
+
return 'text-gray-900 transition-colors group-hover:text-blue-600 dark:text-gray-100 dark:group-hover:text-blue-400'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const RolePermissionAssignPanel = forwardRef<
|
|
110
|
+
RolePermissionAssignPanelHandle,
|
|
111
|
+
Props
|
|
112
|
+
>(function RolePermissionAssignPanel(
|
|
113
|
+
{
|
|
114
|
+
active,
|
|
115
|
+
bootstrapKey = 0,
|
|
116
|
+
maxHeightClass,
|
|
117
|
+
roleId,
|
|
118
|
+
readOnly = false,
|
|
119
|
+
},
|
|
120
|
+
ref,
|
|
121
|
+
) {
|
|
122
|
+
const { t, i18n } = useTranslation()
|
|
123
|
+
const { showToast } = useToast()
|
|
124
|
+
const rightScrollRef = useRef<HTMLDivElement>(null)
|
|
125
|
+
|
|
126
|
+
const [loading, setLoading] = useState(false)
|
|
127
|
+
const [treeData, setTreeData] = useState<any[]>([])
|
|
128
|
+
const [selectedMenuId, setSelectedMenuId] = useState<React.Key | null>(null)
|
|
129
|
+
const [checkedMenuKeys, setCheckedMenuKeys] = useState<string[]>([])
|
|
130
|
+
const [halfCheckedMenuKeys, setHalfCheckedMenuKeys] = useState<string[]>([])
|
|
131
|
+
const [permissionCodes, setPermissionCodes] = useState<string[]>([])
|
|
132
|
+
const [allPermissionRows, setAllPermissionRows] = useState<PermissionRow[]>(
|
|
133
|
+
[],
|
|
134
|
+
)
|
|
135
|
+
const [permLoading, setPermLoading] = useState(false)
|
|
136
|
+
/** 默认不展示内置(apiType=0);提交仍由 merge 强制并入 */
|
|
137
|
+
const [showBuiltinInPanel, setShowBuiltinInPanel] = useState(false)
|
|
138
|
+
|
|
139
|
+
const idKey = 'id'
|
|
140
|
+
const childrenKey = 'children'
|
|
141
|
+
|
|
142
|
+
const resetLocal = useCallback(() => {
|
|
143
|
+
setTreeData([])
|
|
144
|
+
setSelectedMenuId(null)
|
|
145
|
+
setCheckedMenuKeys([])
|
|
146
|
+
setHalfCheckedMenuKeys([])
|
|
147
|
+
setPermissionCodes([])
|
|
148
|
+
setAllPermissionRows([])
|
|
149
|
+
setShowBuiltinInPanel(false)
|
|
150
|
+
}, [])
|
|
151
|
+
|
|
152
|
+
const scrollToMenuSection = useCallback((menuId: string) => {
|
|
153
|
+
const root = rightScrollRef.current
|
|
154
|
+
if (!root) return
|
|
155
|
+
const el = root.querySelector(
|
|
156
|
+
`[data-perm-menu-section="${CSS.escape(menuId)}"]`,
|
|
157
|
+
)
|
|
158
|
+
el?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
159
|
+
}, [])
|
|
160
|
+
|
|
161
|
+
const bootstrap = useCallback(async () => {
|
|
162
|
+
setLoading(true)
|
|
163
|
+
setPermLoading(true)
|
|
164
|
+
try {
|
|
165
|
+
const rid =
|
|
166
|
+
roleId !== undefined && roleId !== null && String(roleId).trim() !== ''
|
|
167
|
+
? roleId
|
|
168
|
+
: null
|
|
169
|
+
const [menuRes, roleDetailRes, listRes] = await Promise.all([
|
|
170
|
+
getUserMenuListAPI({}),
|
|
171
|
+
rid != null ? getRoleDetailAPI(rid) : Promise.resolve({ data: {} }),
|
|
172
|
+
getPermissionListAPI().catch(() => null),
|
|
173
|
+
])
|
|
174
|
+
const menus = unwrapMenuTreeResponse(menuRes)
|
|
175
|
+
setTreeData(menus)
|
|
176
|
+
|
|
177
|
+
const snapMenu = normalizeRoleMenuSnapshot(roleDetailRes)
|
|
178
|
+
const snapApi = normalizeRoleApiListSnapshot(roleDetailRes)
|
|
179
|
+
|
|
180
|
+
const menuNodesForInfer = mapMenusToTreeData(
|
|
181
|
+
menus,
|
|
182
|
+
t,
|
|
183
|
+
i18n.language,
|
|
184
|
+
idKey,
|
|
185
|
+
childrenKey,
|
|
186
|
+
)
|
|
187
|
+
const mergedMenuIdsForInfer = [
|
|
188
|
+
...new Set(
|
|
189
|
+
[...snapMenu.menuIds, ...snapMenu.halfCheckedMenuIds].map(String),
|
|
190
|
+
),
|
|
191
|
+
]
|
|
192
|
+
let initChecked: string[]
|
|
193
|
+
let initHalf: string[]
|
|
194
|
+
if (snapMenu.halfCheckedMenuIds.length > 0) {
|
|
195
|
+
initChecked = snapMenu.menuIds.map(String)
|
|
196
|
+
initHalf = snapMenu.halfCheckedMenuIds.map(String)
|
|
197
|
+
} else {
|
|
198
|
+
const inferred = inferStrictMenuCheckFromMergedMenuIds(
|
|
199
|
+
menuNodesForInfer,
|
|
200
|
+
mergedMenuIdsForInfer,
|
|
201
|
+
)
|
|
202
|
+
initChecked = inferred.checkedKeys
|
|
203
|
+
initHalf = inferred.halfCheckedKeys
|
|
204
|
+
}
|
|
205
|
+
setCheckedMenuKeys(initChecked)
|
|
206
|
+
setHalfCheckedMenuKeys(initHalf)
|
|
207
|
+
|
|
208
|
+
let fromApi: PermissionRow[] = []
|
|
209
|
+
if (listRes != null) {
|
|
210
|
+
try {
|
|
211
|
+
/** 含 apiType=0(提交时强制并入,右栏不展示) */
|
|
212
|
+
fromApi = mapPermissionListResponseToRows(listRes)
|
|
213
|
+
} catch {
|
|
214
|
+
fromApi = []
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const fromTree = flattenPermissionsFromMenuTree(menus, idKey)
|
|
218
|
+
const catalog = dedupePermissionRows([
|
|
219
|
+
...fromApi,
|
|
220
|
+
...fromTree,
|
|
221
|
+
...snapMenu.extraPermissionRows,
|
|
222
|
+
...snapApi.extraPermissionRows,
|
|
223
|
+
])
|
|
224
|
+
setAllPermissionRows(catalog)
|
|
225
|
+
|
|
226
|
+
const codesFromSnap = [
|
|
227
|
+
...new Set([
|
|
228
|
+
...snapMenu.permissionCodes,
|
|
229
|
+
...snapApi.permissionCodes,
|
|
230
|
+
]),
|
|
231
|
+
]
|
|
232
|
+
let nextPermissionCodes = codesFromSnap
|
|
233
|
+
if (snapApi.apiIds.length) {
|
|
234
|
+
const idSet = new Set(snapApi.apiIds.map(String))
|
|
235
|
+
const fromIds = catalog
|
|
236
|
+
.filter((r) => idSet.has(String(r.id)))
|
|
237
|
+
.map((r) => r.code)
|
|
238
|
+
.filter(Boolean)
|
|
239
|
+
nextPermissionCodes = [...new Set([...nextPermissionCodes, ...fromIds])]
|
|
240
|
+
}
|
|
241
|
+
setPermissionCodes(
|
|
242
|
+
augmentInitialMenuBasePermissionCodes(
|
|
243
|
+
nextPermissionCodes,
|
|
244
|
+
catalog,
|
|
245
|
+
[...initChecked, ...initHalf],
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
const firstLeaf =
|
|
250
|
+
findFirstLeafId(menus, idKey, childrenKey) ??
|
|
251
|
+
(menus[0]?.[idKey] != null ? String(menus[0][idKey]) : null)
|
|
252
|
+
if (firstLeaf != null) {
|
|
253
|
+
const sid = String(firstLeaf)
|
|
254
|
+
setSelectedMenuId(sid)
|
|
255
|
+
requestAnimationFrame(() => {
|
|
256
|
+
requestAnimationFrame(() => scrollToMenuSection(sid))
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
} catch (e: any) {
|
|
260
|
+
console.log(e?.message || t('common.error'))
|
|
261
|
+
} finally {
|
|
262
|
+
setLoading(false)
|
|
263
|
+
setPermLoading(false)
|
|
264
|
+
}
|
|
265
|
+
}, [roleId, scrollToMenuSection, showToast, t])
|
|
266
|
+
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
if (!active) {
|
|
269
|
+
resetLocal()
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
void bootstrap()
|
|
273
|
+
// 显隐、roleId、bootstrapKey 变化时拉数;bootstrap 稳定,不写入 deps
|
|
274
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
275
|
+
}, [active, bootstrapKey, roleId, resetLocal])
|
|
276
|
+
|
|
277
|
+
useImperativeHandle(
|
|
278
|
+
ref,
|
|
279
|
+
() => ({
|
|
280
|
+
getPayload: (): RolePermissionAssignPayload => {
|
|
281
|
+
const menuIds = [
|
|
282
|
+
...new Set(
|
|
283
|
+
[...checkedMenuKeys, ...halfCheckedMenuKeys].map((x) => String(x)),
|
|
284
|
+
),
|
|
285
|
+
]
|
|
286
|
+
const permissionCodesMerged = mergeRolePermissionAssignPayloadCodes(
|
|
287
|
+
permissionCodes,
|
|
288
|
+
allPermissionRows,
|
|
289
|
+
menuIds,
|
|
290
|
+
)
|
|
291
|
+
return {
|
|
292
|
+
menuIds,
|
|
293
|
+
permissionCodes: permissionCodesMerged,
|
|
294
|
+
rolePermissionCreateDTO: buildRolePermissionCreateDTO(
|
|
295
|
+
menuIds,
|
|
296
|
+
permissionCodesMerged,
|
|
297
|
+
allPermissionRows,
|
|
298
|
+
),
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
reset: () => {
|
|
302
|
+
resetLocal()
|
|
303
|
+
},
|
|
304
|
+
}),
|
|
305
|
+
[
|
|
306
|
+
allPermissionRows,
|
|
307
|
+
checkedMenuKeys,
|
|
308
|
+
halfCheckedMenuKeys,
|
|
309
|
+
permissionCodes,
|
|
310
|
+
resetLocal,
|
|
311
|
+
],
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
const menuTreeNodes = useMemo(
|
|
315
|
+
() =>
|
|
316
|
+
treeData.length
|
|
317
|
+
? mapMenusToTreeData(treeData, t, i18n.language, idKey, childrenKey)
|
|
318
|
+
: [],
|
|
319
|
+
[treeData, t, i18n.language],
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
const menuKeyEntities = useMemo(() => {
|
|
323
|
+
if (!menuTreeNodes.length) return null
|
|
324
|
+
const { keyEntities } = convertDataToEntities(menuTreeNodes, {
|
|
325
|
+
fieldNames: { title: 'title', key: 'key', children: 'children' },
|
|
326
|
+
})
|
|
327
|
+
return keyEntities
|
|
328
|
+
}, [menuTreeNodes])
|
|
329
|
+
|
|
330
|
+
const panelVisiblePermissionRows = useMemo(
|
|
331
|
+
() =>
|
|
332
|
+
showBuiltinInPanel
|
|
333
|
+
? allPermissionRows
|
|
334
|
+
: allPermissionRows.filter((p) => !isPermissionRowBuiltin(p)),
|
|
335
|
+
[allPermissionRows, showBuiltinInPanel],
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
const menuPermissionSections = useMemo((): MenuPermissionSection[] => {
|
|
339
|
+
if (!panelVisiblePermissionRows.length) return []
|
|
340
|
+
const byMenu: Record<string, PermissionRow[]> = {}
|
|
341
|
+
const unbound: PermissionRow[] = []
|
|
342
|
+
for (const p of panelVisiblePermissionRows) {
|
|
343
|
+
const mid = String((p as PermissionRow).menuId || '').trim()
|
|
344
|
+
if (!mid) {
|
|
345
|
+
unbound.push(p)
|
|
346
|
+
continue
|
|
347
|
+
}
|
|
348
|
+
if (!byMenu[mid]) byMenu[mid] = []
|
|
349
|
+
byMenu[mid].push(p)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const bucket: Record<
|
|
353
|
+
string,
|
|
354
|
+
{
|
|
355
|
+
meta: MenuPermissionSection
|
|
356
|
+
rows: PermissionRow[]
|
|
357
|
+
}
|
|
358
|
+
> = {}
|
|
359
|
+
|
|
360
|
+
const pushPerm = (
|
|
361
|
+
path: any[] | null,
|
|
362
|
+
perm: PermissionRow,
|
|
363
|
+
) => {
|
|
364
|
+
const meta = computePermissionAssignSection(
|
|
365
|
+
path,
|
|
366
|
+
perm.code,
|
|
367
|
+
idKey,
|
|
368
|
+
childrenKey,
|
|
369
|
+
t,
|
|
370
|
+
i18n.language,
|
|
371
|
+
)
|
|
372
|
+
if (!meta) return
|
|
373
|
+
if (!bucket[meta.sectionKey]) {
|
|
374
|
+
bucket[meta.sectionKey] = {
|
|
375
|
+
meta: {
|
|
376
|
+
sectionKey: meta.sectionKey,
|
|
377
|
+
sectionTitle: meta.sectionTitle,
|
|
378
|
+
anchorMenuId: meta.anchorMenuId,
|
|
379
|
+
resourceGroups: [],
|
|
380
|
+
},
|
|
381
|
+
rows: [],
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
bucket[meta.sectionKey].rows.push(perm)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
for (const menuId of Object.keys(byMenu)) {
|
|
388
|
+
const path =
|
|
389
|
+
treeData.length > 0
|
|
390
|
+
? getMenuPathFromRoot(treeData, menuId, idKey, childrenKey)
|
|
391
|
+
: null
|
|
392
|
+
for (const perm of byMenu[menuId]) {
|
|
393
|
+
if (!path) {
|
|
394
|
+
const orphanKey = `__orphan__${menuId}`
|
|
395
|
+
if (!bucket[orphanKey]) {
|
|
396
|
+
bucket[orphanKey] = {
|
|
397
|
+
meta: {
|
|
398
|
+
sectionKey: orphanKey,
|
|
399
|
+
sectionTitle: `${t('system.permission.section_unknown_menu')} (${menuId})`,
|
|
400
|
+
anchorMenuId: menuId,
|
|
401
|
+
resourceGroups: [],
|
|
402
|
+
},
|
|
403
|
+
rows: [],
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
bucket[orphanKey].rows.push(perm)
|
|
407
|
+
continue
|
|
408
|
+
}
|
|
409
|
+
pushPerm(path, perm)
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
for (const perm of unbound) {
|
|
414
|
+
pushPerm(null, perm)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const orderMap =
|
|
418
|
+
treeData.length > 0
|
|
419
|
+
? menuPreorderIndexMap(treeData, idKey, childrenKey)
|
|
420
|
+
: new Map<string, number>()
|
|
421
|
+
const sections: MenuPermissionSection[] = Object.values(bucket).map(
|
|
422
|
+
(b) => ({
|
|
423
|
+
...b.meta,
|
|
424
|
+
resourceGroups: [
|
|
425
|
+
{
|
|
426
|
+
resource: b.meta.sectionKey,
|
|
427
|
+
permissions: [...b.rows].sort(comparePermissionRowsForAssign),
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
}),
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
sections.sort((a, b) => {
|
|
434
|
+
if (a.sectionKey.startsWith('__orphan__')) return 1
|
|
435
|
+
if (b.sectionKey.startsWith('__orphan__')) return -1
|
|
436
|
+
const ia = orderMap.get(a.anchorMenuId) ?? 1_000_000
|
|
437
|
+
const ib = orderMap.get(b.anchorMenuId) ?? 1_000_000
|
|
438
|
+
if (ia !== ib) return ia - ib
|
|
439
|
+
return a.sectionKey.localeCompare(b.sectionKey)
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
return sections
|
|
443
|
+
}, [panelVisiblePermissionRows, treeData, t, i18n.language])
|
|
444
|
+
|
|
445
|
+
const onMenuCheck = useCallback<TreeProps<DataNode>['onCheck']>(
|
|
446
|
+
(_raw, info) => {
|
|
447
|
+
if (!menuKeyEntities) return
|
|
448
|
+
|
|
449
|
+
const toggledKey = String(info.node.key)
|
|
450
|
+
const subtreeIds = collectSubtreeMenuIds(
|
|
451
|
+
treeData,
|
|
452
|
+
toggledKey,
|
|
453
|
+
idKey,
|
|
454
|
+
childrenKey,
|
|
455
|
+
)
|
|
456
|
+
const subtreeCodes = codesForRowsInMenuSubtree(
|
|
457
|
+
allPermissionRows,
|
|
458
|
+
subtreeIds,
|
|
459
|
+
)
|
|
460
|
+
const checkedFlag = info.checked
|
|
461
|
+
|
|
462
|
+
let nextChecked: string[]
|
|
463
|
+
let nextHalf: string[]
|
|
464
|
+
|
|
465
|
+
if (checkedFlag === true) {
|
|
466
|
+
const conducted = conductCheck(
|
|
467
|
+
[...new Set([...checkedMenuKeys, toggledKey].map(String))],
|
|
468
|
+
true,
|
|
469
|
+
menuKeyEntities,
|
|
470
|
+
)
|
|
471
|
+
nextChecked = conducted.checkedKeys.map(String)
|
|
472
|
+
nextHalf = conducted.halfCheckedKeys.map(String)
|
|
473
|
+
} else if (checkedFlag === false) {
|
|
474
|
+
const keySet = new Set(checkedMenuKeys.map(String))
|
|
475
|
+
for (const id of subtreeIds) keySet.delete(id)
|
|
476
|
+
const halfSet = new Set(halfCheckedMenuKeys.map(String))
|
|
477
|
+
for (const id of subtreeIds) halfSet.delete(id)
|
|
478
|
+
const conducted = conductCheck(
|
|
479
|
+
Array.from(keySet),
|
|
480
|
+
{
|
|
481
|
+
checked: false,
|
|
482
|
+
halfCheckedKeys: Array.from(halfSet),
|
|
483
|
+
},
|
|
484
|
+
menuKeyEntities,
|
|
485
|
+
)
|
|
486
|
+
nextChecked = conducted.checkedKeys.map(String)
|
|
487
|
+
nextHalf = conducted.halfCheckedKeys.map(String)
|
|
488
|
+
} else {
|
|
489
|
+
const half = (info?.halfCheckedKeys ?? []).map(String)
|
|
490
|
+
if (Array.isArray(_raw)) {
|
|
491
|
+
nextChecked = _raw.map(String)
|
|
492
|
+
nextHalf = half
|
|
493
|
+
} else {
|
|
494
|
+
const obj = _raw as {
|
|
495
|
+
checked?: React.Key[]
|
|
496
|
+
halfChecked?: React.Key[]
|
|
497
|
+
}
|
|
498
|
+
nextChecked = (obj.checked ?? []).map(String)
|
|
499
|
+
nextHalf = (obj.halfChecked ?? half).map(String)
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (checkedFlag === true || checkedFlag === false) {
|
|
504
|
+
setPermissionCodes((prev) =>
|
|
505
|
+
nextPermissionCodesForMenuSubtree(
|
|
506
|
+
prev,
|
|
507
|
+
allPermissionRows,
|
|
508
|
+
subtreeCodes,
|
|
509
|
+
checkedFlag === true,
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
if (checkedFlag === true && subtreeCodes.size > 0) {
|
|
514
|
+
const scrollId = resolveScrollAnchorForMenuClick(
|
|
515
|
+
treeData,
|
|
516
|
+
toggledKey,
|
|
517
|
+
panelVisiblePermissionRows,
|
|
518
|
+
idKey,
|
|
519
|
+
childrenKey,
|
|
520
|
+
)
|
|
521
|
+
if (scrollId) {
|
|
522
|
+
requestAnimationFrame(() => {
|
|
523
|
+
requestAnimationFrame(() => scrollToMenuSection(scrollId))
|
|
524
|
+
})
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
setCheckedMenuKeys(nextChecked)
|
|
530
|
+
setHalfCheckedMenuKeys(nextHalf)
|
|
531
|
+
},
|
|
532
|
+
[
|
|
533
|
+
menuKeyEntities,
|
|
534
|
+
checkedMenuKeys,
|
|
535
|
+
halfCheckedMenuKeys,
|
|
536
|
+
treeData,
|
|
537
|
+
allPermissionRows,
|
|
538
|
+
panelVisiblePermissionRows,
|
|
539
|
+
scrollToMenuSection,
|
|
540
|
+
idKey,
|
|
541
|
+
childrenKey,
|
|
542
|
+
],
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
const togglePermissionCode = useCallback(
|
|
546
|
+
(perm: PermissionRow) => {
|
|
547
|
+
setPermissionCodes((prev) => {
|
|
548
|
+
if (isPermissionRowBuiltin(perm)) return prev
|
|
549
|
+
const menuSet = new Set(
|
|
550
|
+
[...checkedMenuKeys, ...halfCheckedMenuKeys].map((x) => String(x)),
|
|
551
|
+
)
|
|
552
|
+
if (isPermissionRowMenuLockedBase(perm, menuSet)) return prev
|
|
553
|
+
if (prev.includes('*')) {
|
|
554
|
+
const allInView = allPermissionRows.map((p) => p.code)
|
|
555
|
+
const set = new Set(allInView)
|
|
556
|
+
set.delete(perm.code)
|
|
557
|
+
return Array.from(set)
|
|
558
|
+
}
|
|
559
|
+
if (prev.includes(perm.code)) {
|
|
560
|
+
return prev.filter((c) => c !== perm.code)
|
|
561
|
+
}
|
|
562
|
+
return [...prev, perm.code]
|
|
563
|
+
})
|
|
564
|
+
},
|
|
565
|
+
[allPermissionRows, checkedMenuKeys, halfCheckedMenuKeys],
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
const toggleGroup = useCallback(
|
|
569
|
+
(groupCodes: string[], allSelected: boolean) => {
|
|
570
|
+
setPermissionCodes((prev) => {
|
|
571
|
+
const menuSet = new Set(
|
|
572
|
+
[...checkedMenuKeys, ...halfCheckedMenuKeys].map((x) => String(x)),
|
|
573
|
+
)
|
|
574
|
+
const isLockedCode = (code: string) =>
|
|
575
|
+
allPermissionRows.some(
|
|
576
|
+
(r) =>
|
|
577
|
+
r.code === code &&
|
|
578
|
+
(isPermissionRowBuiltin(r) ||
|
|
579
|
+
isPermissionRowMenuLockedBase(r, menuSet)),
|
|
580
|
+
)
|
|
581
|
+
if (prev.includes('*')) {
|
|
582
|
+
const base = new Set(allPermissionRows.map((p) => p.code))
|
|
583
|
+
if (allSelected) {
|
|
584
|
+
for (const c of groupCodes) {
|
|
585
|
+
if (!isLockedCode(c)) base.delete(c)
|
|
586
|
+
}
|
|
587
|
+
} else {
|
|
588
|
+
for (const c of groupCodes) base.add(c)
|
|
589
|
+
}
|
|
590
|
+
return Array.from(base)
|
|
591
|
+
}
|
|
592
|
+
const set = new Set(prev)
|
|
593
|
+
if (allSelected) {
|
|
594
|
+
for (const c of groupCodes) {
|
|
595
|
+
if (!isLockedCode(c)) set.delete(c)
|
|
596
|
+
}
|
|
597
|
+
} else {
|
|
598
|
+
for (const c of groupCodes) set.add(c)
|
|
599
|
+
}
|
|
600
|
+
return Array.from(set)
|
|
601
|
+
})
|
|
602
|
+
},
|
|
603
|
+
[allPermissionRows, checkedMenuKeys, halfCheckedMenuKeys],
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
const checkedKeysForTree = useMemo(
|
|
607
|
+
() => ({
|
|
608
|
+
checked: checkedMenuKeys,
|
|
609
|
+
halfChecked: halfCheckedMenuKeys,
|
|
610
|
+
}),
|
|
611
|
+
[checkedMenuKeys, halfCheckedMenuKeys],
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
const menuCheckedHalfSet = useMemo(
|
|
615
|
+
() =>
|
|
616
|
+
new Set(
|
|
617
|
+
[...checkedMenuKeys, ...halfCheckedMenuKeys].map((x) => String(x)),
|
|
618
|
+
),
|
|
619
|
+
[checkedMenuKeys, halfCheckedMenuKeys],
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
if (!active) return null
|
|
623
|
+
|
|
624
|
+
const hasLayoutLock = Boolean(maxHeightClass && String(maxHeightClass).trim())
|
|
625
|
+
|
|
626
|
+
const rootLayoutClass = clsx(
|
|
627
|
+
'flex min-h-0 gap-4 overflow-hidden',
|
|
628
|
+
hasLayoutLock ? clsx(maxHeightClass, 'min-h-0 flex-1') : 'min-h-[280px]',
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
const scrollColClass =
|
|
632
|
+
'min-h-0 flex-1 basis-0 overflow-y-auto overflow-x-hidden'
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<div className={rootLayoutClass}>
|
|
636
|
+
<div
|
|
637
|
+
className={clsx(
|
|
638
|
+
'flex min-w-0 w-72 shrink-0 flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800',
|
|
639
|
+
hasLayoutLock && 'h-full min-h-0',
|
|
640
|
+
)}>
|
|
641
|
+
<div className="flex min-h-[44px] shrink-0 items-center border-b border-gray-200 bg-gray-50 px-3 py-2.5 dark:border-gray-700 dark:bg-gray-700/50">
|
|
642
|
+
<h2 className="line-clamp-1 py-0.5 text-xs font-semibold uppercase tracking-wider text-gray-700 dark:text-gray-300">
|
|
643
|
+
{t('system.permission.tree_list')}
|
|
644
|
+
</h2>
|
|
645
|
+
</div>
|
|
646
|
+
<div className={clsx(scrollColClass, 'p-2')}>
|
|
647
|
+
{loading ? (
|
|
648
|
+
<div className="p-4 text-center text-sm text-gray-500">
|
|
649
|
+
{t('common.loading')}
|
|
650
|
+
</div>
|
|
651
|
+
) : (
|
|
652
|
+
<Tree
|
|
653
|
+
blockNode
|
|
654
|
+
checkable
|
|
655
|
+
checkStrictly
|
|
656
|
+
virtual={false}
|
|
657
|
+
className={clsx(
|
|
658
|
+
'text-sm [&_.ant-tree-node-content-wrapper]:rounded-md',
|
|
659
|
+
readOnly &&
|
|
660
|
+
'[&_.ant-tree-checkbox]:pointer-events-none [&_.ant-tree-checkbox]:cursor-default [&_.ant-tree-checkbox]:opacity-50',
|
|
661
|
+
)}
|
|
662
|
+
treeData={menuTreeNodes}
|
|
663
|
+
checkedKeys={checkedKeysForTree}
|
|
664
|
+
onCheck={readOnly ? undefined : onMenuCheck}
|
|
665
|
+
defaultExpandAll
|
|
666
|
+
selectedKeys={
|
|
667
|
+
selectedMenuId != null && selectedMenuId !== ''
|
|
668
|
+
? [selectedMenuId]
|
|
669
|
+
: []
|
|
670
|
+
}
|
|
671
|
+
onSelect={(keys) => {
|
|
672
|
+
if (keys.length > 0) {
|
|
673
|
+
const sid = String(keys[0])
|
|
674
|
+
setSelectedMenuId(sid)
|
|
675
|
+
const anchor = resolveScrollAnchorForMenuClick(
|
|
676
|
+
treeData,
|
|
677
|
+
sid,
|
|
678
|
+
allPermissionRows,
|
|
679
|
+
idKey,
|
|
680
|
+
childrenKey,
|
|
681
|
+
)
|
|
682
|
+
if (anchor) {
|
|
683
|
+
requestAnimationFrame(() => {
|
|
684
|
+
requestAnimationFrame(() =>
|
|
685
|
+
scrollToMenuSection(anchor),
|
|
686
|
+
)
|
|
687
|
+
})
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}}
|
|
691
|
+
/>
|
|
692
|
+
)}
|
|
693
|
+
</div>
|
|
694
|
+
</div>
|
|
695
|
+
|
|
696
|
+
<div
|
|
697
|
+
className={clsx(
|
|
698
|
+
'flex min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900/50',
|
|
699
|
+
hasLayoutLock && 'h-full min-h-0',
|
|
700
|
+
)}>
|
|
701
|
+
<div className="flex min-h-[44px] shrink-0 items-center justify-between gap-3 border-b border-gray-200 bg-gray-50 px-3 py-2.5 dark:border-gray-700 dark:bg-gray-700/50">
|
|
702
|
+
<h2 className="line-clamp-1 min-w-0 flex-1 py-0.5 text-xs font-semibold uppercase tracking-wider text-gray-700 dark:text-gray-300">
|
|
703
|
+
{t('system.role.permissions_panel_short')}
|
|
704
|
+
</h2>
|
|
705
|
+
<div className="flex shrink-0 select-none items-center gap-1.5">
|
|
706
|
+
<CxCheckbox
|
|
707
|
+
checked={showBuiltinInPanel}
|
|
708
|
+
onChange={(checked) => setShowBuiltinInPanel(checked)}
|
|
709
|
+
className="shrink-0"
|
|
710
|
+
aria-label={t(
|
|
711
|
+
'system.permission.assign_panel.show_builtin_permissions',
|
|
712
|
+
)}
|
|
713
|
+
/>
|
|
714
|
+
<button
|
|
715
|
+
type="button"
|
|
716
|
+
onClick={() =>
|
|
717
|
+
setShowBuiltinInPanel(!showBuiltinInPanel)
|
|
718
|
+
}
|
|
719
|
+
className="whitespace-nowrap text-left text-[11px] font-medium text-gray-600 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:no-underline dark:text-gray-300">
|
|
720
|
+
{t('system.permission.assign_panel.show_builtin_permissions')}
|
|
721
|
+
</button>
|
|
722
|
+
</div>
|
|
723
|
+
</div>
|
|
724
|
+
<div ref={rightScrollRef} className={clsx(scrollColClass, 'p-3')}>
|
|
725
|
+
{loading || permLoading ? (
|
|
726
|
+
<p className="py-8 text-center text-sm text-gray-500">
|
|
727
|
+
{t('common.loading')}
|
|
728
|
+
</p>
|
|
729
|
+
) : allPermissionRows.length === 0 ? (
|
|
730
|
+
<p className="py-8 text-center text-sm text-gray-500">
|
|
731
|
+
{t('system.role.no_permissions_available')}
|
|
732
|
+
</p>
|
|
733
|
+
) : menuPermissionSections.length === 0 ? (
|
|
734
|
+
<p className="py-8 text-center text-sm text-gray-500">
|
|
735
|
+
{t('system.role.permissions_panel_expand_builtin_hint')}
|
|
736
|
+
</p>
|
|
737
|
+
) : (
|
|
738
|
+
<div className="space-y-8">
|
|
739
|
+
{menuPermissionSections.map(
|
|
740
|
+
({
|
|
741
|
+
sectionKey,
|
|
742
|
+
sectionTitle,
|
|
743
|
+
anchorMenuId,
|
|
744
|
+
resourceGroups,
|
|
745
|
+
}) => (
|
|
746
|
+
<section
|
|
747
|
+
key={sectionKey}
|
|
748
|
+
data-perm-menu-section={anchorMenuId}
|
|
749
|
+
className="scroll-mt-2">
|
|
750
|
+
<h2 className="mb-3 border-b border-gray-200 pb-2 text-sm font-semibold text-gray-900 dark:border-gray-600 dark:text-gray-100">
|
|
751
|
+
{sectionTitle}
|
|
752
|
+
</h2>
|
|
753
|
+
<div className="space-y-6">
|
|
754
|
+
{resourceGroups.map(
|
|
755
|
+
({ resource, resourceTitle, permissions: perms }) => {
|
|
756
|
+
const groupLabel = resourceTitle ?? resource
|
|
757
|
+
const groupCodes = perms.map((p) => p.code)
|
|
758
|
+
const isAllSelected = perms.every((perm) =>
|
|
759
|
+
isAssignPermissionChecked(
|
|
760
|
+
permissionCodes,
|
|
761
|
+
perm,
|
|
762
|
+
menuCheckedHalfSet,
|
|
763
|
+
),
|
|
764
|
+
)
|
|
765
|
+
const firstParts = splitPermissionCodeParts(
|
|
766
|
+
String(perms[0]?.code ?? ''),
|
|
767
|
+
)
|
|
768
|
+
/** 与「全选」同行:沿用原 h3+蓝点+uppercase 样式,文案为「末冒号前整段」大写;无则回退 groupLabel */
|
|
769
|
+
const groupCodeBeforeLastUpper =
|
|
770
|
+
firstParts.length >= 2
|
|
771
|
+
? firstParts.slice(0, -1).join(':').toUpperCase()
|
|
772
|
+
: ''
|
|
773
|
+
const subgroupHeadingText =
|
|
774
|
+
groupCodeBeforeLastUpper || groupLabel
|
|
775
|
+
const groupAllBuiltin =
|
|
776
|
+
perms.length > 0 &&
|
|
777
|
+
perms.every((p) => isPermissionRowBuiltin(p))
|
|
778
|
+
return (
|
|
779
|
+
<div
|
|
780
|
+
key={`${sectionKey}-${resource}`}
|
|
781
|
+
className="space-y-2">
|
|
782
|
+
<div className="flex min-w-0 items-center justify-between gap-2 border-b border-gray-200 py-0.5 pb-2 dark:border-gray-700">
|
|
783
|
+
<h3 className="flex min-w-0 flex-1 items-center gap-2 text-[0.8125rem] font-bold uppercase leading-snug tracking-wider text-gray-900 dark:text-gray-100">
|
|
784
|
+
<span className="h-2 w-2 shrink-0 rounded-full bg-blue-500" />
|
|
785
|
+
<span
|
|
786
|
+
className="min-w-0 truncate"
|
|
787
|
+
title={subgroupHeadingText}>
|
|
788
|
+
{subgroupHeadingText}
|
|
789
|
+
</span>
|
|
790
|
+
</h3>
|
|
791
|
+
{!readOnly && !groupAllBuiltin && (
|
|
792
|
+
<button
|
|
793
|
+
type="button"
|
|
794
|
+
onClick={() =>
|
|
795
|
+
toggleGroup(groupCodes, isAllSelected)
|
|
796
|
+
}
|
|
797
|
+
className="shrink-0 text-xs font-medium text-blue-600 transition-all hover:text-blue-700 active:scale-95 dark:text-blue-400 dark:hover:text-blue-300">
|
|
798
|
+
{isAllSelected
|
|
799
|
+
? t('common.unselect_all', {
|
|
800
|
+
defaultValue: '取消全选',
|
|
801
|
+
})
|
|
802
|
+
: t('common.select_all', {
|
|
803
|
+
defaultValue: '全选',
|
|
804
|
+
})}
|
|
805
|
+
</button>
|
|
806
|
+
)}
|
|
807
|
+
</div>
|
|
808
|
+
<div
|
|
809
|
+
className="grid gap-2"
|
|
810
|
+
style={{
|
|
811
|
+
gridTemplateColumns:
|
|
812
|
+
'repeat(auto-fill, minmax(220px, 1fr))',
|
|
813
|
+
}}>
|
|
814
|
+
{perms.map((perm) => {
|
|
815
|
+
const selected = isAssignPermissionChecked(
|
|
816
|
+
permissionCodes,
|
|
817
|
+
perm,
|
|
818
|
+
menuCheckedHalfSet,
|
|
819
|
+
)
|
|
820
|
+
const permLocked = isPermissionRowMenuLockedBase(
|
|
821
|
+
perm,
|
|
822
|
+
menuCheckedHalfSet,
|
|
823
|
+
)
|
|
824
|
+
const permBuiltin = isPermissionRowBuiltin(perm)
|
|
825
|
+
const permNoToggle = permLocked || permBuiltin
|
|
826
|
+
const codeStr = String(perm.code ?? '')
|
|
827
|
+
const codeParts = splitPermissionCodeParts(codeStr)
|
|
828
|
+
/** 卡片主文案:仅最后一个冒号后的末段,小写 */
|
|
829
|
+
const codeAfterLastColon =
|
|
830
|
+
codeParts.length >= 1
|
|
831
|
+
? String(
|
|
832
|
+
codeParts[codeParts.length - 1] ?? '',
|
|
833
|
+
).toLowerCase()
|
|
834
|
+
: ''
|
|
835
|
+
return (
|
|
836
|
+
<div
|
|
837
|
+
key={`${sectionKey}-${perm.id}`}
|
|
838
|
+
role={readOnly ? undefined : 'button'}
|
|
839
|
+
tabIndex={readOnly ? undefined : 0}
|
|
840
|
+
className={clsx(
|
|
841
|
+
'group flex items-start gap-2 rounded-lg border p-2 shadow-sm transition-all',
|
|
842
|
+
readOnly || permNoToggle
|
|
843
|
+
? 'cursor-not-allowed'
|
|
844
|
+
: 'cursor-pointer',
|
|
845
|
+
assignCardShellTone(perm.apiType, selected),
|
|
846
|
+
swaggerHttpMethodLeftAccentClass(
|
|
847
|
+
perm.httpMethod,
|
|
848
|
+
perm.apiType,
|
|
849
|
+
),
|
|
850
|
+
)}
|
|
851
|
+
onClick={() =>
|
|
852
|
+
!readOnly &&
|
|
853
|
+
!permNoToggle &&
|
|
854
|
+
togglePermissionCode(perm)
|
|
855
|
+
}
|
|
856
|
+
onKeyDown={(e) => {
|
|
857
|
+
if (
|
|
858
|
+
!readOnly &&
|
|
859
|
+
!permNoToggle &&
|
|
860
|
+
(e.key === 'Enter' || e.key === ' ')
|
|
861
|
+
) {
|
|
862
|
+
e.preventDefault()
|
|
863
|
+
togglePermissionCode(perm)
|
|
864
|
+
}
|
|
865
|
+
}}>
|
|
866
|
+
<CxCheckbox
|
|
867
|
+
checked={selected}
|
|
868
|
+
disabled={readOnly || permNoToggle}
|
|
869
|
+
className="mt-0.5"
|
|
870
|
+
aria-label={perm.code}
|
|
871
|
+
onChange={() =>
|
|
872
|
+
!readOnly &&
|
|
873
|
+
!permNoToggle &&
|
|
874
|
+
togglePermissionCode(perm)
|
|
875
|
+
}
|
|
876
|
+
/>
|
|
877
|
+
<div className="min-w-0 flex-1">
|
|
878
|
+
<div
|
|
879
|
+
className={clsx(
|
|
880
|
+
'break-all text-xs font-semibold lowercase leading-snug',
|
|
881
|
+
assignCodeTitleHoverClass(perm.apiType),
|
|
882
|
+
)}>
|
|
883
|
+
{codeAfterLastColon || codeStr || '-'}
|
|
884
|
+
</div>
|
|
885
|
+
{(perm.description || perm.name) && (
|
|
886
|
+
<div
|
|
887
|
+
className="mt-0.5 line-clamp-2 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400"
|
|
888
|
+
title={
|
|
889
|
+
perm.description || perm.name
|
|
890
|
+
}>
|
|
891
|
+
{perm.description || perm.name}
|
|
892
|
+
</div>
|
|
893
|
+
)}
|
|
894
|
+
</div>
|
|
895
|
+
</div>
|
|
896
|
+
)
|
|
897
|
+
})}
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
)
|
|
901
|
+
})}
|
|
902
|
+
</div>
|
|
903
|
+
</section>
|
|
904
|
+
),
|
|
905
|
+
)}
|
|
906
|
+
</div>
|
|
907
|
+
)}
|
|
908
|
+
</div>
|
|
909
|
+
</div>
|
|
910
|
+
</div>
|
|
911
|
+
)
|
|
912
|
+
})
|
|
913
|
+
|
|
914
|
+
RolePermissionAssignPanel.displayName = 'RolePermissionAssignPanel'
|
|
915
|
+
|
|
916
|
+
export default RolePermissionAssignPanel
|