@backstage-community/plugin-rbac 1.32.3 → 1.32.5
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/CHANGELOG.md +12 -0
- package/dist/api/LicensedUsersClient.esm.js.map +1 -1
- package/dist/api/RBACBackendClient.esm.js.map +1 -1
- package/dist/components/Administration.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/AddNestedConditionButton.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ComplexConditionRow.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ComplexConditionRowButtons.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionRule.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionalAccessSidebar.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionsForm.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionsFormRow.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionsFormRowFields.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/CriteriaToggleButton.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/CustomArrayField.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/RulesDropdownOption.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/const.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/types.esm.js.map +1 -1
- package/dist/components/CreateRole/AddMembersForm.esm.js.map +1 -1
- package/dist/components/CreateRole/AddedMembersTable.esm.js.map +1 -1
- package/dist/components/CreateRole/AddedMembersTableColumn.esm.js.map +1 -1
- package/dist/components/CreateRole/CreateRolePage.esm.js.map +1 -1
- package/dist/components/CreateRole/EditRolePage.esm.js.map +1 -1
- package/dist/components/CreateRole/MembersDropdownOption.esm.js.map +1 -1
- package/dist/components/CreateRole/PermissionPoliciesForm.esm.js.map +1 -1
- package/dist/components/CreateRole/PermissionPoliciesFormRow.esm.js.map +1 -1
- package/dist/components/CreateRole/PoliciesCheckboxGroup.esm.js.map +1 -1
- package/dist/components/CreateRole/ReviewStep.esm.js.map +1 -1
- package/dist/components/CreateRole/ReviewStepTable.esm.js.map +1 -1
- package/dist/components/CreateRole/RoleDetailsForm.esm.js.map +1 -1
- package/dist/components/CreateRole/RoleForm.esm.js.map +1 -1
- package/dist/components/CreateRole/SelectedPermissionPoliciesColumn.esm.js.map +1 -1
- package/dist/components/CreateRole/const.esm.js.map +1 -1
- package/dist/components/DownloadUserStatistics.esm.js.map +1 -1
- package/dist/components/EditRole.esm.js.map +1 -1
- package/dist/components/RbacPage.esm.js.map +1 -1
- package/dist/components/RoleOverview/AboutCard.esm.js.map +1 -1
- package/dist/components/RoleOverview/MembersCard.esm.js.map +1 -1
- package/dist/components/RoleOverview/MembersListColumns.esm.js.map +1 -1
- package/dist/components/RoleOverview/PermissionsCard.esm.js.map +1 -1
- package/dist/components/RoleOverview/PermissionsListColumns.esm.js.map +1 -1
- package/dist/components/RoleOverview/RoleOverviewPage.esm.js.map +1 -1
- package/dist/components/RolesList/DeleteRole.esm.js.map +1 -1
- package/dist/components/RolesList/DeleteRoleDialog.esm.js.map +1 -1
- package/dist/components/RolesList/RolesList.esm.js.map +1 -1
- package/dist/components/RolesList/RolesListColumns.esm.js.map +1 -1
- package/dist/components/RolesList/RolesListToolbar.esm.js.map +1 -1
- package/dist/components/Router.esm.js.map +1 -1
- package/dist/components/SnackbarAlert.esm.js.map +1 -1
- package/dist/components/ToastContext.esm.js.map +1 -1
- package/dist/hooks/useCheckIfLicensePluginEnabled.esm.js.map +1 -1
- package/dist/hooks/useConditionRules.esm.js.map +1 -1
- package/dist/hooks/useLocationToast.esm.js.map +1 -1
- package/dist/hooks/useMembers.esm.js.map +1 -1
- package/dist/hooks/usePermissionPolicies.esm.js.map +1 -1
- package/dist/hooks/useRole.esm.js.map +1 -1
- package/dist/hooks/useRoles.esm.js.map +1 -1
- package/dist/hooks/useSelectedMembers.esm.js.map +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/routes.esm.js.map +1 -1
- package/dist/utils/conditional-access-utils.esm.js.map +1 -1
- package/dist/utils/create-role-utils.esm.js.map +1 -1
- package/dist/utils/rbac-utils.esm.js.map +1 -1
- package/dist/utils/role-form-utils.esm.js.map +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteRoleDialog.esm.js","sources":["../../../src/components/RolesList/DeleteRoleDialog.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport {\n Box,\n Button,\n createStyles,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n makeStyles,\n TextField,\n Theme,\n} from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport ErrorIcon from '@material-ui/icons/Error';\nimport { Alert } from '@material-ui/lab';\nimport Typography from '@mui/material/Typography';\n\nimport { RoleBasedPolicy } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../../api/RBACBackendClient';\nimport { getMembers } from '../../utils/rbac-utils';\nimport {\n removeConditions,\n removePermissions,\n} from '../../utils/role-form-utils';\nimport { useToast } from '../ToastContext';\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n titleContainer: {\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n },\n closeButton: {\n position: 'absolute',\n right: theme.spacing(1),\n top: theme.spacing(1),\n color: theme.palette.grey[500],\n },\n }),\n);\n\ntype DeleteRoleDialogProps = {\n open: boolean;\n closeDialog: () => void;\n roleName: string;\n propOptions: {\n memberRefs: string[];\n permissions: number;\n };\n};\n\nconst DeleteRoleDialog = ({\n open,\n closeDialog,\n roleName,\n propOptions,\n}: DeleteRoleDialogProps) => {\n const classes = useStyles();\n const { setToastMessage } = useToast();\n const [deleteRoleValue, setDeleteRoleValue] = React.useState<string>();\n const [disableDelete, setDisableDelete] = React.useState(false);\n const [error, setError] = React.useState<string>('');\n\n const rbacApi = useApi(rbacApiRef);\n\n const deleteRole = async () => {\n try {\n const policies = await rbacApi.getAssociatedPolicies(roleName);\n const conditionalPolicies = await rbacApi.getRoleConditions(roleName);\n\n if (Array.isArray(policies)) {\n const allowedPolicies = policies.filter(\n (policy: RoleBasedPolicy) => policy.effect !== 'deny',\n );\n await removePermissions(roleName, allowedPolicies, rbacApi);\n }\n\n if (Array.isArray(conditionalPolicies)) {\n const conditionalPoliciesIds = conditionalPolicies.map(cp => cp.id);\n await removeConditions(conditionalPoliciesIds, rbacApi);\n }\n\n const response = await rbacApi.deleteRole(roleName);\n if (response.status === 200 || response.status === 204) {\n setToastMessage(`Role ${roleName} deleted successfully`);\n closeDialog();\n } else {\n setError(`Unable to delete the role. ${response.statusText}`);\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : `${err}`);\n }\n };\n\n const onTextInput = (value: string) => {\n setDeleteRoleValue(value);\n if (value === '') {\n setDisableDelete(true);\n } else if (value === roleName) {\n setDisableDelete(false);\n } else {\n setDisableDelete(true);\n }\n };\n\n return (\n <Dialog maxWidth=\"md\" open={open} onClose={closeDialog}>\n <DialogTitle id=\"delete-role\" title=\"Delete Role\">\n <Box className={classes.titleContainer}>\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n <ErrorIcon\n style={{\n color: 'red',\n alignContent: 'center',\n marginTop: '7px',\n marginBottom: '-3px',\n }}\n fontSize=\"small\"\n />{' '}\n Delete this role?\n </Typography>\n\n <IconButton\n aria-label=\"close\"\n className={classes.closeButton}\n onClick={closeDialog}\n >\n <CloseIcon />\n </IconButton>\n </Box>\n </DialogTitle>\n <DialogContent>\n Are you sure you want to delete the role{' '}\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n {roleName}\n </Typography>{' '}\n ?\n <br />\n <br />\n Deleting this role is irreversible and will remove its functionality\n from the system. Proceed with caution.\n <br />\n <br />\n The{' '}\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>{`${getMembers(\n propOptions.memberRefs,\n ).toLocaleLowerCase('en-US')}`}</Typography>{' '}\n associated with this role will lose access to all the{' '}\n <Typography\n component=\"span\"\n sx={{ fontWeight: 'bold' }}\n >{`${propOptions.permissions} permission policies`}</Typography>{' '}\n specified in this role.\n <br />\n <TextField\n name=\"delete-role\"\n data-testid=\"delete-role\"\n style={{ marginTop: '24px' }}\n required\n variant=\"outlined\"\n label=\"Role name\"\n defaultValue={deleteRoleValue}\n helperText=\"Type the name of the role to confirm\"\n onChange={({ target: { value } }) => onTextInput(value)}\n onBlur={({ target: { value } }) => onTextInput(value)}\n />\n </DialogContent>\n {error && (\n <Box maxWidth=\"650px\" marginLeft=\"20px\">\n <Alert severity=\"error\">{error}</Alert>\n </Box>\n )}\n <DialogActions\n style={{\n paddingLeft: '25px',\n paddingBottom: '30px',\n justifyContent: 'left',\n paddingTop: '16px',\n }}\n >\n <Button\n variant=\"contained\"\n style={\n disableDelete || !deleteRoleValue\n ? {}\n : { background: 'red', color: 'white' }\n }\n onClick={deleteRole}\n disabled={disableDelete || !deleteRoleValue}\n >\n Delete\n </Button>\n <Button variant=\"outlined\" onClick={closeDialog}>\n Cancel\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n\nexport default DeleteRoleDialog;\n"],"names":[],"mappings":";;;;;;;;;;;;AA+CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,cAAgB,EAAA;AAAA,MACd,OAAS,EAAA,MAAA;AAAA,MACT,UAAY,EAAA,QAAA;AAAA,MACZ,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,C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OAAI,QAAS,EAAA,OAAA,EAAQ,UAAW,EAAA,MAAA,EAAA,sCAC9B,KAAM,EAAA,EAAA,QAAA,EAAS,OAAS,EAAA,EAAA,KAAM,CACjC,CAEF,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,WAAa,EAAA,MAAA;AAAA,QACb,aAAe,EAAA,MAAA;AAAA,QACf,cAAgB,EAAA,MAAA;AAAA,QAChB,UAAY,EAAA,MAAA;AAAA,OACd;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,WAAA;AAAA,QACR,KAAA,EACE,aAAiB,IAAA,CAAC,eACd,GAAA,KACA,EAAE,UAAA,EAAY,KAAO,EAAA,KAAA,EAAO,OAAQ,EAAA;AAAA,QAE1C,OAAS,EAAA,UAAA;AAAA,QACT,QAAA,EAAU,iBAAiB,CAAC,eAAA;AAAA,OAAA;AAAA,MAC7B,QAAA;AAAA,KAED;AAAA,wCACC,MAAO,EAAA,EAAA,OAAA,EAAQ,UAAW,EAAA,OAAA,EAAS,eAAa,QAEjD,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DeleteRoleDialog.esm.js","sources":["../../../src/components/RolesList/DeleteRoleDialog.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport {\n Box,\n Button,\n createStyles,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n makeStyles,\n TextField,\n Theme,\n} from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport ErrorIcon from '@material-ui/icons/Error';\nimport { Alert } from '@material-ui/lab';\nimport Typography from '@mui/material/Typography';\n\nimport { RoleBasedPolicy } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../../api/RBACBackendClient';\nimport { getMembers } from '../../utils/rbac-utils';\nimport {\n removeConditions,\n removePermissions,\n} from '../../utils/role-form-utils';\nimport { useToast } from '../ToastContext';\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n titleContainer: {\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n },\n closeButton: {\n position: 'absolute',\n right: theme.spacing(1),\n top: theme.spacing(1),\n color: theme.palette.grey[500],\n },\n }),\n);\n\ntype DeleteRoleDialogProps = {\n open: boolean;\n closeDialog: () => void;\n roleName: string;\n propOptions: {\n memberRefs: string[];\n permissions: number;\n };\n};\n\nconst DeleteRoleDialog = ({\n open,\n closeDialog,\n roleName,\n propOptions,\n}: DeleteRoleDialogProps) => {\n const classes = useStyles();\n const { setToastMessage } = useToast();\n const [deleteRoleValue, setDeleteRoleValue] = React.useState<string>();\n const [disableDelete, setDisableDelete] = React.useState(false);\n const [error, setError] = React.useState<string>('');\n\n const rbacApi = useApi(rbacApiRef);\n\n const deleteRole = async () => {\n try {\n const policies = await rbacApi.getAssociatedPolicies(roleName);\n const conditionalPolicies = await rbacApi.getRoleConditions(roleName);\n\n if (Array.isArray(policies)) {\n const allowedPolicies = policies.filter(\n (policy: RoleBasedPolicy) => policy.effect !== 'deny',\n );\n await removePermissions(roleName, allowedPolicies, rbacApi);\n }\n\n if (Array.isArray(conditionalPolicies)) {\n const conditionalPoliciesIds = conditionalPolicies.map(cp => cp.id);\n await removeConditions(conditionalPoliciesIds, rbacApi);\n }\n\n const response = await rbacApi.deleteRole(roleName);\n if (response.status === 200 || response.status === 204) {\n setToastMessage(`Role ${roleName} deleted successfully`);\n closeDialog();\n } else {\n setError(`Unable to delete the role. ${response.statusText}`);\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : `${err}`);\n }\n };\n\n const onTextInput = (value: string) => {\n setDeleteRoleValue(value);\n if (value === '') {\n setDisableDelete(true);\n } else if (value === roleName) {\n setDisableDelete(false);\n } else {\n setDisableDelete(true);\n }\n };\n\n return (\n <Dialog maxWidth=\"md\" open={open} onClose={closeDialog}>\n <DialogTitle id=\"delete-role\" title=\"Delete Role\">\n <Box className={classes.titleContainer}>\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n <ErrorIcon\n style={{\n color: 'red',\n alignContent: 'center',\n marginTop: '7px',\n marginBottom: '-3px',\n }}\n fontSize=\"small\"\n />{' '}\n Delete this role?\n </Typography>\n\n <IconButton\n aria-label=\"close\"\n className={classes.closeButton}\n onClick={closeDialog}\n >\n <CloseIcon />\n </IconButton>\n </Box>\n </DialogTitle>\n <DialogContent>\n Are you sure you want to delete the role{' '}\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n {roleName}\n </Typography>{' '}\n ?\n <br />\n <br />\n Deleting this role is irreversible and will remove its functionality\n from the system. Proceed with caution.\n <br />\n <br />\n The{' '}\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>{`${getMembers(\n propOptions.memberRefs,\n ).toLocaleLowerCase('en-US')}`}</Typography>{' '}\n associated with this role will lose access to all the{' '}\n <Typography\n component=\"span\"\n sx={{ fontWeight: 'bold' }}\n >{`${propOptions.permissions} permission policies`}</Typography>{' '}\n specified in this role.\n <br />\n <TextField\n name=\"delete-role\"\n data-testid=\"delete-role\"\n style={{ marginTop: '24px' }}\n required\n variant=\"outlined\"\n label=\"Role name\"\n defaultValue={deleteRoleValue}\n helperText=\"Type the name of the role to confirm\"\n onChange={({ target: { value } }) => onTextInput(value)}\n onBlur={({ target: { value } }) => onTextInput(value)}\n />\n </DialogContent>\n {error && (\n <Box maxWidth=\"650px\" marginLeft=\"20px\">\n <Alert severity=\"error\">{error}</Alert>\n </Box>\n )}\n <DialogActions\n style={{\n paddingLeft: '25px',\n paddingBottom: '30px',\n justifyContent: 'left',\n paddingTop: '16px',\n }}\n >\n <Button\n variant=\"contained\"\n style={\n disableDelete || !deleteRoleValue\n ? {}\n : { background: 'red', color: 'white' }\n }\n onClick={deleteRole}\n disabled={disableDelete || !deleteRoleValue}\n >\n Delete\n </Button>\n <Button variant=\"outlined\" onClick={closeDialog}>\n Cancel\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n\nexport default DeleteRoleDialog;\n"],"names":[],"mappings":";;;;;;;;;;;;AA+CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,cAAgB,EAAA;AAAA,MACd,OAAS,EAAA,MAAA;AAAA,MACT,UAAY,EAAA,QAAA;AAAA,MACZ,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,KACtB;AAAA,IACA,WAAa,EAAA;AAAA,MACX,QAAU,EAAA,UAAA;AAAA,MACV,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACtB,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACpB,KAAO,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,GAAG;AAAA;AAC/B,GACD;AACH,CAAA;AAYA,MAAM,mBAAmB,CAAC;AAAA,EACxB,IAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,EAAE,eAAgB,EAAA,GAAI,QAAS,EAAA;AACrC,EAAA,MAAM,CAAC,eAAA,EAAiB,kBAAkB,CAAA,GAAI,MAAM,QAAiB,EAAA;AACrE,EAAA,MAAM,CAAC,aAAe,EAAA,gBAA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The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { Progress, Table, WarningPanel } from '@backstage/core-components';\n\nimport { useDeleteDialog } from '@janus-idp/shared-react';\nimport { makeStyles } from '@material-ui/core';\n\nimport { useCheckIfLicensePluginEnabled } from '../../hooks/useCheckIfLicensePluginEnabled';\nimport { useLocationToast } from '../../hooks/useLocationToast';\nimport { useRoles } from '../../hooks/useRoles';\nimport { RolesData } from '../../types';\nimport DownloadCSVLink from '../DownloadUserStatistics';\nimport { SnackbarAlert } from '../SnackbarAlert';\nimport { useToast } from '../ToastContext';\nimport DeleteRoleDialog from './DeleteRoleDialog';\nimport { columns } from './RolesListColumns';\nimport { RolesListToolbar } from './RolesListToolbar';\n\nconst useStyles = makeStyles(theme => ({\n empty: {\n padding: theme.spacing(2),\n display: 'flex',\n justifyContent: 'center',\n },\n}));\n\nexport const RolesList = () => {\n const { toastMessage, setToastMessage } = useToast();\n const { openDialog, setOpenDialog, deleteComponent } = useDeleteDialog();\n useLocationToast(setToastMessage);\n const [roles, setRoles] = React.useState<number | undefined>();\n const classes = useStyles();\n const { loading, data, retry, createRoleAllowed, createRoleLoading, error } =\n useRoles();\n\n const closeDialog = () => {\n setOpenDialog(false);\n retry.roleRetry();\n retry.policiesRetry();\n };\n\n const onAlertClose = () => {\n setToastMessage('');\n };\n const onSearchResultsChange = (searchResults: RolesData[]) => {\n setRoles(searchResults.length);\n };\n\n const getErrorWarning = () => {\n const errorTitleBase = 'Something went wrong while fetching the';\n const errorWarningArr = [\n { message: error?.rolesError, title: `${errorTitleBase} roles` },\n {\n message: error?.policiesError,\n title: `${errorTitleBase} permission policies`,\n },\n {\n message: error?.roleConditionError,\n title: `${errorTitleBase} role conditions`,\n },\n ];\n\n return (\n errorWarningArr.find(({ message }) => message) || {\n message: '',\n title: '',\n }\n );\n };\n\n const errorWarning = getErrorWarning();\n\n const isLicensePluginEnabled = useCheckIfLicensePluginEnabled();\n if (isLicensePluginEnabled.loading) {\n return <Progress />;\n }\n\n return (\n <>\n <SnackbarAlert toastMessage={toastMessage} onAlertClose={onAlertClose} />\n <RolesListToolbar\n createRoleAllowed={createRoleAllowed}\n createRoleLoading={createRoleLoading}\n />\n {errorWarning.message && (\n <div style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={errorWarning.message}\n title={errorWarning.title}\n severity=\"error\"\n />\n </div>\n )}\n <Table\n title={\n !loading && data?.length\n ? `All roles (${roles ?? data.length})`\n : `All roles`\n }\n options={{ padding: 'default', search: true, paging: true }}\n data={data}\n isLoading={loading}\n columns={columns}\n renderSummaryRow={summary => onSearchResultsChange(summary.data)}\n emptyContent={\n <div data-testid=\"roles-table-empty\" className={classes.empty}>\n No records found\n </div>\n }\n />\n {isLicensePluginEnabled.isEnabled && <DownloadCSVLink />}\n {openDialog && (\n <DeleteRoleDialog\n open={openDialog}\n closeDialog={closeDialog}\n roleName={deleteComponent.roleName}\n propOptions={{\n memberRefs:\n data.find(d => d.name === deleteComponent.roleName)?.members ||\n [],\n permissions:\n data.find(d => d.name === deleteComponent.roleName)\n ?.permissions || 0,\n }}\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,KAAO,EAAA;AAAA,IACL,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACxB,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA
|
|
1
|
+
{"version":3,"file":"RolesList.esm.js","sources":["../../../src/components/RolesList/RolesList.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { Progress, Table, WarningPanel } from '@backstage/core-components';\n\nimport { useDeleteDialog } from '@janus-idp/shared-react';\nimport { makeStyles } from '@material-ui/core';\n\nimport { useCheckIfLicensePluginEnabled } from '../../hooks/useCheckIfLicensePluginEnabled';\nimport { useLocationToast } from '../../hooks/useLocationToast';\nimport { useRoles } from '../../hooks/useRoles';\nimport { RolesData } from '../../types';\nimport DownloadCSVLink from '../DownloadUserStatistics';\nimport { SnackbarAlert } from '../SnackbarAlert';\nimport { useToast } from '../ToastContext';\nimport DeleteRoleDialog from './DeleteRoleDialog';\nimport { columns } from './RolesListColumns';\nimport { RolesListToolbar } from './RolesListToolbar';\n\nconst useStyles = makeStyles(theme => ({\n empty: {\n padding: theme.spacing(2),\n display: 'flex',\n justifyContent: 'center',\n },\n}));\n\nexport const RolesList = () => {\n const { toastMessage, setToastMessage } = useToast();\n const { openDialog, setOpenDialog, deleteComponent } = useDeleteDialog();\n useLocationToast(setToastMessage);\n const [roles, setRoles] = React.useState<number | undefined>();\n const classes = useStyles();\n const { loading, data, retry, createRoleAllowed, createRoleLoading, error } =\n useRoles();\n\n const closeDialog = () => {\n setOpenDialog(false);\n retry.roleRetry();\n retry.policiesRetry();\n };\n\n const onAlertClose = () => {\n setToastMessage('');\n };\n const onSearchResultsChange = (searchResults: RolesData[]) => {\n setRoles(searchResults.length);\n };\n\n const getErrorWarning = () => {\n const errorTitleBase = 'Something went wrong while fetching the';\n const errorWarningArr = [\n { message: error?.rolesError, title: `${errorTitleBase} roles` },\n {\n message: error?.policiesError,\n title: `${errorTitleBase} permission policies`,\n },\n {\n message: error?.roleConditionError,\n title: `${errorTitleBase} role conditions`,\n },\n ];\n\n return (\n errorWarningArr.find(({ message }) => message) || {\n message: '',\n title: '',\n }\n );\n };\n\n const errorWarning = getErrorWarning();\n\n const isLicensePluginEnabled = useCheckIfLicensePluginEnabled();\n if (isLicensePluginEnabled.loading) {\n return <Progress />;\n }\n\n return (\n <>\n <SnackbarAlert toastMessage={toastMessage} onAlertClose={onAlertClose} />\n <RolesListToolbar\n createRoleAllowed={createRoleAllowed}\n createRoleLoading={createRoleLoading}\n />\n {errorWarning.message && (\n <div style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={errorWarning.message}\n title={errorWarning.title}\n severity=\"error\"\n />\n </div>\n )}\n <Table\n title={\n !loading && data?.length\n ? `All roles (${roles ?? data.length})`\n : `All roles`\n }\n options={{ padding: 'default', search: true, paging: true }}\n data={data}\n isLoading={loading}\n columns={columns}\n renderSummaryRow={summary => onSearchResultsChange(summary.data)}\n emptyContent={\n <div data-testid=\"roles-table-empty\" className={classes.empty}>\n No records found\n </div>\n }\n />\n {isLicensePluginEnabled.isEnabled && <DownloadCSVLink />}\n {openDialog && (\n <DeleteRoleDialog\n open={openDialog}\n closeDialog={closeDialog}\n roleName={deleteComponent.roleName}\n propOptions={{\n memberRefs:\n data.find(d => d.name === deleteComponent.roleName)?.members ||\n [],\n permissions:\n data.find(d => d.name === deleteComponent.roleName)\n ?.permissions || 0,\n }}\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,KAAO,EAAA;AAAA,IACL,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACxB,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA;AAAA;AAEpB,CAAE,CAAA,CAAA;AAEK,MAAM,YAAY,MAAM;AA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A,MAC/D,YAAA,sCACG,KAAI,EAAA,EAAA,aAAA,EAAY,qBAAoB,SAAW,EAAA,OAAA,CAAQ,SAAO,kBAE/D;AAAA;AAAA,KAGH,sBAAuB,CAAA,SAAA,oBAAc,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,IAAgB,GACrD,UACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,UAAA;AAAA,MACN,WAAA;AAAA,MACA,UAAU,eAAgB,CAAA,QAAA;AAAA,MAC1B,WAAa,EAAA;AAAA,QACX,UAAA,EACE,IAAK,CAAA,IAAA,CAAK,CAAK,CAAA,KAAA,CAAA,CAAE,SAAS,eAAgB,CAAA,QAAQ,CAAG,EAAA,OAAA,IACrD,EAAC;AAAA,QACH,WAAA,EACE,KAAK,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,IAAS,KAAA,eAAA,CAAgB,QAAQ,CAAA,EAC9C,WAAe,IAAA;AAAA;AACvB;AAAA,GAGN,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RolesListColumns.esm.js","sources":["../../../src/components/RolesList/RolesListColumns.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Link, TableColumn } from '@backstage/core-components';\n\nimport { Tooltip, Typography } from '@material-ui/core';\n\nimport { RolesData } from '../../types';\nimport { getMembers } from '../../utils/rbac-utils';\nimport EditRole from '../EditRole';\nimport DeleteRole from './DeleteRole';\n\nexport const columns: TableColumn<RolesData>[] = [\n {\n title: 'Name',\n field: 'name',\n type: 'string',\n render: (props: RolesData) => {\n const { kind, namespace, name } = parseEntityRef(props.name);\n return (\n <Link to={`roles/${kind}/${namespace}/${name}`}>{props.name}</Link>\n );\n },\n },\n {\n title: 'Users and groups',\n field: 'members',\n type: 'string',\n align: 'left',\n render: props => getMembers(props.members),\n customSort: (a, b) => {\n if (a.members.length === 0) {\n return -1;\n }\n if (b.members.length === 0) {\n return 1;\n }\n if (a.members.length === b.members.length) {\n return 0;\n }\n return a.members.length < b.members.length ? -1 : 1;\n },\n },\n {\n title: 'Accessible plugins',\n field: 'accessiblePlugins',\n type: 'string',\n align: 'left',\n render: (props: RolesData) => {\n const pls = props.accessiblePlugins.map(\n p => p[0].toLocaleUpperCase('en-US') + p.slice(1),\n );\n const plsTooltip = pls.join(', ');\n const plsOverflowCount = pls.length > 2 ? `+ ${pls.length - 2}` : '';\n\n return pls.length > 0 ? (\n <Tooltip title={plsTooltip || ''} placement=\"top-start\">\n <Typography>\n {pls.length === 1\n ? `${pls[0]}`\n : `${pls[0]}, ${pls[1]} ${plsOverflowCount}`}\n </Typography>\n </Tooltip>\n ) : (\n '-'\n );\n },\n },\n {\n title: 'Actions',\n sorting: false,\n render: (props: RolesData) => (\n <>\n <EditRole\n dataTestId={\n !props.actionsPermissionResults.edit.allowed\n ? `disable-update-role-${props.name}`\n : `update-role-${props.name}`\n }\n roleName={props.name}\n disable={!props.actionsPermissionResults.edit.allowed}\n tooltip={\n !props.actionsPermissionResults.edit.allowed\n ? 'Unauthorized to edit'\n : ''\n }\n />\n <DeleteRole\n dataTestId={\n !props.actionsPermissionResults.delete.allowed\n ? `disable-delete-role-${props.name}`\n : `delete-role-${props.name}`\n }\n roleName={props.name}\n disable={!props.actionsPermissionResults.delete.allowed}\n tooltip={\n !props.actionsPermissionResults.delete.allowed\n ? 'Role cannot be deleted'\n : ''\n }\n />\n </>\n ),\n },\n];\n"],"names":[],"mappings":";;;;;;;;AA2BO,MAAM,OAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,KAAO,EAAA,MAAA;AAAA,IACP,KAAO,EAAA,MAAA;AAAA,IACP,IAAM,EAAA,QAAA;AAAA,IACN,MAAA,EAAQ,CAAC,KAAqB,KAAA;AAC5B,MAAA,MAAM,EAAE,IAAM,EAAA,SAAA,EAAW,MAAS,GAAA,cAAA,CAAe,MAAM,IAAI,CAAA
|
|
1
|
+
{"version":3,"file":"RolesListColumns.esm.js","sources":["../../../src/components/RolesList/RolesListColumns.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Link, TableColumn } from '@backstage/core-components';\n\nimport { Tooltip, Typography } from '@material-ui/core';\n\nimport { RolesData } from '../../types';\nimport { getMembers } from '../../utils/rbac-utils';\nimport EditRole from '../EditRole';\nimport DeleteRole from './DeleteRole';\n\nexport const columns: TableColumn<RolesData>[] = [\n {\n title: 'Name',\n field: 'name',\n type: 'string',\n render: (props: RolesData) => {\n const { kind, namespace, name } = parseEntityRef(props.name);\n return (\n <Link to={`roles/${kind}/${namespace}/${name}`}>{props.name}</Link>\n );\n },\n },\n {\n title: 'Users and groups',\n field: 'members',\n type: 'string',\n align: 'left',\n render: props => getMembers(props.members),\n customSort: (a, b) => {\n if (a.members.length === 0) {\n return -1;\n }\n if (b.members.length === 0) {\n return 1;\n }\n if (a.members.length === b.members.length) {\n return 0;\n }\n return a.members.length < b.members.length ? -1 : 1;\n },\n },\n {\n title: 'Accessible plugins',\n field: 'accessiblePlugins',\n type: 'string',\n align: 'left',\n render: (props: RolesData) => {\n const pls = props.accessiblePlugins.map(\n p => p[0].toLocaleUpperCase('en-US') + p.slice(1),\n );\n const plsTooltip = pls.join(', ');\n const plsOverflowCount = pls.length > 2 ? `+ ${pls.length - 2}` : '';\n\n return pls.length > 0 ? (\n <Tooltip title={plsTooltip || ''} placement=\"top-start\">\n <Typography>\n {pls.length === 1\n ? `${pls[0]}`\n : `${pls[0]}, ${pls[1]} ${plsOverflowCount}`}\n </Typography>\n </Tooltip>\n ) : (\n '-'\n );\n },\n },\n {\n title: 'Actions',\n sorting: false,\n render: (props: RolesData) => (\n <>\n <EditRole\n dataTestId={\n !props.actionsPermissionResults.edit.allowed\n ? `disable-update-role-${props.name}`\n : `update-role-${props.name}`\n }\n roleName={props.name}\n disable={!props.actionsPermissionResults.edit.allowed}\n tooltip={\n !props.actionsPermissionResults.edit.allowed\n ? 'Unauthorized to edit'\n : ''\n }\n />\n <DeleteRole\n dataTestId={\n !props.actionsPermissionResults.delete.allowed\n ? `disable-delete-role-${props.name}`\n : `delete-role-${props.name}`\n }\n roleName={props.name}\n disable={!props.actionsPermissionResults.delete.allowed}\n tooltip={\n !props.actionsPermissionResults.delete.allowed\n ? 'Role cannot be deleted'\n : ''\n }\n />\n </>\n ),\n },\n];\n"],"names":[],"mappings":";;;;;;;;AA2BO,MAAM,OAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,KAAO,EAAA,MAAA;AAAA,IACP,KAAO,EAAA,MAAA;AAAA,IACP,IAAM,EAAA,QAAA;AAAA,IACN,MAAA,EAAQ,CAAC,KAAqB,KAAA;AAC5B,MAAA,MAAM,EAAE,IAAM,EAAA,SAAA,EAAW,MAAS,GAAA,cAAA,CAAe,MAAM,IAAI,CAAA;AAC3D,MACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAI,CAAS,MAAA,EAAA,IAAI,CAAI,CA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,QACC,UACE,EAAA,CAAC,KAAM,CAAA,wBAAA,CAAyB,MAAO,CAAA,OAAA,GACnC,CAAuB,oBAAA,EAAA,KAAA,CAAM,IAAI,CAAA,CAAA,GACjC,CAAe,YAAA,EAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AAAA,QAE/B,UAAU,KAAM,CAAA,IAAA;AAAA,QAChB,OAAS,EAAA,CAAC,KAAM,CAAA,wBAAA,CAAyB,MAAO,CAAA,OAAA;AAAA,QAChD,SACE,CAAC,KAAA,CAAM,wBAAyB,CAAA,MAAA,CAAO,UACnC,wBACA,GAAA;AAAA;AAAA,KAGV;AAAA;AAGN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RolesListToolbar.esm.js","sources":["../../../src/components/RolesList/RolesListToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { LinkButton } from '@backstage/core-components';\n\nimport { makeStyles } from '@material-ui/core';\nimport Alert from '@material-ui/lab/Alert';\nimport AlertTitle from '@material-ui/lab/AlertTitle';\nimport Typography from '@mui/material/Typography';\n\nconst useStyles = makeStyles(theme => ({\n toolbar: {\n display: 'flex',\n justifyContent: 'end',\n marginBottom: '24px',\n },\n rbacPreReqLink: {\n color: theme.palette.link,\n },\n alertTitle: {\n fontWeight: 'bold',\n },\n}));\n\nexport const RolesListToolbar = ({\n createRoleAllowed,\n createRoleLoading,\n}: {\n createRoleAllowed: boolean;\n createRoleLoading: boolean;\n}) => {\n const classes = useStyles();\n return (\n <div>\n {!createRoleLoading && !createRoleAllowed && (\n <Alert severity=\"warning\" data-testid=\"create-role-warning\">\n <AlertTitle className={classes.alertTitle}>\n Unable to create role.\n </AlertTitle>\n To enable create/edit role button, make sure required users/groups are\n available in catalog as a role cannot be created without users/groups\n and also the role associated with your user should have the permission\n policies mentioned{' '}\n <a\n href=\"https://github.com/backstage/community-plugins/tree/main/workspaces/rbac/plugins/rbac#prerequisites\"\n target=\"blank\"\n className={classes.rbacPreReqLink}\n >\n here\n </a>\n .\n <br />\n <Typography>\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n Note\n </Typography>\n : Even after ingesting users/groups in catalog and applying above\n permissions if the create/edit button is still disabled then please\n contact your administrator as you might be conditionally restricted\n from accessing the create/edit button.\n </Typography>\n </Alert>\n )}\n <br />\n <Typography component=\"span\" className={classes.toolbar}>\n <LinkButton\n to=\"role/new\"\n color=\"primary\"\n variant=\"contained\"\n disabled={!createRoleAllowed}\n data-testid=\"create-role\"\n >\n Create\n </LinkButton>\n </Typography>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAwBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA,KAAA;AAAA,IAChB,YAAc,EAAA
|
|
1
|
+
{"version":3,"file":"RolesListToolbar.esm.js","sources":["../../../src/components/RolesList/RolesListToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { LinkButton } from '@backstage/core-components';\n\nimport { makeStyles } from '@material-ui/core';\nimport Alert from '@material-ui/lab/Alert';\nimport AlertTitle from '@material-ui/lab/AlertTitle';\nimport Typography from '@mui/material/Typography';\n\nconst useStyles = makeStyles(theme => ({\n toolbar: {\n display: 'flex',\n justifyContent: 'end',\n marginBottom: '24px',\n },\n rbacPreReqLink: {\n color: theme.palette.link,\n },\n alertTitle: {\n fontWeight: 'bold',\n },\n}));\n\nexport const RolesListToolbar = ({\n createRoleAllowed,\n createRoleLoading,\n}: {\n createRoleAllowed: boolean;\n createRoleLoading: boolean;\n}) => {\n const classes = useStyles();\n return (\n <div>\n {!createRoleLoading && !createRoleAllowed && (\n <Alert severity=\"warning\" data-testid=\"create-role-warning\">\n <AlertTitle className={classes.alertTitle}>\n Unable to create role.\n </AlertTitle>\n To enable create/edit role button, make sure required users/groups are\n available in catalog as a role cannot be created without users/groups\n and also the role associated with your user should have the permission\n policies mentioned{' '}\n <a\n href=\"https://github.com/backstage/community-plugins/tree/main/workspaces/rbac/plugins/rbac#prerequisites\"\n target=\"blank\"\n className={classes.rbacPreReqLink}\n >\n here\n </a>\n .\n <br />\n <Typography>\n <Typography component=\"span\" sx={{ fontWeight: 'bold' }}>\n Note\n </Typography>\n : Even after ingesting users/groups in catalog and applying above\n permissions if the create/edit button is still disabled then please\n contact your administrator as you might be conditionally restricted\n from accessing the create/edit button.\n </Typography>\n </Alert>\n )}\n <br />\n <Typography component=\"span\" className={classes.toolbar}>\n <LinkButton\n to=\"role/new\"\n color=\"primary\"\n variant=\"contained\"\n disabled={!createRoleAllowed}\n data-testid=\"create-role\"\n >\n Create\n </LinkButton>\n </Typography>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAwBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA,KAAA;AAAA,IAChB,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,cAAgB,E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,EAAA,SAAA;AAAA,MACN,OAAQ,EAAA,WAAA;AAAA,MACR,UAAU,CAAC,iBAAA;AAAA,MACX,aAAY,EAAA;AAAA,KAAA;AAAA,IACb;AAAA,GAGH,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { ErrorPage } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\n\nimport {\n policyEntityCreatePermission,\n policyEntityUpdatePermission,\n} from '@backstage-community/plugin-rbac-common';\n\nimport { createRoleRouteRef, editRoleRouteRef, roleRouteRef } from '../routes';\nimport { CreateRolePage } from './CreateRole/CreateRolePage';\nimport { EditRolePage } from './CreateRole/EditRolePage';\nimport { RbacPage } from './RbacPage';\nimport { RoleOverviewPage } from './RoleOverview/RoleOverviewPage';\nimport { ToastContextProvider } from './ToastContext';\n\n/**\n *\n * @public\n */\nexport const Router = ({ useHeader = true }: { useHeader?: boolean }) => {\n const config = useApi(configApiRef);\n const isRBACPluginEnabled = config.getOptionalBoolean('permission.enabled');\n\n if (!isRBACPluginEnabled) {\n return (\n <ErrorPage\n status=\"404\"\n statusMessage=\"Enable the RBAC backend plugin to use this feature.\"\n additionalInfo=\"To enable RBAC, set `permission.enabled` to `true` in the app-config file.\"\n />\n );\n }\n\n return (\n <ToastContextProvider>\n <Routes>\n <Route path=\"/\" element={<RbacPage useHeader={useHeader} />} />\n <Route path={roleRouteRef.path} element={<RoleOverviewPage />} />\n <Route\n path={createRoleRouteRef.path}\n element={\n <RequirePermission\n permission={policyEntityCreatePermission}\n resourceRef={policyEntityCreatePermission.resourceType}\n >\n <CreateRolePage />\n </RequirePermission>\n }\n />\n <Route\n path={editRoleRouteRef.path}\n element={\n <RequirePermission\n permission={policyEntityUpdatePermission}\n resourceRef={policyEntityUpdatePermission.resourceType}\n >\n <EditRolePage />\n </RequirePermission>\n }\n />\n </Routes>\n </ToastContextProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsCO,MAAM,MAAS,GAAA,CAAC,EAAE,SAAA,GAAY,MAAoC,KAAA;AACvE,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA
|
|
1
|
+
{"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { ErrorPage } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\n\nimport {\n policyEntityCreatePermission,\n policyEntityUpdatePermission,\n} from '@backstage-community/plugin-rbac-common';\n\nimport { createRoleRouteRef, editRoleRouteRef, roleRouteRef } from '../routes';\nimport { CreateRolePage } from './CreateRole/CreateRolePage';\nimport { EditRolePage } from './CreateRole/EditRolePage';\nimport { RbacPage } from './RbacPage';\nimport { RoleOverviewPage } from './RoleOverview/RoleOverviewPage';\nimport { ToastContextProvider } from './ToastContext';\n\n/**\n *\n * @public\n */\nexport const Router = ({ useHeader = true }: { useHeader?: boolean }) => {\n const config = useApi(configApiRef);\n const isRBACPluginEnabled = config.getOptionalBoolean('permission.enabled');\n\n if (!isRBACPluginEnabled) {\n return (\n <ErrorPage\n status=\"404\"\n statusMessage=\"Enable the RBAC backend plugin to use this feature.\"\n additionalInfo=\"To enable RBAC, set `permission.enabled` to `true` in the app-config file.\"\n />\n );\n }\n\n return (\n <ToastContextProvider>\n <Routes>\n <Route path=\"/\" element={<RbacPage useHeader={useHeader} />} />\n <Route path={roleRouteRef.path} element={<RoleOverviewPage />} />\n <Route\n path={createRoleRouteRef.path}\n element={\n <RequirePermission\n permission={policyEntityCreatePermission}\n resourceRef={policyEntityCreatePermission.resourceType}\n >\n <CreateRolePage />\n </RequirePermission>\n }\n />\n <Route\n path={editRoleRouteRef.path}\n element={\n <RequirePermission\n permission={policyEntityUpdatePermission}\n resourceRef={policyEntityUpdatePermission.resourceType}\n >\n <EditRolePage />\n </RequirePermission>\n }\n />\n </Routes>\n </ToastContextProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsCO,MAAM,MAAS,GAAA,CAAC,EAAE,SAAA,GAAY,MAAoC,KAAA;AACvE,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,EAAM,MAAA,mBAAA,GAAsB,MAAO,CAAA,kBAAA,CAAmB,oBAAoB,CAAA;AAE1E,EAAA,IAAI,CAAC,mBAAqB,EAAA;AACxB,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,MAAO,EAAA,KAAA;AAAA,QACP,aAAc,EAAA,qDAAA;AAAA,QACd,cAAe,EAAA;AAAA;AAAA,KACjB;AAAA;AAIJ,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,4CACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,sCACE,KAAM,EAAA,EAAA,IAAA,EAAK,GAAI,EAAA,OAAA,kBAAU,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,WAAsB,CAAI,EAAA,CAAA,kBAC5D,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,IAAM,EAAA,YAAA,CAAa,MAAM,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,gBAAiB,EAAA,IAAA,CAAA,EAAI,CAC/D,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,MAAM,kBAAmB,CAAA,IAAA;AAAA,MACzB,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,iBAAA;AAAA,QAAA;AAAA,UACC,UAAY,EAAA,4BAAA;AAAA,UACZ,aAAa,4BAA6B,CAAA;AAAA,SAAA;AAAA,4CAEzC,cAAe,EAAA,IAAA;AAAA;AAClB;AAAA,GAGJ,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,MAAM,gBAAiB,CAAA,IAAA;AAAA,MACvB,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,iBAAA;AAAA,QAAA;AAAA,UACC,UAAY,EAAA,4BAAA;AAAA,UACZ,aAAa,4BAA6B,CAAA;AAAA,SAAA;AAAA,4CAEzC,YAAa,EAAA,IAAA;AAAA;AAChB;AAAA,GAGN,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarAlert.esm.js","sources":["../../src/components/SnackbarAlert.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport Snackbar from '@material-ui/core/Snackbar';\nimport Alert from '@material-ui/lab/Alert';\n\nexport const SnackbarAlert = ({\n toastMessage,\n onAlertClose,\n}: {\n toastMessage: string;\n onAlertClose: () => void;\n}) => {\n return (\n <Snackbar\n open={toastMessage !== ''}\n autoHideDuration={10000}\n anchorOrigin={{ vertical: 'top', horizontal: 'right' }}\n style={{ top: '100px', left: '0px', justifyContent: 'center' }}\n onClose={onAlertClose}\n >\n <Alert onClose={onAlertClose} severity=\"success\">\n {toastMessage}\n </Alert>\n </Snackbar>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,YAAA;AAAA,EACA
|
|
1
|
+
{"version":3,"file":"SnackbarAlert.esm.js","sources":["../../src/components/SnackbarAlert.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport Snackbar from '@material-ui/core/Snackbar';\nimport Alert from '@material-ui/lab/Alert';\n\nexport const SnackbarAlert = ({\n toastMessage,\n onAlertClose,\n}: {\n toastMessage: string;\n onAlertClose: () => void;\n}) => {\n return (\n <Snackbar\n open={toastMessage !== ''}\n autoHideDuration={10000}\n anchorOrigin={{ vertical: 'top', horizontal: 'right' }}\n style={{ top: '100px', left: '0px', justifyContent: 'center' }}\n onClose={onAlertClose}\n >\n <Alert onClose={onAlertClose} severity=\"success\">\n {toastMessage}\n </Alert>\n </Snackbar>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,YAAA;AAAA,EACA;AACF,CAGM,KAAA;AACJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,MAAM,YAAiB,KAAA,EAAA;AAAA,MACvB,gBAAkB,EAAA,GAAA;AAAA,MAClB,YAAc,EAAA,EAAE,QAAU,EAAA,KAAA,EAAO,YAAY,OAAQ,EAAA;AAAA,MACrD,OAAO,EAAE,GAAA,EAAK,SAAS,IAAM,EAAA,KAAA,EAAO,gBAAgB,QAAS,EAAA;AAAA,MAC7D,OAAS,EAAA;AAAA,KAAA;AAAA,wCAER,KAAM,EAAA,EAAA,OAAA,EAAS,YAAc,EAAA,QAAA,EAAS,aACpC,YACH;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastContext.esm.js","sources":["../../src/components/ToastContext.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { createContext, useContext } from 'react';\n\ntype ToastContextType = {\n toastMessage: string;\n setToastMessage: (message: string) => void;\n};\n\nexport const ToastContext = createContext<ToastContextType>({\n toastMessage: '',\n setToastMessage: () => {},\n});\n\nexport const ToastContextProvider = (props: any) => {\n const [toastMessage, setToastMessage] = React.useState('');\n const toastContextProviderValue = React.useMemo(\n () => ({ setToastMessage, toastMessage }),\n [setToastMessage, toastMessage],\n );\n return (\n <ToastContext.Provider value={toastContextProviderValue}>\n {props.children}\n </ToastContext.Provider>\n );\n};\nexport const useToast = () => useContext(ToastContext);\n"],"names":[],"mappings":";;AAsBO,MAAM,eAAe,aAAgC,CAAA;AAAA,EAC1D,YAAc,EAAA,EAAA;AAAA,EACd,iBAAiB,MAAM;AAAA
|
|
1
|
+
{"version":3,"file":"ToastContext.esm.js","sources":["../../src/components/ToastContext.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { createContext, useContext } from 'react';\n\ntype ToastContextType = {\n toastMessage: string;\n setToastMessage: (message: string) => void;\n};\n\nexport const ToastContext = createContext<ToastContextType>({\n toastMessage: '',\n setToastMessage: () => {},\n});\n\nexport const ToastContextProvider = (props: any) => {\n const [toastMessage, setToastMessage] = React.useState('');\n const toastContextProviderValue = React.useMemo(\n () => ({ setToastMessage, toastMessage }),\n [setToastMessage, toastMessage],\n );\n return (\n <ToastContext.Provider value={toastContextProviderValue}>\n {props.children}\n </ToastContext.Provider>\n );\n};\nexport const useToast = () => useContext(ToastContext);\n"],"names":[],"mappings":";;AAsBO,MAAM,eAAe,aAAgC,CAAA;AAAA,EAC1D,YAAc,EAAA,EAAA;AAAA,EACd,iBAAiB,MAAM;AAAA;AACzB,CAAC;AAEY,MAAA,oBAAA,GAAuB,CAAC,KAAe,KAAA;AAClD,EAAA,MAAM,CAAC,YAAc,EAAA,eAAe,CAAI,GAAA,KAAA,CAAM,SAAS,EAAE,CAAA;AACzD,EAAA,MAAM,4BAA4B,KAAM,CAAA,OAAA;AAAA,IACtC,OAAO,EAAE,eAAA,EAAiB,YAAa,EAAA,CAAA;AAAA,IACvC,CAAC,iBAAiB,YAAY;AAAA,GAChC;AACA,EAAA,2CACG,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAO,EAAA,yBAAA,EAAA,EAC3B,MAAM,QACT,CAAA;AAEJ;AACa,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,YAAY;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckIfLicensePluginEnabled.esm.js","sources":["../../src/hooks/useCheckIfLicensePluginEnabled.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { licensedUsersApiRef } from '../api/LicensedUsersClient';\n\nexport const useCheckIfLicensePluginEnabled = (): {\n loading: boolean;\n isEnabled: boolean | undefined;\n licenseCheckError: Error;\n} => {\n const licensedUsersClient = useApi(licensedUsersApiRef);\n const {\n value: isEnabled,\n loading,\n error: licenseCheckError,\n } = useAsync(async () => await licensedUsersClient.isLicensePluginEnabled());\n\n return {\n loading,\n isEnabled,\n licenseCheckError: licenseCheckError as Error,\n };\n};\n"],"names":[],"mappings":";;;;AAqBO,MAAM,iCAAiC,MAIzC;AACH,EAAM,MAAA,mBAAA,GAAsB,OAAO,mBAAmB,CAAA
|
|
1
|
+
{"version":3,"file":"useCheckIfLicensePluginEnabled.esm.js","sources":["../../src/hooks/useCheckIfLicensePluginEnabled.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { licensedUsersApiRef } from '../api/LicensedUsersClient';\n\nexport const useCheckIfLicensePluginEnabled = (): {\n loading: boolean;\n isEnabled: boolean | undefined;\n licenseCheckError: Error;\n} => {\n const licensedUsersClient = useApi(licensedUsersApiRef);\n const {\n value: isEnabled,\n loading,\n error: licenseCheckError,\n } = useAsync(async () => await licensedUsersClient.isLicensePluginEnabled());\n\n return {\n loading,\n isEnabled,\n licenseCheckError: licenseCheckError as Error,\n };\n};\n"],"names":[],"mappings":";;;;AAqBO,MAAM,iCAAiC,MAIzC;AACH,EAAM,MAAA,mBAAA,GAAsB,OAAO,mBAAmB,CAAA;AACtD,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,SAAA;AAAA,IACP,OAAA;AAAA,IACA,KAAO,EAAA;AAAA,MACL,QAAS,CAAA,YAAY,MAAM,mBAAA,CAAoB,wBAAwB,CAAA;AAE3E,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConditionRules.esm.js","sources":["../../src/hooks/useConditionRules.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport {\n ConditionRules,\n ConditionRulesData,\n ResourceTypeRuleData,\n RulesData,\n} from '../components/ConditionalAccess/types';\nimport { ConditionRule, PluginConditionRules } from '../types';\nimport { uniqBy } from '../utils/create-role-utils';\n\nconst getPluginsResourceTypes = (\n conditionRules: PluginConditionRules[],\n): { [plugin: string]: string[] } => {\n return conditionRules.reduce((acc, pluginRules) => {\n return {\n ...acc,\n [`${pluginRules.pluginId}`]: uniqBy(\n pluginRules.rules.map(rule => rule.resourceType),\n val => val,\n ),\n };\n }, {});\n};\n\nconst getRuleData = (pluginRules: PluginConditionRules, resType: string) => {\n return pluginRules.rules.reduce(\n (ruleAcc: RulesData, rule: ConditionRule) => {\n return rule.resourceType === resType\n ? {\n ...ruleAcc,\n [`${rule.name}`]: {\n schema: rule.paramsSchema,\n description: rule.description,\n },\n rules: [...ruleAcc.rules, rule.name],\n }\n : ruleAcc;\n },\n { rules: [] },\n );\n};\n\nconst getConditionRulesData = (conditionRules: PluginConditionRules[]) => {\n const pluginsResourceTypes = getPluginsResourceTypes(conditionRules);\n\n return conditionRules.reduce((acc: ConditionRulesData, pluginRules) => {\n return {\n ...acc,\n [`${pluginRules.pluginId}`]: pluginsResourceTypes[\n pluginRules.pluginId\n ].reduce((resAcc: ResourceTypeRuleData, resType: string) => {\n return {\n ...resAcc,\n [`${resType}`]: getRuleData(pluginRules, resType),\n };\n }, {}),\n };\n }, {});\n};\n\nexport const useConditionRules = (): ConditionRules => {\n const rbacApi = useApi(rbacApiRef);\n\n const {\n value: conditionRules,\n loading: conditionRulesLoading,\n error: conditionRulesErr,\n } = useAsync(async () => {\n return await rbacApi.getPluginsConditionRules();\n });\n\n const isConditionRulesAvailable =\n !conditionRulesLoading && Array.isArray(conditionRules);\n\n const conditionRulesData = isConditionRulesAvailable\n ? getConditionRulesData(conditionRules)\n : undefined;\n\n return {\n data: conditionRulesData,\n error: conditionRulesErr,\n };\n};\n"],"names":[],"mappings":";;;;;AA6BA,MAAM,uBAAA,GAA0B,CAC9B,cACmC,KAAA;AACnC,EAAA,OAAO,cAAe,CAAA,MAAA,CAAO,CAAC,GAAA,EAAK,WAAgB,KAAA;AACjD,IAAO,OAAA;AAAA,MACL,GAAG,GAAA;AAAA,MACH,CAAC,CAAA,EAAG,WAAY,CAAA,QAAQ,EAAE,GAAG,MAAA;AAAA,QAC3B,WAAY,CAAA,KAAA,CAAM,GAAI,CAAA,CAAA,IAAA,KAAQ,KAAK,YAAY,CAAA;AAAA,QAC/C,CAAO,GAAA,KAAA
|
|
1
|
+
{"version":3,"file":"useConditionRules.esm.js","sources":["../../src/hooks/useConditionRules.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport {\n ConditionRules,\n ConditionRulesData,\n ResourceTypeRuleData,\n RulesData,\n} from '../components/ConditionalAccess/types';\nimport { ConditionRule, PluginConditionRules } from '../types';\nimport { uniqBy } from '../utils/create-role-utils';\n\nconst getPluginsResourceTypes = (\n conditionRules: PluginConditionRules[],\n): { [plugin: string]: string[] } => {\n return conditionRules.reduce((acc, pluginRules) => {\n return {\n ...acc,\n [`${pluginRules.pluginId}`]: uniqBy(\n pluginRules.rules.map(rule => rule.resourceType),\n val => val,\n ),\n };\n }, {});\n};\n\nconst getRuleData = (pluginRules: PluginConditionRules, resType: string) => {\n return pluginRules.rules.reduce(\n (ruleAcc: RulesData, rule: ConditionRule) => {\n return rule.resourceType === resType\n ? {\n ...ruleAcc,\n [`${rule.name}`]: {\n schema: rule.paramsSchema,\n description: rule.description,\n },\n rules: [...ruleAcc.rules, rule.name],\n }\n : ruleAcc;\n },\n { rules: [] },\n );\n};\n\nconst getConditionRulesData = (conditionRules: PluginConditionRules[]) => {\n const pluginsResourceTypes = getPluginsResourceTypes(conditionRules);\n\n return conditionRules.reduce((acc: ConditionRulesData, pluginRules) => {\n return {\n ...acc,\n [`${pluginRules.pluginId}`]: pluginsResourceTypes[\n pluginRules.pluginId\n ].reduce((resAcc: ResourceTypeRuleData, resType: string) => {\n return {\n ...resAcc,\n [`${resType}`]: getRuleData(pluginRules, resType),\n };\n }, {}),\n };\n }, {});\n};\n\nexport const useConditionRules = (): ConditionRules => {\n const rbacApi = useApi(rbacApiRef);\n\n const {\n value: conditionRules,\n loading: conditionRulesLoading,\n error: conditionRulesErr,\n } = useAsync(async () => {\n return await rbacApi.getPluginsConditionRules();\n });\n\n const isConditionRulesAvailable =\n !conditionRulesLoading && Array.isArray(conditionRules);\n\n const conditionRulesData = isConditionRulesAvailable\n ? getConditionRulesData(conditionRules)\n : undefined;\n\n return {\n data: conditionRulesData,\n error: conditionRulesErr,\n };\n};\n"],"names":[],"mappings":";;;;;AA6BA,MAAM,uBAAA,GAA0B,CAC9B,cACmC,KAAA;AACnC,EAAA,OAAO,cAAe,CAAA,MAAA,CAAO,CAAC,GAAA,EAAK,WAAgB,KAAA;AACjD,IAAO,OAAA;AAAA,MACL,GAAG,GAAA;AAAA,MACH,CAAC,CAAA,EAAG,WAAY,CAAA,QAAQ,EAAE,GAAG,MAAA;AAAA,QAC3B,WAAY,CAAA,KAAA,CAAM,GAAI,CAAA,CAAA,IAAA,KAAQ,KAAK,YAAY,CAAA;AAAA,QAC/C,CAAO,GAAA,KAAA;AAAA;AACT,KACF;AAAA,GACF,EAAG,EAAE,CAA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BAAA;AAAA,IACT,KAAO,EAAA;AAAA,GACT,GAAI,SAAS,YAAY;AACvB,IAAO,OAAA,MAAM,QAAQ,wBAAyB,EAAA;AAAA,GAC/C,CAAA;AAED,EAAA,MAAM,yBACJ,GAAA,CAAC,qBAAyB,IAAA,KAAA,CAAM,QAAQ,cAAc,CAAA;AAExD,EAAA,MAAM,kBAAqB,GAAA,yBAAA,GACvB,qBAAsB,CAAA,cAAc,CACpC,GAAA,KAAA,CAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,kBAAA;AAAA,IACN,KAAO,EAAA;AAAA,GACT;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocationToast.esm.js","sources":["../../src/hooks/useLocationToast.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\nexport const useLocationToast = (\n setToastMessage: (message: string) => void,\n) => {\n const location = useLocation();\n\n useEffect(() => {\n if (location?.state?.toastMessage) {\n setToastMessage(location.state.toastMessage);\n }\n return () => setToastMessage('');\n }, [location, setToastMessage]);\n};\n"],"names":[],"mappings":";;;AAkBa,MAAA,gBAAA,GAAmB,CAC9B,eACG,KAAA;AACH,EAAA,MAAM,WAAW,WAAY,EAAA
|
|
1
|
+
{"version":3,"file":"useLocationToast.esm.js","sources":["../../src/hooks/useLocationToast.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\nexport const useLocationToast = (\n setToastMessage: (message: string) => void,\n) => {\n const location = useLocation();\n\n useEffect(() => {\n if (location?.state?.toastMessage) {\n setToastMessage(location.state.toastMessage);\n }\n return () => setToastMessage('');\n }, [location, setToastMessage]);\n};\n"],"names":[],"mappings":";;;AAkBa,MAAA,gBAAA,GAAmB,CAC9B,eACG,KAAA;AACH,EAAA,MAAM,WAAW,WAAY,EAAA;AAE7B,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,QAAA,EAAU,OAAO,YAAc,EAAA;AACjC,MAAgB,eAAA,CAAA,QAAA,CAAS,MAAM,YAAY,CAAA;AAAA;AAE7C,IAAO,OAAA,MAAM,gBAAgB,EAAE,CAAA;AAAA,GAC9B,EAAA,CAAC,QAAU,EAAA,eAAe,CAAC,CAAA;AAChC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMembers.esm.js","sources":["../../src/hooks/useMembers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsyncRetry, useInterval } from 'react-use';\n\nimport { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { MemberEntity, MembersData } from '../types';\nimport { getMembersFromGroup } from '../utils/rbac-utils';\n\nexport type MembersInfo = {\n loading: boolean;\n data: MembersData[];\n retry: { roleRetry: () => void; membersRetry: () => void };\n error?: { message: string };\n canReadUsersAndGroups: boolean;\n};\n\nconst getErrorText = (\n role: any,\n members: any,\n): { message: string } | undefined => {\n if (!Array.isArray(role) && (role as Response)?.statusText) {\n return {\n message: `Unable to fetch role: ${(role as Response).statusText}`,\n };\n } else if (!Array.isArray(members) && (members as Response)?.statusText) {\n return {\n message: `Unable to fetch members: ${(members as Response).statusText}`,\n };\n }\n return undefined;\n};\n\nconst getMemberData = (\n memberResource: MemberEntity | undefined,\n ref: string,\n) => {\n if (memberResource) {\n return {\n name:\n memberResource.spec.profile?.displayName ??\n memberResource.metadata.name,\n type: memberResource.kind,\n ref: {\n namespace: memberResource.metadata.namespace as string,\n kind: memberResource.kind.toLocaleLowerCase('en-US'),\n name: memberResource.metadata.name,\n },\n members:\n memberResource.kind === 'Group'\n ? getMembersFromGroup(memberResource)\n : 0,\n };\n }\n const { kind, namespace, name } = parseEntityRef(ref);\n return {\n name,\n type: kind === 'user' ? 'User' : ('Group' as 'User' | 'Group'),\n ref: {\n namespace,\n kind,\n name,\n },\n members: 0,\n };\n};\n\nexport const useMembers = (\n roleName: string,\n pollInterval?: number,\n): MembersInfo => {\n const rbacApi = useApi(rbacApiRef);\n let data: MembersData[] = [];\n const {\n value: role,\n retry: roleRetry,\n error: roleError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getRole(roleName);\n });\n\n const {\n value: members,\n retry: membersRetry,\n error: membersError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getMembers();\n });\n\n const canReadUsersAndGroups =\n !membersError && Array.isArray(members) && members.length > 0;\n\n const loading = !roleError && !membersError && !role && !members;\n\n data = React.useMemo(\n () =>\n Array.isArray(role)\n ? role[0].memberReferences.reduce((acc: MembersData[], ref: string) => {\n const memberResource: MemberEntity | undefined = Array.isArray(\n members,\n )\n ? members.find(member => stringifyEntityRef(member) === ref)\n : undefined;\n const memberData = getMemberData(memberResource, ref);\n acc.push(memberData);\n return acc;\n }, [])\n : [],\n [role, members],\n );\n\n useInterval(\n () => {\n roleRetry();\n membersRetry();\n },\n loading ? null : pollInterval || 10000,\n );\n\n return {\n loading,\n data,\n retry: { roleRetry, membersRetry },\n error: getErrorText(role, members) || roleError || membersError,\n canReadUsersAndGroups,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAiCA,MAAM,YAAA,GAAe,CACnB,IAAA,EACA,OACoC,KAAA;AACpC,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA,IAAM,MAAmB,UAAY,EAAA;AAC1D,IAAO,OAAA;AAAA,MACL,OAAA,EAAS,CAA0B,sBAAA,EAAA,IAAA,CAAkB,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"useMembers.esm.js","sources":["../../src/hooks/useMembers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsyncRetry, useInterval } from 'react-use';\n\nimport { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { MemberEntity, MembersData } from '../types';\nimport { getMembersFromGroup } from '../utils/rbac-utils';\n\nexport type MembersInfo = {\n loading: boolean;\n data: MembersData[];\n retry: { roleRetry: () => void; membersRetry: () => void };\n error?: { message: string };\n canReadUsersAndGroups: boolean;\n};\n\nconst getErrorText = (\n role: any,\n members: any,\n): { message: string } | undefined => {\n if (!Array.isArray(role) && (role as Response)?.statusText) {\n return {\n message: `Unable to fetch role: ${(role as Response).statusText}`,\n };\n } else if (!Array.isArray(members) && (members as Response)?.statusText) {\n return {\n message: `Unable to fetch members: ${(members as Response).statusText}`,\n };\n }\n return undefined;\n};\n\nconst getMemberData = (\n memberResource: MemberEntity | undefined,\n ref: string,\n) => {\n if (memberResource) {\n return {\n name:\n memberResource.spec.profile?.displayName ??\n memberResource.metadata.name,\n type: memberResource.kind,\n ref: {\n namespace: memberResource.metadata.namespace as string,\n kind: memberResource.kind.toLocaleLowerCase('en-US'),\n name: memberResource.metadata.name,\n },\n members:\n memberResource.kind === 'Group'\n ? getMembersFromGroup(memberResource)\n : 0,\n };\n }\n const { kind, namespace, name } = parseEntityRef(ref);\n return {\n name,\n type: kind === 'user' ? 'User' : ('Group' as 'User' | 'Group'),\n ref: {\n namespace,\n kind,\n name,\n },\n members: 0,\n };\n};\n\nexport const useMembers = (\n roleName: string,\n pollInterval?: number,\n): MembersInfo => {\n const rbacApi = useApi(rbacApiRef);\n let data: MembersData[] = [];\n const {\n value: role,\n retry: roleRetry,\n error: roleError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getRole(roleName);\n });\n\n const {\n value: members,\n retry: membersRetry,\n error: membersError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getMembers();\n });\n\n const canReadUsersAndGroups =\n !membersError && Array.isArray(members) && members.length > 0;\n\n const loading = !roleError && !membersError && !role && !members;\n\n data = React.useMemo(\n () =>\n Array.isArray(role)\n ? role[0].memberReferences.reduce((acc: MembersData[], ref: string) => {\n const memberResource: MemberEntity | undefined = Array.isArray(\n members,\n )\n ? members.find(member => stringifyEntityRef(member) === ref)\n : undefined;\n const memberData = getMemberData(memberResource, ref);\n acc.push(memberData);\n return acc;\n }, [])\n : [],\n [role, members],\n );\n\n useInterval(\n () => {\n roleRetry();\n membersRetry();\n },\n loading ? null : pollInterval || 10000,\n );\n\n return {\n loading,\n data,\n retry: { roleRetry, membersRetry },\n error: getErrorText(role, members) || roleError || membersError,\n canReadUsersAndGroups,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAiCA,MAAM,YAAA,GAAe,CACnB,IAAA,EACA,OACoC,KAAA;AACpC,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA,IAAM,MAAmB,UAAY,EAAA;AAC1D,IAAO,OAAA;AAAA,MACL,OAAA,EAAS,CAA0B,sBAAA,EAAA,IAAA,CAAkB,UAAU,CAAA;AAAA,KACjE;AAAA,aACS,CAAC,KAAA,CAAM,QAAQ,OAAO,CAAA,IAAM,SAAsB,UAAY,EAAA;AACvE,IAAO,OAAA;AAAA,MACL,OAAA,EAAS,CAA6B,yBAAA,EAAA,OAAA,CAAqB,UAAU,CAAA;AAAA,KACvE;AAAA;AAEF,EAAO,OAAA,KAAA,CAAA;AACT,CAAA;AAEA,MAAM,aAAA,GAAgB,CACpB,cAAA,EACA,GACG,KAAA;AACH,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAO,OAAA;AAAA,MACL,MACE,cAAe,CAAA,IAAA,CAAK,OAAS,EAAA,WAAA,IAC7B,eAAe,QAAS,CAAA,IAAA;AAAA,MAC1B,MAAM,cAAe,CAAA,IAAA;AAAA,MACrB,GAAK,EAAA;AAAA,QACH,SAAA,EAAW,eAAe,QAAS,CAAA,SAAA;AAAA,QACnC,IAAM,EAAA,cAAA,CAAe,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,QACnD,IAAA,EAAM,eAAe,QAAS,CAAA;AAAA,OAChC;AAAA,MACA,SACE,cAAe,CAAA,IAAA,KAAS,OACpB,GAAA,mBAAA,CAAoB,cAAc,CAClC,GAAA;AAAA,KACR;AAAA;AAEF,EAAA,MAAM,EAAE,IAAM,EAAA,SAAA,EAAW,IAAK,EAAA,GAAI,eAAe,GAAG,CAAA;AACpD,EAAO,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A,MAAA,KAAU,mBAAmB,MAAM,CAAA,KAAM,GAAG,CACzD,GAAA,KAAA,CAAA;AACJ,MAAM,MAAA,UAAA,GAAa,aAAc,CAAA,cAAA,EAAgB,GAAG,CAAA;AACpD,MAAA,GAAA,CAAI,KAAK,UAAU,CAAA;AACnB,MAAO,OAAA,GAAA;AAAA,KACN,EAAA,EAAE,CAAA,GACL,EAAC;AAAA,IACP,CAAC,MAAM,OAAO;AAAA,GAChB;AAEA,EAAA,WAAA;AAAA,IACE,MAAM;AACJ,MAAU,SAAA,EAAA;AACV,MAAa,YAAA,EAAA;AAAA,KACf;AAAA,IACA,OAAA,GAAU,OAAuB;AAAA,GACnC;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,SAAA,EAAW,YAAa,EAAA;AAAA,IACjC,KAAO,EAAA,YAAA,CAAa,IAAM,EAAA,OAAO,KAAK,SAAa,IAAA,YAAA;AAAA,IACnD;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePermissionPolicies.esm.js","sources":["../../src/hooks/usePermissionPolicies.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsyncRetry, useInterval } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { getPluginsPermissionPoliciesData } from '../utils/create-role-utils';\nimport {\n getConditionalPermissionsData,\n getPermissionsData,\n} from '../utils/rbac-utils';\n\nconst getErrorText = (\n policies: any,\n permissionPolicies: any,\n conditionalPolicies: any,\n): { name: number; message: string } | undefined => {\n if (!Array.isArray(policies) && (policies as Response)?.statusText) {\n return {\n name: (policies as Response).status,\n message: `Error fetching policies. ${(policies as Response).statusText}`,\n };\n } else if (\n !Array.isArray(permissionPolicies) &&\n (permissionPolicies as Response)?.statusText\n ) {\n return {\n name: (permissionPolicies as Response).status,\n message: `Error fetching the plugins. ${\n (permissionPolicies as Response).statusText\n }`,\n };\n } else if (\n !Array.isArray(conditionalPolicies) &&\n (conditionalPolicies as Response)?.statusText\n ) {\n return {\n name: (conditionalPolicies as Response).status,\n message: `Error fetching the conditional permission policies. ${\n (conditionalPolicies as Response).statusText\n }`,\n };\n }\n return undefined;\n};\n\nexport const usePermissionPolicies = (\n entityReference: string,\n pollInterval?: number,\n) => {\n const rbacApi = useApi(rbacApiRef);\n const {\n value: policies,\n retry: policiesRetry,\n error: policiesError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getAssociatedPolicies(entityReference);\n });\n\n const {\n value: conditionalPolicies,\n retry: conditionalPoliciesRetry,\n error: conditionalPoliciesError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getRoleConditions(entityReference);\n });\n\n const {\n value: permissionPolicies,\n error: permissionPoliciesError,\n retry: permissionPoliciesRetry,\n } = useAsyncRetry(async () => {\n return await rbacApi.listPermissions();\n });\n\n const loading =\n !permissionPoliciesError &&\n !policiesError &&\n !conditionalPoliciesError &&\n (!permissionPolicies || !policies || !conditionalPolicies);\n\n const allPermissionPolicies = React.useMemo(\n () => (Array.isArray(permissionPolicies) ? permissionPolicies : []),\n [permissionPolicies],\n );\n\n const data = React.useMemo(() => {\n return Array.isArray(policies)\n ? getPermissionsData(policies, allPermissionPolicies)\n : [];\n }, [allPermissionPolicies, policies]);\n\n const conditionsData = React.useMemo(() => {\n const cpp = Array.isArray(conditionalPolicies) ? conditionalPolicies : [];\n const pluginsPermissionsPoliciesData =\n allPermissionPolicies.length > 0\n ? getPluginsPermissionPoliciesData(allPermissionPolicies)\n : undefined;\n return pluginsPermissionsPoliciesData\n ? getConditionalPermissionsData(cpp, pluginsPermissionsPoliciesData)\n : [];\n }, [allPermissionPolicies, conditionalPolicies]);\n\n useInterval(\n () => {\n policiesRetry();\n permissionPoliciesRetry();\n conditionalPoliciesRetry();\n },\n loading ? null : pollInterval || null,\n );\n return {\n loading,\n data: [...conditionsData, ...data],\n retry: { policiesRetry, permissionPoliciesRetry, conditionalPoliciesRetry },\n error:\n policiesError ||\n permissionPoliciesError ||\n conditionalPoliciesError ||\n getErrorText(policies, permissionPolicies, conditionalPolicies),\n };\n};\n"],"names":[],"mappings":";;;;;;;AA2BA,MAAM,YAAe,GAAA,CACnB,QACA,EAAA,kBAAA,EACA,mBACkD,KAAA;AAClD,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAA,IAAM,UAAuB,UAAY,EAAA;AAClE,IAAO,OAAA;AAAA,MACL,MAAO,QAAsB,CAAA,MAAA;AAAA,MAC7B,OAAA,EAAS,CAA6B,yBAAA,EAAA,QAAA,CAAsB,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"usePermissionPolicies.esm.js","sources":["../../src/hooks/usePermissionPolicies.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsyncRetry, useInterval } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { getPluginsPermissionPoliciesData } from '../utils/create-role-utils';\nimport {\n getConditionalPermissionsData,\n getPermissionsData,\n} from '../utils/rbac-utils';\n\nconst getErrorText = (\n policies: any,\n permissionPolicies: any,\n conditionalPolicies: any,\n): { name: number; message: string } | undefined => {\n if (!Array.isArray(policies) && (policies as Response)?.statusText) {\n return {\n name: (policies as Response).status,\n message: `Error fetching policies. ${(policies as Response).statusText}`,\n };\n } else if (\n !Array.isArray(permissionPolicies) &&\n (permissionPolicies as Response)?.statusText\n ) {\n return {\n name: (permissionPolicies as Response).status,\n message: `Error fetching the plugins. ${\n (permissionPolicies as Response).statusText\n }`,\n };\n } else if (\n !Array.isArray(conditionalPolicies) &&\n (conditionalPolicies as Response)?.statusText\n ) {\n return {\n name: (conditionalPolicies as Response).status,\n message: `Error fetching the conditional permission policies. ${\n (conditionalPolicies as Response).statusText\n }`,\n };\n }\n return undefined;\n};\n\nexport const usePermissionPolicies = (\n entityReference: string,\n pollInterval?: number,\n) => {\n const rbacApi = useApi(rbacApiRef);\n const {\n value: policies,\n retry: policiesRetry,\n error: policiesError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getAssociatedPolicies(entityReference);\n });\n\n const {\n value: conditionalPolicies,\n retry: conditionalPoliciesRetry,\n error: conditionalPoliciesError,\n } = useAsyncRetry(async () => {\n return await rbacApi.getRoleConditions(entityReference);\n });\n\n const {\n value: permissionPolicies,\n error: permissionPoliciesError,\n retry: permissionPoliciesRetry,\n } = useAsyncRetry(async () => {\n return await rbacApi.listPermissions();\n });\n\n const loading =\n !permissionPoliciesError &&\n !policiesError &&\n !conditionalPoliciesError &&\n (!permissionPolicies || !policies || !conditionalPolicies);\n\n const allPermissionPolicies = React.useMemo(\n () => (Array.isArray(permissionPolicies) ? permissionPolicies : []),\n [permissionPolicies],\n );\n\n const data = React.useMemo(() => {\n return Array.isArray(policies)\n ? getPermissionsData(policies, allPermissionPolicies)\n : [];\n }, [allPermissionPolicies, policies]);\n\n const conditionsData = React.useMemo(() => {\n const cpp = Array.isArray(conditionalPolicies) ? conditionalPolicies : [];\n const pluginsPermissionsPoliciesData =\n allPermissionPolicies.length > 0\n ? getPluginsPermissionPoliciesData(allPermissionPolicies)\n : undefined;\n return pluginsPermissionsPoliciesData\n ? getConditionalPermissionsData(cpp, pluginsPermissionsPoliciesData)\n : [];\n }, [allPermissionPolicies, conditionalPolicies]);\n\n useInterval(\n () => {\n policiesRetry();\n permissionPoliciesRetry();\n conditionalPoliciesRetry();\n },\n loading ? null : pollInterval || null,\n );\n return {\n loading,\n data: [...conditionsData, ...data],\n retry: { policiesRetry, permissionPoliciesRetry, conditionalPoliciesRetry },\n error:\n policiesError ||\n permissionPoliciesError ||\n conditionalPoliciesError ||\n getErrorText(policies, permissionPolicies, conditionalPolicies),\n };\n};\n"],"names":[],"mappings":";;;;;;;AA2BA,MAAM,YAAe,GAAA,CACnB,QACA,EAAA,kBAAA,EACA,mBACkD,KAAA;AAClD,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAA,IAAM,UAAuB,UAAY,EAAA;AAClE,IAAO,OAAA;AAAA,MACL,MAAO,QAAsB,CAAA,MAAA;AAAA,MAC7B,OAAA,EAAS,CAA6B,yBAAA,EAAA,QAAA,CAAsB,UAAU,CAAA;AAAA,KACxE;AAAA,aAEA,CAAC,KAAA,CAAM,QAAQ,kBAAkB,CAAA,IAChC,oBAAiC,UAClC,EAAA;AACA,IAAO,OAAA;AAAA,MACL,MAAO,kBAAgC,CAAA,MAAA;AAAA,MACvC,OAAA,EAAS,CACN,4BAAA,EAAA,kBAAA,CAAgC,UACnC,CAAA;AAAA,KACF;AAAA,aAEA,CAAC,KAAA,CAAM,QAAQ,mBAAmB,CAAA,IACjC,qBAAkC,UACnC,EAAA;AACA,IAAO,OAAA;AAAA,MACL,MAAO,mBAAiC,CAAA,MAAA;AAAA,MACxC,OAAA,EAAS,CACN,oDAAA,EAAA,mBAAA,CAAiC,UACpC,CAAA;AAAA,KACF;AAAA;AAEF,EAAO,OAAA,KAAA,CAAA;AACT,CAAA;AAE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AA;AAEpC,EAAM,MAAA,cAAA,GAAiB,KAAM,CAAA,OAAA,CAAQ,MAAM;AACzC,IAAA,MAAM,MAAM,KAAM,CAAA,OAAA,CAAQ,mBAAmB,CAAA,GAAI,sBAAsB,EAAC;AACxE,IAAA,MAAM,iCACJ,qBAAsB,CAAA,MAAA,GAAS,CAC3B,GAAA,gCAAA,CAAiC,qBAAqB,CACtD,GAAA,KAAA,CAAA;AACN,IAAA,OAAO,8BACH,GAAA,6BAAA,CAA8B,GAAK,EAAA,8BAA8B,IACjE,EAAC;AAAA,GACJ,EAAA,CAAC,qBAAuB,EAAA,mBAAmB,CAAC,CAAA;AAE/C,EAAA,WAAA;AAAA,IACE,MAAM;AACJ,MAAc,aAAA,EAAA;AACd,MAAwB,uBAAA,EAAA;AACxB,MAAyB,wBAAA,EAAA;AAAA,KAC3B;AAAA,IACA,OAAA,GAAU,OAAuB;AAAA,GACnC;AACA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,IAAM,EAAA,CAAC,GAAG,cAAA,EAAgB,GAAG,IAAI,CAAA;AAAA,IACjC,KAAO,EAAA,EAAE,aAAe,EAAA,uBAAA,EAAyB,wBAAyB,EAAA;AAAA,IAC1E,OACE,aACA,IAAA,uBAAA,IACA,4BACA,YAAa,CAAA,QAAA,EAAU,oBAAoB,mBAAmB;AAAA,GAClE;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRole.esm.js","sources":["../../src/hooks/useRole.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { Role } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\n\nexport const useRole = (\n roleEntityRef: string,\n): {\n loading: boolean;\n role: Role | undefined;\n roleError: Error;\n} => {\n const rbacApi = useApi(rbacApiRef);\n const {\n value: roles,\n loading,\n error: roleError,\n } = useAsync(async () => await rbacApi.getRole(roleEntityRef));\n\n return {\n loading,\n role: Array.isArray(roles) ? roles[0] : undefined,\n roleError: (roleError as Error) || {\n name: (roles as Response)?.status,\n message: `Error fetching the role. ${(roles as Response)?.statusText}`,\n },\n };\n};\n"],"names":[],"mappings":";;;;AAuBa,MAAA,OAAA,GAAU,CACrB,aAKG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"useRole.esm.js","sources":["../../src/hooks/useRole.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { Role } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\n\nexport const useRole = (\n roleEntityRef: string,\n): {\n loading: boolean;\n role: Role | undefined;\n roleError: Error;\n} => {\n const rbacApi = useApi(rbacApiRef);\n const {\n value: roles,\n loading,\n error: roleError,\n } = useAsync(async () => await rbacApi.getRole(roleEntityRef));\n\n return {\n loading,\n role: Array.isArray(roles) ? roles[0] : undefined,\n roleError: (roleError as Error) || {\n name: (roles as Response)?.status,\n message: `Error fetching the role. ${(roles as Response)?.statusText}`,\n },\n };\n};\n"],"names":[],"mappings":";;;;AAuBa,MAAA,OAAA,GAAU,CACrB,aAKG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA;AACjC,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,KAAA;AAAA,IACP,OAAA;AAAA,IACA,KAAO,EAAA;AAAA,MACL,QAAS,CAAA,YAAY,MAAM,OAAQ,CAAA,OAAA,CAAQ,aAAa,CAAC,CAAA;AAE7D,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,MAAM,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAI,GAAA,KAAA,CAAM,CAAC,CAAI,GAAA,KAAA,CAAA;AAAA,IACxC,WAAY,SAAuB,IAAA;AAAA,MACjC,MAAO,KAAoB,EAAA,MAAA;AAAA,MAC3B,OAAA,EAAS,CAA6B,yBAAA,EAAA,KAAA,EAAoB,UAAU,CAAA;AAAA;AACtE,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRoles.esm.js","sources":["../../src/hooks/useRoles.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsync, useAsyncRetry, useInterval } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {\n isResourcedPolicy,\n PluginPermissionMetaData,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n Role,\n RoleBasedPolicy,\n} from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { RolesData } from '../types';\nimport { getPermissions, getPermissionsArray } from '../utils/rbac-utils';\n\ntype RoleWithConditionalPoliciesCount = Role & {\n conditionalPoliciesCount: number;\n accessiblePlugins: string[];\n};\n\nexport const useRoles = (\n pollInterval?: number,\n): {\n loading: boolean;\n data: RolesData[];\n createRoleLoading: boolean;\n createRoleAllowed: boolean;\n error: {\n rolesError: string;\n policiesError: string;\n roleConditionError: string;\n };\n retry: { roleRetry: () => void; policiesRetry: () => void };\n} => {\n const rbacApi = useApi(rbacApiRef);\n const [newRoles, setNewRoles] = React.useState<\n RoleWithConditionalPoliciesCount[]\n >([]);\n const [roleConditionError, setRoleConditionError] =\n React.useState<string>('');\n const {\n value: roles,\n retry: roleRetry,\n error: rolesError,\n } = useAsyncRetry(async () => await rbacApi.getRoles());\n\n const {\n value: policies,\n retry: policiesRetry,\n error: policiesError,\n } = useAsyncRetry(async () => await rbacApi.getPolicies(), []);\n\n const {\n loading: membersLoading,\n value: members,\n error: membersError,\n } = useAsync(async () => {\n return await rbacApi.getMembers();\n });\n\n const {\n value: permissionPolicies,\n loading: loadingPermissionPolicies,\n error: permissionPoliciesError,\n } = useAsync(async () => {\n return await rbacApi.listPermissions();\n });\n\n const canReadUsersAndGroups =\n !membersLoading &&\n !membersError &&\n Array.isArray(members) &&\n members.length > 0;\n\n const deletePermissionResult = usePermission({\n permission: policyEntityDeletePermission,\n resourceRef: policyEntityDeletePermission.resourceType,\n });\n\n const policyEntityCreatePermissionResult = usePermission({\n permission: policyEntityCreatePermission,\n resourceRef: policyEntityCreatePermission.resourceType,\n });\n\n const createRoleLoading =\n policyEntityCreatePermissionResult.loading || membersLoading;\n\n const createRoleAllowed =\n policyEntityCreatePermissionResult.allowed && canReadUsersAndGroups;\n\n const editPermissionResult = usePermission({\n permission: policyEntityUpdatePermission,\n resourceRef: policyEntityUpdatePermission.resourceType,\n });\n\n React.useEffect(() => {\n const fetchAllPermissionPolicies = async () => {\n if (!Array.isArray(roles)) return;\n const failedFetchConditionRoles: string[] = [];\n const conditionPromises = roles.map(async role => {\n try {\n const conditionalPolicies = await rbacApi.getRoleConditions(\n role.name,\n );\n\n if ((conditionalPolicies as any as Response)?.statusText) {\n failedFetchConditionRoles.push(role.name);\n throw new Error(\n (conditionalPolicies as any as Response).statusText,\n );\n }\n const accessiblePlugins =\n Array.isArray(conditionalPolicies) && conditionalPolicies.length > 0\n ? conditionalPolicies.map(c => c.pluginId)\n : [];\n return {\n ...role,\n conditionalPoliciesCount: Array.isArray(conditionalPolicies)\n ? conditionalPolicies.length\n : 0,\n accessiblePlugins,\n };\n } catch (error) {\n setRoleConditionError(\n `Error fetching role conditions for ${\n failedFetchConditionRoles.length > 1 ? 'roles' : 'role'\n } ${failedFetchConditionRoles.join(', ')}, please try again later.`,\n );\n return {\n ...role,\n conditionalPoliciesCount: 0,\n accessiblePlugins: [],\n };\n }\n });\n\n const updatedRoles = await Promise.all(conditionPromises);\n setNewRoles(updatedRoles);\n };\n\n fetchAllPermissionPolicies();\n }, [roles, rbacApi]);\n\n const data: RolesData[] = React.useMemo(\n () =>\n Array.isArray(newRoles) && newRoles?.length > 0\n ? newRoles.reduce(\n (acc: RolesData[], role: RoleWithConditionalPoliciesCount) => {\n const permissions = getPermissions(\n role.name,\n policies as RoleBasedPolicy[],\n );\n\n let accPls = role.accessiblePlugins;\n if (\n !loadingPermissionPolicies &&\n !permissionPoliciesError &&\n (permissionPolicies as PluginPermissionMetaData[])?.length > 0\n ) {\n const pls = getPermissionsArray(\n role.name,\n policies as RoleBasedPolicy[],\n ).map(\n po =>\n (permissionPolicies as PluginPermissionMetaData[]).find(\n pp =>\n pp.policies?.find(pol =>\n isResourcedPolicy(pol)\n ? po.permission === pol.resourceType\n : po.permission === pol.name,\n ),\n )?.pluginId,\n );\n accPls = [...accPls, ...pls].filter(val => !!val) as string[];\n }\n const accessiblePlugins = accPls\n .filter((val, index, plugins) => plugins.indexOf(val) === index)\n .sort();\n\n return [\n ...acc,\n {\n id: role.name,\n name: role.name,\n description: role.metadata?.description ?? '-',\n members: role.memberReferences,\n permissions: role.conditionalPoliciesCount + permissions,\n modifiedBy: '-',\n lastModified: '-',\n actionsPermissionResults: {\n delete: deletePermissionResult,\n edit: {\n allowed:\n editPermissionResult.allowed && canReadUsersAndGroups,\n loading: editPermissionResult.loading,\n },\n },\n accessiblePlugins,\n },\n ];\n },\n [],\n )\n : [],\n [\n newRoles,\n policies,\n loadingPermissionPolicies,\n permissionPoliciesError,\n permissionPolicies,\n deletePermissionResult,\n editPermissionResult.allowed,\n editPermissionResult.loading,\n canReadUsersAndGroups,\n ],\n );\n const loading = !rolesError && !policiesError && !roles && !policies;\n\n useInterval(\n () => {\n roleRetry();\n policiesRetry();\n },\n loading ? null : pollInterval || 10000,\n );\n\n return {\n loading,\n data,\n error: {\n rolesError: (rolesError?.message ||\n (typeof roles === 'object'\n ? (roles as any as Response)?.statusText\n : '')) as string,\n policiesError: (policiesError?.message ||\n (typeof policies === 'object'\n ? (policies as any as Response)?.statusText\n : '')) as string,\n roleConditionError,\n },\n createRoleLoading,\n createRoleAllowed,\n retry: { roleRetry, policiesRetry },\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAwCa,MAAA,QAAA,GAAW,CACtB,YAYG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA,CAAA;AACjC,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,IAAI,KAAM,CAAA,QAAA,CAEpC,EAAE,CAAA,CAAA;AACJ,EAAA,MAAM,CAAC,kBAAoB,EAAA,qBAAqB,CAC9C,GAAA,KAAA,CAAM,SAAiB,EAAE,CAAA,CAAA;AAC3B,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,KAAA;AAAA,IACP,KAAO,EAAA,SAAA;AAAA,IACP,KAAO,EAAA,UAAA;AAAA,MACL,aAAc,CAAA,YAAY,MAAM,O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A;AAAA,IACE,MAAM;AACJ,MAAU,SAAA,EAAA,CAAA;AACV,MAAc,aAAA,EAAA,CAAA;AAAA,KAChB;AAAA,IACA,OAAA,GAAU,OAAuB,GAAA;AAAA,GACnC,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;AAAA,MACL,YAAa,UAAY,EAAA,OAAA,KACtB,OAAO,KAAU,KAAA,QAAA,GACb,OAA2B,UAC5B,GAAA,EAAA,CAAA;AAAA,MACN,eAAgB,aAAe,EAAA,OAAA,KAC5B,OAAO,QAAa,KAAA,QAAA,GAChB,UAA8B,UAC/B,GAAA,EAAA,CAAA;AAAA,MACN,kBAAA;AAAA,KACF;AAAA,IACA,iBAAA;AAAA,IACA,iBAAA;AAAA,IACA,KAAA,EAAO,EAAE,SAAA,EAAW,aAAc,EAAA;AAAA,GACpC,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useRoles.esm.js","sources":["../../src/hooks/useRoles.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useAsync, useAsyncRetry, useInterval } from 'react-use';\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { usePermission } from '@backstage/plugin-permission-react';\n\nimport {\n isResourcedPolicy,\n PluginPermissionMetaData,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n Role,\n RoleBasedPolicy,\n} from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { RolesData } from '../types';\nimport { getPermissions, getPermissionsArray } from '../utils/rbac-utils';\n\ntype RoleWithConditionalPoliciesCount = Role & {\n conditionalPoliciesCount: number;\n accessiblePlugins: string[];\n};\n\nexport const useRoles = (\n pollInterval?: number,\n): {\n loading: boolean;\n data: RolesData[];\n createRoleLoading: boolean;\n createRoleAllowed: boolean;\n error: {\n rolesError: string;\n policiesError: string;\n roleConditionError: string;\n };\n retry: { roleRetry: () => void; policiesRetry: () => void };\n} => {\n const rbacApi = useApi(rbacApiRef);\n const [newRoles, setNewRoles] = React.useState<\n RoleWithConditionalPoliciesCount[]\n >([]);\n const [roleConditionError, setRoleConditionError] =\n React.useState<string>('');\n const {\n value: roles,\n retry: roleRetry,\n error: rolesError,\n } = useAsyncRetry(async () => await rbacApi.getRoles());\n\n const {\n value: policies,\n retry: policiesRetry,\n error: policiesError,\n } = useAsyncRetry(async () => await rbacApi.getPolicies(), []);\n\n const {\n loading: membersLoading,\n value: members,\n error: membersError,\n } = useAsync(async () => {\n return await rbacApi.getMembers();\n });\n\n const {\n value: permissionPolicies,\n loading: loadingPermissionPolicies,\n error: permissionPoliciesError,\n } = useAsync(async () => {\n return await rbacApi.listPermissions();\n });\n\n const canReadUsersAndGroups =\n !membersLoading &&\n !membersError &&\n Array.isArray(members) &&\n members.length > 0;\n\n const deletePermissionResult = usePermission({\n permission: policyEntityDeletePermission,\n resourceRef: policyEntityDeletePermission.resourceType,\n });\n\n const policyEntityCreatePermissionResult = usePermission({\n permission: policyEntityCreatePermission,\n resourceRef: policyEntityCreatePermission.resourceType,\n });\n\n const createRoleLoading =\n policyEntityCreatePermissionResult.loading || membersLoading;\n\n const createRoleAllowed =\n policyEntityCreatePermissionResult.allowed && canReadUsersAndGroups;\n\n const editPermissionResult = usePermission({\n permission: policyEntityUpdatePermission,\n resourceRef: policyEntityUpdatePermission.resourceType,\n });\n\n React.useEffect(() => {\n const fetchAllPermissionPolicies = async () => {\n if (!Array.isArray(roles)) return;\n const failedFetchConditionRoles: string[] = [];\n const conditionPromises = roles.map(async role => {\n try {\n const conditionalPolicies = await rbacApi.getRoleConditions(\n role.name,\n );\n\n if ((conditionalPolicies as any as Response)?.statusText) {\n failedFetchConditionRoles.push(role.name);\n throw new Error(\n (conditionalPolicies as any as Response).statusText,\n );\n }\n const accessiblePlugins =\n Array.isArray(conditionalPolicies) && conditionalPolicies.length > 0\n ? conditionalPolicies.map(c => c.pluginId)\n : [];\n return {\n ...role,\n conditionalPoliciesCount: Array.isArray(conditionalPolicies)\n ? conditionalPolicies.length\n : 0,\n accessiblePlugins,\n };\n } catch (error) {\n setRoleConditionError(\n `Error fetching role conditions for ${\n failedFetchConditionRoles.length > 1 ? 'roles' : 'role'\n } ${failedFetchConditionRoles.join(', ')}, please try again later.`,\n );\n return {\n ...role,\n conditionalPoliciesCount: 0,\n accessiblePlugins: [],\n };\n }\n });\n\n const updatedRoles = await Promise.all(conditionPromises);\n setNewRoles(updatedRoles);\n };\n\n fetchAllPermissionPolicies();\n }, [roles, rbacApi]);\n\n const data: RolesData[] = React.useMemo(\n () =>\n Array.isArray(newRoles) && newRoles?.length > 0\n ? newRoles.reduce(\n (acc: RolesData[], role: RoleWithConditionalPoliciesCount) => {\n const permissions = getPermissions(\n role.name,\n policies as RoleBasedPolicy[],\n );\n\n let accPls = role.accessiblePlugins;\n if (\n !loadingPermissionPolicies &&\n !permissionPoliciesError &&\n (permissionPolicies as PluginPermissionMetaData[])?.length > 0\n ) {\n const pls = getPermissionsArray(\n role.name,\n policies as RoleBasedPolicy[],\n ).map(\n po =>\n (permissionPolicies as PluginPermissionMetaData[]).find(\n pp =>\n pp.policies?.find(pol =>\n isResourcedPolicy(pol)\n ? po.permission === pol.resourceType\n : po.permission === pol.name,\n ),\n )?.pluginId,\n );\n accPls = [...accPls, ...pls].filter(val => !!val) as string[];\n }\n const accessiblePlugins = accPls\n .filter((val, index, plugins) => plugins.indexOf(val) === index)\n .sort();\n\n return [\n ...acc,\n {\n id: role.name,\n name: role.name,\n description: role.metadata?.description ?? '-',\n members: role.memberReferences,\n permissions: role.conditionalPoliciesCount + permissions,\n modifiedBy: '-',\n lastModified: '-',\n actionsPermissionResults: {\n delete: deletePermissionResult,\n edit: {\n allowed:\n editPermissionResult.allowed && canReadUsersAndGroups,\n loading: editPermissionResult.loading,\n },\n },\n accessiblePlugins,\n },\n ];\n },\n [],\n )\n : [],\n [\n newRoles,\n policies,\n loadingPermissionPolicies,\n permissionPoliciesError,\n permissionPolicies,\n deletePermissionResult,\n editPermissionResult.allowed,\n editPermissionResult.loading,\n canReadUsersAndGroups,\n ],\n );\n const loading = !rolesError && !policiesError && !roles && !policies;\n\n useInterval(\n () => {\n roleRetry();\n policiesRetry();\n },\n loading ? null : pollInterval || 10000,\n );\n\n return {\n loading,\n data,\n error: {\n rolesError: (rolesError?.message ||\n (typeof roles === 'object'\n ? (roles as any as Response)?.statusText\n : '')) as string,\n policiesError: (policiesError?.message ||\n (typeof policies === 'object'\n ? (policies as any as Response)?.statusText\n : '')) as string,\n roleConditionError,\n },\n createRoleLoading,\n createRoleAllowed,\n retry: { roleRetry, policiesRetry },\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAwCa,MAAA,QAAA,GAAW,CACtB,YAYG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA;AACjC,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,IAAI,KAAM,CAAA,QAAA,CAEpC,EAAE,CAAA;AACJ,EAAA,MAAM,CAAC,kBAAoB,EAAA,qBAAqB,CAC9C,GAAA,KAAA,CAAM,SAAiB,EAAE,CAAA;AAC3B,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,KAAA;AAAA,IACP,KAAO,EAAA,SAAA;AAAA,IACP,KAAO,EAAA;AAAA,MACL,aAAc,CAAA,YAAY,MAAM,OAAA,CAAQ,UAAU,CAAA;AAEtD,EAAM,MAAA;AAAA,IACJ,KAAO,EAAA,QAAA;AAAA,IACP,KAAO,EAAA,aAAA;AAAA,IACP,K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,EAAE,SAAA,EAAW,aAAc;AAAA,GACpC;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectedMembers.esm.js","sources":["../../src/hooks/useSelectedMembers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { Role } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { SelectedMember } from '../components/CreateRole/types';\nimport { MemberEntity } from '../types';\nimport { getSelectedMember } from '../utils/rbac-utils';\nimport { useRole } from './useRole';\n\nexport const useSelectedMembers = (\n roleName: string,\n): {\n members: MemberEntity[];\n selectedMembers: SelectedMember[];\n role: Role | undefined;\n membersError: Error;\n roleError: Error;\n loading: boolean;\n canReadUsersAndGroups: boolean;\n} => {\n const rbacApi = useApi(rbacApiRef);\n const { role, loading: roleLoading, roleError } = useRole(roleName);\n\n const {\n loading: membersLoading,\n value: members,\n error: membersError,\n } = useAsync(async () => {\n return await rbacApi.getMembers();\n });\n\n const canReadUsersAndGroups =\n !membersLoading &&\n !membersError &&\n Array.isArray(members) &&\n members.length > 0;\n\n const data: SelectedMember[] = role\n ? (role as Role).memberReferences.reduce((acc: SelectedMember[], ref) => {\n const memberResource =\n (Array.isArray(members) &&\n members.find(member => stringifyEntityRef(member) === ref)) ||\n undefined;\n acc.push(getSelectedMember(memberResource, ref));\n\n return acc;\n }, [])\n : [];\n\n return {\n selectedMembers: data,\n members: Array.isArray(members) ? members : ([] as MemberEntity[]),\n role,\n membersError: (membersError as Error) || {\n name: (members as Response)?.status,\n message: (members as Response)?.statusText,\n },\n roleError: roleError,\n loading: roleLoading || membersLoading,\n canReadUsersAndGroups,\n };\n};\n"],"names":[],"mappings":";;;;;;;AA4Ba,MAAA,kBAAA,GAAqB,CAChC,QASG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"useSelectedMembers.esm.js","sources":["../../src/hooks/useSelectedMembers.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync } from 'react-use';\n\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { Role } from '@backstage-community/plugin-rbac-common';\n\nimport { rbacApiRef } from '../api/RBACBackendClient';\nimport { SelectedMember } from '../components/CreateRole/types';\nimport { MemberEntity } from '../types';\nimport { getSelectedMember } from '../utils/rbac-utils';\nimport { useRole } from './useRole';\n\nexport const useSelectedMembers = (\n roleName: string,\n): {\n members: MemberEntity[];\n selectedMembers: SelectedMember[];\n role: Role | undefined;\n membersError: Error;\n roleError: Error;\n loading: boolean;\n canReadUsersAndGroups: boolean;\n} => {\n const rbacApi = useApi(rbacApiRef);\n const { role, loading: roleLoading, roleError } = useRole(roleName);\n\n const {\n loading: membersLoading,\n value: members,\n error: membersError,\n } = useAsync(async () => {\n return await rbacApi.getMembers();\n });\n\n const canReadUsersAndGroups =\n !membersLoading &&\n !membersError &&\n Array.isArray(members) &&\n members.length > 0;\n\n const data: SelectedMember[] = role\n ? (role as Role).memberReferences.reduce((acc: SelectedMember[], ref) => {\n const memberResource =\n (Array.isArray(members) &&\n members.find(member => stringifyEntityRef(member) === ref)) ||\n undefined;\n acc.push(getSelectedMember(memberResource, ref));\n\n return acc;\n }, [])\n : [];\n\n return {\n selectedMembers: data,\n members: Array.isArray(members) ? members : ([] as MemberEntity[]),\n role,\n membersError: (membersError as Error) || {\n name: (members as Response)?.status,\n message: (members as Response)?.statusText,\n },\n roleError: roleError,\n loading: roleLoading || membersLoading,\n canReadUsersAndGroups,\n };\n};\n"],"names":[],"mappings":";;;;;;;AA4Ba,MAAA,kBAAA,GAAqB,CAChC,QASG,KAAA;AACH,EAAM,MAAA,OAAA,GAAU,OAAO,UAAU,CAAA;AACjC,EAAA,MAAM,EAAE,IAAM,EAAA,OAAA,EAAS,aAAa,SAAU,EAAA,GAAI,QAAQ,QAAQ,CAAA;AAElE,EAAM,MAAA;AAAA,IACJ,OAAS,EAAA,cAAA;AAAA,IACT,KAAO,EAAA,OAAA;AAAA,IACP,KAAO,EAAA;AAAA,GACT,GAAI,SAAS,YAAY;AACvB,IAAO,OAAA,MAAM,QAAQ,UAAW,EAAA;AAAA,GACjC,CAAA;AAED,EAAM,MAAA,qBAAA,GACJ,CAAC,cAAA,IACD,CAAC,YAAA,IACD,MAAM,OAAQ,CAAA,OAAO,CACrB,IAAA,OAAA,CAAQ,MAAS,GAAA,CAAA;AAEnB,EAAA,MAAM,OAAyB,IAC1B,GAAA,IAAA,CAAc,iBAAiB,MAAO,CAAA,CAAC,KAAuB,GAAQ,KAAA;AACrE,IAAA,MAAM,cACH,GAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,CACpB,IAAA,OAAA,CAAQ,IAAK,CAAA,CAAA,MAAA,KAAU,kBAAmB,CAAA,MAAM,CAAM,KAAA,GAAG,CAC3D,IAAA,KAAA,CAAA;AACF,IAAA,GAAA,CAAI,IAAK,CAAA,iBAAA,CAAkB,cAAgB,EAAA,GAAG,CAAC,CAAA;AAE/C,IAAO,OAAA,GAAA;AAAA,GACN,EAAA,EAAE,CAAA,GACL,EAAC;AAEL,EAAO,OAAA;AAAA,IACL,eAAiB,EAAA,IAAA;AAAA,IACjB,SAAS,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,GAAI,UAAW,EAAC;AAAA,IAC9C,IAAA;AAAA,IACA,cAAe,YAA0B,IAAA;AAAA,MACvC,MAAO,OAAsB,EAAA,MAAA;AAAA,MAC7B,SAAU,OAAsB,EAAA;AAAA,KAClC;AAAA,IACA,SAAA;AAAA,IACA,SAAS,WAAe,IAAA,cAAA;AAAA,IACxB;AAAA,GACF;AACF;;;;"}
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n identityApiRef,\n} from '@backstage/core-plugin-api';\n\nimport {\n LicensedUsersAPIClient,\n licensedUsersApiRef,\n} from './api/LicensedUsersClient';\nimport { rbacApiRef, RBACBackendClient } from './api/RBACBackendClient';\nimport { createRoleRouteRef, roleRouteRef, rootRouteRef } from './routes';\n\nexport const rbacPlugin = createPlugin({\n id: 'rbac',\n routes: {\n root: rootRouteRef,\n role: roleRouteRef,\n createRole: createRoleRouteRef,\n },\n apis: [\n createApiFactory({\n api: rbacApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi }) =>\n new RBACBackendClient({ configApi, identityApi }),\n }),\n createApiFactory({\n api: licensedUsersApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi }) =>\n new LicensedUsersAPIClient({ configApi, identityApi }),\n }),\n ],\n});\n\nexport const RbacPage = rbacPlugin.provide(\n createRoutableExtension({\n name: 'RbacPage',\n component: () => import('./components').then(m => m.Router),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const Administration = rbacPlugin.provide(\n createComponentExtension({\n name: 'Administration',\n component: {\n lazy: () => import('./components').then(m => m.Administration),\n },\n }),\n);\n"],"names":[],"mappings":";;;;;AA+BO,MAAM,aAAa,YAAa,CAAA;AAAA,EACrC,EAAI,EAAA,MAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,IACN,UAAY,EAAA
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n identityApiRef,\n} from '@backstage/core-plugin-api';\n\nimport {\n LicensedUsersAPIClient,\n licensedUsersApiRef,\n} from './api/LicensedUsersClient';\nimport { rbacApiRef, RBACBackendClient } from './api/RBACBackendClient';\nimport { createRoleRouteRef, roleRouteRef, rootRouteRef } from './routes';\n\nexport const rbacPlugin = createPlugin({\n id: 'rbac',\n routes: {\n root: rootRouteRef,\n role: roleRouteRef,\n createRole: createRoleRouteRef,\n },\n apis: [\n createApiFactory({\n api: rbacApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi }) =>\n new RBACBackendClient({ configApi, identityApi }),\n }),\n createApiFactory({\n api: licensedUsersApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi }) =>\n new LicensedUsersAPIClient({ configApi, identityApi }),\n }),\n ],\n});\n\nexport const RbacPage = rbacPlugin.provide(\n createRoutableExtension({\n name: 'RbacPage',\n component: () => import('./components').then(m => m.Router),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const Administration = rbacPlugin.provide(\n createComponentExtension({\n name: 'Administration',\n component: {\n lazy: () => import('./components').then(m => m.Administration),\n },\n }),\n);\n"],"names":[],"mappings":";;;;;AA+BO,MAAM,aAAa,YAAa,CAAA;AAAA,EACrC,EAAI,EAAA,MAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,IACN,UAAY,EAAA;AAAA,GACd;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,UAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,SAAW,EAAA,YAAA;AAAA,QACX,WAAa,EAAA;AAAA,OACf;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,SAAW,EAAA,WAAA,EACrB,KAAA,IAAI,iBAAkB,CAAA,EAAE,SAAW,EAAA,WAAA,EAAa;AAAA,KACnD,CAAA;AAAA,IACD,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,mBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,SAAW,EAAA,YAAA;AAAA,QACX,WAAa,EAAA;AAAA,OACf;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,SAAW,EAAA,WAAA,EACrB,KAAA,IAAI,sBAAuB,CAAA,EAAE,SAAW,EAAA,WAAA,EAAa;AAAA,KACxD;AAAA;AAEL,CAAC;AAEM,MAAM,WAAW,UAAW,CAAA,OAAA;AAAA,EACjC,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,UAAA;AAAA,IACN,SAAA,EAAW,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,MAAM,CAAA;AAAA,IAC1D,UAAY,EAAA;AAAA,GACb;AACH;AAEO,MAAM,iBAAiB,UAAW,CAAA,OAAA;AAAA,EACvC,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,gBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,2BAAc,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,cAAc;AAAA;AAC/D,GACD;AACH;;;;"}
|
package/dist/routes.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef, createSubRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'rbac',\n});\n\nexport const roleRouteRef = createSubRouteRef({\n id: 'rbac-role-overview',\n parent: rootRouteRef,\n path: '/roles/:roleKind/:roleNamespace/:roleName',\n});\n\nexport const createRoleRouteRef = createSubRouteRef({\n id: 'rbac-create-role',\n parent: rootRouteRef,\n path: '/role/new',\n});\n\nexport const editRoleRouteRef = createSubRouteRef({\n id: 'rbac-edit-role',\n parent: rootRouteRef,\n path: '/role/:roleKind/:roleNamespace/:roleName',\n});\n"],"names":[],"mappings":";;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA
|
|
1
|
+
{"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef, createSubRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'rbac',\n});\n\nexport const roleRouteRef = createSubRouteRef({\n id: 'rbac-role-overview',\n parent: rootRouteRef,\n path: '/roles/:roleKind/:roleNamespace/:roleName',\n});\n\nexport const createRoleRouteRef = createSubRouteRef({\n id: 'rbac-create-role',\n parent: rootRouteRef,\n path: '/role/new',\n});\n\nexport const editRoleRouteRef = createSubRouteRef({\n id: 'rbac-edit-role',\n parent: rootRouteRef,\n path: '/role/:roleKind/:roleNamespace/:roleName',\n});\n"],"names":[],"mappings":";;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA;AACN,CAAC;AAEM,MAAM,eAAe,iBAAkB,CAAA;AAAA,EAC5C,EAAI,EAAA,oBAAA;AAAA,EACJ,MAAQ,EAAA,YAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAC;AAEM,MAAM,qBAAqB,iBAAkB,CAAA;AAAA,EAClD,EAAI,EAAA,kBAAA;AAAA,EACJ,MAAQ,EAAA,YAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAC;AAEM,MAAM,mBAAmB,iBAAkB,CAAA;AAAA,EAChD,EAAI,EAAA,gBAAA;AAAA,EACJ,MAAQ,EAAA,YAAA;AAAA,EACR,IAAM,EAAA;AACR,CAAC;;;;"}
|