@openedx/frontend-app-admin-console 1.0.0-alpha.0
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/LICENSE +661 -0
- package/README.rst +164 -0
- package/dist/Main.d.ts +3 -0
- package/dist/Main.js +15 -0
- package/dist/Main.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.js +10 -0
- package/dist/app.js.map +1 -0
- package/dist/authz-module/audit-user/index.d.ts +2 -0
- package/dist/authz-module/audit-user/index.js +191 -0
- package/dist/authz-module/audit-user/index.js.map +1 -0
- package/dist/authz-module/audit-user/messages.d.ts +58 -0
- package/dist/authz-module/audit-user/messages.js +60 -0
- package/dist/authz-module/audit-user/messages.js.map +1 -0
- package/dist/authz-module/authz-home/index.d.ts +2 -0
- package/dist/authz-module/authz-home/index.js +23 -0
- package/dist/authz-module/authz-home/index.js.map +1 -0
- package/dist/authz-module/authz-home/messages.d.ts +23 -0
- package/dist/authz-module/authz-home/messages.js +25 -0
- package/dist/authz-module/authz-home/messages.js.map +1 -0
- package/dist/authz-module/components/AddRoleButton.d.ts +6 -0
- package/dist/authz-module/components/AddRoleButton.js +22 -0
- package/dist/authz-module/components/AddRoleButton.js.map +1 -0
- package/dist/authz-module/components/AnchorButton.d.ts +2 -0
- package/dist/authz-module/components/AnchorButton.js +35 -0
- package/dist/authz-module/components/AnchorButton.js.map +1 -0
- package/dist/authz-module/components/AuthZLayout.d.ts +12 -0
- package/dist/authz-module/components/AuthZLayout.js +19 -0
- package/dist/authz-module/components/AuthZLayout.js.map +1 -0
- package/dist/authz-module/components/AuthZTitle.d.ts +20 -0
- package/dist/authz-module/components/AuthZTitle.js +22 -0
- package/dist/authz-module/components/AuthZTitle.js.map +1 -0
- package/dist/authz-module/components/ConfirmDeletionModal.d.ts +15 -0
- package/dist/authz-module/components/ConfirmDeletionModal.js +21 -0
- package/dist/authz-module/components/ConfirmDeletionModal.js.map +1 -0
- package/dist/authz-module/components/ErrorPage/index.d.ts +3 -0
- package/dist/authz-module/components/ErrorPage/index.js +59 -0
- package/dist/authz-module/components/ErrorPage/index.js.map +1 -0
- package/dist/authz-module/components/ErrorPage/messages.d.ts +53 -0
- package/dist/authz-module/components/ErrorPage/messages.js +55 -0
- package/dist/authz-module/components/ErrorPage/messages.js.map +1 -0
- package/dist/authz-module/components/PermissionTable.d.ts +9 -0
- package/dist/authz-module/components/PermissionTable.js +24 -0
- package/dist/authz-module/components/PermissionTable.js.map +1 -0
- package/dist/authz-module/components/RenderAdminRole.d.ts +5 -0
- package/dist/authz-module/components/RenderAdminRole.js +13 -0
- package/dist/authz-module/components/RenderAdminRole.js.map +1 -0
- package/dist/authz-module/components/RenderPermissionColumn.d.ts +6 -0
- package/dist/authz-module/components/RenderPermissionColumn.js +8 -0
- package/dist/authz-module/components/RenderPermissionColumn.js.map +1 -0
- package/dist/authz-module/components/RenderPermissionInLine.d.ts +6 -0
- package/dist/authz-module/components/RenderPermissionInLine.js +8 -0
- package/dist/authz-module/components/RenderPermissionInLine.js.map +1 -0
- package/dist/authz-module/components/ResourceTooltip.d.ts +11 -0
- package/dist/authz-module/components/ResourceTooltip.js +9 -0
- package/dist/authz-module/components/ResourceTooltip.js.map +1 -0
- package/dist/authz-module/components/RoleCard/constants.d.ts +14 -0
- package/dist/authz-module/components/RoleCard/constants.js +15 -0
- package/dist/authz-module/components/RoleCard/constants.js.map +1 -0
- package/dist/authz-module/components/RoleCard/messages.d.ts +73 -0
- package/dist/authz-module/components/RoleCard/messages.js +75 -0
- package/dist/authz-module/components/RoleCard/messages.js.map +1 -0
- package/dist/authz-module/components/TableCells.d.ts +29 -0
- package/dist/authz-module/components/TableCells.js +137 -0
- package/dist/authz-module/components/TableCells.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/MultipleChoiceFilter.d.ts +3 -0
- package/dist/authz-module/components/TableControlBar/MultipleChoiceFilter.js +47 -0
- package/dist/authz-module/components/TableControlBar/MultipleChoiceFilter.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/OrgFilter.d.ts +5 -0
- package/dist/authz-module/components/TableControlBar/OrgFilter.js +36 -0
- package/dist/authz-module/components/TableControlBar/OrgFilter.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/RolesFilter.d.ts +4 -0
- package/dist/authz-module/components/TableControlBar/RolesFilter.js +29 -0
- package/dist/authz-module/components/TableControlBar/RolesFilter.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/ScopesFilter.d.ts +4 -0
- package/dist/authz-module/components/TableControlBar/ScopesFilter.js +45 -0
- package/dist/authz-module/components/TableControlBar/ScopesFilter.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/SearchFilter.d.ts +7 -0
- package/dist/authz-module/components/TableControlBar/SearchFilter.js +8 -0
- package/dist/authz-module/components/TableControlBar/SearchFilter.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/TableControlBar.d.ts +5 -0
- package/dist/authz-module/components/TableControlBar/TableControlBar.js +99 -0
- package/dist/authz-module/components/TableControlBar/TableControlBar.js.map +1 -0
- package/dist/authz-module/components/TableControlBar/types.d.ts +18 -0
- package/dist/authz-module/components/TableControlBar/types.js +2 -0
- package/dist/authz-module/components/TableControlBar/types.js.map +1 -0
- package/dist/authz-module/components/TableFooter/TableFooter.d.ts +2 -0
- package/dist/authz-module/components/TableFooter/TableFooter.js +15 -0
- package/dist/authz-module/components/TableFooter/TableFooter.js.map +1 -0
- package/dist/authz-module/components/UserPermissions.d.ts +9 -0
- package/dist/authz-module/components/UserPermissions.js +56 -0
- package/dist/authz-module/components/UserPermissions.js.map +1 -0
- package/dist/authz-module/components/ViewMoreLink.d.ts +8 -0
- package/dist/authz-module/components/ViewMoreLink.js +8 -0
- package/dist/authz-module/components/ViewMoreLink.js.map +1 -0
- package/dist/authz-module/components/constants.d.ts +13 -0
- package/dist/authz-module/components/constants.js +80 -0
- package/dist/authz-module/components/constants.js.map +1 -0
- package/dist/authz-module/components/messages.d.ts +183 -0
- package/dist/authz-module/components/messages.js +185 -0
- package/dist/authz-module/components/messages.js.map +1 -0
- package/dist/authz-module/constants.d.ts +38 -0
- package/dist/authz-module/constants.js +77 -0
- package/dist/authz-module/constants.js.map +1 -0
- package/dist/authz-module/data/api.d.ts +109 -0
- package/dist/authz-module/data/api.js +107 -0
- package/dist/authz-module/data/api.js.map +1 -0
- package/dist/authz-module/data/hooks.d.ts +94 -0
- package/dist/authz-module/data/hooks.js +191 -0
- package/dist/authz-module/data/hooks.js.map +1 -0
- package/dist/authz-module/hooks/useCourseAuthoringFlag.d.ts +26 -0
- package/dist/authz-module/hooks/useCourseAuthoringFlag.js +86 -0
- package/dist/authz-module/hooks/useCourseAuthoringFlag.js.map +1 -0
- package/dist/authz-module/hooks/useQuerySettings.d.ts +27 -0
- package/dist/authz-module/hooks/useQuerySettings.js +72 -0
- package/dist/authz-module/hooks/useQuerySettings.js.map +1 -0
- package/dist/authz-module/hooks/useViewTeamPermissions.d.ts +5 -0
- package/dist/authz-module/hooks/useViewTeamPermissions.js +13 -0
- package/dist/authz-module/hooks/useViewTeamPermissions.js.map +1 -0
- package/dist/authz-module/index.d.ts +3 -0
- package/dist/authz-module/index.js +20 -0
- package/dist/authz-module/index.js.map +1 -0
- package/dist/authz-module/index.scss +131 -0
- package/dist/authz-module/messages.d.ts +48 -0
- package/dist/authz-module/messages.js +50 -0
- package/dist/authz-module/messages.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizard.d.ts +8 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizard.js +154 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizard.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizardPage.d.ts +2 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizardPage.js +39 -0
- package/dist/authz-module/role-assignation-wizard/AssignRoleWizardPage.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/DefineApplicationScopeStep.d.ts +8 -0
- package/dist/authz-module/role-assignation-wizard/components/DefineApplicationScopeStep.js +39 -0
- package/dist/authz-module/role-assignation-wizard/components/DefineApplicationScopeStep.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/HighlightedUsersInput.d.ts +11 -0
- package/dist/authz-module/role-assignation-wizard/components/HighlightedUsersInput.js +36 -0
- package/dist/authz-module/role-assignation-wizard/components/HighlightedUsersInput.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/OrgSection.d.ts +10 -0
- package/dist/authz-module/role-assignation-wizard/components/OrgSection.js +14 -0
- package/dist/authz-module/role-assignation-wizard/components/OrgSection.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeCheckboxItem.d.ts +8 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeCheckboxItem.js +5 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeCheckboxItem.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeFilterBar.d.ts +12 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeFilterBar.js +12 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeFilterBar.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeList.d.ts +20 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeList.js +30 -0
- package/dist/authz-module/role-assignation-wizard/components/ScopeList.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/components/SelectUsersAndRoleStep.d.ts +12 -0
- package/dist/authz-module/role-assignation-wizard/components/SelectUsersAndRoleStep.js +34 -0
- package/dist/authz-module/role-assignation-wizard/components/SelectUsersAndRoleStep.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/constants.d.ts +5 -0
- package/dist/authz-module/role-assignation-wizard/constants.js +6 -0
- package/dist/authz-module/role-assignation-wizard/constants.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopeListData.d.ts +23 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopeListData.js +112 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopeListData.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopePermissions.d.ts +10 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopePermissions.js +54 -0
- package/dist/authz-module/role-assignation-wizard/hooks/useScopePermissions.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/messages.d.ts +243 -0
- package/dist/authz-module/role-assignation-wizard/messages.js +258 -0
- package/dist/authz-module/role-assignation-wizard/messages.js.map +1 -0
- package/dist/authz-module/role-assignation-wizard/utils.d.ts +5 -0
- package/dist/authz-module/role-assignation-wizard/utils.js +16 -0
- package/dist/authz-module/role-assignation-wizard/utils.js.map +1 -0
- package/dist/authz-module/roles-permissions/RolesPermissions.d.ts +2 -0
- package/dist/authz-module/roles-permissions/RolesPermissions.js +35 -0
- package/dist/authz-module/roles-permissions/RolesPermissions.js.map +1 -0
- package/dist/authz-module/roles-permissions/course/constants.d.ts +39 -0
- package/dist/authz-module/roles-permissions/course/constants.js +474 -0
- package/dist/authz-module/roles-permissions/course/constants.js.map +1 -0
- package/dist/authz-module/roles-permissions/index.d.ts +10 -0
- package/dist/authz-module/roles-permissions/index.js +15 -0
- package/dist/authz-module/roles-permissions/index.js.map +1 -0
- package/dist/authz-module/roles-permissions/library/constants.d.ts +18 -0
- package/dist/authz-module/roles-permissions/library/constants.js +193 -0
- package/dist/authz-module/roles-permissions/library/constants.js.map +1 -0
- package/dist/authz-module/roles-permissions/messages.d.ts +63 -0
- package/dist/authz-module/roles-permissions/messages.js +65 -0
- package/dist/authz-module/roles-permissions/messages.js.map +1 -0
- package/dist/authz-module/roles-permissions/utils.d.ts +41 -0
- package/dist/authz-module/roles-permissions/utils.js +70 -0
- package/dist/authz-module/roles-permissions/utils.js.map +1 -0
- package/dist/authz-module/team-members/TeamMembersTable.d.ts +5 -0
- package/dist/authz-module/team-members/TeamMembersTable.js +107 -0
- package/dist/authz-module/team-members/TeamMembersTable.js.map +1 -0
- package/dist/authz-module/team-members/messages.d.ts +33 -0
- package/dist/authz-module/team-members/messages.js +35 -0
- package/dist/authz-module/team-members/messages.js.map +1 -0
- package/dist/authz-module/utils.d.ts +24 -0
- package/dist/authz-module/utils.js +45 -0
- package/dist/authz-module/utils.js.map +1 -0
- package/dist/components/LoadingPage.d.ts +2 -0
- package/dist/components/LoadingPage.js +5 -0
- package/dist/components/LoadingPage.js.map +1 -0
- package/dist/components/ToastManager/ToastManagerContext.d.ts +24 -0
- package/dist/components/ToastManager/ToastManagerContext.js +91 -0
- package/dist/components/ToastManager/ToastManagerContext.js.map +1 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -0
- package/dist/data/api.d.ts +4 -0
- package/dist/data/api.js +21 -0
- package/dist/data/api.js.map +1 -0
- package/dist/data/hooks.d.ts +38 -0
- package/dist/data/hooks.js +69 -0
- package/dist/data/hooks.js.map +1 -0
- package/dist/data/types.d.ts +38 -0
- package/dist/data/types.js +2 -0
- package/dist/data/types.js.map +1 -0
- package/dist/data/utils.d.ts +6 -0
- package/dist/data/utils.js +11 -0
- package/dist/data/utils.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +8 -0
- package/dist/messages.js +10 -0
- package/dist/messages.js.map +1 -0
- package/dist/providers.d.ts +3 -0
- package/dist/providers.js +4 -0
- package/dist/providers.js.map +1 -0
- package/dist/routes.d.ts +11 -0
- package/dist/routes.js +16 -0
- package/dist/routes.js.map +1 -0
- package/dist/style.scss +15 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PermissionItem } from '../../types';
|
|
2
|
+
interface RenderPermissionInLineProps {
|
|
3
|
+
items: PermissionItem[];
|
|
4
|
+
}
|
|
5
|
+
declare const RenderPermissionInLine: ({ items }: RenderPermissionInLineProps) => import("react").JSX.Element;
|
|
6
|
+
export default RenderPermissionInLine;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '@openedx/paragon';
|
|
3
|
+
import ResourceTooltip from './ResourceTooltip';
|
|
4
|
+
const RenderPermissionInLine = ({ items }) => (_jsx("div", { className: "d-flex align-items-start w-100 no-scroll", children: items.map(({ key, icon, label, description, perms, }, index) => (_jsxs("div", { className: `d-flex flex-column ${index !== items.length - 1 ? 'pr-4 mr-4 border-right' : ''}`, children: [_jsxs("div", { className: "d-flex align-items-center mb-2", children: [_jsx(Icon, { src: icon, className: "mr-2 text-primary", size: "xs" }), _jsx("h5", { className: "text-primary m-0", children: label }), _jsx(ResourceTooltip, { resourceGroup: {
|
|
5
|
+
key, label, description, permissions: perms,
|
|
6
|
+
} })] }), _jsx("div", { className: "d-flex", children: perms.map((perm, i) => (_jsxs("div", { className: `d-flex align-items-center ${i !== perms.length - 1 ? 'pr-2 mr-2 border-right' : ''}`, children: [_jsx(Icon, { src: perm.icon, className: "mr-2", size: "xs" }), _jsx("span", { className: "text-primary small font-weight-light", children: perm.label })] }, perm.key))) })] }, key))) }));
|
|
7
|
+
export default RenderPermissionInLine;
|
|
8
|
+
//# sourceMappingURL=RenderPermissionInLine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderPermissionInLine.js","sourceRoot":"","sources":["../../../src/authz-module/components/RenderPermissionInLine.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAMhD,MAAM,sBAAsB,GAAG,CAAC,EAAE,KAAK,EAA+B,EAAE,EAAE,CAAC,CACzE,cAAK,SAAS,EAAC,0CAA0C,YACtD,KAAK,CAAC,GAAG,CAAC,CAAC,EACV,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,GACrC,EAAE,KAAK,EAAE,EAAE,CAAC,CACX,eAEE,SAAS,EAAE,sBAAsB,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE,aAE7F,eAAK,SAAS,EAAC,gCAAgC,aAC7C,KAAC,IAAI,IAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,IAAI,GAAG,EAC3D,aAAI,SAAS,EAAC,kBAAkB,YAAE,KAAK,GAAM,EAC7C,KAAC,eAAe,IACd,aAAa,EAAE;4BACb,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK;yBAC5C,GACD,IACE,EACN,cAAK,SAAS,EAAC,QAAQ,YACpB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,eAEE,SAAS,EAAE,6BAA6B,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE,aAEhG,KAAC,IAAI,IAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,GAAG,EACnD,eAAM,SAAS,EAAC,sCAAsC,YACnD,IAAI,CAAC,KAAK,GACN,KANF,IAAI,CAAC,GAAG,CAOT,CACP,CAAC,GACE,KAxBD,GAAG,CAyBJ,CACP,CAAC,GACE,CACP,CAAC;AACF,eAAe,sBAAsB,CAAC","sourcesContent":["import { Icon } from '@openedx/paragon';\nimport { PermissionItem } from '@src/types';\nimport ResourceTooltip from './ResourceTooltip';\n\ninterface RenderPermissionInLineProps {\n items: PermissionItem[];\n}\n\nconst RenderPermissionInLine = ({ items }: RenderPermissionInLineProps) => (\n <div className=\"d-flex align-items-start w-100 no-scroll\">\n {items.map(({\n key, icon, label, description, perms,\n }, index) => (\n <div\n key={key}\n className={`d-flex flex-column ${index !== items.length - 1 ? 'pr-4 mr-4 border-right' : ''}`}\n >\n <div className=\"d-flex align-items-center mb-2\">\n <Icon src={icon} className=\"mr-2 text-primary\" size=\"xs\" />\n <h5 className=\"text-primary m-0\">{label}</h5>\n <ResourceTooltip\n resourceGroup={{\n key, label, description, permissions: perms,\n }}\n />\n </div>\n <div className=\"d-flex\">\n {perms.map((perm, i) => (\n <div\n key={perm.key}\n className={`d-flex align-items-center ${i !== perms.length - 1 ? 'pr-2 mr-2 border-right' : ''}`}\n >\n <Icon src={perm.icon} className=\"mr-2\" size=\"xs\" />\n <span className=\"text-primary small font-weight-light\">\n {perm.label}\n </span>\n </div>\n ))}\n </div>\n </div>\n ))}\n </div>\n);\nexport default RenderPermissionInLine;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PermissionMetadata } from '../../types';
|
|
2
|
+
interface ResourceTooltipProps {
|
|
3
|
+
resourceGroup: {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
permissions: PermissionMetadata[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare const ResourceTooltip: ({ resourceGroup }: ResourceTooltipProps) => import("react").JSX.Element;
|
|
11
|
+
export default ResourceTooltip;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, OverlayTrigger, Popover } from '@openedx/paragon';
|
|
3
|
+
import { Info } from '@openedx/paragon/icons';
|
|
4
|
+
const ResourceTooltip = ({ resourceGroup }) => (_jsx(OverlayTrigger, { placement: "auto", overlay: (_jsx(Popover, { id: `tooltip-${resourceGroup.label}`, children: _jsxs(Popover.Content, { className: "p-3", children: [_jsx("h4", { className: "text-primary", children: resourceGroup.label }), _jsx("p", { className: "small", children: resourceGroup.description }), _jsx("ul", { className: "small", children: resourceGroup.permissions.map(permission => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
return (_jsxs("li", { children: [_jsxs("b", { children: [(_b = (_a = permission.label) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '', ":"] }), " ", permission.description] }, permission.key));
|
|
7
|
+
}) })] }) })), children: _jsx(Icon, { className: "d-inline-block text-gray-300 ml-2 my-auto", src: Info }) }, `overlay-${resourceGroup.key}`));
|
|
8
|
+
export default ResourceTooltip;
|
|
9
|
+
//# sourceMappingURL=ResourceTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceTooltip.js","sourceRoot":"","sources":["../../../src/authz-module/components/ResourceTooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAY9C,MAAM,eAAe,GAAG,CAAC,EAAE,aAAa,EAAwB,EAAE,EAAE,CAAC,CACnE,KAAC,cAAc,IAEb,SAAS,EAAC,MAAM,EAChB,OAAO,EAAE,CACP,KAAC,OAAO,IAAC,EAAE,EAAE,WAAW,aAAa,CAAC,KAAK,EAAE,YAC3C,MAAC,OAAO,CAAC,OAAO,IAAC,SAAS,EAAC,KAAK,aAC9B,aAAI,SAAS,EAAC,cAAc,YAAE,aAAa,CAAC,KAAK,GAAM,EACvD,YAAG,SAAS,EAAC,OAAO,YAAE,aAAa,CAAC,WAAW,GAAK,EACpD,aAAI,SAAS,EAAC,OAAO,YAClB,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;;wBAAC,OAAA,CAC3C,yBAAyB,wBAAI,MAAA,MAAA,UAAU,CAAC,KAAK,0CAAE,IAAI,EAAE,mCAAI,EAAE,SAAM,OAAE,UAAU,CAAC,WAAW,KAAhF,UAAU,CAAC,GAAG,CAAwE,CAChG,CAAA;qBAAA,CAAC,GACC,IACW,GACV,CACX,YAED,KAAC,IAAI,IAAC,SAAS,EAAC,2CAA2C,EAAC,GAAG,EAAE,IAAI,GAAI,IAhBpE,WAAW,aAAa,CAAC,GAAG,EAAE,CAiBpB,CAClB,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { Icon, OverlayTrigger, Popover } from '@openedx/paragon';\nimport { Info } from '@openedx/paragon/icons';\nimport { PermissionMetadata } from '@src/types';\n\ninterface ResourceTooltipProps {\n resourceGroup: {\n key: string;\n label: string;\n description: string;\n permissions: PermissionMetadata[];\n };\n}\n\nconst ResourceTooltip = ({ resourceGroup }: ResourceTooltipProps) => (\n <OverlayTrigger\n key={`overlay-${resourceGroup.key}`}\n placement=\"auto\"\n overlay={(\n <Popover id={`tooltip-${resourceGroup.label}`}>\n <Popover.Content className=\"p-3\">\n <h4 className=\"text-primary\">{resourceGroup.label}</h4>\n <p className=\"small\">{resourceGroup.description}</p>\n <ul className=\"small\">\n {resourceGroup.permissions.map(permission => (\n <li key={permission.key}><b>{permission.label?.trim() ?? ''}:</b> {permission.description}</li>\n ))}\n </ul>\n </Popover.Content>\n </Popover>\n )}\n >\n <Icon className=\"d-inline-block text-gray-300 ml-2 my-auto\" src={Info} />\n </OverlayTrigger>\n);\n\nexport default ResourceTooltip;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const actionsDictionary: {
|
|
2
|
+
create: any;
|
|
3
|
+
edit: any;
|
|
4
|
+
delete: any;
|
|
5
|
+
import: any;
|
|
6
|
+
publish: any;
|
|
7
|
+
view: any;
|
|
8
|
+
reuse: any;
|
|
9
|
+
team: any;
|
|
10
|
+
export: any;
|
|
11
|
+
manage: any;
|
|
12
|
+
};
|
|
13
|
+
export type ActionKey = keyof typeof actionsDictionary;
|
|
14
|
+
export declare const actionKeys: string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Add, Delete, DownloadDone, Edit, ManageAccounts, Sync, FileUpload, Visibility, FileDownload, Settings, } from '@openedx/paragon/icons';
|
|
2
|
+
export const actionsDictionary = {
|
|
3
|
+
create: Add,
|
|
4
|
+
edit: Edit,
|
|
5
|
+
delete: Delete,
|
|
6
|
+
import: FileDownload,
|
|
7
|
+
publish: DownloadDone,
|
|
8
|
+
view: Visibility,
|
|
9
|
+
reuse: Sync,
|
|
10
|
+
team: ManageAccounts,
|
|
11
|
+
export: FileUpload,
|
|
12
|
+
manage: Settings,
|
|
13
|
+
};
|
|
14
|
+
export const actionKeys = Object.keys(actionsDictionary);
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/authz-module/components/RoleCard/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,GACtG,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAGF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import {\n Add, Delete, DownloadDone, Edit, ManageAccounts, Sync, FileUpload, Visibility, FileDownload, Settings,\n} from '@openedx/paragon/icons';\n\nexport const actionsDictionary = {\n create: Add,\n edit: Edit,\n delete: Delete,\n import: FileDownload,\n publish: DownloadDone,\n view: Visibility,\n reuse: Sync,\n team: ManageAccounts,\n export: FileUpload,\n manage: Settings,\n};\n\nexport type ActionKey = keyof typeof actionsDictionary;\nexport const actionKeys = Object.keys(actionsDictionary);\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
'authz.permissions.title': {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
'authz.permissions.actions.create': {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
'authz.permissions.actions.edit': {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
'authz.permissions.actions.import': {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
'authz.permissions.actions.delete': {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
'authz.permissions.actions.manage': {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
'authz.permissions.actions.publish': {
|
|
33
|
+
id: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
'authz.permissions.actions.view': {
|
|
38
|
+
id: string;
|
|
39
|
+
defaultMessage: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
'authz.permissions.actions.reuse': {
|
|
43
|
+
id: string;
|
|
44
|
+
defaultMessage: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
'authz.role.card.delete.action.alt': {
|
|
48
|
+
id: string;
|
|
49
|
+
defaultMessage: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
'authz.role.card.userCounter': {
|
|
53
|
+
id: string;
|
|
54
|
+
defaultMessage: string;
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
'authz.role.card.permissions.ariaLabel': {
|
|
58
|
+
id: string;
|
|
59
|
+
defaultMessage: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
'authz.role.card.permissions.status.denied': {
|
|
63
|
+
id: string;
|
|
64
|
+
defaultMessage: string;
|
|
65
|
+
description: string;
|
|
66
|
+
};
|
|
67
|
+
'authz.role.card.permissions.status.granted': {
|
|
68
|
+
id: string;
|
|
69
|
+
defaultMessage: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export default messages;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineMessages } from '@openedx/frontend-base';
|
|
2
|
+
const messages = defineMessages({
|
|
3
|
+
'authz.permissions.title': {
|
|
4
|
+
id: 'authz.permissions.title',
|
|
5
|
+
defaultMessage: 'Permissions',
|
|
6
|
+
description: 'Title for the permissions section in the role card',
|
|
7
|
+
},
|
|
8
|
+
'authz.permissions.actions.create': {
|
|
9
|
+
id: 'authz.permissions.actions.create',
|
|
10
|
+
defaultMessage: 'Create {resource}',
|
|
11
|
+
description: 'Default label for the create action',
|
|
12
|
+
},
|
|
13
|
+
'authz.permissions.actions.edit': {
|
|
14
|
+
id: 'authz.permissions.actions.edit',
|
|
15
|
+
defaultMessage: 'Edit {resource}',
|
|
16
|
+
description: 'Default label for the edit action',
|
|
17
|
+
},
|
|
18
|
+
'authz.permissions.actions.import': {
|
|
19
|
+
id: 'authz.permissions.actions.import',
|
|
20
|
+
defaultMessage: 'Import {resource}',
|
|
21
|
+
description: 'Default label for the import action',
|
|
22
|
+
},
|
|
23
|
+
'authz.permissions.actions.delete': {
|
|
24
|
+
id: 'authz.permissions.actions.delete',
|
|
25
|
+
defaultMessage: 'Delete {resource}',
|
|
26
|
+
description: 'Default label for the delete action',
|
|
27
|
+
},
|
|
28
|
+
'authz.permissions.actions.manage': {
|
|
29
|
+
id: 'authz.permissions.actions.manage',
|
|
30
|
+
defaultMessage: 'Manage {resource}',
|
|
31
|
+
description: 'Default label for the manage action',
|
|
32
|
+
},
|
|
33
|
+
'authz.permissions.actions.publish': {
|
|
34
|
+
id: 'authz.permissions.actions.publish',
|
|
35
|
+
defaultMessage: 'Publish {resource}',
|
|
36
|
+
description: 'Default label for the publish action',
|
|
37
|
+
},
|
|
38
|
+
'authz.permissions.actions.view': {
|
|
39
|
+
id: 'authz.permissions.actions.view',
|
|
40
|
+
defaultMessage: 'View {resource}',
|
|
41
|
+
description: 'Default label for the view action',
|
|
42
|
+
},
|
|
43
|
+
'authz.permissions.actions.reuse': {
|
|
44
|
+
id: 'authz.permissions.actions.reuse',
|
|
45
|
+
defaultMessage: 'Reuse {resource}',
|
|
46
|
+
description: 'Default label for the reuse action',
|
|
47
|
+
},
|
|
48
|
+
'authz.role.card.delete.action.alt': {
|
|
49
|
+
id: 'authz.role.card.delete.action.alt',
|
|
50
|
+
defaultMessage: 'Delete role action',
|
|
51
|
+
description: 'Alt description for delete button',
|
|
52
|
+
},
|
|
53
|
+
'authz.role.card.userCounter': {
|
|
54
|
+
id: 'authz.role.card.userCounter',
|
|
55
|
+
defaultMessage: 'Number of users with this role',
|
|
56
|
+
description: 'Screen reader text for the user counter icon in the role card header',
|
|
57
|
+
},
|
|
58
|
+
'authz.role.card.permissions.ariaLabel': {
|
|
59
|
+
id: 'authz.role.card.permissions.ariaLabel',
|
|
60
|
+
defaultMessage: '{permissionName} permission is {permissionStatus}',
|
|
61
|
+
description: 'Aria label for permission chips in the role card',
|
|
62
|
+
},
|
|
63
|
+
'authz.role.card.permissions.status.denied': {
|
|
64
|
+
id: 'authz.role.card.permissions.status.denied',
|
|
65
|
+
defaultMessage: 'denied',
|
|
66
|
+
description: 'Label for denied status of a permission in the role card',
|
|
67
|
+
},
|
|
68
|
+
'authz.role.card.permissions.status.granted': {
|
|
69
|
+
id: 'authz.role.card.permissions.status.granted',
|
|
70
|
+
defaultMessage: 'granted',
|
|
71
|
+
description: 'Label for granted status of a permission in the role card',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
export default messages;
|
|
75
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/authz-module/components/RoleCard/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,yBAAyB,EAAE;QACzB,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,aAAa;QAC7B,WAAW,EAAE,oDAAoD;KAClE;IACD,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,qCAAqC;KACnD;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,gCAAgC;QACpC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,mCAAmC;KACjD;IACD,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,qCAAqC;KACnD;IACD,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,qCAAqC;KACnD;IACD,kCAAkC,EAAE;QAClC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,qCAAqC;KACnD;IACD,mCAAmC,EAAE;QACnC,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,sCAAsC;KACpD;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,gCAAgC;QACpC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,mCAAmC;KACjD;IACD,iCAAiC,EAAE;QACjC,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,kBAAkB;QAClC,WAAW,EAAE,oCAAoC;KAClD;IACD,mCAAmC,EAAE;QACnC,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,mCAAmC;KACjD;IACD,6BAA6B,EAAE;QAC7B,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,gCAAgC;QAChD,WAAW,EAAE,sEAAsE;KACpF;IACD,uCAAuC,EAAE;QACvC,EAAE,EAAE,uCAAuC;QAC3C,cAAc,EAAE,mDAAmD;QACnE,WAAW,EAAE,kDAAkD;KAChE;IACD,2CAA2C,EAAE;QAC3C,EAAE,EAAE,2CAA2C;QAC/C,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,0DAA0D;KACxE;IACD,4CAA4C,EAAE;QAC5C,EAAE,EAAE,4CAA4C;QAChD,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,2DAA2D;KACzE;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n 'authz.permissions.title': {\n id: 'authz.permissions.title',\n defaultMessage: 'Permissions',\n description: 'Title for the permissions section in the role card',\n },\n 'authz.permissions.actions.create': {\n id: 'authz.permissions.actions.create',\n defaultMessage: 'Create {resource}',\n description: 'Default label for the create action',\n },\n 'authz.permissions.actions.edit': {\n id: 'authz.permissions.actions.edit',\n defaultMessage: 'Edit {resource}',\n description: 'Default label for the edit action',\n },\n 'authz.permissions.actions.import': {\n id: 'authz.permissions.actions.import',\n defaultMessage: 'Import {resource}',\n description: 'Default label for the import action',\n },\n 'authz.permissions.actions.delete': {\n id: 'authz.permissions.actions.delete',\n defaultMessage: 'Delete {resource}',\n description: 'Default label for the delete action',\n },\n 'authz.permissions.actions.manage': {\n id: 'authz.permissions.actions.manage',\n defaultMessage: 'Manage {resource}',\n description: 'Default label for the manage action',\n },\n 'authz.permissions.actions.publish': {\n id: 'authz.permissions.actions.publish',\n defaultMessage: 'Publish {resource}',\n description: 'Default label for the publish action',\n },\n 'authz.permissions.actions.view': {\n id: 'authz.permissions.actions.view',\n defaultMessage: 'View {resource}',\n description: 'Default label for the view action',\n },\n 'authz.permissions.actions.reuse': {\n id: 'authz.permissions.actions.reuse',\n defaultMessage: 'Reuse {resource}',\n description: 'Default label for the reuse action',\n },\n 'authz.role.card.delete.action.alt': {\n id: 'authz.role.card.delete.action.alt',\n defaultMessage: 'Delete role action',\n description: 'Alt description for delete button',\n },\n 'authz.role.card.userCounter': {\n id: 'authz.role.card.userCounter',\n defaultMessage: 'Number of users with this role',\n description: 'Screen reader text for the user counter icon in the role card header',\n },\n 'authz.role.card.permissions.ariaLabel': {\n id: 'authz.role.card.permissions.ariaLabel',\n defaultMessage: '{permissionName} permission is {permissionStatus}',\n description: 'Aria label for permission chips in the role card',\n },\n 'authz.role.card.permissions.status.denied': {\n id: 'authz.role.card.permissions.status.denied',\n defaultMessage: 'denied',\n description: 'Label for denied status of a permission in the role card',\n },\n 'authz.role.card.permissions.status.granted': {\n id: 'authz.role.card.permissions.status.granted',\n defaultMessage: 'granted',\n description: 'Label for granted status of a permission in the role card',\n },\n});\n\nexport default messages;\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UserRoleWithPermissions, RoleToDelete } from '../../types';
|
|
2
|
+
import { type DataTableCellProps } from '@openedx/paragon';
|
|
3
|
+
interface ViewActionCellExtraProps {
|
|
4
|
+
isCourseEnabled: (scope: string) => boolean;
|
|
5
|
+
}
|
|
6
|
+
type CellProps = DataTableCellProps<UserRoleWithPermissions>;
|
|
7
|
+
type CellPropsWithValue = CellProps & {
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
type ExtendedCellProps = CellPropsWithValue & {
|
|
11
|
+
cell: {
|
|
12
|
+
getCellProps: (props?: Record<string, string>) => Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
interface ActionsCellExtraProps {
|
|
16
|
+
onClickDeleteButton: (role: RoleToDelete) => void;
|
|
17
|
+
isUserAuthenticatedPage: boolean;
|
|
18
|
+
isCourseEnabled?: (scope: string) => boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const NameCell: ({ row }: CellProps) => import("react").JSX.Element;
|
|
21
|
+
declare const ViewActionCell: ({ row, isCourseEnabled }: CellProps & Partial<ViewActionCellExtraProps>) => import("react").JSX.Element;
|
|
22
|
+
declare const createViewActionCell: (extraProps: ViewActionCellExtraProps) => (cellProps: any) => import("react").JSX.Element;
|
|
23
|
+
declare const OrgCell: ({ value, row }: CellPropsWithValue) => import("react").JSX.Element;
|
|
24
|
+
declare const ScopeCell: ({ row }: CellProps) => import("react").JSX.Element;
|
|
25
|
+
declare const RoleCell: ({ value, cell }: ExtendedCellProps) => import("react").JSX.Element;
|
|
26
|
+
declare const PermissionsCell: ({ row }: CellProps) => import("react").JSX.Element;
|
|
27
|
+
declare const ViewAllPermissionsCell: ({ row }: CellProps) => import("react").JSX.Element;
|
|
28
|
+
declare const createActionsCell: (extraProps: ActionsCellExtraProps) => (cellProps: any) => import("react").JSX.Element;
|
|
29
|
+
export { NameCell, ViewActionCell, RoleCell, OrgCell, ScopeCell, PermissionsCell, ViewAllPermissionsCell, createActionsCell, createViewActionCell, };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { SiteContext, useIntl } from '@openedx/frontend-base';
|
|
14
|
+
import { RemoveRedEye, Delete, ExpandMore, Info, } from '@openedx/paragon/icons';
|
|
15
|
+
import { useNavigate } from 'react-router-dom';
|
|
16
|
+
import { useContext, useMemo } from 'react';
|
|
17
|
+
import { ADMIN_ROLES, DJANGO_MANAGED_ROLES, MAP_ROLE_KEY_TO_LABEL, } from '../constants';
|
|
18
|
+
import { Icon, IconButton, OverlayTrigger, Tooltip, DataTableContext, } from '@openedx/paragon';
|
|
19
|
+
import { RESOURCE_ICONS } from './constants';
|
|
20
|
+
import messages from './messages';
|
|
21
|
+
import ViewMoreLink from './ViewMoreLink';
|
|
22
|
+
// A disabled button can't trigger its own tooltip (Paragon sets pointer-events: none on it),
|
|
23
|
+
// so the OverlayTrigger must live on a wrapper element that still receives hover events.
|
|
24
|
+
const DisabledCourseActionButton = ({ src, alt, size, variant, }) => {
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
return (_jsx(OverlayTrigger, { placement: "left", overlay: (_jsx(Tooltip, { variant: "light", id: "tooltip-left", children: formatMessage(messages['authz.table.actions.course.disabled.tooltip']) })), children: _jsx("span", { className: "d-inline-block", children: _jsx(IconButton, { src: src, alt: alt, size: size, variant: variant, disabled: true }) }) }));
|
|
27
|
+
};
|
|
28
|
+
const NameCell = ({ row }) => {
|
|
29
|
+
const intl = useIntl();
|
|
30
|
+
const { authenticatedUser } = useContext(SiteContext);
|
|
31
|
+
const username = authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.username;
|
|
32
|
+
if (row.original.username === username) {
|
|
33
|
+
return (_jsxs("span", { children: [row.original.fullName || row.original.username, _jsx("span", { className: "text-gray-500", children: intl.formatMessage(messages['authz.table.username.current']) })] }));
|
|
34
|
+
}
|
|
35
|
+
return _jsx("span", { children: row.original.fullName || row.original.username || '' });
|
|
36
|
+
};
|
|
37
|
+
const ViewActionCell = ({ row, isCourseEnabled }) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const { formatMessage } = useIntl();
|
|
40
|
+
const navigate = useNavigate();
|
|
41
|
+
const viewPath = `/authz/user/${row.original.username}`;
|
|
42
|
+
const isCourseScope = !((_a = row.original.role) === null || _a === void 0 ? void 0 : _a.startsWith('lib')) && !DJANGO_MANAGED_ROLES.includes(row.original.role);
|
|
43
|
+
const isDisabled = isCourseEnabled !== undefined && isCourseScope && !isCourseEnabled(row.original.scope);
|
|
44
|
+
if (isDisabled) {
|
|
45
|
+
return (_jsx(DisabledCourseActionButton, { src: RemoveRedEye, alt: formatMessage(messages['authz.table.column.actions.view.title']), size: "sm" }));
|
|
46
|
+
}
|
|
47
|
+
return (_jsx(IconButton, { src: RemoveRedEye, alt: formatMessage(messages['authz.table.column.actions.view.title']), size: "sm", onClick: () => navigate(viewPath) }));
|
|
48
|
+
};
|
|
49
|
+
const createViewActionCell = (extraProps) => function customViewActionCell(cellProps) {
|
|
50
|
+
return _jsx(ViewActionCell, Object.assign({}, cellProps, extraProps));
|
|
51
|
+
};
|
|
52
|
+
const OrgCell = ({ value, row }) => {
|
|
53
|
+
const { formatMessage } = useIntl();
|
|
54
|
+
return (_jsx("span", { children: DJANGO_MANAGED_ROLES.includes(row.original.role) ? formatMessage(messages['authz.user.table.org.all.organizations.label']) : value }));
|
|
55
|
+
};
|
|
56
|
+
const ScopeCell = ({ row }) => {
|
|
57
|
+
const { formatMessage } = useIntl();
|
|
58
|
+
const { scopeText, iconSrc } = useMemo(() => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (DJANGO_MANAGED_ROLES.includes(row.original.role)) {
|
|
61
|
+
return {
|
|
62
|
+
scopeText: formatMessage(messages['authz.user.table.scope.global.label']),
|
|
63
|
+
iconSrc: RESOURCE_ICONS.GLOBAL,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const scopeIcon = ((_a = row.original.role) === null || _a === void 0 ? void 0 : _a.startsWith('lib')) ? RESOURCE_ICONS.LIBRARY : RESOURCE_ICONS.COURSE;
|
|
67
|
+
return {
|
|
68
|
+
scopeText: row.original.scope,
|
|
69
|
+
iconSrc: scopeIcon,
|
|
70
|
+
};
|
|
71
|
+
}, [row.original.role, row.original.scope, formatMessage]);
|
|
72
|
+
return (_jsxs("span", { className: "d-flex align-items-center", children: [iconSrc && _jsx(Icon, { color: "primary", src: iconSrc, className: "mr-2", size: "xs" }), scopeText] }));
|
|
73
|
+
};
|
|
74
|
+
const RoleCell = ({ value, cell }) => {
|
|
75
|
+
const _a = cell.getCellProps({ 'data-role': MAP_ROLE_KEY_TO_LABEL[value] || '' }), { key } = _a, cellProps = __rest(_a, ["key"]);
|
|
76
|
+
return (_jsx("span", Object.assign({}, cellProps, { children: MAP_ROLE_KEY_TO_LABEL[value] || '' }), key));
|
|
77
|
+
};
|
|
78
|
+
const PermissionsCell = ({ row }) => {
|
|
79
|
+
const { formatMessage } = useIntl();
|
|
80
|
+
const { role, permissionCount: count } = row.original;
|
|
81
|
+
const isDjangoRole = DJANGO_MANAGED_ROLES.includes(role);
|
|
82
|
+
return (_jsx("span", { children: isDjangoRole
|
|
83
|
+
? formatMessage(messages['authz.user.table.permissions.access.label'], { accessType: role === 'django.superuser' ? 'total' : 'partial' })
|
|
84
|
+
: formatMessage(messages['authz.user.table.permissions.available.count'], { count }) }));
|
|
85
|
+
};
|
|
86
|
+
const ViewAllPermissionsCell = ({ row }) => {
|
|
87
|
+
const { formatMessage } = useIntl();
|
|
88
|
+
const instance = useContext(DataTableContext);
|
|
89
|
+
const handleToggleExpanded = () => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
if (!row.isExpanded && instance) {
|
|
92
|
+
// Close all other expanded rows first
|
|
93
|
+
const expanded = ((_a = instance.state) === null || _a === void 0 ? void 0 : _a.expanded) || {};
|
|
94
|
+
Object.keys(expanded).forEach(rowId => {
|
|
95
|
+
var _a;
|
|
96
|
+
if (rowId !== row.id && expanded[rowId]) {
|
|
97
|
+
(_a = instance.toggleRowExpanded) === null || _a === void 0 ? void 0 : _a.call(instance, rowId, false);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Toggle the current row
|
|
102
|
+
(_b = row.toggleRowExpanded) === null || _b === void 0 ? void 0 : _b.call(row);
|
|
103
|
+
};
|
|
104
|
+
return (_jsx("div", { role: "button", children: _jsx(ViewMoreLink, { label: formatMessage(row.isExpanded
|
|
105
|
+
? messages['authz.user.table.view_all_permissions.link.text.close']
|
|
106
|
+
: messages['authz.user.table.view_all_permissions.link.text.open']), onClick: handleToggleExpanded, iconSrc: ExpandMore }) }));
|
|
107
|
+
};
|
|
108
|
+
const ActionsCell = ({ row, onClickDeleteButton, isUserAuthenticatedPage, isCourseEnabled, }) => {
|
|
109
|
+
const { formatMessage } = useIntl();
|
|
110
|
+
const { role, canManageScope } = row.original;
|
|
111
|
+
const handleDelete = () => {
|
|
112
|
+
const roleToDelete = {
|
|
113
|
+
role,
|
|
114
|
+
scope: row.original.scope,
|
|
115
|
+
name: MAP_ROLE_KEY_TO_LABEL[role] || '',
|
|
116
|
+
};
|
|
117
|
+
onClickDeleteButton(roleToDelete);
|
|
118
|
+
};
|
|
119
|
+
if (DJANGO_MANAGED_ROLES.includes(role)) {
|
|
120
|
+
return (_jsx(OverlayTrigger, { placement: "left", overlay: (_jsx(Tooltip, { variant: "light", id: "tooltip-left", children: formatMessage(messages['authz.user.table.delete.action.djangorole.tooltip']) })), children: _jsx(Icon, { className: "mx-2 pl-1", src: Info }) }));
|
|
121
|
+
}
|
|
122
|
+
if (ADMIN_ROLES.includes(role) && isUserAuthenticatedPage) {
|
|
123
|
+
return (_jsx(OverlayTrigger, { placement: "left", overlay: (_jsx(Tooltip, { variant: "light", id: "tooltip-left", children: formatMessage(messages['authz.user.table.delete.action.adminrole.tooltip']) })), children: _jsx(Icon, { className: "mx-2 pl-1 text-light-500", src: Delete }) }));
|
|
124
|
+
}
|
|
125
|
+
const isCourseScope = !(role === null || role === void 0 ? void 0 : role.startsWith('lib'));
|
|
126
|
+
const isCourseAuthoringDisabled = isCourseEnabled !== undefined
|
|
127
|
+
&& isCourseScope && !isCourseEnabled(row.original.scope);
|
|
128
|
+
if (isCourseAuthoringDisabled) {
|
|
129
|
+
return (_jsx(DisabledCourseActionButton, { src: Delete, alt: formatMessage(messages['authz.user.table.delete.action.alt']), variant: "light" }));
|
|
130
|
+
}
|
|
131
|
+
return (_jsx(IconButton, { disabled: !canManageScope, variant: canManageScope ? 'danger' : 'light', onClick: handleDelete, alt: formatMessage(messages['authz.user.table.delete.action.alt']), src: Delete }));
|
|
132
|
+
};
|
|
133
|
+
const createActionsCell = (extraProps) => function customActionsCell(cellProps) {
|
|
134
|
+
return _jsx(ActionsCell, Object.assign({}, cellProps, extraProps));
|
|
135
|
+
};
|
|
136
|
+
export { NameCell, ViewActionCell, RoleCell, OrgCell, ScopeCell, PermissionsCell, ViewAllPermissionsCell, createActionsCell, createViewActionCell, };
|
|
137
|
+
//# sourceMappingURL=TableCells.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCells.js","sourceRoot":"","sources":["../../../src/authz-module/components/TableCells.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,MAAM,EAAE,UAAU,EAClB,IAAI,GACL,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,OAAO,CAAC;AACjE,OAAO,EACL,WAAW,EAAE,oBAAoB,EAAE,qBAAqB,GACzD,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAE5D,MAAM,kBAAk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AAC;IAE3D,IAAI,yBAAyB,EAAE,CAAC;QAC9B,OAAO,CACL,KAAC,0BAA0B,IACzB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC,EAClE,OAAO,EAAC,OAAO,GACf,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,CAAC,cAAc,EACzB,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAC5C,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC,EAClE,GAAG,EAAE,MAAM,GACX,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,UAAiC,EAAE,EAAE,CAAC,SAAS,iBAAiB,CAAC,SAAS;IACnG,OAAO,KAAC,WAAW,oBAAK,SAAS,EAAM,UAAU,EAAI,CAAC;AACxD,CAAC,CAAC;AAEF,OAAO,EACL,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,GACrB,CAAC","sourcesContent":["import { SiteContext, useIntl } from '@openedx/frontend-base';\nimport {\n RemoveRedEye,\n Delete, ExpandMore,\n Info,\n} from '@openedx/paragon/icons';\nimport { UserRoleWithPermissions, RoleToDelete } from '@src/types';\nimport { useNavigate } from 'react-router-dom';\nimport { useContext, useMemo, type ComponentProps } from 'react';\nimport {\n ADMIN_ROLES, DJANGO_MANAGED_ROLES, MAP_ROLE_KEY_TO_LABEL,\n} from '@src/authz-module/constants';\nimport {\n Icon, IconButton, OverlayTrigger, Tooltip, DataTableContext,\n type DataTableCellProps,\n} from '@openedx/paragon';\nimport { RESOURCE_ICONS } from './constants';\nimport messages from './messages';\nimport ViewMoreLink from './ViewMoreLink';\n\ninterface ViewActionCellExtraProps {\n isCourseEnabled: (scope: string) => boolean;\n}\n\ninterface DataTableInstance {\n state?: {\n expanded?: Record<string, boolean>;\n };\n toggleRowExpanded?: (rowId: string, expanded: boolean) => void;\n}\n\ntype CellProps = DataTableCellProps<UserRoleWithPermissions>;\ntype CellPropsWithValue = CellProps & {\n value: string;\n};\ntype ExtendedCellProps = CellPropsWithValue & {\n cell: {\n getCellProps: (props?: Record<string, string>) => Record<string, string>;\n };\n};\n\ninterface ActionsCellExtraProps {\n onClickDeleteButton: (role: RoleToDelete) => void;\n isUserAuthenticatedPage: boolean;\n isCourseEnabled?: (scope: string) => boolean;\n}\n\ntype ActionsCellProps = CellProps & ActionsCellExtraProps;\n\ntype DisabledCourseActionButtonProps = Pick<ComponentProps<typeof IconButton>, 'src' | 'alt' | 'size' | 'variant'>;\n\n// A disabled button can't trigger its own tooltip (Paragon sets pointer-events: none on it),\n// so the OverlayTrigger must live on a wrapper element that still receives hover events.\nconst DisabledCourseActionButton = ({\n src, alt, size, variant,\n}: DisabledCourseActionButtonProps) => {\n const { formatMessage } = useIntl();\n return (\n <OverlayTrigger\n placement=\"left\"\n overlay={(\n <Tooltip variant=\"light\" id=\"tooltip-left\">\n {formatMessage(messages['authz.table.actions.course.disabled.tooltip'])}\n </Tooltip>\n )}\n >\n <span className=\"d-inline-block\">\n <IconButton\n src={src}\n alt={alt}\n size={size}\n variant={variant}\n disabled\n />\n </span>\n </OverlayTrigger>\n );\n};\n\nconst NameCell = ({ row }: CellProps) => {\n const intl = useIntl();\n const { authenticatedUser } = useContext(SiteContext);\n const username = authenticatedUser?.username;\n\n if (row.original.username === username) {\n return (\n <span>\n {row.original.fullName || row.original.username}\n <span className=\"text-gray-500\">{intl.formatMessage(messages['authz.table.username.current'])}</span>\n </span>\n );\n }\n return <span>{row.original.fullName || row.original.username || ''}</span>;\n};\n\nconst ViewActionCell = ({ row, isCourseEnabled }: CellProps & Partial<ViewActionCellExtraProps>) => {\n const { formatMessage } = useIntl();\n const navigate = useNavigate();\n const viewPath = `/authz/user/${row.original.username}`;\n const isCourseScope = !row.original.role?.startsWith('lib') && !DJANGO_MANAGED_ROLES.includes(row.original.role);\n const isDisabled = isCourseEnabled !== undefined && isCourseScope && !isCourseEnabled(row.original.scope);\n\n if (isDisabled) {\n return (\n <DisabledCourseActionButton\n src={RemoveRedEye}\n alt={formatMessage(messages['authz.table.column.actions.view.title'])}\n size=\"sm\"\n />\n );\n }\n\n return (\n <IconButton\n src={RemoveRedEye}\n alt={formatMessage(messages['authz.table.column.actions.view.title'])}\n size=\"sm\"\n onClick={() => navigate(viewPath)}\n />\n );\n};\n\nconst createViewActionCell = (extraProps: ViewActionCellExtraProps) => function customViewActionCell(cellProps) {\n return <ViewActionCell {...cellProps} {...extraProps} />;\n};\n\nconst OrgCell = ({ value, row }: CellPropsWithValue) => {\n const { formatMessage } = useIntl();\n return (\n <span>\n {DJANGO_MANAGED_ROLES.includes(row.original.role) ? formatMessage(messages['authz.user.table.org.all.organizations.label']) : value}\n </span>\n );\n};\n\nconst ScopeCell = ({ row }: CellProps) => {\n const { formatMessage } = useIntl();\n\n const { scopeText, iconSrc } = useMemo(() => {\n if (DJANGO_MANAGED_ROLES.includes(row.original.role)) {\n return {\n scopeText: formatMessage(messages['authz.user.table.scope.global.label']),\n iconSrc: RESOURCE_ICONS.GLOBAL,\n };\n }\n const scopeIcon = row.original.role?.startsWith('lib') ? RESOURCE_ICONS.LIBRARY : RESOURCE_ICONS.COURSE;\n return {\n scopeText: row.original.scope,\n iconSrc: scopeIcon,\n };\n }, [row.original.role, row.original.scope, formatMessage]);\n\n return (\n <span className=\"d-flex align-items-center\">\n {iconSrc && <Icon color=\"primary\" src={iconSrc} className=\"mr-2\" size=\"xs\" />}\n {scopeText}\n </span>\n );\n};\n\nconst RoleCell = ({ value, cell }: ExtendedCellProps) => {\n const { key, ...cellProps } = cell.getCellProps({ 'data-role': MAP_ROLE_KEY_TO_LABEL[value] || '' });\n return (\n <span key={key} {...cellProps}>\n {MAP_ROLE_KEY_TO_LABEL[value] || ''}\n </span>\n );\n};\n\nconst PermissionsCell = ({ row }: CellProps) => {\n const { formatMessage } = useIntl();\n const { role, permissionCount: count } = row.original;\n const isDjangoRole = DJANGO_MANAGED_ROLES.includes(role);\n return (\n <span>\n { isDjangoRole\n ? formatMessage(\n messages['authz.user.table.permissions.access.label'],\n { accessType: role === 'django.superuser' ? 'total' : 'partial' },\n )\n : formatMessage(messages['authz.user.table.permissions.available.count'], { count })}\n </span>\n );\n};\n\nconst ViewAllPermissionsCell = ({ row }: CellProps) => {\n const { formatMessage } = useIntl();\n const instance = useContext(DataTableContext) as DataTableInstance;\n const handleToggleExpanded = () => {\n if (!row.isExpanded && instance) {\n // Close all other expanded rows first\n const expanded = instance.state?.expanded || {};\n Object.keys(expanded).forEach(rowId => {\n if (rowId !== row.id && expanded[rowId]) {\n instance.toggleRowExpanded?.(rowId, false);\n }\n });\n }\n // Toggle the current row\n row.toggleRowExpanded?.();\n };\n\n return (\n <div role=\"button\">\n <ViewMoreLink\n label={formatMessage(\n row.isExpanded\n ? messages['authz.user.table.view_all_permissions.link.text.close']\n : messages['authz.user.table.view_all_permissions.link.text.open'],\n )}\n onClick={handleToggleExpanded}\n iconSrc={ExpandMore}\n />\n </div>\n );\n};\n\nconst ActionsCell = ({\n row, onClickDeleteButton, isUserAuthenticatedPage, isCourseEnabled,\n}: ActionsCellProps) => {\n const { formatMessage } = useIntl();\n const { role, canManageScope } = row.original;\n\n const handleDelete = () => {\n const roleToDelete = {\n role,\n scope: row.original.scope,\n name: MAP_ROLE_KEY_TO_LABEL[role] || '',\n } as RoleToDelete;\n onClickDeleteButton(roleToDelete);\n };\n\n if (DJANGO_MANAGED_ROLES.includes(role)) {\n return (\n <OverlayTrigger\n placement=\"left\"\n overlay={(\n <Tooltip variant=\"light\" id=\"tooltip-left\">\n {formatMessage(messages['authz.user.table.delete.action.djangorole.tooltip'])}\n </Tooltip>\n )}\n >\n <Icon\n className=\"mx-2 pl-1\"\n src={Info}\n />\n </OverlayTrigger>\n );\n }\n\n if (ADMIN_ROLES.includes(role) && isUserAuthenticatedPage) {\n return (\n <OverlayTrigger\n placement=\"left\"\n overlay={(\n <Tooltip variant=\"light\" id=\"tooltip-left\">\n {formatMessage(messages['authz.user.table.delete.action.adminrole.tooltip'])}\n </Tooltip>\n )}\n >\n <Icon\n className=\"mx-2 pl-1 text-light-500\"\n src={Delete}\n />\n </OverlayTrigger>\n );\n }\n\n const isCourseScope = !role?.startsWith('lib');\n const isCourseAuthoringDisabled = isCourseEnabled !== undefined\n && isCourseScope && !isCourseEnabled(row.original.scope);\n\n if (isCourseAuthoringDisabled) {\n return (\n <DisabledCourseActionButton\n src={Delete}\n alt={formatMessage(messages['authz.user.table.delete.action.alt'])}\n variant=\"light\"\n />\n );\n }\n\n return (\n <IconButton\n disabled={!canManageScope}\n variant={canManageScope ? 'danger' : 'light'}\n onClick={handleDelete}\n alt={formatMessage(messages['authz.user.table.delete.action.alt'])}\n src={Delete}\n />\n );\n};\n\nconst createActionsCell = (extraProps: ActionsCellExtraProps) => function customActionsCell(cellProps) {\n return <ActionsCell {...cellProps} {...extraProps} />;\n};\n\nexport {\n NameCell,\n ViewActionCell,\n RoleCell,\n OrgCell,\n ScopeCell,\n PermissionsCell,\n ViewAllPermissionsCell,\n createActionsCell,\n createViewActionCell,\n};\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MultipleChoiceFilterProps } from './types';
|
|
2
|
+
declare const MultipleChoiceFilter: ({ filterButtonText, filterChoices, filterValue, setFilter, isGrouped, isSearchable, onSearchChange, iconSrc, disabled, }: MultipleChoiceFilterProps) => import("react").JSX.Element;
|
|
3
|
+
export default MultipleChoiceFilter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dropdown, Form, Icon, Stack, } from '@openedx/paragon';
|
|
3
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import { FilterList, Info, Search } from '@openedx/paragon/icons';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import messages from '../messages';
|
|
7
|
+
const MultipleChoiceFilter = ({ filterButtonText, filterChoices, filterValue, setFilter, isGrouped = false, isSearchable = false, onSearchChange, iconSrc, disabled = false, }) => {
|
|
8
|
+
const [searchValue, setSearchValue] = useState(undefined);
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const checkedBoxes = filterValue || [];
|
|
11
|
+
const handleClickCheckbox = (value, displayName) => {
|
|
12
|
+
const newValue = {
|
|
13
|
+
groupName: (filterButtonText === null || filterButtonText === void 0 ? void 0 : filterButtonText.toLocaleLowerCase()) || '',
|
|
14
|
+
value,
|
|
15
|
+
displayName,
|
|
16
|
+
};
|
|
17
|
+
if (checkedBoxes.includes(value)) {
|
|
18
|
+
const newCheckedBoxes = checkedBoxes.filter((val) => val !== value);
|
|
19
|
+
return setFilter(newCheckedBoxes, newValue);
|
|
20
|
+
}
|
|
21
|
+
const newCheckedBoxes = [...checkedBoxes, value];
|
|
22
|
+
return setFilter(newCheckedBoxes, newValue);
|
|
23
|
+
};
|
|
24
|
+
const getGroupedChoices = () => {
|
|
25
|
+
const groupedFilterChoices = filterChoices.reduce((groups, choice) => {
|
|
26
|
+
const groupName = choice.groupName || 'Ungrouped';
|
|
27
|
+
const icon = choice.groupIcon || undefined;
|
|
28
|
+
if (!groups.has(groupName)) {
|
|
29
|
+
groups.set(groupName, { groupName, options: [], icon });
|
|
30
|
+
}
|
|
31
|
+
groups.get(groupName).options.push({
|
|
32
|
+
displayName: choice.displayName,
|
|
33
|
+
value: choice.value,
|
|
34
|
+
description: choice.description,
|
|
35
|
+
});
|
|
36
|
+
return groups;
|
|
37
|
+
}, new Map());
|
|
38
|
+
return Array.from(groupedFilterChoices.values());
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs(Dropdown, { className: "no-caret-dropdown filters", children: [_jsx(Dropdown.Toggle, { variant: checkedBoxes.length > 0 ? 'primary' : 'outline-primary', children: _jsxs(Stack, { direction: "horizontal", gap: 2, children: [iconSrc && _jsx(Icon, { color: "primary", src: iconSrc }), filterButtonText, checkedBoxes.length > 0 && ` (${checkedBoxes.length})`, _jsx(Icon, { color: "primary", src: FilterList })] }) }), _jsxs(Dropdown.Menu, { children: [isSearchable && (_jsx(Form.Control, { className: "m-1", type: "text", trailingElement: _jsx(Icon, { src: Search }), placeholder: formatMessage(messages['authz.table.controlbar.search']), onChange: (e) => {
|
|
41
|
+
setSearchValue(e.target.value);
|
|
42
|
+
onSearchChange === null || onSearchChange === void 0 ? void 0 : onSearchChange(e.target.value);
|
|
43
|
+
}, value: searchValue })), _jsxs(Form.CheckboxSet, { className: "pgn__dropdown-filter-checkbox-group", name: filterButtonText, "aria-label": filterButtonText, value: checkedBoxes, children: [_jsx("span", { className: "small text-info-700 mt-2", children: formatMessage(messages['authz.table.controlbar.filters.items.showing'], { current: filterChoices.length, total: filterChoices.length }) }), !isGrouped ? filterChoices.map(({ displayName, value, description, }) => (_jsx(Form.Checkbox, { className: "m-2 w-100", checked: checkedBoxes.includes(value), value: value, onChange: () => handleClickCheckbox(value, displayName), "aria-label": displayName, disabled: checkedBoxes.includes(value) ? false : disabled, children: _jsxs("div", { className: "d-flex flex-column", children: [_jsx("span", { className: "small", children: displayName }), description && _jsx("span", { className: "small text-muted d-block", children: description })] }) }, displayName)))
|
|
44
|
+
: getGroupedChoices().map(({ groupName, icon, options }) => (_jsxs("div", { children: [_jsxs("div", { className: "pgn__dropdown-filter-group-name text-info-700 d-flex align-items-center small m-2 ml-0", children: [icon && _jsx(Icon, { color: "primary", src: icon, className: "mr-2", size: "xs" }), _jsx("span", { children: groupName })] }), options.map(({ displayName, value, description }) => (_jsx(Form.Checkbox, { className: "m-2 w-100", value: value, onChange: () => handleClickCheckbox(value, displayName), disabled: checkedBoxes.includes(value) ? false : disabled, "aria-label": displayName, children: _jsxs("div", { className: "d-flex flex-column", children: [_jsx("span", { className: "small", children: displayName }), description && _jsx("span", { className: "small text-muted d-block", children: description })] }) }, displayName)))] }, groupName))), isSearchable && (_jsxs("div", { className: "d-flex align-items-center justify-content-between p-2", children: [_jsx("span", { className: "text-muted small", children: formatMessage(messages['authz.table.controlbar.filters.more.results']) }), _jsx(Icon, { className: "text-gray-300 ml-1", src: Info, size: "xs" })] }))] })] })] }));
|
|
45
|
+
};
|
|
46
|
+
export default MultipleChoiceFilter;
|
|
47
|
+
//# sourceMappingURL=MultipleChoiceFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultipleChoiceFilter.js","sourceRoot":"","sources":["../../../../src/authz-module/components/TableControlBar/MultipleChoiceFilter.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,QAAQ,MAAM,uCAAuC,CAAC;AAG7D,MAAM,oBAAoB,GAAG,CAAC,EAC5B,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,SAAS,EACT,SAAS,GAAG,KAAK,EACjB,YAAY,GAAG,KAAK,EACpB,cAAc,EACd,OAAO,EACP,QAAQ,GAAG,KAAK,GACU,EAAE,EAAE;IAC9B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAC9E,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpC,MAAM,YAAY,GAAG,WAAW,IAAI,EAAE,CAAC;IACvC,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG;YACf,S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S,EAAC,WAAW,EAErB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,EACvD,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,gBAC7C,WAAW,YAEvB,eAAK,SAAS,EAAC,oBAAoB,aACjC,eAAM,SAAS,EAAC,OAAO,YAAE,WAAW,GAAQ,EAC1C,WAAW,IAAI,eAAM,SAAS,EAAC,0BAA0B,YAAE,WAAW,GAAQ,IAC5E,IATD,WAAW,CAUF,CACjB,CAAC,KAnBM,SAAS,CAoBb,CACP,CAAC,EACJ,YAAY,IAAI,CAChB,eAAK,SAAS,EAAC,uDAAuD,aACpE,eAAM,SAAS,EAAC,kBAAkB,YAAE,aAAa,CAAC,QAAQ,CAAC,6CAA6C,CAAC,CAAC,GAAQ,EAClH,KAAC,IAAI,IAAC,SAAS,EAAC,oBAAoB,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,IACxD,CACP,IACgB,IACL,IAEP,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import {\n Dropdown, Form, Icon, Stack,\n} from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\nimport { FilterList, Info, Search } from '@openedx/paragon/icons';\nimport { useState } from 'react';\nimport messages from '@src/authz-module/components/messages';\nimport { FilterChoice, MultipleChoiceFilterProps } from './types';\n\nconst MultipleChoiceFilter = ({\n filterButtonText,\n filterChoices,\n filterValue,\n setFilter,\n isGrouped = false,\n isSearchable = false,\n onSearchChange,\n iconSrc,\n disabled = false,\n}: MultipleChoiceFilterProps) => {\n const [searchValue, setSearchValue] = useState<string | undefined>(undefined);\n const { formatMessage } = useIntl();\n\n const checkedBoxes = filterValue || [];\n const handleClickCheckbox = (value, displayName) => {\n const newValue = {\n groupName: filterButtonText?.toLocaleLowerCase() || '',\n value,\n displayName,\n };\n if (checkedBoxes.includes(value)) {\n const newCheckedBoxes = checkedBoxes.filter((val) => val !== value);\n return setFilter(newCheckedBoxes, newValue);\n }\n const newCheckedBoxes = [...checkedBoxes, value];\n return setFilter(newCheckedBoxes, newValue);\n };\n\n const getGroupedChoices = () => {\n const groupedFilterChoices = filterChoices.reduce((groups, choice) => {\n const groupName = choice.groupName || 'Ungrouped';\n const icon = choice.groupIcon || undefined;\n if (!groups.has(groupName)) {\n groups.set(groupName, { groupName, options: [], icon });\n }\n groups.get(groupName)!.options.push({\n displayName: choice.displayName,\n value: choice.value,\n description: choice.description,\n });\n return groups;\n }, new Map<string, { groupName: string; options: FilterChoice[]; icon?: any }>());\n return Array.from(groupedFilterChoices.values());\n };\n\n return (\n <Dropdown className=\"no-caret-dropdown filters\">\n <Dropdown.Toggle variant={checkedBoxes.length > 0 ? 'primary' : 'outline-primary'}>\n <Stack direction=\"horizontal\" gap={2}>\n {iconSrc && <Icon color=\"primary\" src={iconSrc} />}\n {filterButtonText}\n {checkedBoxes.length > 0 && ` (${checkedBoxes.length})`}\n <Icon color=\"primary\" src={FilterList} />\n </Stack>\n </Dropdown.Toggle>\n\n <Dropdown.Menu>\n {isSearchable && (\n <Form.Control\n className=\"m-1\"\n type=\"text\"\n trailingElement={<Icon src={Search} />}\n placeholder={formatMessage(messages['authz.table.controlbar.search'])}\n onChange={(e) => {\n setSearchValue(e.target.value);\n onSearchChange?.(e.target.value);\n }}\n value={searchValue}\n />\n )}\n <Form.CheckboxSet\n className=\"pgn__dropdown-filter-checkbox-group\"\n name={filterButtonText}\n aria-label={filterButtonText}\n value={checkedBoxes}\n >\n <span className=\"small text-info-700 mt-2\">\n {formatMessage(messages['authz.table.controlbar.filters.items.showing'], { current: filterChoices.length, total: filterChoices.length })}\n </span>\n {!isGrouped ? filterChoices.map(({\n displayName, value, description,\n }) => (\n <Form.Checkbox\n className=\"m-2 w-100\"\n key={displayName}\n checked={checkedBoxes.includes(value)}\n value={value}\n onChange={() => handleClickCheckbox(value, displayName)}\n aria-label={displayName}\n disabled={checkedBoxes.includes(value) ? false : disabled}\n >\n <div className=\"d-flex flex-column\">\n <span className=\"small\">{displayName}</span>\n { description && <span className=\"small text-muted d-block\">{description}</span> }\n </div>\n </Form.Checkbox>\n ))\n : getGroupedChoices().map(({ groupName, icon, options }) => (\n <div key={groupName}>\n <div className=\"pgn__dropdown-filter-group-name text-info-700 d-flex align-items-center small m-2 ml-0\">\n {icon && <Icon color=\"primary\" src={icon} className=\"mr-2\" size=\"xs\" />}\n <span>{groupName}</span>\n </div>\n {options.map(({ displayName, value, description }) => (\n <Form.Checkbox\n className=\"m-2 w-100\"\n key={displayName}\n value={value}\n onChange={() => handleClickCheckbox(value, displayName)}\n disabled={checkedBoxes.includes(value) ? false : disabled}\n aria-label={displayName}\n >\n <div className=\"d-flex flex-column\">\n <span className=\"small\">{displayName}</span>\n { description && <span className=\"small text-muted d-block\">{description}</span> }\n </div>\n </Form.Checkbox>\n ))}\n </div>\n ))}\n { isSearchable && (\n <div className=\"d-flex align-items-center justify-content-between p-2\">\n <span className=\"text-muted small\">{formatMessage(messages['authz.table.controlbar.filters.more.results'])}</span>\n <Icon className=\"text-gray-300 ml-1\" src={Info} size=\"xs\" />\n </div>\n )}\n </Form.CheckboxSet>\n </Dropdown.Menu>\n\n </Dropdown>\n );\n};\n\nexport default MultipleChoiceFilter;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MultipleChoiceFilterProps } from './types';
|
|
3
|
+
type OrgFilterProps = Omit<MultipleChoiceFilterProps, 'filterChoices' | 'isSearchable' | 'onSearchChange'>;
|
|
4
|
+
declare const OrgFilter: ({ filterButtonText, filterValue, setFilter, disabled, }: OrgFilterProps) => React.JSX.Element;
|
|
5
|
+
export default OrgFilter;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { Business } from '@openedx/paragon/icons';
|
|
4
|
+
import { useOrgs } from '../../data/hooks';
|
|
5
|
+
import { useViewTeamPermissions } from '../../hooks/useViewTeamPermissions';
|
|
6
|
+
import { useCourseAuthoringFlag } from '../../hooks/useCourseAuthoringFlag';
|
|
7
|
+
import { DEFAULT_FILTER_PAGE_SIZE } from '../../constants';
|
|
8
|
+
import MultipleChoiceFilter from './MultipleChoiceFilter';
|
|
9
|
+
const OrgFilter = ({ filterButtonText, filterValue, setFilter, disabled, }) => {
|
|
10
|
+
const [searchValue, setSearchValue] = React.useState(undefined);
|
|
11
|
+
const { isLibraryViewAllowed, isLoading } = useViewTeamPermissions();
|
|
12
|
+
const { isOrgAuthoringEnabled, isLoading: isFlagLoading } = useCourseAuthoringFlag();
|
|
13
|
+
const { data: orgsData = {
|
|
14
|
+
count: 0, next: null, previous: null, results: [],
|
|
15
|
+
}, } = useOrgs(searchValue, 1, DEFAULT_FILTER_PAGE_SIZE);
|
|
16
|
+
// Users with library access (including those with both library and course roles) must
|
|
17
|
+
// always see all orgs: library access is not gated by the course-authoring flag,
|
|
18
|
+
// so the flag must never be used to filter orgs for them. Only filter orgs by the
|
|
19
|
+
// flag for course-only users, and never while permissions or flag states are loading.
|
|
20
|
+
const filterByAuthoringFlag = !isLoading && !isFlagLoading && !isLibraryViewAllowed;
|
|
21
|
+
const filterChoices = useMemo(() => {
|
|
22
|
+
var _a;
|
|
23
|
+
return ((_a = orgsData === null || orgsData === void 0 ? void 0 : orgsData.results) !== null && _a !== void 0 ? _a : [])
|
|
24
|
+
.filter((org) => !filterByAuthoringFlag || isOrgAuthoringEnabled(org.shortName))
|
|
25
|
+
.map((org) => ({
|
|
26
|
+
displayName: org.name,
|
|
27
|
+
value: org.shortName,
|
|
28
|
+
}));
|
|
29
|
+
}, [orgsData, filterByAuthoringFlag, isOrgAuthoringEnabled]);
|
|
30
|
+
const handleSearchChange = (value) => {
|
|
31
|
+
setSearchValue(value);
|
|
32
|
+
};
|
|
33
|
+
return (_jsx(MultipleChoiceFilter, { filterButtonText: filterButtonText, filterChoices: filterChoices, filterValue: filterValue, setFilter: setFilter, isSearchable: true, onSearchChange: handleSearchChange, iconSrc: Business, disabled: disabled }));
|
|
34
|
+
};
|
|
35
|
+
export default OrgFilter;
|
|
36
|
+
//# sourceMappingURL=OrgFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrgFilter.js","sourceRoot":"","sources":["../../../../src/authz-module/components/TableControlBar/OrgFilter.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAI1D,MAAM,SAAS,GAAG,CAAC,EACjB,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,GACnC,EAAE,EAAE;IACnB,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,SAAS,CAAC,CAAC;IACpF,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACrE,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACrF,MAAM,EACJ,IAAI,EAAE,QAAQ,GAAG;QACf,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;KAClD,GACF,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,wBAAwB,CAAC,CAAC;IAEtD,sFAAsF;IACtF,iFAAiF;IACjF,kFAAkF;IAClF,sFAAsF;IACtF,MAAM,qBAAqB,GAAG,CAAC,SAAS,IAAI,CAAC,aAAa,IAAI,CAAC,oBAAoB,CAAC;IAEpF,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;;QAAC,OAAA,CAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,mCAAI,EAAE,CAAC;aAC1D,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;aAC/E,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACb,WAAW,EAAE,GAAG,CAAC,IAAI;YACrB,KAAK,EAAE,GAAG,CAAC,SAAS;SACrB,CAAC,CAAC,CAAA;KAAA,EAAE,CAAC,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAEjE,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;QAC3C,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,oBAAoB,IACnB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,YAAY,QACZ,cAAc,EAAE,kBAAkB,EAClC,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { Business } from '@openedx/paragon/icons';\nimport { useOrgs } from '@src/authz-module/data/hooks';\nimport { useViewTeamPermissions } from '@src/authz-module/hooks/useViewTeamPermissions';\nimport { useCourseAuthoringFlag } from '@src/authz-module/hooks/useCourseAuthoringFlag';\nimport { DEFAULT_FILTER_PAGE_SIZE } from '@src/authz-module/constants';\nimport { MultipleChoiceFilterProps } from './types';\nimport MultipleChoiceFilter from './MultipleChoiceFilter';\n\ntype OrgFilterProps = Omit<MultipleChoiceFilterProps, 'filterChoices' | 'isSearchable' | 'onSearchChange'>;\n\nconst OrgFilter = ({\n filterButtonText, filterValue, setFilter, disabled,\n}: OrgFilterProps) => {\n const [searchValue, setSearchValue] = React.useState<string | undefined>(undefined);\n const { isLibraryViewAllowed, isLoading } = useViewTeamPermissions();\n const { isOrgAuthoringEnabled, isLoading: isFlagLoading } = useCourseAuthoringFlag();\n const {\n data: orgsData = {\n count: 0, next: null, previous: null, results: [],\n },\n } = useOrgs(searchValue, 1, DEFAULT_FILTER_PAGE_SIZE);\n\n // Users with library access (including those with both library and course roles) must\n // always see all orgs: library access is not gated by the course-authoring flag,\n // so the flag must never be used to filter orgs for them. Only filter orgs by the\n // flag for course-only users, and never while permissions or flag states are loading.\n const filterByAuthoringFlag = !isLoading && !isFlagLoading && !isLibraryViewAllowed;\n\n const filterChoices = useMemo(() => (orgsData?.results ?? [])\n .filter((org) => !filterByAuthoringFlag || isOrgAuthoringEnabled(org.shortName))\n .map((org) => ({\n displayName: org.name,\n value: org.shortName,\n })), [orgsData, filterByAuthoringFlag, isOrgAuthoringEnabled]);\n\n const handleSearchChange = (value: string) => {\n setSearchValue(value);\n };\n\n return (\n <MultipleChoiceFilter\n filterButtonText={filterButtonText}\n filterChoices={filterChoices}\n filterValue={filterValue}\n setFilter={setFilter}\n isSearchable\n onSearchChange={handleSearchChange}\n iconSrc={Business}\n disabled={disabled}\n />\n );\n};\n\nexport default OrgFilter;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MultipleChoiceFilterProps } from './types';
|
|
2
|
+
type RolesFilterProps = Omit<MultipleChoiceFilterProps, 'filterChoices' | 'isSearchable' | 'onSearchChange'>;
|
|
3
|
+
declare const RolesFilter: ({ filterButtonText, filterValue, setFilter, disabled, }: RolesFilterProps) => import("react").JSX.Element;
|
|
4
|
+
export default RolesFilter;
|