cx-chat 0.0.1 → 0.0.3
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/dist/cx-chat.css +1 -0
- package/dist/cx-chat.es.js +97326 -0
- package/dist/cx-chat.umd.js +734 -0
- package/package.json +21 -1
- package/.cursor/rules/i18n-cn-gloss-comments.mdc +0 -31
- package/.cursor/rules/list-page-view-pageconfig.mdc +0 -32
- package/.cursor/rules/no-over-defensive-programming.mdc +0 -90
- package/.cursor/rules/requirement-description-for-agent.mdc +0 -33
- package/.cursor/rules/use-showToast-not-antd-message.mdc +0 -28
- package/.docker/Dockerfile +0 -7
- package/.env +0 -9
- package/.env.development +0 -7
- package/.env.production +0 -7
- package/.gitlab-ci/docker-build.yaml +0 -28
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +0 -42
- package/.gitlab-ci/npm-build.yaml +0 -17
- package/.gitlab-ci.yml +0 -8
- package/.k8s/0-namespace.yaml +0 -6
- package/.k8s/1-configmap-web.yaml +0 -7
- package/.k8s/1-nginx-conf-dev.yaml +0 -110
- package/.k8s/2-deployment.yaml +0 -27
- package/.k8s/3-service.yaml +0 -16
- package/.k8s/4-ingress-dev.yaml +0 -30
- package/.lingma/rules/use-showToast-not-antd-message.md +0 -34
- package/.nginx/nginx.conf +0 -52
- package/.prettierrc +0 -9
- package/eslint.config.js +0 -32
- package/index.html +0 -13
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -96
- package/src/_doc/0.docs-overview.md +0 -28
- package/src/_doc/cx-ui/0.docs-overview.md +0 -30
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +0 -82
- package/src/_doc/cx-ui/comp.2.cx-modal.md +0 -82
- package/src/_doc/cx-ui/comp.3.cx-button.md +0 -89
- package/src/_doc/cx-ui/comp.4.cx-form.md +0 -72
- package/src/_doc/cx-ui/comp.5.cx-fields.md +0 -76
- package/src/_doc/cx-ui/comp.6.cx-tag.md +0 -57
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +0 -29
- package/src/_doc/meta/0.docs-overview.md +0 -24
- package/src/_doc/meta/comp.1.enum-runtime.md +0 -33
- package/src/_doc/meta/comp.2.dict-runtime.md +0 -39
- package/src/_doc/router/0.docs-overview.md +0 -14
- package/src/_doc/router/guide.1.menu-component-config.md +0 -181
- package/src/_doc/router/guide.2.router-auto-registration.md +0 -114
- package/src/_doc/table-view/0.docs-overview.md +0 -30
- package/src/_doc/table-view/comp.1.table-view.md +0 -542
- package/src/_doc/table-view/props.1.create-table-view-config.md +0 -193
- package/src/_doc/table-view/props.2.table-view-search-fields.md +0 -106
- package/src/api/_mock/README.md +0 -340
- package/src/api/_mock/api.ts +0 -1642
- package/src/api/_mock/bundle-shim.ts +0 -16
- package/src/api/_mock/handler-shim.ts +0 -6
- package/src/api/_mock/handler.ts +0 -458
- package/src/api/_mock/index.ts +0 -711
- package/src/api/_mock/interceptor.ts +0 -15
- package/src/api/_mock/mod.ts +0 -12
- package/src/api/_mock/utils.ts +0 -65
- package/src/api/base/memory.js +0 -24
- package/src/api/chat.js +0 -210
- package/src/api/common/auth.js +0 -70
- package/src/api/menus/business-rules.js +0 -76
- package/src/api/menus/feedback.js +0 -102
- package/src/api/menus/knowledge.js +0 -159
- package/src/api/menus/model-metadata/manage.js +0 -70
- package/src/api/menus/model-metadata/role.js +0 -50
- package/src/api/menus/model-metadata/training-detail-mock-data.js +0 -569
- package/src/api/menus/model-metadata/training.js +0 -28
- package/src/api/menus/skill.js +0 -40
- package/src/api/system/agent-config.js +0 -16
- package/src/api/system/department.js +0 -94
- package/src/api/system/dict.js +0 -86
- package/src/api/system/menu.js +0 -37
- package/src/api/system/permission.js +0 -26
- package/src/api/system/role.js +0 -34
- package/src/api/system/sys-config.js +0 -16
- package/src/api/system/sys-log.js +0 -17
- package/src/api/system/user.js +0 -75
- package/src/api/upload.js +0 -39
- package/src/assets/react.svg +0 -1
- package/src/components/auth/current-user-avatar.tsx +0 -77
- package/src/components/common/code-view.tsx +0 -149
- package/src/components/common/detail-link.tsx +0 -67
- package/src/components/common/error-boundary.tsx +0 -98
- package/src/components/common/language-switcher.tsx +0 -91
- package/src/components/common/lite-table/index.tsx +0 -135
- package/src/components/common/md-editor.tsx +0 -126
- package/src/components/common/modal/confirm-dialog.tsx +0 -113
- package/src/components/common/modal/dep-user-select-multi.tsx +0 -324
- package/src/components/common/modal/dep-user-select.tsx +0 -249
- package/src/components/common/modal/user-select-multi.tsx +0 -266
- package/src/components/common/pagination.tsx +0 -472
- package/src/components/common/path.tsx +0 -175
- package/src/components/common/system-logo-mark.tsx +0 -48
- package/src/components/cx-ui/button/index.less +0 -208
- package/src/components/cx-ui/button/index.tsx +0 -611
- package/src/components/cx-ui/checkbox/index.tsx +0 -78
- package/src/components/cx-ui/date-picker/index.less +0 -17
- package/src/components/cx-ui/date-picker/index.tsx +0 -193
- package/src/components/cx-ui/drawer/index.tsx +0 -47
- package/src/components/cx-ui/empty-state/index.tsx +0 -20
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +0 -89
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +0 -283
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +0 -41
- package/src/components/cx-ui/form/CxForm.tsx +0 -15
- package/src/components/cx-ui/form/index.tsx +0 -20
- package/src/components/cx-ui/form-item/index.less +0 -26
- package/src/components/cx-ui/form-item/index.tsx +0 -36
- package/src/components/cx-ui/index.ts +0 -70
- package/src/components/cx-ui/input/auto-complete.tsx +0 -134
- package/src/components/cx-ui/input/index.tsx +0 -259
- package/src/components/cx-ui/input-number/index.jsx +0 -66
- package/src/components/cx-ui/modal/index.jsx +0 -212
- package/src/components/cx-ui/modal/index.less +0 -144
- package/src/components/cx-ui/modal/useCxModal.ts +0 -125
- package/src/components/cx-ui/multi-select/index.jsx +0 -74
- package/src/components/cx-ui/multi-select/index.less +0 -40
- package/src/components/cx-ui/multi-select/index2.tsx +0 -361
- package/src/components/cx-ui/radio/index.tsx +0 -33
- package/src/components/cx-ui/range-picker/index.less +0 -65
- package/src/components/cx-ui/range-picker/index.tsx +0 -219
- package/src/components/cx-ui/select/index.less +0 -34
- package/src/components/cx-ui/select/index.tsx +0 -196
- package/src/components/cx-ui/skeleton/index.tsx +0 -12
- package/src/components/cx-ui/steps/index.tsx +0 -14
- package/src/components/cx-ui/styles/_tokens.less +0 -79
- package/src/components/cx-ui/styles/index.less +0 -246
- package/src/components/cx-ui/switch/index.less +0 -106
- package/src/components/cx-ui/switch/index.tsx +0 -120
- package/src/components/cx-ui/table/index.less +0 -160
- package/src/components/cx-ui/table/index.tsx +0 -152
- package/src/components/cx-ui/tabs/index.less +0 -15
- package/src/components/cx-ui/tabs/index.tsx +0 -34
- package/src/components/cx-ui/tag/index.less +0 -51
- package/src/components/cx-ui/tag/index.tsx +0 -140
- package/src/components/cx-ui/timeline/index.tsx +0 -14
- package/src/components/cx-ui/tooltip/index.tsx +0 -67
- package/src/components/cx-ui/tree/index.tsx +0 -193
- package/src/components/cx-ui/tree-select/index.jsx +0 -91
- package/src/components/cx-ui/tree-select/index.less +0 -27
- package/src/components/cx-ui/upload-file/index.less +0 -223
- package/src/components/cx-ui/upload-file/index.tsx +0 -640
- package/src/components/cx-ui/upload-img/index.tsx +0 -291
- package/src/components/layout/components/Header.tsx +0 -216
- package/src/components/layout/components/Sidebar.tsx +0 -717
- package/src/components/layout/index.tsx +0 -95
- package/src/components/table-view/components/search-area.tsx +0 -411
- package/src/components/table-view/components/table-view-config.tsx +0 -528
- package/src/components/table-view/components/table-view.types.ts +0 -478
- package/src/components/table-view/components/tree-api-normalize.ts +0 -38
- package/src/components/table-view/components/tree-data-annotate.ts +0 -31
- package/src/components/table-view/components/tree-sidebar.tsx +0 -74
- package/src/components/table-view/index.tsx +0 -61
- package/src/components/table-view/list-page-view.tsx +0 -1049
- package/src/components/table-view/select-table-view.tsx +0 -1094
- package/src/components/table-view/styles/select-table-view.less +0 -51
- package/src/config/default-system-name.ts +0 -9
- package/src/config/system.ts +0 -165
- package/src/constants/countryCodes.ts +0 -3
- package/src/contexts/AuthContext.tsx +0 -256
- package/src/contexts/ChatContext.tsx +0 -839
- package/src/contexts/MenuContext.tsx +0 -62
- package/src/contexts/ToastContext.tsx +0 -181
- package/src/hooks/useCopyToClipboard.ts +0 -47
- package/src/hooks/useModalSubmit.ts +0 -104
- package/src/hooks/useRouter.ts +0 -240
- package/src/hooks/useStepForm.ts +0 -46
- package/src/hooks/useStickyHeader.ts +0 -42
- package/src/hooks/useThreadActions.ts +0 -105
- package/src/hooks/useUserPreferences.ts +0 -101
- package/src/http/axios.js +0 -372
- package/src/http/mock.interceptor.ts +0 -9
- package/src/http/obfuscationKey.ts +0 -41
- package/src/i18n.ts +0 -60
- package/src/index.js +0 -1
- package/src/index.less +0 -169
- package/src/locales/en/auth.ts +0 -70
- package/src/locales/en/base/memory.ts +0 -28
- package/src/locales/en/base/settings.ts +0 -41
- package/src/locales/en/chat.ts +0 -40
- package/src/locales/en/common.ts +0 -173
- package/src/locales/en/enum.ts +0 -27
- package/src/locales/en/menus/business-rules.ts +0 -48
- package/src/locales/en/menus/feedback.ts +0 -62
- package/src/locales/en/menus/knowledge.ts +0 -120
- package/src/locales/en/menus/model-metadata/index.ts +0 -10
- package/src/locales/en/menus/model-metadata/manage.ts +0 -151
- package/src/locales/en/menus/model-metadata/role.ts +0 -48
- package/src/locales/en/menus/model-metadata/training.ts +0 -65
- package/src/locales/en/menus/skill.ts +0 -34
- package/src/locales/en/system/agent-config.ts +0 -34
- package/src/locales/en/system/department.ts +0 -68
- package/src/locales/en/system/dict.ts +0 -44
- package/src/locales/en/system/menu.ts +0 -45
- package/src/locales/en/system/permission.ts +0 -89
- package/src/locales/en/system/role.ts +0 -25
- package/src/locales/en/system/sys-config.ts +0 -33
- package/src/locales/en/system/sys-log.ts +0 -38
- package/src/locales/en/system/user.ts +0 -113
- package/src/locales/en.ts +0 -68
- package/src/locales/zh/auth.ts +0 -70
- package/src/locales/zh/base/memory.ts +0 -29
- package/src/locales/zh/base/settings.ts +0 -41
- package/src/locales/zh/chat.ts +0 -47
- package/src/locales/zh/common.ts +0 -178
- package/src/locales/zh/enum.ts +0 -28
- package/src/locales/zh/menus/business-rules.ts +0 -47
- package/src/locales/zh/menus/feedback.ts +0 -62
- package/src/locales/zh/menus/knowledge.ts +0 -117
- package/src/locales/zh/menus/model-metadata/index.ts +0 -10
- package/src/locales/zh/menus/model-metadata/manage.ts +0 -151
- package/src/locales/zh/menus/model-metadata/role.ts +0 -47
- package/src/locales/zh/menus/model-metadata/training.ts +0 -64
- package/src/locales/zh/menus/skill.ts +0 -34
- package/src/locales/zh/system/agent-config.ts +0 -33
- package/src/locales/zh/system/department.ts +0 -69
- package/src/locales/zh/system/dict.ts +0 -44
- package/src/locales/zh/system/menu.ts +0 -47
- package/src/locales/zh/system/permission.ts +0 -94
- package/src/locales/zh/system/role.ts +0 -25
- package/src/locales/zh/system/sys-config.ts +0 -32
- package/src/locales/zh/system/sys-log.ts +0 -38
- package/src/locales/zh/system/user.ts +0 -114
- package/src/locales/zh.ts +0 -67
- package/src/main.tsx +0 -50
- package/src/meta/const/index.ts +0 -40
- package/src/meta/index-dict.ts +0 -56
- package/src/meta/index-enum.ts +0 -95
- package/src/meta/index.ts +0 -14
- package/src/meta/module/dict-data/runtime.ts +0 -199
- package/src/meta/module/dict-data/types.ts +0 -17
- package/src/meta/module/enum-data/runtime.ts +0 -75
- package/src/meta/module/enum-data/types.ts +0 -18
- package/src/router/index.tsx +0 -312
- package/src/styles/AntdThemeProvider.tsx +0 -40
- package/src/styles/antd-theme.ts +0 -20
- package/src/styles/global.less +0 -107
- package/src/styles/variable.less +0 -103
- package/src/types/feedback.ts +0 -43
- package/src/types/index.ts +0 -85
- package/src/types/menu.ts +0 -43
- package/src/utils/aesUtil.ts +0 -123
- package/src/utils/chatUtils.ts +0 -524
- package/src/utils/cn.ts +0 -6
- package/src/utils/crypto.ts +0 -164
- package/src/utils/date.ts +0 -72
- package/src/utils/file-icons.tsx +0 -79
- package/src/utils/index.ts +0 -168
- package/src/utils/markdown-math-plugins.ts +0 -21
- package/src/utils/menuI18n.ts +0 -305
- package/src/utils/menuRouteRegistry.ts +0 -78
- package/src/utils/permission-crud.ts +0 -147
- package/src/utils/routeConfig.ts +0 -350
- package/src/utils/storage.ts +0 -135
- package/src/utils/toastBridge.ts +0 -26
- package/src/utils/url.ts +0 -38
- package/src/utils/validation.ts +0 -16
- package/src/views/auth/auth-code/index.less +0 -169
- package/src/views/auth/auth-code/index.module.less +0 -174
- package/src/views/auth/auth-code/index.tsx +0 -233
- package/src/views/auth/login.tsx +0 -498
- package/src/views/auth/register.tsx +0 -388
- package/src/views/base/memory/index.tsx +0 -136
- package/src/views/base/memory/modal/detail-modal.tsx +0 -89
- package/src/views/base/memory/modal/submit-modal.tsx +0 -134
- package/src/views/base/settings/index.tsx +0 -657
- package/src/views/chat/chat.less +0 -323
- package/src/views/chat/components/chat-input.tsx +0 -298
- package/src/views/chat/components/header-thread-title.tsx +0 -210
- package/src/views/chat/components/message-list/content-answer.tsx +0 -100
- package/src/views/chat/components/message-list/content-question.tsx +0 -18
- package/src/views/chat/components/message-list/index.tsx +0 -520
- package/src/views/chat/components/message-list/message-item.tsx +0 -199
- package/src/views/chat/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/chat/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/chat/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/chat/components/message-list/thinking-process.tsx +0 -49
- package/src/views/chat/components/message-list/toolbar.tsx +0 -224
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/chat/components/references-knowledge/context.tsx +0 -57
- package/src/views/chat/components/references-knowledge/index.ts +0 -9
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +0 -556
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +0 -529
- package/src/views/chat/components/references-knowledge/panel.tsx +0 -115
- package/src/views/chat/hooks/use-chat-common.ts +0 -19
- package/src/views/chat/index-session.tsx +0 -647
- package/src/views/chat/index.tsx +0 -127
- package/src/views/page-error/401.tsx +0 -56
- package/src/views/page-error/404.tsx +0 -56
- package/src/views/page-menus/business-rules/index.tsx +0 -376
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +0 -186
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +0 -272
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +0 -142
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +0 -471
- package/src/views/page-menus/feedback/index.tsx +0 -166
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +0 -367
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +0 -32
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +0 -330
- package/src/views/page-menus/knowledge/detail.tsx +0 -600
- package/src/views/page-menus/knowledge/index.tsx +0 -337
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +0 -618
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +0 -550
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +0 -99
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +0 -349
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +0 -88
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +0 -283
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +0 -179
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +0 -114
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +0 -232
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +0 -316
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +0 -101
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +0 -338
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +0 -276
- package/src/views/page-menus/model-metadata/manage/detail.tsx +0 -298
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +0 -113
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +0 -20
- package/src/views/page-menus/model-metadata/manage/index.tsx +0 -304
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +0 -374
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +0 -151
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +0 -423
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +0 -218
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +0 -261
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +0 -196
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +0 -229
- package/src/views/page-menus/model-metadata/manage/submit.tsx +0 -31
- package/src/views/page-menus/model-metadata/role/index.tsx +0 -207
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +0 -97
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +0 -254
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +0 -393
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +0 -120
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +0 -698
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +0 -237
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +0 -135
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +0 -4
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +0 -72
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +0 -196
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +0 -153
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +0 -103
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +0 -82
- package/src/views/page-menus/model-metadata/training/detail.tsx +0 -159
- package/src/views/page-menus/model-metadata/training/index.tsx +0 -236
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +0 -154
- package/src/views/page-menus/skill/index.tsx +0 -201
- package/src/views/page-menus/skill/modal/detail-modal.tsx +0 -156
- package/src/views/page-menus/skill/modal/submit-modal.tsx +0 -214
- package/src/views/page-system/agent-config/index.tsx +0 -370
- package/src/views/page-system/department/departmentFormShared.ts +0 -36
- package/src/views/page-system/department/index.tsx +0 -541
- package/src/views/page-system/department/modal/detail-modal.tsx +0 -94
- package/src/views/page-system/department/modal/member-role-modal.tsx +0 -128
- package/src/views/page-system/department/modal/submit-modal.tsx +0 -265
- package/src/views/page-system/dict/index.tsx +0 -440
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +0 -315
- package/src/views/page-system/dict/modal/submit-modal.tsx +0 -184
- package/src/views/page-system/logs/components/index.ts +0 -3
- package/src/views/page-system/logs/components/log-message-demo.tsx +0 -30
- package/src/views/page-system/logs/components/log-message-stream.ts +0 -184
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +0 -100
- package/src/views/page-system/logs/components/message-list/content-question.tsx +0 -18
- package/src/views/page-system/logs/components/message-list/index.tsx +0 -515
- package/src/views/page-system/logs/components/message-list/message-item.tsx +0 -193
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +0 -49
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +0 -134
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/page-system/logs/components/message-modal.tsx +0 -239
- package/src/views/page-system/logs/index.tsx +0 -132
- package/src/views/page-system/logs/modal/detail-modal.tsx +0 -157
- package/src/views/page-system/menu/components/menuFormShared.ts +0 -283
- package/src/views/page-system/menu/index.less +0 -12
- package/src/views/page-system/menu/index.tsx +0 -410
- package/src/views/page-system/menu/modal/icon-modal.less +0 -51
- package/src/views/page-system/menu/modal/icon-modal.tsx +0 -87
- package/src/views/page-system/menu/modal/submit-modal.tsx +0 -263
- package/src/views/page-system/permission/index.tsx +0 -562
- package/src/views/page-system/permission/modal/detail-modal.tsx +0 -179
- package/src/views/page-system/permission/modal/submit-modal.less +0 -146
- package/src/views/page-system/permission/modal/submit-modal.tsx +0 -650
- package/src/views/page-system/role/index.tsx +0 -163
- package/src/views/page-system/role/modal/detail-modal.tsx +0 -127
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +0 -86
- package/src/views/page-system/role/modal/permission-modal.tsx +0 -111
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +0 -21
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +0 -916
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +0 -1047
- package/src/views/page-system/role/modal/submit-modal.tsx +0 -193
- package/src/views/page-system/sys-config/index.tsx +0 -294
- package/src/views/page-system/user/components/user-role-column.tsx +0 -87
- package/src/views/page-system/user/index.tsx +0 -439
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +0 -389
- package/src/views/page-system/user/modal/detail-modal.tsx +0 -72
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.tsx +0 -287
- package/src/views/page-system/user/userFormShared.ts +0 -51
- package/tailwind.config.js +0 -17
- package/tsconfig.app.json +0 -48
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -264
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,916 +0,0 @@
|
|
|
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
|