@backstage-community/plugin-rbac 1.41.2 → 1.41.4
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 +23 -0
- package/dist/components/ConditionalAccess/AddNestedConditionButton.esm.js +1 -1
- package/dist/components/ConditionalAccess/AddNestedConditionButton.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ComplexConditionRow.esm.js +1 -1
- package/dist/components/ConditionalAccess/ComplexConditionRow.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ComplexConditionRowButtons.esm.js +10 -12
- package/dist/components/ConditionalAccess/ComplexConditionRowButtons.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionsFormRow.esm.js +3 -2
- package/dist/components/ConditionalAccess/ConditionsFormRow.esm.js.map +1 -1
- package/dist/components/ConditionalAccess/ConditionsFormRowFields.esm.js +20 -5
- package/dist/components/ConditionalAccess/ConditionsFormRowFields.esm.js.map +1 -1
- package/dist/components/CreateRole/AddMembersForm.esm.js +5 -1
- package/dist/components/CreateRole/AddMembersForm.esm.js.map +1 -1
- package/dist/components/CreateRole/AddedMembersTable.esm.js +2 -1
- package/dist/components/CreateRole/AddedMembersTable.esm.js.map +1 -1
- package/dist/components/CreateRole/PluginsDropdown.esm.js +14 -1
- package/dist/components/CreateRole/PluginsDropdown.esm.js.map +1 -1
- package/dist/components/EditRole.esm.js +10 -5
- package/dist/components/EditRole.esm.js.map +1 -1
- package/dist/components/RoleOverview/MembersCard.esm.js +4 -3
- package/dist/components/RoleOverview/MembersCard.esm.js.map +1 -1
- package/dist/components/RoleOverview/PermissionsCard.esm.js +8 -3
- package/dist/components/RoleOverview/PermissionsCard.esm.js.map +1 -1
- package/dist/components/RoleOverview/StyledTableWrapper.esm.js +14 -0
- package/dist/components/RoleOverview/StyledTableWrapper.esm.js.map +1 -0
- package/dist/components/RolesList/DeleteRole.esm.js +5 -2
- package/dist/components/RolesList/DeleteRole.esm.js.map +1 -1
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
### Dependencies
|
|
2
2
|
|
|
3
|
+
## 1.41.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eebc68d: UI Enhancements:
|
|
8
|
+
|
|
9
|
+
- Added vertical spacing between buttons in the side drawer for improved usability.
|
|
10
|
+
- Fixed layout issue in the Users and Groups table where adding a row caused unexpected height changes.
|
|
11
|
+
- Aligned action icon colors in the Roles table for visual consistency.
|
|
12
|
+
- Simplified label formatting in the Overview table for a cleaner look.
|
|
13
|
+
- Improved dropdown behavior in Users, Groups, and Permissions sections — selecting an option no longer clears the input text.
|
|
14
|
+
- Conditionally hid input field labels when validation errors are present to reduce visual clutter.
|
|
15
|
+
- Aligned “No options” placeholder text across the Users and Groups and Plugin selection dropdowns.
|
|
16
|
+
- Prevented backspace from unintentionally removing selected items in the Users and Groups and Plugin dropdowns.
|
|
17
|
+
|
|
18
|
+
## 1.41.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 658c51c: chore: Remove usage of @spotify/prettier-config
|
|
23
|
+
- Updated dependencies [658c51c]
|
|
24
|
+
- @backstage-community/plugin-rbac-common@1.16.1
|
|
25
|
+
|
|
3
26
|
## 1.41.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -22,7 +22,7 @@ const AddNestedConditionButton = () => {
|
|
|
22
22
|
alignItems: "center"
|
|
23
23
|
},
|
|
24
24
|
children: [
|
|
25
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body1", component: "span", children: "Add
|
|
25
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", component: "span", children: "Add nested condition" }),
|
|
26
26
|
/* @__PURE__ */ jsx(Tooltip, { title: tooltipTitle(), placement: "top", children: /* @__PURE__ */ jsx(HelpOutlineIcon, { fontSize: "inherit", style: { marginLeft: "0.25rem" } }) })
|
|
27
27
|
]
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNestedConditionButton.esm.js","sources":["../../../src/components/ConditionalAccess/AddNestedConditionButton.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 HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport Box from '@mui/material/Box';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\n\nexport const tooltipTitle = () => (\n <div>\n <Typography variant=\"body1\" component=\"p\" align=\"center\">\n Nested conditions are <b>1 layer rules within a main condition</b>. It\n lets you allow appropriate access by using detailed permissions based on\n various conditions. You can add multiple nested conditions.\n </Typography>\n <Typography variant=\"body1\" component=\"p\" align=\"center\">\n For example, you can allow access to all entity types in the main\n condition and use a nested condition to limit the access to entities owned\n by the user.\n </Typography>\n </div>\n);\n\nexport const AddNestedConditionButton = () => {\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n <Typography variant=\"body1\" component=\"span\">\n Add
|
|
1
|
+
{"version":3,"file":"AddNestedConditionButton.esm.js","sources":["../../../src/components/ConditionalAccess/AddNestedConditionButton.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 HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport Box from '@mui/material/Box';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\n\nexport const tooltipTitle = () => (\n <div>\n <Typography variant=\"body1\" component=\"p\" align=\"center\">\n Nested conditions are <b>1 layer rules within a main condition</b>. It\n lets you allow appropriate access by using detailed permissions based on\n various conditions. You can add multiple nested conditions.\n </Typography>\n <Typography variant=\"body1\" component=\"p\" align=\"center\">\n For example, you can allow access to all entity types in the main\n condition and use a nested condition to limit the access to entities owned\n by the user.\n </Typography>\n </div>\n);\n\nexport const AddNestedConditionButton = () => {\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n <Typography variant=\"body1\" component=\"span\">\n Add nested condition\n </Typography>\n <Tooltip title={tooltipTitle()} placement=\"top\">\n <HelpOutlineIcon fontSize=\"inherit\" style={{ marginLeft: '0.25rem' }} />\n </Tooltip>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;AAoBa,MAAA,YAAA,GAAe,sBAC1B,IAAA,CAAC,KACC,EAAA,EAAA,QAAA,EAAA;AAAA,kBAAA,IAAA,CAAC,cAAW,OAAQ,EAAA,OAAA,EAAQ,SAAU,EAAA,GAAA,EAAI,OAAM,QAAS,EAAA,QAAA,EAAA;AAAA,IAAA,wBAAA;AAAA,oBACjC,GAAA,CAAC,OAAE,QAAqC,EAAA,uCAAA,EAAA,CAAA;AAAA,IAAI;AAAA,GAGpE,EAAA,CAAA;AAAA,kBACA,GAAA,CAAC,cAAW,OAAQ,EAAA,OAAA,EAAQ,WAAU,GAAI,EAAA,KAAA,EAAM,UAAS,QAIzD,EAAA,2JAAA,EAAA;AAAA,CACF,EAAA;AAGK,MAAM,2BAA2B,MAAM;AAC5C,EACE,uBAAA,IAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,OAAS,EAAA,MAAA;AAAA,QACT,cAAgB,EAAA,QAAA;AAAA,QAChB,UAAY,EAAA;AAAA,OACd;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,SAAA,EAAU,QAAO,QAE7C,EAAA,sBAAA,EAAA,CAAA;AAAA,4BACC,OAAQ,EAAA,EAAA,KAAA,EAAO,YAAa,EAAA,EAAG,WAAU,KACxC,EAAA,QAAA,kBAAA,GAAA,CAAC,eAAgB,EAAA,EAAA,QAAA,EAAS,WAAU,KAAO,EAAA,EAAE,UAAY,EAAA,SAAA,IAAa,CACxE,EAAA;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -136,7 +136,7 @@ const ComplexConditionRow = ({
|
|
|
136
136
|
color: (theme) => theme.palette.grey[500],
|
|
137
137
|
flexGrow: 0,
|
|
138
138
|
alignSelf: "baseline",
|
|
139
|
-
|
|
139
|
+
mt: "34px"
|
|
140
140
|
},
|
|
141
141
|
disabled: isNestedCondition ? nestedDisabled : disabled,
|
|
142
142
|
onClick: isNestedCondition && activeNestedCriteria && nestedConditionIndex !== undefined ? () => handleRemoveNestedConditionRule(activeNestedCriteria) : () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplexConditionRow.esm.js","sources":["../../../src/components/ConditionalAccess/ComplexConditionRow.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 type { SetStateAction, Dispatch } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport RemoveIcon from '@mui/icons-material/Remove';\nimport IconButton from '@mui/material/IconButton';\n\nimport {\n getNestedRuleErrors,\n getRowKey,\n getRowStyle,\n getSimpleRuleErrors,\n isSimpleRule,\n} from '../../utils/conditional-access-utils';\nimport { ConditionsFormRowFields } from './ConditionsFormRowFields';\nimport { criterias } from './const';\nimport {\n AccessConditionsErrors,\n ComplexErrors,\n Condition,\n ConditionsData,\n NestedCriteriaErrors,\n NotConditionType,\n RulesData,\n} from './types';\n\ntype ComplexConditionRowProps = {\n conditionRow: ConditionsData;\n nestedConditionRow: Condition[];\n criteria: keyof ConditionsData;\n onRuleChange: (newCondition: ConditionsData) => void;\n updateRules: (updatedNestedConditionRow: Condition[] | Condition) => void;\n setErrors: Dispatch<SetStateAction<AccessConditionsErrors | undefined>>;\n setRemoveAllClicked: Dispatch<SetStateAction<boolean>>;\n conditionRulesData?: RulesData;\n notConditionType?: NotConditionType;\n currentCondition: Condition;\n ruleIndex: number;\n activeCriteria?: 'allOf' | 'anyOf';\n isNestedCondition?: boolean;\n nestedConditionIndex?: number;\n activeNestedCriteria?: 'allOf' | 'anyOf';\n};\n\nexport const ComplexConditionRow = ({\n conditionRow,\n nestedConditionRow,\n criteria,\n onRuleChange,\n updateRules,\n setErrors,\n setRemoveAllClicked,\n conditionRulesData,\n notConditionType,\n currentCondition,\n ruleIndex,\n activeCriteria,\n isNestedCondition = false,\n nestedConditionIndex,\n activeNestedCriteria,\n}: ComplexConditionRowProps) => {\n const handleRemoveSimpleConditionRule = (\n index: number,\n ruleList: PermissionCondition[],\n ) => {\n if (!activeCriteria) {\n return;\n }\n const updatedSimpleRules = ruleList.filter(\n (_r, rindex) => index !== rindex,\n );\n const nestedConditions =\n (conditionRow[criteria] as PermissionCondition[])?.filter(\n (con: PermissionCondition) =>\n criterias.allOf in con ||\n criterias.anyOf in con ||\n criterias.not in con,\n ) || [];\n\n onRuleChange({\n [activeCriteria as keyof ConditionsData]: [\n ...updatedSimpleRules,\n ...nestedConditions,\n ],\n });\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[activeCriteria]) {\n const criteriaErrors = updatedErrors[activeCriteria] as ComplexErrors[];\n const simpleRuleErrors = getSimpleRuleErrors(criteriaErrors);\n\n if (Array.isArray(simpleRuleErrors) && simpleRuleErrors.length > 0) {\n const updatedCriteriaErrors = [\n ...simpleRuleErrors.filter((_, rindex) => rindex !== index),\n ...getNestedRuleErrors(criteriaErrors),\n ];\n\n updatedErrors[activeCriteria] =\n updatedCriteriaErrors.length > 0 ? updatedCriteriaErrors : [];\n } else {\n delete updatedErrors[activeCriteria];\n }\n }\n\n return updatedErrors;\n });\n };\n\n const handleRemoveNestedConditionRule = (nestedConditionCriteria: string) => {\n const updatedNestedConditionRow: Condition[] = [];\n\n nestedConditionRow.forEach((c, index) => {\n if (index === nestedConditionIndex) {\n const updatedRules = (\n (c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []\n ).filter((_r, rindex) => rindex !== ruleIndex);\n updatedNestedConditionRow.push({\n [nestedConditionCriteria as keyof Condition]: updatedRules,\n });\n } else {\n updatedNestedConditionRow.push(c);\n }\n });\n\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria] as ComplexErrors[];\n\n if (\n criteria === criterias.not &&\n notConditionType === 'nested-condition'\n ) {\n (\n (updatedErrors[criteria] as NestedCriteriaErrors)[\n nestedConditionCriteria\n ] as string[]\n ).splice(ruleIndex, 1);\n return updatedErrors;\n }\n\n const nestedConditionErrors = getNestedRuleErrors(criteriaErrors);\n\n if (\n Array.isArray(nestedConditionErrors) &&\n nestedConditionIndex !== undefined\n ) {\n const nestedErrors = nestedConditionErrors[nestedConditionIndex];\n if (nestedErrors[nestedConditionCriteria]) {\n const updatedNestedErrors = (\n nestedErrors[nestedConditionCriteria] as string[]\n ).filter((_error, index) => index !== ruleIndex);\n\n if (updatedNestedErrors.length > 0) {\n nestedErrors[nestedConditionCriteria] = updatedNestedErrors;\n } else {\n delete nestedErrors[nestedConditionCriteria];\n }\n\n nestedConditionErrors[nestedConditionIndex] = nestedErrors;\n }\n\n updatedErrors[criteria] = [\n ...getSimpleRuleErrors(criteriaErrors),\n ...nestedConditionErrors,\n ];\n }\n }\n\n return updatedErrors;\n });\n };\n\n const ruleList = isNestedCondition\n ? (currentCondition[\n activeCriteria as keyof Condition\n ] as PermissionCondition[])\n : ((conditionRow[activeCriteria as keyof Condition] as Condition[]).filter(\n r => isSimpleRule(r),\n ) as PermissionCondition[]);\n\n const disabled =\n !isNestedCondition &&\n (conditionRow[criteria as keyof Condition] as Condition[]).length === 1 &&\n nestedConditionRow.length === 0 &&\n ruleIndex === 0;\n const nestedDisabled =\n isNestedCondition &&\n (\n nestedConditionRow[nestedConditionIndex ?? 0][\n activeNestedCriteria as keyof Condition\n ] as Condition[]\n ).length === 1 &&\n ruleIndex === 0;\n\n return (\n (currentCondition as PermissionCondition).resourceType && (\n <div\n style={getRowStyle(currentCondition, isNestedCondition)}\n key={getRowKey(isNestedCondition, ruleIndex)}\n >\n <ConditionsFormRowFields\n oldCondition={currentCondition}\n index={isNestedCondition ? undefined : ruleIndex}\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n nestedConditionRow={\n isNestedCondition ? nestedConditionRow : undefined\n }\n nestedConditionCriteria={\n isNestedCondition ? activeNestedCriteria : undefined\n }\n nestedConditionIndex={\n isNestedCondition ? nestedConditionIndex : undefined\n }\n nestedConditionRuleIndex={isNestedCondition ? ruleIndex : undefined}\n updateRules={isNestedCondition ? updateRules : undefined}\n />\n <IconButton\n title=\"Remove\"\n sx={{\n color: theme => theme.palette.grey[500],\n flexGrow: 0,\n alignSelf: 'baseline',\n marginTop: theme => theme.spacing(3.3),\n }}\n disabled={isNestedCondition ? nestedDisabled : disabled}\n onClick={\n isNestedCondition &&\n activeNestedCriteria &&\n nestedConditionIndex !== undefined\n ? () => handleRemoveNestedConditionRule(activeNestedCriteria)\n : () => {\n handleRemoveSimpleConditionRule(ruleIndex, ruleList);\n }\n }\n >\n <RemoveIcon />\n </IconButton>\n </div>\n )\n );\n};\n"],"names":["ruleList"],"mappings":";;;;;;;AA2DO,MAAM,sBAAsB,CAAC;AAAA,EAClC,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,iBAAoB,GAAA,KAAA;AAAA,EACpB,oBAAA;AAAA,EACA;AACF,CAAgC,KAAA;AAC9B,EAAM,MAAA,+BAAA,GAAkC,CACtC,KAAA,EACAA,SACG,KAAA;AACH,IAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,MAAA;AAAA;AAEF,IAAA,MAAM,qBAAqBA,SAAS,CAAA,MAAA;AAAA,MAClC,CAAC,EAAI,EAAA,MAAA,KAAW,KAAU,KAAA;AAAA,KAC5B;AACA,IAAM,MAAA,gBAAA,GACH,YAAa,CAAA,QAAQ,CAA6B,EAAA,MAAA;AAAA,MACjD,CAAC,QACC,SAAU,CAAA,KAAA,IAAS,OACnB,SAAU,CAAA,KAAA,IAAS,GACnB,IAAA,SAAA,CAAU,GAAO,IAAA;AAAA,SAChB,EAAC;AAER,IAAa,YAAA,CAAA;AAAA,MACX,CAAC,cAAsC,GAAG;AAAA,QACxC,GAAG,kBAAA;AAAA,QACH,GAAG;AAAA;AACL,KACD,CAAA;AAED,IAAA,SAAA,CAAU,CAAc,UAA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A;AAAA,YACN,EAAI,EAAA;AAAA,cACF,KAAO,EAAA,CAAA,KAAA,KAAS,KAAM,CAAA,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,cACtC,QAAU,EAAA,CAAA;AAAA,cACV,SAAW,EAAA,UAAA;AAAA,cACX,SAAW,EAAA,CAAA,KAAA,KAAS,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA,aACvC;AAAA,YACA,QAAA,EAAU,oBAAoB,cAAiB,GAAA,QAAA;AAAA,YAC/C,OAAA,EACE,qBACA,oBACA,IAAA,oBAAA,KAAyB,YACrB,MAAM,+BAAA,CAAgC,oBAAoB,CAAA,GAC1D,MAAM;AACJ,cAAA,+BAAA,CAAgC,WAAW,QAAQ,CAAA;AAAA,aACrD;AAAA,YAGN,8BAAC,UAAW,EAAA,EAAA;AAAA;AAAA;AACd;AAAA,KAAA;AAAA,IA3CK,SAAA,CAAU,mBAAmB,SAAS;AAAA,GA4C7C;AAGN;;;;"}
|
|
1
|
+
{"version":3,"file":"ComplexConditionRow.esm.js","sources":["../../../src/components/ConditionalAccess/ComplexConditionRow.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 type { SetStateAction, Dispatch } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport RemoveIcon from '@mui/icons-material/Remove';\nimport IconButton from '@mui/material/IconButton';\n\nimport {\n getNestedRuleErrors,\n getRowKey,\n getRowStyle,\n getSimpleRuleErrors,\n isSimpleRule,\n} from '../../utils/conditional-access-utils';\nimport { ConditionsFormRowFields } from './ConditionsFormRowFields';\nimport { criterias } from './const';\nimport {\n AccessConditionsErrors,\n ComplexErrors,\n Condition,\n ConditionsData,\n NestedCriteriaErrors,\n NotConditionType,\n RulesData,\n} from './types';\n\ntype ComplexConditionRowProps = {\n conditionRow: ConditionsData;\n nestedConditionRow: Condition[];\n criteria: keyof ConditionsData;\n onRuleChange: (newCondition: ConditionsData) => void;\n updateRules: (updatedNestedConditionRow: Condition[] | Condition) => void;\n setErrors: Dispatch<SetStateAction<AccessConditionsErrors | undefined>>;\n setRemoveAllClicked: Dispatch<SetStateAction<boolean>>;\n conditionRulesData?: RulesData;\n notConditionType?: NotConditionType;\n currentCondition: Condition;\n ruleIndex: number;\n activeCriteria?: 'allOf' | 'anyOf';\n isNestedCondition?: boolean;\n nestedConditionIndex?: number;\n activeNestedCriteria?: 'allOf' | 'anyOf';\n};\n\nexport const ComplexConditionRow = ({\n conditionRow,\n nestedConditionRow,\n criteria,\n onRuleChange,\n updateRules,\n setErrors,\n setRemoveAllClicked,\n conditionRulesData,\n notConditionType,\n currentCondition,\n ruleIndex,\n activeCriteria,\n isNestedCondition = false,\n nestedConditionIndex,\n activeNestedCriteria,\n}: ComplexConditionRowProps) => {\n const handleRemoveSimpleConditionRule = (\n index: number,\n ruleList: PermissionCondition[],\n ) => {\n if (!activeCriteria) {\n return;\n }\n const updatedSimpleRules = ruleList.filter(\n (_r, rindex) => index !== rindex,\n );\n const nestedConditions =\n (conditionRow[criteria] as PermissionCondition[])?.filter(\n (con: PermissionCondition) =>\n criterias.allOf in con ||\n criterias.anyOf in con ||\n criterias.not in con,\n ) || [];\n\n onRuleChange({\n [activeCriteria as keyof ConditionsData]: [\n ...updatedSimpleRules,\n ...nestedConditions,\n ],\n });\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[activeCriteria]) {\n const criteriaErrors = updatedErrors[activeCriteria] as ComplexErrors[];\n const simpleRuleErrors = getSimpleRuleErrors(criteriaErrors);\n\n if (Array.isArray(simpleRuleErrors) && simpleRuleErrors.length > 0) {\n const updatedCriteriaErrors = [\n ...simpleRuleErrors.filter((_, rindex) => rindex !== index),\n ...getNestedRuleErrors(criteriaErrors),\n ];\n\n updatedErrors[activeCriteria] =\n updatedCriteriaErrors.length > 0 ? updatedCriteriaErrors : [];\n } else {\n delete updatedErrors[activeCriteria];\n }\n }\n\n return updatedErrors;\n });\n };\n\n const handleRemoveNestedConditionRule = (nestedConditionCriteria: string) => {\n const updatedNestedConditionRow: Condition[] = [];\n\n nestedConditionRow.forEach((c, index) => {\n if (index === nestedConditionIndex) {\n const updatedRules = (\n (c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []\n ).filter((_r, rindex) => rindex !== ruleIndex);\n updatedNestedConditionRow.push({\n [nestedConditionCriteria as keyof Condition]: updatedRules,\n });\n } else {\n updatedNestedConditionRow.push(c);\n }\n });\n\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria] as ComplexErrors[];\n\n if (\n criteria === criterias.not &&\n notConditionType === 'nested-condition'\n ) {\n (\n (updatedErrors[criteria] as NestedCriteriaErrors)[\n nestedConditionCriteria\n ] as string[]\n ).splice(ruleIndex, 1);\n return updatedErrors;\n }\n\n const nestedConditionErrors = getNestedRuleErrors(criteriaErrors);\n\n if (\n Array.isArray(nestedConditionErrors) &&\n nestedConditionIndex !== undefined\n ) {\n const nestedErrors = nestedConditionErrors[nestedConditionIndex];\n if (nestedErrors[nestedConditionCriteria]) {\n const updatedNestedErrors = (\n nestedErrors[nestedConditionCriteria] as string[]\n ).filter((_error, index) => index !== ruleIndex);\n\n if (updatedNestedErrors.length > 0) {\n nestedErrors[nestedConditionCriteria] = updatedNestedErrors;\n } else {\n delete nestedErrors[nestedConditionCriteria];\n }\n\n nestedConditionErrors[nestedConditionIndex] = nestedErrors;\n }\n\n updatedErrors[criteria] = [\n ...getSimpleRuleErrors(criteriaErrors),\n ...nestedConditionErrors,\n ];\n }\n }\n\n return updatedErrors;\n });\n };\n\n const ruleList = isNestedCondition\n ? (currentCondition[\n activeCriteria as keyof Condition\n ] as PermissionCondition[])\n : ((conditionRow[activeCriteria as keyof Condition] as Condition[]).filter(\n r => isSimpleRule(r),\n ) as PermissionCondition[]);\n\n const disabled =\n !isNestedCondition &&\n (conditionRow[criteria as keyof Condition] as Condition[]).length === 1 &&\n nestedConditionRow.length === 0 &&\n ruleIndex === 0;\n const nestedDisabled =\n isNestedCondition &&\n (\n nestedConditionRow[nestedConditionIndex ?? 0][\n activeNestedCriteria as keyof Condition\n ] as Condition[]\n ).length === 1 &&\n ruleIndex === 0;\n\n return (\n (currentCondition as PermissionCondition).resourceType && (\n <div\n style={getRowStyle(currentCondition, isNestedCondition)}\n key={getRowKey(isNestedCondition, ruleIndex)}\n >\n <ConditionsFormRowFields\n oldCondition={currentCondition}\n index={isNestedCondition ? undefined : ruleIndex}\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n nestedConditionRow={\n isNestedCondition ? nestedConditionRow : undefined\n }\n nestedConditionCriteria={\n isNestedCondition ? activeNestedCriteria : undefined\n }\n nestedConditionIndex={\n isNestedCondition ? nestedConditionIndex : undefined\n }\n nestedConditionRuleIndex={isNestedCondition ? ruleIndex : undefined}\n updateRules={isNestedCondition ? updateRules : undefined}\n />\n <IconButton\n title=\"Remove\"\n sx={{\n color: theme => theme.palette.grey[500],\n flexGrow: 0,\n alignSelf: 'baseline',\n mt: '34px',\n }}\n disabled={isNestedCondition ? nestedDisabled : disabled}\n onClick={\n isNestedCondition &&\n activeNestedCriteria &&\n nestedConditionIndex !== undefined\n ? () => handleRemoveNestedConditionRule(activeNestedCriteria)\n : () => {\n handleRemoveSimpleConditionRule(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AAA,QAAA;AAAA,YAC/C,OAAA,EACE,qBACA,oBACA,IAAA,oBAAA,KAAyB,YACrB,MAAM,+BAAA,CAAgC,oBAAoB,CAAA,GAC1D,MAAM;AACJ,cAAA,+BAAA,CAAgC,WAAW,QAAQ,CAAA;AAAA,aACrD;AAAA,YAGN,8BAAC,UAAW,EAAA,EAAA;AAAA;AAAA;AACd;AAAA,KAAA;AAAA,IA3CK,SAAA,CAAU,mBAAmB,SAAS;AAAA,GA4C7C;AAGN;;;;"}
|
|
@@ -4,6 +4,7 @@ import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
|
4
4
|
import Box from '@mui/material/Box';
|
|
5
5
|
import Button from '@mui/material/Button';
|
|
6
6
|
import Tooltip from '@mui/material/Tooltip';
|
|
7
|
+
import Typography from '@mui/material/Typography';
|
|
7
8
|
import { getDefaultRule } from '../../utils/conditional-access-utils.esm.js';
|
|
8
9
|
import { tooltipTitle } from './AddNestedConditionButton.esm.js';
|
|
9
10
|
import { criterias } from './const.esm.js';
|
|
@@ -41,11 +42,12 @@ const ComplexConditionRowButtons = ({
|
|
|
41
42
|
return (criteria === criterias.allOf || criteria === criterias.anyOf) && /* @__PURE__ */ jsxs(
|
|
42
43
|
Box,
|
|
43
44
|
{
|
|
44
|
-
mt:
|
|
45
|
-
mb: 1,
|
|
45
|
+
mt: 2,
|
|
46
46
|
sx: {
|
|
47
47
|
display: "flex",
|
|
48
48
|
flexDirection: "column",
|
|
49
|
+
justifyContent: "space-between",
|
|
50
|
+
gap: 1,
|
|
49
51
|
alignItems: "flex-start"
|
|
50
52
|
},
|
|
51
53
|
children: [
|
|
@@ -58,10 +60,10 @@ const ComplexConditionRowButtons = ({
|
|
|
58
60
|
size: "small",
|
|
59
61
|
onClick: handleAddRule,
|
|
60
62
|
startIcon: /* @__PURE__ */ jsx(AddIcon, { fontSize: "small" }),
|
|
61
|
-
children: "Add rule"
|
|
63
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "span", children: "Add rule" })
|
|
62
64
|
}
|
|
63
65
|
),
|
|
64
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ jsxs(
|
|
65
67
|
Button,
|
|
66
68
|
{
|
|
67
69
|
sx: {
|
|
@@ -70,14 +72,10 @@ const ComplexConditionRowButtons = ({
|
|
|
70
72
|
size: "small",
|
|
71
73
|
onClick: () => handleAddNestedCondition(criteria),
|
|
72
74
|
startIcon: /* @__PURE__ */ jsx(AddIcon, { fontSize: "small" }),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
style: { marginLeft: "0.25rem" }
|
|
78
|
-
}
|
|
79
|
-
) }),
|
|
80
|
-
children: "Add Nested Condition"
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", component: "span", children: "Add nested condition" }),
|
|
77
|
+
/* @__PURE__ */ jsx(Tooltip, { title: tooltipTitle(), placement: "top", children: /* @__PURE__ */ jsx(HelpOutlineIcon, { fontSize: "inherit", style: { marginLeft: 4 } }) })
|
|
78
|
+
]
|
|
81
79
|
}
|
|
82
80
|
)
|
|
83
81
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplexConditionRowButtons.esm.js","sources":["../../../src/components/ConditionalAccess/ComplexConditionRowButtons.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 AddIcon from '@mui/icons-material/Add';\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport { getDefaultRule } from '../../utils/conditional-access-utils';\nimport { tooltipTitle } from './AddNestedConditionButton';\nimport { criterias } from './const';\nimport { Condition, ConditionsData } from './types';\n\ntype ComplexConditionRowButtonsProps = {\n conditionRow: ConditionsData;\n onRuleChange: (newCondition: ConditionsData) => void;\n criteria: string;\n selPluginResourceType: string;\n updateErrors: (_index: number) => void;\n isNestedConditionRule: (condition: Condition) => boolean;\n handleAddNestedCondition: (criteria: string) => void;\n};\n\nexport const ComplexConditionRowButtons = ({\n conditionRow,\n onRuleChange,\n criteria,\n selPluginResourceType,\n updateErrors,\n isNestedConditionRule,\n handleAddNestedCondition,\n}: ComplexConditionRowButtonsProps) => {\n const findFirstNestedConditionIndex = (rules: Condition[]): number => {\n return rules.findIndex(e => isNestedConditionRule(e)) || 0;\n };\n const handleAddRule = () => {\n const updatedRules = [\n ...(conditionRow.allOf ?? []),\n ...(conditionRow.anyOf ?? []),\n ];\n\n const firstNestedConditionIndex =\n findFirstNestedConditionIndex(updatedRules);\n if (firstNestedConditionIndex !== -1) {\n updatedRules.splice(\n firstNestedConditionIndex,\n 0,\n getDefaultRule(selPluginResourceType),\n );\n } else {\n updatedRules.push(getDefaultRule(selPluginResourceType));\n }\n\n onRuleChange({ [criteria]: [...updatedRules] });\n updateErrors(firstNestedConditionIndex);\n };\n\n return (\n (criteria === criterias.allOf || criteria === criterias.anyOf) && (\n <Box\n mt={
|
|
1
|
+
{"version":3,"file":"ComplexConditionRowButtons.esm.js","sources":["../../../src/components/ConditionalAccess/ComplexConditionRowButtons.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 AddIcon from '@mui/icons-material/Add';\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\n\nimport { getDefaultRule } from '../../utils/conditional-access-utils';\nimport { tooltipTitle } from './AddNestedConditionButton';\nimport { criterias } from './const';\nimport { Condition, ConditionsData } from './types';\n\ntype ComplexConditionRowButtonsProps = {\n conditionRow: ConditionsData;\n onRuleChange: (newCondition: ConditionsData) => void;\n criteria: string;\n selPluginResourceType: string;\n updateErrors: (_index: number) => void;\n isNestedConditionRule: (condition: Condition) => boolean;\n handleAddNestedCondition: (criteria: string) => void;\n};\n\nexport const ComplexConditionRowButtons = ({\n conditionRow,\n onRuleChange,\n criteria,\n selPluginResourceType,\n updateErrors,\n isNestedConditionRule,\n handleAddNestedCondition,\n}: ComplexConditionRowButtonsProps) => {\n const findFirstNestedConditionIndex = (rules: Condition[]): number => {\n return rules.findIndex(e => isNestedConditionRule(e)) || 0;\n };\n const handleAddRule = () => {\n const updatedRules = [\n ...(conditionRow.allOf ?? []),\n ...(conditionRow.anyOf ?? []),\n ];\n\n const firstNestedConditionIndex =\n findFirstNestedConditionIndex(updatedRules);\n if (firstNestedConditionIndex !== -1) {\n updatedRules.splice(\n firstNestedConditionIndex,\n 0,\n getDefaultRule(selPluginResourceType),\n );\n } else {\n updatedRules.push(getDefaultRule(selPluginResourceType));\n }\n\n onRuleChange({ [criteria]: [...updatedRules] });\n updateErrors(firstNestedConditionIndex);\n };\n\n return (\n (criteria === criterias.allOf || criteria === criterias.anyOf) && (\n <Box\n mt={2}\n sx={{\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n gap: 1,\n alignItems: 'flex-start',\n }}\n >\n <Button\n sx={{\n color: theme => theme.palette.primary.light,\n }}\n size=\"small\"\n onClick={handleAddRule}\n startIcon={<AddIcon fontSize=\"small\" />}\n >\n <Typography variant=\"body2\" component=\"span\">\n Add rule\n </Typography>\n </Button>\n <Button\n sx={{\n color: theme => theme.palette.primary.light,\n }}\n size=\"small\"\n onClick={() => handleAddNestedCondition(criteria)}\n startIcon={<AddIcon fontSize=\"small\" />}\n >\n <Typography variant=\"body2\" component=\"span\">\n Add nested condition\n </Typography>\n <Tooltip title={tooltipTitle()} placement=\"top\">\n <HelpOutlineIcon fontSize=\"inherit\" style={{ marginLeft: 4 }} />\n </Tooltip>\n </Button>\n </Box>\n )\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAqCO,MAAM,6BAA6B,CAAC;AAAA,EACzC,YAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,qBAAA;AAAA,EACA,YAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAuC,KAAA;AACrC,EAAM,MAAA,6BAAA,GAAgC,CAAC,KAA+B,KAAA;AACpE,IAAA,OAAO,MAAM,SAAU,CAAA,CAAA,CAAA,KAAK,qBAAsB,CAAA,CAAC,CAAC,CAAK,IAAA,CAAA;AAAA,GAC3D;AACA,EAAA,MAAM,gBAAgB,MAAM;AAC1B,IAAA,MAAM,YAAe,GAAA;AAAA,MACnB,GAAI,YAAa,CAAA,KAAA,IAAS,EAAC;AAAA,MAC3B,GAAI,YAAa,CAAA,KAAA,IAAS;AAAC,KAC7B;AAEA,IAAM,MAAA,yBAAA,GACJ,8BAA8B,YAAY,CAAA;AAC5C,IAAA,IAAI,8BAA8B,EAAI,EAAA;AACpC,MAAa,YAAA,CAAA,MAAA;AAAA,QACX,yBAAA;AAAA,QACA,CAAA;AAAA,QACA,eAAe,qBAAqB;AAAA,OACtC;AAAA,KACK,MAAA;AACL,MAAa,YAAA,CAAA,IAAA,CAAK,cAAe,CAAA,qBAAqB,CAAC,CAAA;AAAA;AAGzD,IAAa,YAAA,CAAA,EAAE,CAAC,QAAQ,GAAG,CAAC,GAA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GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,SAAA,EAAU,QAAO,QAE7C,EAAA,sBAAA,EAAA,CAAA;AAAA,kCACC,OAAQ,EAAA,EAAA,KAAA,EAAO,YAAa,EAAA,EAAG,WAAU,KACxC,EAAA,QAAA,kBAAA,GAAA,CAAC,eAAgB,EAAA,EAAA,QAAA,EAAS,WAAU,KAAO,EAAA,EAAE,UAAY,EAAA,CAAA,IAAK,CAChE,EAAA;AAAA;AAAA;AAAA;AACF;AAAA;AAAA,GACF;AAGN;;;;"}
|
|
@@ -19,6 +19,7 @@ import { ConditionsFormRowFields } from './ConditionsFormRowFields.esm.js';
|
|
|
19
19
|
import { criterias, conditionButtons } from './const.esm.js';
|
|
20
20
|
import { CriteriaToggleButton } from './CriteriaToggleButton.esm.js';
|
|
21
21
|
import { NotConditionType } from './types.esm.js';
|
|
22
|
+
import Typography from '@mui/material/Typography';
|
|
22
23
|
|
|
23
24
|
const ConditionsFormRow = ({
|
|
24
25
|
conditionRulesData,
|
|
@@ -364,7 +365,7 @@ const ConditionsFormRow = ({
|
|
|
364
365
|
Button,
|
|
365
366
|
{
|
|
366
367
|
sx: {
|
|
367
|
-
mt:
|
|
368
|
+
mt: 2,
|
|
368
369
|
color: theme.palette.primary.light
|
|
369
370
|
},
|
|
370
371
|
size: "small",
|
|
@@ -373,7 +374,7 @@ const ConditionsFormRow = ({
|
|
|
373
374
|
nestedConditionIndex
|
|
374
375
|
),
|
|
375
376
|
startIcon: /* @__PURE__ */ jsx(AddIcon, { fontSize: "small" }),
|
|
376
|
-
children: "Add rule"
|
|
377
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "span", children: "Add rule" })
|
|
377
378
|
}
|
|
378
379
|
)
|
|
379
380
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionsFormRow.esm.js","sources":["../../../src/components/ConditionalAccess/ConditionsFormRow.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 { useState, useEffect } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport AddIcon from '@mui/icons-material/Add';\nimport RemoveIcon from '@mui/icons-material/Remove';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport IconButton from '@mui/material/IconButton';\nimport Radio from '@mui/material/Radio';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { useTheme } from '@mui/material/styles';\nimport ToggleButtonGroup from '@mui/material/ToggleButtonGroup';\n\nimport {\n extractNestedConditions,\n getDefaultRule,\n getNestedConditionSimpleRulesCount,\n getSimpleRulesCount,\n isNestedConditionRule,\n isSimpleRule,\n nestedConditionButtons,\n resetErrors,\n ruleOptionDisabled,\n} from '../../utils/conditional-access-utils';\nimport { AddNestedConditionButton } from './AddNestedConditionButton';\nimport { ComplexConditionRow } from './ComplexConditionRow';\nimport { ComplexConditionRowButtons } from './ComplexConditionRowButtons';\nimport { ConditionRule } from './ConditionRule';\nimport { ConditionsFormRowFields } from './ConditionsFormRowFields';\nimport { conditionButtons, criterias } from './const';\nimport { CriteriaToggleButton } from './CriteriaToggleButton';\nimport {\n ComplexErrors,\n Condition,\n ConditionFormRowProps,\n ConditionsData,\n NestedCriteriaErrors,\n NotConditionType,\n} from './types';\n\nexport const ConditionsFormRow = ({\n conditionRulesData,\n conditionRow,\n selPluginResourceType,\n criteria,\n onRuleChange,\n setCriteria,\n setErrors,\n setRemoveAllClicked,\n}: ConditionFormRowProps) => {\n const theme = useTheme();\n const [nestedConditionRow, setNestedConditionRow] = useState<Condition[]>([]);\n const [notConditionType, setNotConditionType] = useState<NotConditionType>(\n NotConditionType.SimpleCondition,\n );\n\n useEffect(() => {\n const nestedConditions: Condition[] = [];\n const criteriaTypes = [criterias.allOf, criterias.anyOf, criterias.not];\n switch (criteria) {\n case criterias.allOf:\n extractNestedConditions(\n conditionRow.allOf || [],\n criteriaTypes,\n nestedConditions,\n );\n break;\n case criterias.anyOf:\n extractNestedConditions(\n conditionRow.anyOf || [],\n criteriaTypes,\n nestedConditions,\n );\n break;\n case criterias.not:\n if (\n conditionRow.not &&\n criteriaTypes.includes(\n Object.keys(conditionRow.not)[0] as keyof ConditionsData,\n )\n ) {\n nestedConditions.push(conditionRow.not);\n setNotConditionType(NotConditionType.NestedCondition);\n }\n break;\n default:\n break;\n }\n\n setNestedConditionRow(nestedConditions);\n }, [conditionRow, criteria]);\n\n const handleCriteriaChange = (val: keyof ConditionsData) => {\n setCriteria(val);\n setErrors(resetErrors(val));\n\n const defaultRule = getDefaultRule(selPluginResourceType);\n\n const ruleMap = {\n [criterias.condition]: { condition: defaultRule },\n [criterias.allOf]: { allOf: [defaultRule] },\n [criterias.anyOf]: { anyOf: [defaultRule] },\n [criterias.not]: { not: defaultRule },\n };\n\n if (val === criterias.not) {\n setNotConditionType(NotConditionType.SimpleCondition);\n }\n\n const ruleChange = ruleMap[val];\n if (ruleChange) {\n onRuleChange(ruleChange);\n }\n };\n\n const updateRules = (updatedNestedConditionRow: Condition[] | Condition) => {\n const existingSimpleCondition =\n criteria !== criterias.not\n ? (conditionRow[criteria as keyof Condition] as Condition[])?.filter(\n con => isSimpleRule(con),\n ) || []\n : [];\n\n const newCondition: Condition[] = Array.isArray(updatedNestedConditionRow)\n ? [...existingSimpleCondition, ...updatedNestedConditionRow]\n : [...existingSimpleCondition, updatedNestedConditionRow];\n\n if (criteria === criterias.anyOf || criteria === criterias.allOf) {\n onRuleChange({\n [criteria]: newCondition,\n });\n } else if (\n criteria === criterias.not &&\n !Array.isArray(updatedNestedConditionRow)\n ) {\n onRuleChange({\n not: updatedNestedConditionRow,\n });\n }\n };\n\n const handleNestedConditionCriteriaChange = (\n val: string,\n nestedConditionIndex: number,\n ) => {\n const defaultRule = getDefaultRule(selPluginResourceType);\n\n const nestedConditionMap = {\n [criterias.not]: { [val]: defaultRule },\n [criterias.allOf]: { [val]: [defaultRule] },\n [criterias.anyOf]: { [val]: [defaultRule] },\n [criterias.condition]: { [val]: [defaultRule] },\n };\n\n const newCondition = nestedConditionMap[val] || { [val]: [defaultRule] };\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n if (criteria === criterias.not) {\n (updatedErrors[criteria] as ComplexErrors) =\n val !== criterias.not ? { [val]: [''] } : { [val]: '' };\n return updatedErrors;\n }\n const criteriaErrors = updatedErrors[criteria];\n const simpleRuleErrors = (criteriaErrors as ComplexErrors[]).filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = (\n criteriaErrors as ComplexErrors[]\n ).filter((err: ComplexErrors) => typeof err !== 'string');\n nestedConditionErrors[nestedConditionIndex] =\n val !== criterias.not ? { [val]: [''] } : { [val]: '' };\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n\n return updatedErrors;\n });\n\n if (criteria === criterias.not) {\n updateRules(newCondition);\n } else {\n const updatedNestedConditionRow = nestedConditionRow.map((c, index) => {\n if (index === nestedConditionIndex) {\n return newCondition;\n }\n return c;\n });\n updateRules(updatedNestedConditionRow);\n }\n };\n\n const handleAddNestedCondition = (currentCriteria: string) => {\n const newNestedCondition = {\n [criterias.allOf]: [getDefaultRule(selPluginResourceType)],\n };\n const updatedNestedConditionRow = [\n ...nestedConditionRow,\n newNestedCondition,\n ];\n updateRules(\n currentCriteria === criterias.not\n ? newNestedCondition\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n if (updatedErrors[currentCriteria]) {\n const criteriaErrors = updatedErrors[\n currentCriteria\n ] as ComplexErrors[];\n if (Array.isArray(criteriaErrors)) {\n criteriaErrors.push({ [criterias.allOf]: [''] });\n } else {\n (updatedErrors[currentCriteria] as ComplexErrors) = {\n [criterias.allOf]: [''],\n };\n }\n }\n return updatedErrors;\n });\n };\n\n const handleNotConditionTypeChange = (val: NotConditionType) => {\n setNotConditionType(val);\n setErrors(resetErrors(criteria, val));\n if (val === 'nested-condition') {\n handleAddNestedCondition(criterias.not);\n } else {\n onRuleChange({\n not: getDefaultRule(selPluginResourceType),\n });\n }\n };\n\n const handleAddRuleInNestedCondition = (\n nestedConditionCriteria: string,\n nestedConditionIndex: number,\n ) => {\n const updatedNestedConditionRow: Condition[] = [];\n\n nestedConditionRow.forEach((c, index) => {\n if (index === nestedConditionIndex) {\n updatedNestedConditionRow.push({\n [nestedConditionCriteria as keyof Condition]: [\n ...((c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []),\n getDefaultRule(selPluginResourceType),\n ],\n });\n } else {\n updatedNestedConditionRow.push(c);\n }\n });\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria];\n if (\n criteria === criterias.not &&\n notConditionType === 'nested-condition'\n ) {\n (\n (criteriaErrors as NestedCriteriaErrors)[\n nestedConditionCriteria\n ] as string[]\n ).push('');\n return updatedErrors;\n }\n const simpleRuleErrors = (criteriaErrors as ComplexErrors[]).filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = (\n criteriaErrors as ComplexErrors[]\n ).filter((err: ComplexErrors) => typeof err !== 'string');\n\n (\n ((\n nestedConditionErrors[nestedConditionIndex] as NestedCriteriaErrors\n )[nestedConditionCriteria] as string[]) || []\n ).push('');\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n return updatedErrors;\n });\n };\n\n const handleRemoveNestedCondition = (nestedConditionIndex: number) => {\n const updatedNestedConditionRow = nestedConditionRow.filter(\n (_, index) => index !== nestedConditionIndex,\n );\n\n updateRules(updatedNestedConditionRow);\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria] as ComplexErrors[];\n const simpleRuleErrors = criteriaErrors.filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = criteriaErrors.filter(\n (err: ComplexErrors) => typeof err !== 'string',\n );\n nestedConditionErrors.splice(nestedConditionIndex, 1);\n\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n\n return updatedErrors;\n });\n };\n\n const updateErrors = (_index: number) => {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (!Array.isArray(updatedErrors[criteria])) {\n updatedErrors[criteria] = [];\n }\n\n const firstNestedConditionErrorIndex =\n (updatedErrors[criteria] as ComplexErrors[]).findIndex(\n e => typeof e !== 'string',\n ) || 0;\n\n (updatedErrors[criteria] as ComplexErrors[]).splice(\n firstNestedConditionErrorIndex,\n 0,\n '',\n );\n\n return updatedErrors;\n });\n };\n\n const renderNestedConditionRow = (\n nc: Condition,\n nestedConditionIndex: number,\n ) => {\n const selectedNestedConditionCriteria = Object.keys(nc)[0];\n const simpleRulesCount = getSimpleRulesCount(conditionRow, criteria);\n const nestedConditionsCount = nestedConditionRow.length;\n const nestedConditionSimpleRulesCount = getNestedConditionSimpleRulesCount(\n nc,\n selectedNestedConditionCriteria,\n );\n return (\n nestedConditionSimpleRulesCount > 0 && (\n <Box\n mt={2}\n key={`nestedCondition-${nestedConditionIndex}`}\n sx={{\n padding: '20px',\n marginLeft: theme.spacing(3),\n border: `1px solid ${theme.palette.border}`,\n borderRadius: '4px',\n backgroundColor: theme.palette.background.default,\n '& input': {\n backgroundColor: `${theme.palette.background.paper}!important`,\n },\n }}\n >\n <div style={{ display: 'flex', justifyContent: 'space-between' }}>\n <ToggleButtonGroup\n exclusive\n value={selectedNestedConditionCriteria}\n onChange={(_event, newNestedCriteria) =>\n handleNestedConditionCriteriaChange(\n newNestedCriteria,\n nestedConditionIndex,\n )\n }\n sx={{\n backgroundColor: theme.palette.background.paper,\n width: '60%',\n height: '100%',\n }}\n >\n {nestedConditionButtons.map(({ val, label }) => (\n <CriteriaToggleButton\n key={`nested-criteria-${val}`}\n val={val}\n label={label}\n selectedCriteria={selectedNestedConditionCriteria}\n theme={theme}\n />\n ))}\n </ToggleButtonGroup>\n {criteria !== criterias.not && (\n <IconButton\n title=\"Remove nested condition\"\n sx={{\n color: theme.palette.grey[500],\n flexGrow: 0,\n alignSelf: 'baseline',\n }}\n disabled={simpleRulesCount === 0 && nestedConditionsCount === 1} // 0 simple rules and this is the only 1 nested condition\n onClick={() =>\n handleRemoveNestedCondition(nestedConditionIndex)\n }\n >\n <RemoveIcon data-testid=\"remove-nested-condition\" />\n </IconButton>\n )}\n </div>\n <Box>\n {selectedNestedConditionCriteria !== criterias.not &&\n (\n nc[\n selectedNestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]\n ).map((c, ncrIndex) => (\n <ComplexConditionRow\n key={`nested-condition-${nestedConditionIndex}-${ncrIndex}`}\n conditionRow={conditionRow}\n nestedConditionRow={nestedConditionRow}\n criteria={criteria}\n onRuleChange={onRuleChange}\n updateRules={updateRules}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n conditionRulesData={conditionRulesData}\n notConditionType={notConditionType}\n currentCondition={c}\n ruleIndex={ncrIndex}\n isNestedCondition\n nestedConditionIndex={nestedConditionIndex}\n activeNestedCriteria={\n selectedNestedConditionCriteria as 'allOf' | 'anyOf'\n }\n />\n ))}\n {selectedNestedConditionCriteria === criterias.not &&\n ((nc as ConditionsData).not as PermissionCondition)\n .resourceType && (\n <ConditionsFormRowFields\n oldCondition={\n (nc as ConditionsData).not ??\n getDefaultRule(selPluginResourceType)\n }\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n optionDisabled={ruleOption =>\n ruleOptionDisabled(\n ruleOption,\n (nc as ConditionsData).not\n ? [(nc as ConditionsData).not as PermissionCondition]\n : undefined,\n )\n }\n setRemoveAllClicked={setRemoveAllClicked}\n nestedConditionRow={nestedConditionRow}\n nestedConditionCriteria={selectedNestedConditionCriteria}\n nestedConditionIndex={nestedConditionIndex}\n updateRules={updateRules}\n />\n )}\n {selectedNestedConditionCriteria !== criterias.not && (\n <Button\n sx={{\n mt: 1,\n color: theme.palette.primary.light,\n }}\n size=\"small\"\n onClick={() =>\n handleAddRuleInNestedCondition(\n selectedNestedConditionCriteria,\n nestedConditionIndex,\n )\n }\n startIcon={<AddIcon fontSize=\"small\" />}\n >\n Add rule\n </Button>\n )}\n </Box>\n </Box>\n )\n );\n };\n\n return (\n <Box\n sx={{\n padding: '20px',\n border: `1px solid ${theme.palette.border}`,\n borderRadius: '4px',\n backgroundColor: theme.palette.background.default,\n '& input': {\n color: `${theme.palette.textContrast}!important`,\n '&:-internal-autofill-selected, &:-webkit-autofill, &:-webkit-autofill:hover, &:-webkit-autofill:focus, &:-webkit-autofill:active':\n {\n WebkitBoxShadow: `0 0 0px 1000px ${theme.palette.background.paper} inset`,\n WebkitTextFillColor: `${theme.palette.textContrast}!important`,\n caretColor: `${theme.palette.textContrast}!important`,\n },\n },\n '& button': {\n textTransform: 'none',\n },\n }}\n data-testid=\"conditions-row\"\n >\n <ToggleButtonGroup\n exclusive\n value={criteria}\n onChange={(_event, newCriteria) => handleCriteriaChange(newCriteria)}\n sx={{\n backgroundColor: theme.palette.background.paper,\n width: '80%',\n }}\n >\n {conditionButtons.map(({ val, label }) => (\n <CriteriaToggleButton\n key={`criteria-${val}`}\n val={val}\n label={label}\n selectedCriteria={criteria}\n theme={theme}\n />\n ))}\n </ToggleButtonGroup>\n <ConditionRule\n conditionRow={conditionRow}\n selPluginResourceType={selPluginResourceType}\n onRuleChange={onRuleChange}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n />\n {criteria !== criterias.condition && (\n <Box>\n {criteria !== criterias.not &&\n (conditionRow[criteria] as PermissionCondition[])?.map(\n (c, srIndex) => (\n <ComplexConditionRow\n key={`${criteria}-simple-condition-${srIndex}`}\n conditionRow={conditionRow}\n nestedConditionRow={nestedConditionRow}\n criteria={criteria}\n onRuleChange={onRuleChange}\n updateRules={updateRules}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n conditionRulesData={conditionRulesData}\n notConditionType={notConditionType}\n currentCondition={c}\n ruleIndex={srIndex}\n activeCriteria={criteria as 'allOf' | 'anyOf'}\n />\n ),\n )}\n {criteria === criterias.not && (\n <RadioGroup\n sx={{\n margin: theme.spacing(1),\n }}\n value={notConditionType}\n onChange={(_event, value) =>\n handleNotConditionTypeChange(value as NotConditionType)\n }\n >\n <FormControlLabel\n value={NotConditionType.SimpleCondition}\n control={<Radio color=\"primary\" />}\n label=\"Add rule\"\n sx={{\n marginTop: theme.spacing(1),\n }}\n />\n {notConditionType === NotConditionType.SimpleCondition && (\n <ConditionsFormRowFields\n oldCondition={\n conditionRow.not ?? getDefaultRule(selPluginResourceType)\n }\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n optionDisabled={ruleOption =>\n ruleOptionDisabled(\n ruleOption,\n conditionRow.not\n ? [conditionRow.not as PermissionCondition]\n : undefined,\n )\n }\n setRemoveAllClicked={setRemoveAllClicked}\n />\n )}\n <FormControlLabel\n value={NotConditionType.NestedCondition}\n control={<Radio color=\"primary\" />}\n label={<AddNestedConditionButton />}\n sx={{\n marginTop: theme.spacing(1),\n }}\n />\n </RadioGroup>\n )}\n <ComplexConditionRowButtons\n conditionRow={conditionRow}\n onRuleChange={onRuleChange}\n criteria={criteria}\n selPluginResourceType={selPluginResourceType}\n updateErrors={updateErrors}\n isNestedConditionRule={isNestedConditionRule}\n handleAddNestedCondition={handleAddNestedCondition}\n />\n {nestedConditionRow?.length > 0 &&\n nestedConditionRow.map((nc, nestedConditionIndex) =>\n renderNestedConditionRow(nc, nestedConditionIndex),\n )}\n </Box>\n )}\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDO,MAAM,oBAAoB,CAAC;AAAA,EAChC,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,qBAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAA,MAAM,CAAC,kBAAoB,EAAA,qBAAqB,CAAI,GAAA,QAAA,CAAsB,EAAE,CAAA;AAC5E,EAAM,MAAA,CAAC,gBAAkB,EAAA,mBAAmB,CAAI,GAAA,QAAA;AAAA,IAC9C,gBAAiB,CAAA;AAAA,GACnB;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,mBAAgC,EAAC;AACvC,IAAA,MAAM,gBAAgB,CAAC,SAAA,CAAU,OAAO,SAAU,CAAA,KAAA,EAAO,UAAU,GAAG,CAAA;AACtE,IAAA,QAAQ,QAAU;AAAA,MAChB,KAAK,SAAU,CAAA,KAAA;AACb,QAAA,uBAAA;AAAA,UACE,YAAA,CAAa,SAAS,EAAC;AAAA,UACvB,aAAA;AAAA,UACA;AAAA,SACF;AACA,QAAA;AAAA,MACF,KAAK,SAAU,CAAA,KAAA;AACb,QAAA,uBAAA;AAAA,UACE,YAAA,CAAa,SAAS,EAAC;AAAA,UACvB,aAAA;AAAA,UACA;AAAA,SACF;AACA,QAAA;AAAA,MACF,KAAK,SAAU,CAAA,GAAA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SAAA;AAAA,oBACA,gBAAgB,CACd,UAAA,KAAA,kBAAA;AAAA,sBACE,UAAA;AAAA,sBACA,YAAa,CAAA,GAAA,GACT,CAAC,YAAA,CAAa,GAA0B,CACxC,GAAA;AAAA,qBACN;AAAA,oBAEF;AAAA;AAAA,iBACF;AAAA,gCAEF,GAAA;AAAA,kBAAC,gBAAA;AAAA,kBAAA;AAAA,oBACC,OAAO,gBAAiB,CAAA,eAAA;AAAA,oBACxB,OAAS,kBAAA,GAAA,CAAC,KAAM,EAAA,EAAA,KAAA,EAAM,SAAU,EAAA,CAAA;AAAA,oBAChC,KAAA,sBAAQ,wBAAyB,EAAA,EAAA,CAAA;AAAA,oBACjC,EAAI,EAAA;AAAA,sBACF,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA;AAC5B;AAAA;AACF;AAAA;AAAA,WACF;AAAA,0BAEF,GAAA;AAAA,YAAC,0BAAA;AAAA,YAAA;AAAA,cACC,YAAA;AAAA,cACA,YAAA;AAAA,cACA,QAAA;AAAA,cACA,qBAAA;AAAA,cACA,YAAA;AAAA,cACA,qBAAA;AAAA,cACA;AAAA;AAAA,WACF;AAAA,UACC,kBAAA,EAAoB,MAAS,GAAA,CAAA,IAC5B,kBAAmB,CAAA,GAAA;AAAA,YAAI,CAAC,EAAA,EAAI,oBAC1B,KAAA,wBAAA,CAAyB,IAAI,oBAAoB;AAAA;AACnD,SACJ,EAAA;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"ConditionsFormRow.esm.js","sources":["../../../src/components/ConditionalAccess/ConditionsFormRow.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 { useState, useEffect } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport AddIcon from '@mui/icons-material/Add';\nimport RemoveIcon from '@mui/icons-material/Remove';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport IconButton from '@mui/material/IconButton';\nimport Radio from '@mui/material/Radio';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { useTheme } from '@mui/material/styles';\nimport ToggleButtonGroup from '@mui/material/ToggleButtonGroup';\n\nimport {\n extractNestedConditions,\n getDefaultRule,\n getNestedConditionSimpleRulesCount,\n getSimpleRulesCount,\n isNestedConditionRule,\n isSimpleRule,\n nestedConditionButtons,\n resetErrors,\n ruleOptionDisabled,\n} from '../../utils/conditional-access-utils';\nimport { AddNestedConditionButton } from './AddNestedConditionButton';\nimport { ComplexConditionRow } from './ComplexConditionRow';\nimport { ComplexConditionRowButtons } from './ComplexConditionRowButtons';\nimport { ConditionRule } from './ConditionRule';\nimport { ConditionsFormRowFields } from './ConditionsFormRowFields';\nimport { conditionButtons, criterias } from './const';\nimport { CriteriaToggleButton } from './CriteriaToggleButton';\nimport {\n ComplexErrors,\n Condition,\n ConditionFormRowProps,\n ConditionsData,\n NestedCriteriaErrors,\n NotConditionType,\n} from './types';\nimport Typography from '@mui/material/Typography';\n\nexport const ConditionsFormRow = ({\n conditionRulesData,\n conditionRow,\n selPluginResourceType,\n criteria,\n onRuleChange,\n setCriteria,\n setErrors,\n setRemoveAllClicked,\n}: ConditionFormRowProps) => {\n const theme = useTheme();\n const [nestedConditionRow, setNestedConditionRow] = useState<Condition[]>([]);\n const [notConditionType, setNotConditionType] = useState<NotConditionType>(\n NotConditionType.SimpleCondition,\n );\n\n useEffect(() => {\n const nestedConditions: Condition[] = [];\n const criteriaTypes = [criterias.allOf, criterias.anyOf, criterias.not];\n switch (criteria) {\n case criterias.allOf:\n extractNestedConditions(\n conditionRow.allOf || [],\n criteriaTypes,\n nestedConditions,\n );\n break;\n case criterias.anyOf:\n extractNestedConditions(\n conditionRow.anyOf || [],\n criteriaTypes,\n nestedConditions,\n );\n break;\n case criterias.not:\n if (\n conditionRow.not &&\n criteriaTypes.includes(\n Object.keys(conditionRow.not)[0] as keyof ConditionsData,\n )\n ) {\n nestedConditions.push(conditionRow.not);\n setNotConditionType(NotConditionType.NestedCondition);\n }\n break;\n default:\n break;\n }\n\n setNestedConditionRow(nestedConditions);\n }, [conditionRow, criteria]);\n\n const handleCriteriaChange = (val: keyof ConditionsData) => {\n setCriteria(val);\n setErrors(resetErrors(val));\n\n const defaultRule = getDefaultRule(selPluginResourceType);\n\n const ruleMap = {\n [criterias.condition]: { condition: defaultRule },\n [criterias.allOf]: { allOf: [defaultRule] },\n [criterias.anyOf]: { anyOf: [defaultRule] },\n [criterias.not]: { not: defaultRule },\n };\n\n if (val === criterias.not) {\n setNotConditionType(NotConditionType.SimpleCondition);\n }\n\n const ruleChange = ruleMap[val];\n if (ruleChange) {\n onRuleChange(ruleChange);\n }\n };\n\n const updateRules = (updatedNestedConditionRow: Condition[] | Condition) => {\n const existingSimpleCondition =\n criteria !== criterias.not\n ? (conditionRow[criteria as keyof Condition] as Condition[])?.filter(\n con => isSimpleRule(con),\n ) || []\n : [];\n\n const newCondition: Condition[] = Array.isArray(updatedNestedConditionRow)\n ? [...existingSimpleCondition, ...updatedNestedConditionRow]\n : [...existingSimpleCondition, updatedNestedConditionRow];\n\n if (criteria === criterias.anyOf || criteria === criterias.allOf) {\n onRuleChange({\n [criteria]: newCondition,\n });\n } else if (\n criteria === criterias.not &&\n !Array.isArray(updatedNestedConditionRow)\n ) {\n onRuleChange({\n not: updatedNestedConditionRow,\n });\n }\n };\n\n const handleNestedConditionCriteriaChange = (\n val: string,\n nestedConditionIndex: number,\n ) => {\n const defaultRule = getDefaultRule(selPluginResourceType);\n\n const nestedConditionMap = {\n [criterias.not]: { [val]: defaultRule },\n [criterias.allOf]: { [val]: [defaultRule] },\n [criterias.anyOf]: { [val]: [defaultRule] },\n [criterias.condition]: { [val]: [defaultRule] },\n };\n\n const newCondition = nestedConditionMap[val] || { [val]: [defaultRule] };\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n if (criteria === criterias.not) {\n (updatedErrors[criteria] as ComplexErrors) =\n val !== criterias.not ? { [val]: [''] } : { [val]: '' };\n return updatedErrors;\n }\n const criteriaErrors = updatedErrors[criteria];\n const simpleRuleErrors = (criteriaErrors as ComplexErrors[]).filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = (\n criteriaErrors as ComplexErrors[]\n ).filter((err: ComplexErrors) => typeof err !== 'string');\n nestedConditionErrors[nestedConditionIndex] =\n val !== criterias.not ? { [val]: [''] } : { [val]: '' };\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n\n return updatedErrors;\n });\n\n if (criteria === criterias.not) {\n updateRules(newCondition);\n } else {\n const updatedNestedConditionRow = nestedConditionRow.map((c, index) => {\n if (index === nestedConditionIndex) {\n return newCondition;\n }\n return c;\n });\n updateRules(updatedNestedConditionRow);\n }\n };\n\n const handleAddNestedCondition = (currentCriteria: string) => {\n const newNestedCondition = {\n [criterias.allOf]: [getDefaultRule(selPluginResourceType)],\n };\n const updatedNestedConditionRow = [\n ...nestedConditionRow,\n newNestedCondition,\n ];\n updateRules(\n currentCriteria === criterias.not\n ? newNestedCondition\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n if (updatedErrors[currentCriteria]) {\n const criteriaErrors = updatedErrors[\n currentCriteria\n ] as ComplexErrors[];\n if (Array.isArray(criteriaErrors)) {\n criteriaErrors.push({ [criterias.allOf]: [''] });\n } else {\n (updatedErrors[currentCriteria] as ComplexErrors) = {\n [criterias.allOf]: [''],\n };\n }\n }\n return updatedErrors;\n });\n };\n\n const handleNotConditionTypeChange = (val: NotConditionType) => {\n setNotConditionType(val);\n setErrors(resetErrors(criteria, val));\n if (val === 'nested-condition') {\n handleAddNestedCondition(criterias.not);\n } else {\n onRuleChange({\n not: getDefaultRule(selPluginResourceType),\n });\n }\n };\n\n const handleAddRuleInNestedCondition = (\n nestedConditionCriteria: string,\n nestedConditionIndex: number,\n ) => {\n const updatedNestedConditionRow: Condition[] = [];\n\n nestedConditionRow.forEach((c, index) => {\n if (index === nestedConditionIndex) {\n updatedNestedConditionRow.push({\n [nestedConditionCriteria as keyof Condition]: [\n ...((c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []),\n getDefaultRule(selPluginResourceType),\n ],\n });\n } else {\n updatedNestedConditionRow.push(c);\n }\n });\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria];\n if (\n criteria === criterias.not &&\n notConditionType === 'nested-condition'\n ) {\n (\n (criteriaErrors as NestedCriteriaErrors)[\n nestedConditionCriteria\n ] as string[]\n ).push('');\n return updatedErrors;\n }\n const simpleRuleErrors = (criteriaErrors as ComplexErrors[]).filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = (\n criteriaErrors as ComplexErrors[]\n ).filter((err: ComplexErrors) => typeof err !== 'string');\n\n (\n ((\n nestedConditionErrors[nestedConditionIndex] as NestedCriteriaErrors\n )[nestedConditionCriteria] as string[]) || []\n ).push('');\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n return updatedErrors;\n });\n };\n\n const handleRemoveNestedCondition = (nestedConditionIndex: number) => {\n const updatedNestedConditionRow = nestedConditionRow.filter(\n (_, index) => index !== nestedConditionIndex,\n );\n\n updateRules(updatedNestedConditionRow);\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (updatedErrors[criteria] !== undefined) {\n const criteriaErrors = updatedErrors[criteria] as ComplexErrors[];\n const simpleRuleErrors = criteriaErrors.filter(\n (err: ComplexErrors) => typeof err === 'string',\n );\n const nestedConditionErrors = criteriaErrors.filter(\n (err: ComplexErrors) => typeof err !== 'string',\n );\n nestedConditionErrors.splice(nestedConditionIndex, 1);\n\n updatedErrors[criteria] = [\n ...simpleRuleErrors,\n ...nestedConditionErrors,\n ];\n }\n\n return updatedErrors;\n });\n };\n\n const updateErrors = (_index: number) => {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n\n if (!Array.isArray(updatedErrors[criteria])) {\n updatedErrors[criteria] = [];\n }\n\n const firstNestedConditionErrorIndex =\n (updatedErrors[criteria] as ComplexErrors[]).findIndex(\n e => typeof e !== 'string',\n ) || 0;\n\n (updatedErrors[criteria] as ComplexErrors[]).splice(\n firstNestedConditionErrorIndex,\n 0,\n '',\n );\n\n return updatedErrors;\n });\n };\n\n const renderNestedConditionRow = (\n nc: Condition,\n nestedConditionIndex: number,\n ) => {\n const selectedNestedConditionCriteria = Object.keys(nc)[0];\n const simpleRulesCount = getSimpleRulesCount(conditionRow, criteria);\n const nestedConditionsCount = nestedConditionRow.length;\n const nestedConditionSimpleRulesCount = getNestedConditionSimpleRulesCount(\n nc,\n selectedNestedConditionCriteria,\n );\n return (\n nestedConditionSimpleRulesCount > 0 && (\n <Box\n mt={2}\n key={`nestedCondition-${nestedConditionIndex}`}\n sx={{\n padding: '20px',\n marginLeft: theme.spacing(3),\n border: `1px solid ${theme.palette.border}`,\n borderRadius: '4px',\n backgroundColor: theme.palette.background.default,\n '& input': {\n backgroundColor: `${theme.palette.background.paper}!important`,\n },\n }}\n >\n <div style={{ display: 'flex', justifyContent: 'space-between' }}>\n <ToggleButtonGroup\n exclusive\n value={selectedNestedConditionCriteria}\n onChange={(_event, newNestedCriteria) =>\n handleNestedConditionCriteriaChange(\n newNestedCriteria,\n nestedConditionIndex,\n )\n }\n sx={{\n backgroundColor: theme.palette.background.paper,\n width: '60%',\n height: '100%',\n }}\n >\n {nestedConditionButtons.map(({ val, label }) => (\n <CriteriaToggleButton\n key={`nested-criteria-${val}`}\n val={val}\n label={label}\n selectedCriteria={selectedNestedConditionCriteria}\n theme={theme}\n />\n ))}\n </ToggleButtonGroup>\n {criteria !== criterias.not && (\n <IconButton\n title=\"Remove nested condition\"\n sx={{\n color: theme.palette.grey[500],\n flexGrow: 0,\n alignSelf: 'baseline',\n }}\n disabled={simpleRulesCount === 0 && nestedConditionsCount === 1} // 0 simple rules and this is the only 1 nested condition\n onClick={() =>\n handleRemoveNestedCondition(nestedConditionIndex)\n }\n >\n <RemoveIcon data-testid=\"remove-nested-condition\" />\n </IconButton>\n )}\n </div>\n <Box>\n {selectedNestedConditionCriteria !== criterias.not &&\n (\n nc[\n selectedNestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]\n ).map((c, ncrIndex) => (\n <ComplexConditionRow\n key={`nested-condition-${nestedConditionIndex}-${ncrIndex}`}\n conditionRow={conditionRow}\n nestedConditionRow={nestedConditionRow}\n criteria={criteria}\n onRuleChange={onRuleChange}\n updateRules={updateRules}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n conditionRulesData={conditionRulesData}\n notConditionType={notConditionType}\n currentCondition={c}\n ruleIndex={ncrIndex}\n isNestedCondition\n nestedConditionIndex={nestedConditionIndex}\n activeNestedCriteria={\n selectedNestedConditionCriteria as 'allOf' | 'anyOf'\n }\n />\n ))}\n {selectedNestedConditionCriteria === criterias.not &&\n ((nc as ConditionsData).not as PermissionCondition)\n .resourceType && (\n <ConditionsFormRowFields\n oldCondition={\n (nc as ConditionsData).not ??\n getDefaultRule(selPluginResourceType)\n }\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n optionDisabled={ruleOption =>\n ruleOptionDisabled(\n ruleOption,\n (nc as ConditionsData).not\n ? [(nc as ConditionsData).not as PermissionCondition]\n : undefined,\n )\n }\n setRemoveAllClicked={setRemoveAllClicked}\n nestedConditionRow={nestedConditionRow}\n nestedConditionCriteria={selectedNestedConditionCriteria}\n nestedConditionIndex={nestedConditionIndex}\n updateRules={updateRules}\n />\n )}\n {selectedNestedConditionCriteria !== criterias.not && (\n <Button\n sx={{\n mt: 2,\n color: theme.palette.primary.light,\n }}\n size=\"small\"\n onClick={() =>\n handleAddRuleInNestedCondition(\n selectedNestedConditionCriteria,\n nestedConditionIndex,\n )\n }\n startIcon={<AddIcon fontSize=\"small\" />}\n >\n <Typography variant=\"body2\" component=\"span\">\n Add rule\n </Typography>\n </Button>\n )}\n </Box>\n </Box>\n )\n );\n };\n\n return (\n <Box\n sx={{\n padding: '20px',\n border: `1px solid ${theme.palette.border}`,\n borderRadius: '4px',\n backgroundColor: theme.palette.background.default,\n '& input': {\n color: `${theme.palette.textContrast}!important`,\n '&:-internal-autofill-selected, &:-webkit-autofill, &:-webkit-autofill:hover, &:-webkit-autofill:focus, &:-webkit-autofill:active':\n {\n WebkitBoxShadow: `0 0 0px 1000px ${theme.palette.background.paper} inset`,\n WebkitTextFillColor: `${theme.palette.textContrast}!important`,\n caretColor: `${theme.palette.textContrast}!important`,\n },\n },\n '& button': {\n textTransform: 'none',\n },\n }}\n data-testid=\"conditions-row\"\n >\n <ToggleButtonGroup\n exclusive\n value={criteria}\n onChange={(_event, newCriteria) => handleCriteriaChange(newCriteria)}\n sx={{\n backgroundColor: theme.palette.background.paper,\n width: '80%',\n }}\n >\n {conditionButtons.map(({ val, label }) => (\n <CriteriaToggleButton\n key={`criteria-${val}`}\n val={val}\n label={label}\n selectedCriteria={criteria}\n theme={theme}\n />\n ))}\n </ToggleButtonGroup>\n <ConditionRule\n conditionRow={conditionRow}\n selPluginResourceType={selPluginResourceType}\n onRuleChange={onRuleChange}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n />\n {criteria !== criterias.condition && (\n <Box>\n {criteria !== criterias.not &&\n (conditionRow[criteria] as PermissionCondition[])?.map(\n (c, srIndex) => (\n <ComplexConditionRow\n key={`${criteria}-simple-condition-${srIndex}`}\n conditionRow={conditionRow}\n nestedConditionRow={nestedConditionRow}\n criteria={criteria}\n onRuleChange={onRuleChange}\n updateRules={updateRules}\n setErrors={setErrors}\n setRemoveAllClicked={setRemoveAllClicked}\n conditionRulesData={conditionRulesData}\n notConditionType={notConditionType}\n currentCondition={c}\n ruleIndex={srIndex}\n activeCriteria={criteria as 'allOf' | 'anyOf'}\n />\n ),\n )}\n {criteria === criterias.not && (\n <RadioGroup\n sx={{\n margin: theme.spacing(1),\n }}\n value={notConditionType}\n onChange={(_event, value) =>\n handleNotConditionTypeChange(value as NotConditionType)\n }\n >\n <FormControlLabel\n value={NotConditionType.SimpleCondition}\n control={<Radio color=\"primary\" />}\n label=\"Add rule\"\n sx={{\n marginTop: theme.spacing(1),\n }}\n />\n {notConditionType === NotConditionType.SimpleCondition && (\n <ConditionsFormRowFields\n oldCondition={\n conditionRow.not ?? getDefaultRule(selPluginResourceType)\n }\n onRuleChange={onRuleChange}\n conditionRow={conditionRow}\n criteria={criteria}\n conditionRulesData={conditionRulesData}\n setErrors={setErrors}\n optionDisabled={ruleOption =>\n ruleOptionDisabled(\n ruleOption,\n conditionRow.not\n ? [conditionRow.not as PermissionCondition]\n : undefined,\n )\n }\n setRemoveAllClicked={setRemoveAllClicked}\n />\n )}\n <FormControlLabel\n value={NotConditionType.NestedCondition}\n control={<Radio color=\"primary\" />}\n label={<AddNestedConditionButton />}\n sx={{\n marginTop: theme.spacing(1),\n }}\n />\n </RadioGroup>\n )}\n <ComplexConditionRowButtons\n conditionRow={conditionRow}\n onRuleChange={onRuleChange}\n criteria={criteria}\n selPluginResourceType={selPluginResourceType}\n updateErrors={updateErrors}\n isNestedConditionRule={isNestedConditionRule}\n handleAddNestedCondition={handleAddNestedCondition}\n />\n {nestedConditionRow?.length > 0 &&\n nestedConditionRow.map((nc, nestedConditionIndex) =>\n renderNestedConditionRow(nc, nestedConditionIndex),\n )}\n </Box>\n )}\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0DO,MAAM,oBAAoB,CAAC;AAAA,EAChC,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,qBAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAA,MAAM,CAAC,kBAAoB,EAAA,qBAAqB,CAAI,GAAA,QAAA,CAAsB,EAAE,CAAA;AAC5E,EAAM,MAAA,CAAC,gBAAkB,EAAA,mBAAmB,CAAI,GAAA,QAAA;AAAA,IAC9C,gBAAiB,CAAA;AAAA,GACnB;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,mBAAgC,EAAC;AACvC,IAAA,MAAM,gBAAgB,CAAC,SAAA,CAAU,OAAO,SAAU,CAAA,KAAA,EAAO,UAAU,GAAG,CAAA;AACtE,IAAA,QAAQ,QAAU;AAAA,MAChB,KAAK,SAAU,CAAA,KAAA;AACb,QAAA,uBAAA;AAAA,UACE,YAAA,CAAa,SAAS,EAAC;AAAA,UACvB,aAAA;AAAA,UACA;AAAA,SACF;AACA,QAAA;AAAA,MACF,KAAK,SAAU,CAAA,KAAA;AACb,QAAA,uBAAA;AAAA,UACE,YAAA,CAAa,SAAS,EAAC;AAAA,UACvB,aAAA;AAAA,UACA;AAAA,SACF;AACA,QAAA;AAAA,MACF,KAAK,SAAU,CAAA,GAAA;AACb,QACE,IAAA,YAAA,CAAa,OACb,aAAc,CAAA,QAAA;AAAA,UACZ,MAAO,CAAA,IAAA,CAAK,YAAa,CAAA,GAAG,EAAE,CAAC;AAAA,SAEjC,EAAA;AACA,U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E,UAAA;AAAA,sBACA,YAAa,CAAA,GAAA,GACT,CAAC,YAAA,CAAa,GAA0B,CACxC,GAAA;AAAA,qBACN;AAAA,oBAEF;AAAA;AAAA,iBACF;AAAA,gCAEF,GAAA;AAAA,kBAAC,gBAAA;AAAA,kBAAA;AAAA,oBACC,OAAO,gBAAiB,CAAA,eAAA;AAAA,oBACxB,OAAS,kBAAA,GAAA,CAAC,KAAM,EAAA,EAAA,KAAA,EAAM,SAAU,EAAA,CAAA;AAAA,oBAChC,KAAA,sBAAQ,wBAAyB,EAAA,EAAA,CAAA;AAAA,oBACjC,EAAI,EAAA;AAAA,sBACF,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA;AAC5B;AAAA;AACF;AAAA;AAAA,WACF;AAAA,0BAEF,GAAA;AAAA,YAAC,0BAAA;AAAA,YAAA;AAAA,cACC,YAAA;AAAA,cACA,YAAA;AAAA,cACA,QAAA;AAAA,cACA,qBAAA;AAAA,cACA,YAAA;AAAA,cACA,qBAAA;AAAA,cACA;AAAA;AAAA,WACF;AAAA,UACC,kBAAA,EAAoB,MAAS,GAAA,CAAA,IAC5B,kBAAmB,CAAA,GAAA;AAAA,YAAI,CAAC,EAAA,EAAI,oBAC1B,KAAA,wBAAA,CAAyB,IAAI,oBAAoB;AAAA;AACnD,SACJ,EAAA;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
3
4
|
import Box from '@mui/material/Box';
|
|
4
5
|
import { useTheme } from '@mui/material/styles';
|
|
@@ -12,12 +13,19 @@ import { CustomArrayField } from './CustomArrayField.esm.js';
|
|
|
12
13
|
import { RulesDropdownOption } from './RulesDropdownOption.esm.js';
|
|
13
14
|
|
|
14
15
|
const makeConditionsFormRowFieldsStyles = makeStyles(() => ({
|
|
15
|
-
|
|
16
|
+
leftInputFieldContainer: {
|
|
16
17
|
display: "flex",
|
|
17
18
|
flexFlow: "row",
|
|
18
|
-
gap: "
|
|
19
|
+
gap: "1rem",
|
|
19
20
|
flexGrow: 1,
|
|
21
|
+
paddingLeft: 0,
|
|
20
22
|
margin: ({ isNotSimpleCondition }) => isNotSimpleCondition ? "-1.5rem 0 0 1.85rem" : "0"
|
|
23
|
+
},
|
|
24
|
+
rightInputFieldContainer: {
|
|
25
|
+
width: "50%",
|
|
26
|
+
"& span > h6": {
|
|
27
|
+
display: ({ hasError }) => hasError ? "none" : "block"
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
30
|
}));
|
|
23
31
|
const getTextFieldStyles = (theme) => ({
|
|
@@ -75,8 +83,10 @@ const ConditionsFormRowFields = ({
|
|
|
75
83
|
}) => {
|
|
76
84
|
const isNotSimpleCondition = criteria === criterias.not && !nestedConditionCriteria;
|
|
77
85
|
const theme = useTheme();
|
|
86
|
+
const [hasError, setHasError] = useState(false);
|
|
78
87
|
const classes = makeConditionsFormRowFieldsStyles({
|
|
79
|
-
isNotSimpleCondition
|
|
88
|
+
isNotSimpleCondition,
|
|
89
|
+
hasError
|
|
80
90
|
});
|
|
81
91
|
const rules = conditionRulesData?.rules ?? [];
|
|
82
92
|
const paramsSchema = conditionRulesData?.[oldCondition.rule]?.schema;
|
|
@@ -178,6 +188,11 @@ const ConditionsFormRowFields = ({
|
|
|
178
188
|
);
|
|
179
189
|
};
|
|
180
190
|
const handleTransformErrors = (errors) => {
|
|
191
|
+
if (errors.length > 0) {
|
|
192
|
+
setHasError(true);
|
|
193
|
+
} else {
|
|
194
|
+
setHasError(false);
|
|
195
|
+
}
|
|
181
196
|
if (criteria === criterias.condition || criteria === criterias.not && isSimpleRule(conditionRow[criteria])) {
|
|
182
197
|
setErrors((prevErrors) => {
|
|
183
198
|
const updatedErrors = { ...prevErrors };
|
|
@@ -233,7 +248,7 @@ const ConditionsFormRowFields = ({
|
|
|
233
248
|
handleConditionChange(newCondition);
|
|
234
249
|
}
|
|
235
250
|
};
|
|
236
|
-
return /* @__PURE__ */ jsxs(Box, { className: classes.
|
|
251
|
+
return /* @__PURE__ */ jsxs(Box, { className: classes.leftInputFieldContainer, children: [
|
|
237
252
|
/* @__PURE__ */ jsx(
|
|
238
253
|
Autocomplete,
|
|
239
254
|
{
|
|
@@ -267,7 +282,7 @@ const ConditionsFormRowFields = ({
|
|
|
267
282
|
)
|
|
268
283
|
}
|
|
269
284
|
),
|
|
270
|
-
/* @__PURE__ */ jsx(Box, {
|
|
285
|
+
/* @__PURE__ */ jsx(Box, { className: classes.rightInputFieldContainer, children: schema ? /* @__PURE__ */ jsx(
|
|
271
286
|
Form,
|
|
272
287
|
{
|
|
273
288
|
schema: paramsSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionsFormRowFields.esm.js","sources":["../../../src/components/ConditionalAccess/ConditionsFormRowFields.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 type { SetStateAction, Dispatch } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport Autocomplete from '@mui/material/Autocomplete';\nimport Box from '@mui/material/Box';\nimport { Theme, useTheme } from '@mui/material/styles';\nimport TextField from '@mui/material/TextField';\nimport { makeStyles } from '@mui/styles';\nimport Form from '@rjsf/mui';\nimport {\n RegistryFieldsType,\n RJSFSchema,\n RJSFValidationError,\n UiSchema,\n} from '@rjsf/utils';\nimport validator from '@rjsf/validator-ajv8';\n\nimport {\n getNestedRuleErrors,\n getSimpleRuleErrors,\n isSimpleRule,\n setErrorMessage,\n} from '../../utils/conditional-access-utils';\nimport { criterias } from './const';\nimport { CustomArrayField } from './CustomArrayField';\nimport { RulesDropdownOption } from './RulesDropdownOption';\nimport {\n AccessConditionsErrors,\n ComplexErrors,\n Condition,\n ConditionsData,\n NestedCriteriaErrors,\n RulesData,\n} from './types';\n\ntype ConditionFormRowFieldsProps = {\n oldCondition: Condition;\n index?: number;\n criteria: string;\n onRuleChange: (newCondition: ConditionsData) => void;\n conditionRow: ConditionsData | Condition;\n conditionRulesData?: RulesData;\n setErrors: Dispatch<SetStateAction<AccessConditionsErrors | undefined>>;\n optionDisabled?: (ruleOption: string) => boolean;\n setRemoveAllClicked: Dispatch<SetStateAction<boolean>>;\n nestedConditionRow?: Condition[];\n nestedConditionCriteria?: string;\n nestedConditionIndex?: number;\n nestedConditionRuleIndex?: number;\n updateRules?: (newCondition: Condition[] | Condition) => void;\n};\n\ninterface StyleProps {\n isNotSimpleCondition: boolean;\n}\n\nconst makeConditionsFormRowFieldsStyles = makeStyles<Theme, StyleProps>(() => ({\n inputFieldContainer: {\n display: 'flex',\n flexFlow: 'row',\n gap: '10px',\n flexGrow: 1,\n margin: ({ isNotSimpleCondition }) =>\n isNotSimpleCondition ? '-1.5rem 0 0 1.85rem' : '0',\n },\n}));\n\nexport const getTextFieldStyles = (theme: Theme) => ({\n '& div[class*=\"MuiInputBase-root\"]': {\n backgroundColor: theme.palette.background.paper,\n },\n '& span': {\n color: theme.palette.textSubtle,\n },\n '& input': {\n color: theme.palette.textContrast,\n },\n '& fieldset.MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.grey[500],\n },\n '& div.MuiOutlinedInput-root': {\n '&.Mui-focused .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.primary.light,\n },\n '&.Mui-error .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.status.error,\n '&:hover': {\n borderColor: theme.palette.status.error,\n },\n },\n },\n '& label.MuiFormLabel-root.Mui-focused': {\n color: theme.palette.primary.light,\n },\n '& label.MuiFormLabel-root.Mui-error': {\n color: theme.palette.status.error,\n },\n '& div.MuiOutlinedInput-root:hover fieldset': {\n borderColor:\n theme.palette.mode === 'dark' ? theme.palette.textContrast : 'unset',\n },\n '& label': {\n color: theme.palette.textSubtle,\n },\n});\n\nexport const ConditionsFormRowFields = ({\n oldCondition,\n index,\n criteria,\n onRuleChange,\n conditionRow,\n conditionRulesData,\n setErrors,\n optionDisabled,\n setRemoveAllClicked,\n nestedConditionRow,\n nestedConditionCriteria,\n nestedConditionIndex,\n nestedConditionRuleIndex,\n updateRules,\n}: ConditionFormRowFieldsProps) => {\n const isNotSimpleCondition =\n criteria === criterias.not && !nestedConditionCriteria;\n const theme = useTheme();\n const classes = makeConditionsFormRowFieldsStyles({\n isNotSimpleCondition,\n });\n\n const rules = conditionRulesData?.rules ?? [];\n const paramsSchema =\n conditionRulesData?.[(oldCondition as PermissionCondition).rule]?.schema;\n\n const schema: RJSFSchema = paramsSchema;\n\n const uiSchema: UiSchema = {\n 'ui:submitButtonOptions': {\n norender: true,\n },\n 'ui:classNames': `{\n '& div[class*=\"MuiInputBase-root\"]': {\n backgroundColor: theme.palette.background.paper,\n },\n '& span': {\n color: theme.palette.textSubtle,\n },\n '& input': {\n color: theme.palette.textContrast,\n },\n '& fieldset.MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.grey[500],\n },\n '& div.MuiOutlinedInput-root': {\n '&.Mui-focused .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.primary.light,\n },\n '&.Mui-error .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.status.error,\n '&:hover': {\n borderColor: theme.palette.status.error,\n },\n },\n },\n '& label.MuiFormLabel-root.Mui-focused': {\n color: theme.palette.primary.light,\n },\n '& label.MuiFormLabel-root.Mui-error': {\n color: theme.palette.status.error,\n },\n '& div.MuiOutlinedInput-root:hover fieldset': {\n borderColor:\n theme.palette.mode === 'dark' ? theme.palette.textContrast : 'unset',\n },\n '& label': {\n color: theme.palette.textSubtle,\n },\n }`,\n 'ui:field': 'array',\n };\n\n const customFields: RegistryFieldsType = { ArrayField: CustomArrayField };\n\n const handleConditionChange = (newCondition: PermissionCondition) => {\n setRemoveAllClicked(false);\n switch (criteria) {\n case criterias.condition: {\n onRuleChange({ condition: newCondition });\n break;\n }\n case criterias.allOf: {\n const updatedCriteria = (conditionRow as ConditionsData).allOf ?? [];\n updatedCriteria[index ?? 0] = newCondition;\n onRuleChange({ allOf: updatedCriteria });\n break;\n }\n case criterias.anyOf: {\n const updatedCriteria = (conditionRow as ConditionsData).anyOf ?? [];\n updatedCriteria[index ?? 0] = newCondition;\n onRuleChange({ anyOf: updatedCriteria });\n break;\n }\n case criterias.not: {\n onRuleChange({ not: newCondition });\n break;\n }\n default:\n }\n };\n\n const handleNestedConditionChange = (newCondition: PermissionCondition) => {\n if (\n !nestedConditionRow ||\n !nestedConditionCriteria ||\n nestedConditionIndex === undefined ||\n !updateRules\n ) {\n return;\n }\n const updatedNestedConditionRow: Condition[] = nestedConditionRow.map(\n (c, i) => {\n if (i === nestedConditionIndex) {\n if (nestedConditionCriteria === criterias.not) {\n return {\n [nestedConditionCriteria]: newCondition,\n };\n }\n const updatedNestedConditionRules = (\n (c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []\n ).map((rule, rindex) => {\n return rindex === nestedConditionRuleIndex ? newCondition : rule;\n });\n\n return {\n [nestedConditionCriteria]: updatedNestedConditionRules,\n };\n }\n return c;\n },\n );\n\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n };\n\n const handleTransformErrors = (errors: RJSFValidationError[]) => {\n // criteria: condition or not simple-condition\n if (\n criteria === criterias.condition ||\n (criteria === criterias.not &&\n isSimpleRule(conditionRow[criteria as keyof Condition]))\n ) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n updatedErrors[criteria] = setErrorMessage(errors);\n\n return updatedErrors;\n });\n }\n\n // criteria: not nested-condition\n if (\n criteria === criterias.not &&\n nestedConditionCriteria &&\n !isSimpleRule(conditionRow[criteria as keyof Condition])\n ) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n const nestedErrors = (updatedErrors[criteria] as ComplexErrors)[\n nestedConditionCriteria as keyof Condition\n ] as NestedCriteriaErrors;\n\n // nestedCriteria: allOf or anyOf\n if (\n Array.isArray(nestedErrors) &&\n nestedConditionRuleIndex !== undefined\n ) {\n nestedErrors[nestedConditionRuleIndex] = setErrorMessage(errors);\n } else {\n // nestedCriteria: not\n updatedErrors[criteria] = {\n [nestedConditionCriteria]: setErrorMessage(errors),\n };\n }\n\n return updatedErrors;\n });\n }\n\n // criteria: allOf or anyOf\n if (criteria === criterias.allOf || criteria === criterias.anyOf) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n const simpleRuleErrors = getSimpleRuleErrors(\n updatedErrors[\n criteria as keyof AccessConditionsErrors\n ] as ComplexErrors[],\n );\n if (\n Array.isArray(simpleRuleErrors) &&\n simpleRuleErrors.length > 0 &&\n index !== undefined\n ) {\n simpleRuleErrors[index] = setErrorMessage(errors);\n }\n\n const nestedRuleErrors = getNestedRuleErrors(\n updatedErrors[\n criteria as keyof AccessConditionsErrors\n ] as ComplexErrors[],\n );\n\n // nestedCriteria: allOf or anyOf\n if (\n nestedConditionCriteria &&\n nestedConditionIndex !== undefined &&\n nestedConditionRuleIndex !== undefined\n ) {\n const nestedConditionRuleList =\n nestedRuleErrors[nestedConditionIndex][nestedConditionCriteria];\n\n if (Array.isArray(nestedConditionRuleList)) {\n nestedConditionRuleList[nestedConditionRuleIndex] =\n setErrorMessage(errors);\n }\n }\n\n // nestedCriteria: not\n if (\n Array.isArray(nestedRuleErrors) &&\n nestedRuleErrors.length > 0 &&\n nestedConditionCriteria === criterias.not &&\n nestedConditionIndex !== undefined\n ) {\n nestedRuleErrors[nestedConditionIndex][nestedConditionCriteria] =\n setErrorMessage(errors);\n }\n\n updatedErrors[criteria] = [...simpleRuleErrors, ...nestedRuleErrors];\n return updatedErrors;\n });\n }\n\n return errors;\n };\n\n const onConditionChange = (newCondition: PermissionCondition) => {\n if (nestedConditionRow) {\n handleNestedConditionChange(newCondition);\n } else {\n handleConditionChange(newCondition);\n }\n };\n\n return (\n <Box className={classes.inputFieldContainer}>\n <Autocomplete\n style={{ width: '50%', marginTop: '26px' }}\n sx={getTextFieldStyles(theme)}\n options={rules ?? []}\n value={(oldCondition as PermissionCondition)?.rule || null}\n getOptionDisabled={option =>\n optionDisabled ? optionDisabled(option) : false\n }\n onChange={(_event, ruleVal?: string | null) =>\n onConditionChange({\n ...oldCondition,\n rule: ruleVal ?? '',\n params: {},\n } as PermissionCondition)\n }\n renderOption={(props, option) => (\n <RulesDropdownOption\n props={props}\n label={option ?? ''}\n rulesData={conditionRulesData}\n />\n )}\n renderInput={(params: any) => (\n <TextField\n {...params}\n label=\"Rule\"\n variant=\"outlined\"\n placeholder=\"Select a rule\"\n required\n />\n )}\n />\n <Box style={{ width: '50%' }}>\n {schema ? (\n <Form\n schema={paramsSchema}\n formData={(oldCondition as PermissionCondition)?.params || {}}\n validator={validator}\n uiSchema={uiSchema}\n fields={customFields}\n onChange={data =>\n onConditionChange({\n ...oldCondition,\n params: data.formData || {},\n } as PermissionCondition)\n }\n transformErrors={handleTransformErrors}\n showErrorList={false}\n liveValidate\n />\n ) : (\n <TextField\n style={{ width: '100%', marginTop: '26px' }}\n sx={getTextFieldStyles(theme)}\n disabled\n label=\"string, string\"\n required\n variant=\"outlined\"\n />\n )}\n </Box>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwEA,MAAM,iCAAA,GAAoC,WAA8B,OAAO;AAAA,EAC7E,mBAAqB,EAAA;AAAA,IACnB,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,KAAA;AAAA,IACV,GAAK,EAAA,MAAA;AAAA,IACL,QAAU,EAAA,CAAA;AAAA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A,YACJ,KAAM,EAAA,MAAA;AAAA,YACN,OAAQ,EAAA,UAAA;AAAA,YACR,WAAY,EAAA,eAAA;AAAA,YACZ,QAAQ,EAAA;AAAA;AAAA;AACV;AAAA,KAEJ;AAAA,wBACC,GAAI,EAAA,EAAA,KAAA,EAAO,EAAE,KAAO,EAAA,KAAA,IAClB,QACC,EAAA,MAAA,mBAAA,GAAA;AAAA,MAAC,IAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA,YAAA;AAAA,QACR,QAAA,EAAW,YAAsC,EAAA,MAAA,IAAU,EAAC;AAAA,QAC5D,SAAA;AAAA,QACA,QAAA;AAAA,QACA,MAAQ,EAAA,YAAA;AAAA,QACR,QAAA,EAAU,UACR,iBAAkB,CAAA;AAAA,UAChB,GAAG,YAAA;AAAA,UACH,MAAA,EAAQ,IAAK,CAAA,QAAA,IAAY;AAAC,SACJ,CAAA;AAAA,QAE1B,eAAiB,EAAA,qBAAA;AAAA,QACjB,aAAe,EAAA,KAAA;AAAA,QACf,YAAY,EAAA;AAAA;AAAA,KAGd,mBAAA,GAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,KAAO,EAAA,EAAE,KAAO,EAAA,MAAA,EAAQ,WAAW,MAAO,EAAA;AAAA,QAC1C,EAAA,EAAI,mBAAmB,KAAK,CAAA;AAAA,QAC5B,QAAQ,EAAA,IAAA;AAAA,QACR,KAAM,EAAA,gBAAA;AAAA,QACN,QAAQ,EAAA,IAAA;AAAA,QACR,OAAQ,EAAA;AAAA;AAAA,KAGd,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"ConditionsFormRowFields.esm.js","sources":["../../../src/components/ConditionalAccess/ConditionsFormRowFields.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 type { SetStateAction, Dispatch } from 'react';\nimport { useState } from 'react';\n\nimport { PermissionCondition } from '@backstage/plugin-permission-common';\n\nimport Autocomplete from '@mui/material/Autocomplete';\nimport Box from '@mui/material/Box';\nimport { Theme, useTheme } from '@mui/material/styles';\nimport TextField from '@mui/material/TextField';\nimport { makeStyles } from '@mui/styles';\nimport Form from '@rjsf/mui';\nimport {\n RegistryFieldsType,\n RJSFSchema,\n RJSFValidationError,\n UiSchema,\n} from '@rjsf/utils';\nimport validator from '@rjsf/validator-ajv8';\n\nimport {\n getNestedRuleErrors,\n getSimpleRuleErrors,\n isSimpleRule,\n setErrorMessage,\n} from '../../utils/conditional-access-utils';\nimport { criterias } from './const';\nimport { CustomArrayField } from './CustomArrayField';\nimport { RulesDropdownOption } from './RulesDropdownOption';\nimport {\n AccessConditionsErrors,\n ComplexErrors,\n Condition,\n ConditionsData,\n NestedCriteriaErrors,\n RulesData,\n} from './types';\n\ntype ConditionFormRowFieldsProps = {\n oldCondition: Condition;\n index?: number;\n criteria: string;\n onRuleChange: (newCondition: ConditionsData) => void;\n conditionRow: ConditionsData | Condition;\n conditionRulesData?: RulesData;\n setErrors: Dispatch<SetStateAction<AccessConditionsErrors | undefined>>;\n optionDisabled?: (ruleOption: string) => boolean;\n setRemoveAllClicked: Dispatch<SetStateAction<boolean>>;\n nestedConditionRow?: Condition[];\n nestedConditionCriteria?: string;\n nestedConditionIndex?: number;\n nestedConditionRuleIndex?: number;\n updateRules?: (newCondition: Condition[] | Condition) => void;\n};\n\ninterface StyleProps {\n isNotSimpleCondition: boolean;\n hasError: boolean;\n}\n\nconst makeConditionsFormRowFieldsStyles = makeStyles<Theme, StyleProps>(() => ({\n leftInputFieldContainer: {\n display: 'flex',\n flexFlow: 'row',\n gap: '1rem',\n flexGrow: 1,\n paddingLeft: 0,\n margin: ({ isNotSimpleCondition }) =>\n isNotSimpleCondition ? '-1.5rem 0 0 1.85rem' : '0',\n },\n rightInputFieldContainer: {\n width: '50%',\n '& span > h6': {\n display: ({ hasError }) => (hasError ? 'none' : 'block'),\n },\n },\n}));\n\nexport const getTextFieldStyles = (theme: Theme) => ({\n '& div[class*=\"MuiInputBase-root\"]': {\n backgroundColor: theme.palette.background.paper,\n },\n '& span': {\n color: theme.palette.textSubtle,\n },\n '& input': {\n color: theme.palette.textContrast,\n },\n '& fieldset.MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.grey[500],\n },\n '& div.MuiOutlinedInput-root': {\n '&.Mui-focused .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.primary.light,\n },\n '&.Mui-error .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.status.error,\n '&:hover': {\n borderColor: theme.palette.status.error,\n },\n },\n },\n '& label.MuiFormLabel-root.Mui-focused': {\n color: theme.palette.primary.light,\n },\n '& label.MuiFormLabel-root.Mui-error': {\n color: theme.palette.status.error,\n },\n '& div.MuiOutlinedInput-root:hover fieldset': {\n borderColor:\n theme.palette.mode === 'dark' ? theme.palette.textContrast : 'unset',\n },\n '& label': {\n color: theme.palette.textSubtle,\n },\n});\n\nexport const ConditionsFormRowFields = ({\n oldCondition,\n index,\n criteria,\n onRuleChange,\n conditionRow,\n conditionRulesData,\n setErrors,\n optionDisabled,\n setRemoveAllClicked,\n nestedConditionRow,\n nestedConditionCriteria,\n nestedConditionIndex,\n nestedConditionRuleIndex,\n updateRules,\n}: ConditionFormRowFieldsProps) => {\n const isNotSimpleCondition =\n criteria === criterias.not && !nestedConditionCriteria;\n const theme = useTheme();\n const [hasError, setHasError] = useState(false);\n const classes = makeConditionsFormRowFieldsStyles({\n isNotSimpleCondition,\n hasError,\n });\n\n const rules = conditionRulesData?.rules ?? [];\n const paramsSchema =\n conditionRulesData?.[(oldCondition as PermissionCondition).rule]?.schema;\n\n const schema: RJSFSchema = paramsSchema;\n\n const uiSchema: UiSchema = {\n 'ui:submitButtonOptions': {\n norender: true,\n },\n 'ui:classNames': `{\n '& div[class*=\"MuiInputBase-root\"]': {\n backgroundColor: theme.palette.background.paper,\n },\n '& span': {\n color: theme.palette.textSubtle,\n },\n '& input': {\n color: theme.palette.textContrast,\n },\n '& fieldset.MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.grey[500],\n },\n '& div.MuiOutlinedInput-root': {\n '&.Mui-focused .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.primary.light,\n },\n '&.Mui-error .MuiOutlinedInput-notchedOutline': {\n borderColor: theme.palette.status.error,\n '&:hover': {\n borderColor: theme.palette.status.error,\n },\n },\n },\n '& label.MuiFormLabel-root.Mui-focused': {\n color: theme.palette.primary.light,\n },\n '& label.MuiFormLabel-root.Mui-error': {\n color: theme.palette.status.error,\n },\n '& div.MuiOutlinedInput-root:hover fieldset': {\n borderColor:\n theme.palette.mode === 'dark' ? theme.palette.textContrast : 'unset',\n },\n '& label': {\n color: theme.palette.textSubtle,\n },\n }`,\n 'ui:field': 'array',\n };\n\n const customFields: RegistryFieldsType = { ArrayField: CustomArrayField };\n\n const handleConditionChange = (newCondition: PermissionCondition) => {\n setRemoveAllClicked(false);\n switch (criteria) {\n case criterias.condition: {\n onRuleChange({ condition: newCondition });\n break;\n }\n case criterias.allOf: {\n const updatedCriteria = (conditionRow as ConditionsData).allOf ?? [];\n updatedCriteria[index ?? 0] = newCondition;\n onRuleChange({ allOf: updatedCriteria });\n break;\n }\n case criterias.anyOf: {\n const updatedCriteria = (conditionRow as ConditionsData).anyOf ?? [];\n updatedCriteria[index ?? 0] = newCondition;\n onRuleChange({ anyOf: updatedCriteria });\n break;\n }\n case criterias.not: {\n onRuleChange({ not: newCondition });\n break;\n }\n default:\n }\n };\n\n const handleNestedConditionChange = (newCondition: PermissionCondition) => {\n if (\n !nestedConditionRow ||\n !nestedConditionCriteria ||\n nestedConditionIndex === undefined ||\n !updateRules\n ) {\n return;\n }\n const updatedNestedConditionRow: Condition[] = nestedConditionRow.map(\n (c, i) => {\n if (i === nestedConditionIndex) {\n if (nestedConditionCriteria === criterias.not) {\n return {\n [nestedConditionCriteria]: newCondition,\n };\n }\n const updatedNestedConditionRules = (\n (c[\n nestedConditionCriteria as keyof Condition\n ] as PermissionCondition[]) || []\n ).map((rule, rindex) => {\n return rindex === nestedConditionRuleIndex ? newCondition : rule;\n });\n\n return {\n [nestedConditionCriteria]: updatedNestedConditionRules,\n };\n }\n return c;\n },\n );\n\n updateRules(\n criteria === criterias.not\n ? updatedNestedConditionRow[0]\n : updatedNestedConditionRow,\n );\n };\n\n const handleTransformErrors = (errors: RJSFValidationError[]) => {\n if (errors.length > 0) {\n setHasError(true);\n } else {\n setHasError(false);\n }\n // criteria: condition or not simple-condition\n if (\n criteria === criterias.condition ||\n (criteria === criterias.not &&\n isSimpleRule(conditionRow[criteria as keyof Condition]))\n ) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n updatedErrors[criteria] = setErrorMessage(errors);\n\n return updatedErrors;\n });\n }\n\n // criteria: not nested-condition\n if (\n criteria === criterias.not &&\n nestedConditionCriteria &&\n !isSimpleRule(conditionRow[criteria as keyof Condition])\n ) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n const nestedErrors = (updatedErrors[criteria] as ComplexErrors)[\n nestedConditionCriteria as keyof Condition\n ] as NestedCriteriaErrors;\n\n // nestedCriteria: allOf or anyOf\n if (\n Array.isArray(nestedErrors) &&\n nestedConditionRuleIndex !== undefined\n ) {\n nestedErrors[nestedConditionRuleIndex] = setErrorMessage(errors);\n } else {\n // nestedCriteria: not\n updatedErrors[criteria] = {\n [nestedConditionCriteria]: setErrorMessage(errors),\n };\n }\n\n return updatedErrors;\n });\n }\n\n // criteria: allOf or anyOf\n if (criteria === criterias.allOf || criteria === criterias.anyOf) {\n setErrors(prevErrors => {\n const updatedErrors = { ...prevErrors };\n const simpleRuleErrors = getSimpleRuleErrors(\n updatedErrors[\n criteria as keyof AccessConditionsErrors\n ] as ComplexErrors[],\n );\n if (\n Array.isArray(simpleRuleErrors) &&\n simpleRuleErrors.length > 0 &&\n index !== undefined\n ) {\n simpleRuleErrors[index] = setErrorMessage(errors);\n }\n\n const nestedRuleErrors = getNestedRuleErrors(\n updatedErrors[\n criteria as keyof AccessConditionsErrors\n ] as ComplexErrors[],\n );\n\n // nestedCriteria: allOf or anyOf\n if (\n nestedConditionCriteria &&\n nestedConditionIndex !== undefined &&\n nestedConditionRuleIndex !== undefined\n ) {\n const nestedConditionRuleList =\n nestedRuleErrors[nestedConditionIndex][nestedConditionCriteria];\n\n if (Array.isArray(nestedConditionRuleList)) {\n nestedConditionRuleList[nestedConditionRuleIndex] =\n setErrorMessage(errors);\n }\n }\n\n // nestedCriteria: not\n if (\n Array.isArray(nestedRuleErrors) &&\n nestedRuleErrors.length > 0 &&\n nestedConditionCriteria === criterias.not &&\n nestedConditionIndex !== undefined\n ) {\n nestedRuleErrors[nestedConditionIndex][nestedConditionCriteria] =\n setErrorMessage(errors);\n }\n\n updatedErrors[criteria] = [...simpleRuleErrors, ...nestedRuleErrors];\n return updatedErrors;\n });\n }\n\n return errors;\n };\n\n const onConditionChange = (newCondition: PermissionCondition) => {\n if (nestedConditionRow) {\n handleNestedConditionChange(newCondition);\n } else {\n handleConditionChange(newCondition);\n }\n };\n\n return (\n <Box className={classes.leftInputFieldContainer}>\n <Autocomplete\n style={{ width: '50%', marginTop: '26px' }}\n sx={getTextFieldStyles(theme)}\n options={rules ?? []}\n value={(oldCondition as PermissionCondition)?.rule || null}\n getOptionDisabled={option =>\n optionDisabled ? optionDisabled(option) : false\n }\n onChange={(_event, ruleVal?: string | null) =>\n onConditionChange({\n ...oldCondition,\n rule: ruleVal ?? '',\n params: {},\n } as PermissionCondition)\n }\n renderOption={(props, option) => (\n <RulesDropdownOption\n props={props}\n label={option ?? ''}\n rulesData={conditionRulesData}\n />\n )}\n renderInput={(params: any) => (\n <TextField\n {...params}\n label=\"Rule\"\n variant=\"outlined\"\n placeholder=\"Select a rule\"\n required\n />\n )}\n />\n <Box className={classes.rightInputFieldContainer}>\n {schema ? (\n <Form\n schema={paramsSchema}\n formData={(oldCondition as PermissionCondition)?.params || {}}\n validator={validator}\n uiSchema={uiSchema}\n fields={customFields}\n onChange={data =>\n onConditionChange({\n ...oldCondition,\n params: data.formData || {},\n } as PermissionCondition)\n }\n transformErrors={handleTransformErrors}\n showErrorList={false}\n liveValidate\n />\n ) : (\n <TextField\n style={{ width: '100%', marginTop: '26px' }}\n sx={getTextFieldStyles(theme)}\n disabled\n label=\"string, string\"\n required\n variant=\"outlined\"\n />\n )}\n </Box>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA0EA,MAAM,iCAAA,GAAoC,WAA8B,OAAO;AAAA,EAC7E,uBAAyB,EAAA;AAAA,IACvB,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,KAAA;AAAA,IACV,GAAK,EAAA,MAAA;AAAA,IACL,QAAU,EAAA,CAAA;AAAA,IACV,WAAa,EAAA,CAAA;AAAA,IACb,QAAQ,CAAC,EAAE,oBAAqB,EAAA,KAC9B,uBAAuB,qBAAwB,GAAA;AAAA,GACnD;AAAA,EACA,wBAA0B,EAAA;AAAA,IACxB,KAAO,EAAA,KAAA;AAAA,IACP,aAAe,EAAA;AAAA,MACb,SAAS,CAAC,EAAE,QAAS,EAAA,KAAO,WAAW,MAAS,GAAA;AAAA;AAClD;AAEJ,CAAE,CAAA,CAAA;AAEW,MAAA,kBAAA,GAAqB,CAAC,KAAkB,MAAA;AAAA,EACnD,mCAAqC,EAAA;AAAA,IACnC,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA;AAAA,GAC5C;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAA,EAAO,MAAM,OAAQ,CAAA;AAAA,GACvB;AAAA,EACA,SA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,EAAA;AAAA;AAAA;AACV;AAAA,KAEJ;AAAA,oBACC,GAAA,CAAA,GAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,0BACrB,QACC,EAAA,MAAA,mBAAA,GAAA;AAAA,MAAC,IAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA,YAAA;AAAA,QACR,QAAA,EAAW,YAAsC,EAAA,MAAA,IAAU,EAAC;AAAA,QAC5D,SAAA;AAAA,QACA,QAAA;AAAA,QACA,MAAQ,EAAA,YAAA;AAAA,QACR,QAAA,EAAU,UACR,iBAAkB,CAAA;AAAA,UAChB,GAAG,YAAA;AAAA,UACH,MAAA,EAAQ,IAAK,CAAA,QAAA,IAAY;AAAC,SACJ,CAAA;AAAA,QAE1B,eAAiB,EAAA,qBAAA;AAAA,QACjB,aAAe,EAAA,KAAA;AAAA,QACf,YAAY,EAAA;AAAA;AAAA,KAGd,mBAAA,GAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,KAAO,EAAA,EAAE,KAAO,EAAA,MAAA,EAAQ,WAAW,MAAO,EAAA;AAAA,QAC1C,EAAA,EAAI,mBAAmB,KAAK,CAAA;AAAA,QAC5B,QAAQ,EAAA,IAAA;AAAA,QACR,KAAM,EAAA,gBAAA;AAAA,QACN,QAAQ,EAAA,IAAA;AAAA,QACR,OAAQ,EAAA;AAAA;AAAA,KAGd,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -75,7 +75,6 @@ const AddMembersForm = ({
|
|
|
75
75
|
onChange: (_e, value) => {
|
|
76
76
|
setSelectedMember(value);
|
|
77
77
|
setFieldValue("selectedMembers", value);
|
|
78
|
-
setSearch("");
|
|
79
78
|
},
|
|
80
79
|
renderTags: () => "",
|
|
81
80
|
inputValue: search,
|
|
@@ -94,6 +93,11 @@ const AddMembersForm = ({
|
|
|
94
93
|
error: !!selectedMembersError,
|
|
95
94
|
helperText: selectedMembersError ?? "",
|
|
96
95
|
required: true,
|
|
96
|
+
onKeyDown: (event) => {
|
|
97
|
+
if (event.key === "Backspace" && params.inputProps.value === "") {
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
97
101
|
InputProps: {
|
|
98
102
|
...params.InputProps,
|
|
99
103
|
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddMembersForm.esm.js","sources":["../../../src/components/CreateRole/AddMembersForm.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 { useState, useEffect, useMemo } from 'react';\n\nimport { stringifyEntityRef } from '@backstage/catalog-model';\n\nimport Autocomplete from '@mui/material/Autocomplete';\nimport FormHelperText from '@mui/material/FormHelperText';\nimport LinearProgress from '@mui/material/LinearProgress';\nimport TextField from '@mui/material/TextField';\nimport HighlightOffIcon from '@mui/icons-material/HighlightOff';\nimport IconButton from '@mui/material/IconButton';\nimport { FormikErrors } from 'formik';\n\nimport { MemberEntity } from '../../types';\nimport {\n getChildGroupsCount,\n getMembersCount,\n getParentGroupsCount,\n} from '../../utils/create-role-utils';\nimport { MembersDropdownOption } from './MembersDropdownOption';\nimport { RoleFormValues, SelectedMember } from './types';\n\ntype AddMembersFormProps = {\n selectedMembers: SelectedMember[];\n selectedMembersError?: string;\n membersData: { members: MemberEntity[]; loading: boolean; error: Error };\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n};\n\nexport const AddMembersForm = ({\n selectedMembers,\n selectedMembersError,\n setFieldValue,\n membersData,\n}: AddMembersFormProps) => {\n const [search, setSearch] = useState<string>('');\n const [selectedMember, setSelectedMember] =\n useState<SelectedMember[]>(selectedMembers);\n useEffect(() => {\n setSelectedMember(selectedMembers);\n }, [selectedMembers]);\n\n const getDescription = (member: MemberEntity) => {\n const memberCount = getMembersCount(member);\n const parentCount = getParentGroupsCount(member);\n const childCount = getChildGroupsCount(member);\n\n return member.kind === 'Group'\n ? [\n memberCount > 0 ? `${memberCount} members` : '',\n parentCount > 0 ? `${parentCount} parent group` : '',\n childCount > 0 ? `${childCount} child groups` : '',\n ]\n .filter(Boolean) // Remove any empty strings\n .join(', ')\n : undefined;\n };\n\n const membersOptions: SelectedMember[] = useMemo(() => {\n return membersData.members\n ? membersData.members.map((member: MemberEntity, index: number) => {\n const tag =\n member.metadata.etag ??\n `${member.metadata.name}-${member.kind}-${index}`;\n return {\n id: tag,\n label: member.spec?.profile?.displayName ?? member.metadata.name,\n description: getDescription(member),\n etag: tag,\n type: member.kind,\n namespace: member.metadata.namespace,\n members: getMembersCount(member),\n ref: stringifyEntityRef(member),\n };\n })\n : ([] as SelectedMember[]);\n }, [membersData.members]);\n\n const filteredMembers = useMemo(() => {\n if (search) {\n return membersOptions\n .filter(m =>\n m.label\n .toLocaleLowerCase('en-US')\n .includes(search.toLocaleLowerCase('en-US')),\n )\n .slice(0, 99);\n }\n\n return membersOptions.slice(0, 99);\n }, [membersOptions, search]);\n\n const handleIsOptionEqualToValue = (\n option: SelectedMember,\n value: SelectedMember,\n ) =>\n value.etag\n ? option.etag === value.etag\n : selectedMember?.[0].etag === value.etag;\n\n return (\n <>\n <FormHelperText>\n Search and select users and groups to be added. Selected users and\n groups will appear in the table below.\n </FormHelperText>\n <br />\n <Autocomplete\n disableCloseOnSelect\n data-testid=\"users-and-groups-autocomplete\"\n sx={{ width: '30%' }}\n multiple\n options={filteredMembers || []}\n getOptionLabel={(option: SelectedMember) => option.label ?? ''}\n isOptionEqualToValue={handleIsOptionEqualToValue}\n loading={membersData.loading}\n loadingText={<LinearProgress />}\n disableClearable\n value={selectedMember}\n onChange={(_e, value: SelectedMember[]) => {\n setSelectedMember(value);\n setFieldValue('selectedMembers', value);\n setSearch('');\n }}\n renderTags={() => ''}\n inputValue={search}\n onInputChange={(_e, newSearch: string, reason) =>\n reason === 'input' && setSearch(newSearch)\n }\n renderOption={(props, option: SelectedMember, state) => (\n <MembersDropdownOption props={props} option={option} state={state} />\n )}\n noOptionsText=\"No users and groups found.\"\n clearOnEscape\n renderInput={params => (\n <TextField\n data-testid=\"users-and-groups-text-field\"\n {...params}\n name=\"add-users-and-groups\"\n variant=\"outlined\"\n label=\"Select users and groups\"\n error={!!selectedMembersError}\n helperText={selectedMembersError ?? ''}\n required\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {search && (\n <IconButton\n size=\"small\"\n onClick={() => {\n setSearch('');\n }}\n aria-label=\"clear search\"\n >\n <HighlightOffIcon fontSize=\"small\" />\n </IconButton>\n )}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n )}\n />\n <br />\n {membersData.error?.message && (\n <FormHelperText error={!!membersData.error}>\n {`Error fetching user and groups: ${membersData.error.message}`}\n </FormHelperText>\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA+CO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAA2B,KAAA;AACzB,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAiB,EAAE,CAAA;AAC/C,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GACtC,SAA2B,eAAe,CAAA;AAC5C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,iBAAA,CAAkB,eAAe,CAAA;AAAA,GACnC,EAAG,CAAC,eAAe,CAAC,CAAA;AAEpB,EAAM,MAAA,cAAA,GAAiB,CAAC,MAAyB,KAAA;A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;AACb,sBAAA,SAAA,CAAU,EAAE,CAAA;AAAA,qBACd;AAAA,oBACA,YAAW,EAAA,cAAA;AAAA,oBAEX,QAAA,kBAAA,GAAA,CAAC,gBAAiB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA;AAAA;AAAA,iBACrC;AAAA,gBAED,OAAO,UAAW,CAAA;AAAA,eACrB,EAAA;AAAA;AAEJ;AAAA;AACF;AAAA,KAEJ;AAAA,wBACC,IAAG,EAAA,EAAA,CAAA;AAAA,IACH,WAAY,CAAA,KAAA,EAAO,OAClB,oBAAA,GAAA,CAAC,kBAAe,KAAO,EAAA,CAAC,CAAC,WAAA,CAAY,KAClC,EAAA,QAAA,EAAA,CAAA,gCAAA,EAAmC,WAAY,CAAA,KAAA,CAAM,OAAO,CAC/D,CAAA,EAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"AddMembersForm.esm.js","sources":["../../../src/components/CreateRole/AddMembersForm.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 { useState, useEffect, useMemo } from 'react';\n\nimport { stringifyEntityRef } from '@backstage/catalog-model';\n\nimport Autocomplete from '@mui/material/Autocomplete';\nimport FormHelperText from '@mui/material/FormHelperText';\nimport LinearProgress from '@mui/material/LinearProgress';\nimport TextField from '@mui/material/TextField';\nimport HighlightOffIcon from '@mui/icons-material/HighlightOff';\nimport IconButton from '@mui/material/IconButton';\nimport { FormikErrors } from 'formik';\n\nimport { MemberEntity } from '../../types';\nimport {\n getChildGroupsCount,\n getMembersCount,\n getParentGroupsCount,\n} from '../../utils/create-role-utils';\nimport { MembersDropdownOption } from './MembersDropdownOption';\nimport { RoleFormValues, SelectedMember } from './types';\n\ntype AddMembersFormProps = {\n selectedMembers: SelectedMember[];\n selectedMembersError?: string;\n membersData: { members: MemberEntity[]; loading: boolean; error: Error };\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n};\n\nexport const AddMembersForm = ({\n selectedMembers,\n selectedMembersError,\n setFieldValue,\n membersData,\n}: AddMembersFormProps) => {\n const [search, setSearch] = useState<string>('');\n const [selectedMember, setSelectedMember] =\n useState<SelectedMember[]>(selectedMembers);\n useEffect(() => {\n setSelectedMember(selectedMembers);\n }, [selectedMembers]);\n\n const getDescription = (member: MemberEntity) => {\n const memberCount = getMembersCount(member);\n const parentCount = getParentGroupsCount(member);\n const childCount = getChildGroupsCount(member);\n\n return member.kind === 'Group'\n ? [\n memberCount > 0 ? `${memberCount} members` : '',\n parentCount > 0 ? `${parentCount} parent group` : '',\n childCount > 0 ? `${childCount} child groups` : '',\n ]\n .filter(Boolean) // Remove any empty strings\n .join(', ')\n : undefined;\n };\n\n const membersOptions: SelectedMember[] = useMemo(() => {\n return membersData.members\n ? membersData.members.map((member: MemberEntity, index: number) => {\n const tag =\n member.metadata.etag ??\n `${member.metadata.name}-${member.kind}-${index}`;\n return {\n id: tag,\n label: member.spec?.profile?.displayName ?? member.metadata.name,\n description: getDescription(member),\n etag: tag,\n type: member.kind,\n namespace: member.metadata.namespace,\n members: getMembersCount(member),\n ref: stringifyEntityRef(member),\n };\n })\n : ([] as SelectedMember[]);\n }, [membersData.members]);\n\n const filteredMembers = useMemo(() => {\n if (search) {\n return membersOptions\n .filter(m =>\n m.label\n .toLocaleLowerCase('en-US')\n .includes(search.toLocaleLowerCase('en-US')),\n )\n .slice(0, 99);\n }\n\n return membersOptions.slice(0, 99);\n }, [membersOptions, search]);\n\n const handleIsOptionEqualToValue = (\n option: SelectedMember,\n value: SelectedMember,\n ) =>\n value.etag\n ? option.etag === value.etag\n : selectedMember?.[0].etag === value.etag;\n\n return (\n <>\n <FormHelperText>\n Search and select users and groups to be added. Selected users and\n groups will appear in the table below.\n </FormHelperText>\n <br />\n <Autocomplete\n disableCloseOnSelect\n data-testid=\"users-and-groups-autocomplete\"\n sx={{ width: '30%' }}\n multiple\n options={filteredMembers || []}\n getOptionLabel={(option: SelectedMember) => option.label ?? ''}\n isOptionEqualToValue={handleIsOptionEqualToValue}\n loading={membersData.loading}\n loadingText={<LinearProgress />}\n disableClearable\n value={selectedMember}\n onChange={(_e, value: SelectedMember[]) => {\n setSelectedMember(value);\n setFieldValue('selectedMembers', value);\n }}\n renderTags={() => ''}\n inputValue={search}\n onInputChange={(_e, newSearch: string, reason) =>\n reason === 'input' && setSearch(newSearch)\n }\n renderOption={(props, option: SelectedMember, state) => (\n <MembersDropdownOption props={props} option={option} state={state} />\n )}\n noOptionsText=\"No users and groups found.\"\n clearOnEscape\n renderInput={params => (\n <TextField\n data-testid=\"users-and-groups-text-field\"\n {...params}\n name=\"add-users-and-groups\"\n variant=\"outlined\"\n label=\"Select users and groups\"\n error={!!selectedMembersError}\n helperText={selectedMembersError ?? ''}\n required\n onKeyDown={event => {\n if (event.key === 'Backspace' && params.inputProps.value === '') {\n event.stopPropagation();\n }\n }}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {search && (\n <IconButton\n size=\"small\"\n onClick={() => {\n setSearch('');\n }}\n aria-label=\"clear search\"\n >\n <HighlightOffIcon fontSize=\"small\" />\n </IconButton>\n )}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n )}\n />\n <br />\n {membersData.error?.message && (\n <FormHelperText error={!!membersData.error}>\n {`Error fetching user and groups: ${membersData.error.message}`}\n </FormHelperText>\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA+CO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,eAAA;AAAA,EACA,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KAAA,EAAO,CAAC,CAAC,oBAAA;AAAA,YACT,YAAY,oBAAwB,IAAA,EAAA;AAAA,YACpC,QAAQ,EAAA,IAAA;AAAA,YACR,WAAW,CAAS,KAAA,KAAA;AAClB,cAAA,IAAI,MAAM,GAAQ,KAAA,WAAA,IAAe,MAAO,CAAA,UAAA,CAAW,UAAU,EAAI,EAAA;AAC/D,gBAAA,KAAA,CAAM,eAAgB,EAAA;AAAA;AACxB,aACF;AAAA,YACA,UAAY,EAAA;AAAA,cACV,GAAG,MAAO,CAAA,UAAA;AAAA,cACV,8BAEK,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,gBACC,MAAA,oBAAA,GAAA;AAAA,kBAAC,UAAA;AAAA,kBAAA;AAAA,oBACC,IAAK,EAAA,OAAA;AAAA,oBACL,SAAS,MAAM;AACb,sBAAA,SAAA,CAAU,EAAE,CAAA;AAAA,qBACd;AAAA,oBACA,YAAW,EAAA,cAAA;AAAA,oBAEX,QAAA,kBAAA,GAAA,CAAC,gBAAiB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA;AAAA;AAAA,iBACrC;AAAA,gBAED,OAAO,UAAW,CAAA;AAAA,eACrB,EAAA;AAAA;AAEJ;AAAA;AACF;AAAA,KAEJ;AAAA,wBACC,IAAG,EAAA,EAAA,CAAA;AAAA,IACH,WAAY,CAAA,KAAA,EAAO,OAClB,oBAAA,GAAA,CAAC,kBAAe,KAAO,EAAA,CAAC,CAAC,WAAA,CAAY,KAClC,EAAA,QAAA,EAAA,CAAA,gCAAA,EAAmC,WAAY,CAAA,KAAA,CAAM,OAAO,CAC/D,CAAA,EAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -14,7 +14,8 @@ const AddedMembersTable = ({
|
|
|
14
14
|
title: selectedMembers.length > 0 ? `${getMembers(selectedMembers)}` : "No users and groups selected",
|
|
15
15
|
data: selectedMembers,
|
|
16
16
|
columns: selectedMembersColumns(selectedMembers, setFieldValue),
|
|
17
|
-
emptyContent: /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", p: 2 }, children: "Selected users and groups appear here." })
|
|
17
|
+
emptyContent: /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", p: 2 }, children: "Selected users and groups appear here." }),
|
|
18
|
+
options: { emptyRowsWhenPaging: false }
|
|
18
19
|
}
|
|
19
20
|
);
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddedMembersTable.esm.js","sources":["../../../src/components/CreateRole/AddedMembersTable.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 { Table } from '@backstage/core-components';\n\nimport Box from '@mui/material/Box';\nimport { FormikErrors } from 'formik';\n\nimport { getMembers } from '../../utils/rbac-utils';\nimport { selectedMembersColumns } from './AddedMembersTableColumn';\nimport { RoleFormValues, SelectedMember } from './types';\n\ntype AddedMembersTableProps = {\n selectedMembers: SelectedMember[];\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n};\n\nexport const AddedMembersTable = ({\n selectedMembers,\n setFieldValue,\n}: AddedMembersTableProps) => {\n return (\n <Table\n title={\n selectedMembers.length > 0\n ? `${getMembers(selectedMembers)}`\n : 'No users and groups selected'\n }\n data={selectedMembers}\n columns={selectedMembersColumns(selectedMembers, setFieldValue)}\n emptyContent={\n <Box sx={{ display: 'flex', justifyContent: 'center', p: 2 }}>\n Selected users and groups appear here.\n </Box>\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAiCO,MAAM,oBAAoB,CAAC;AAAA,EAChC,eAAA;AAAA,EACA;AACF,CAA8B,KAAA;AAC5B,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAA,EACE,gBAAgB,MAAS,GAAA,CAAA,GACrB,GAAG,UAAW,CAAA,eAAe,CAAC,CAC9B,CAAA,GAAA,8BAAA;AAAA,MAEN,IAAM,EAAA,eAAA;AAAA,MACN,OAAA,EAAS,sBAAuB,CAAA,eAAA,EAAiB,aAAa,CAAA;AAAA,MAC9D,YACE,kBAAA,GAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,OAAA,EAAS,MAAQ,EAAA,cAAA,EAAgB,QAAU,EAAA,CAAA,EAAG,CAAE,EAAA,EAAG,QAE9D,EAAA,wCAAA,EAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"AddedMembersTable.esm.js","sources":["../../../src/components/CreateRole/AddedMembersTable.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 { Table } from '@backstage/core-components';\n\nimport Box from '@mui/material/Box';\nimport { FormikErrors } from 'formik';\n\nimport { getMembers } from '../../utils/rbac-utils';\nimport { selectedMembersColumns } from './AddedMembersTableColumn';\nimport { RoleFormValues, SelectedMember } from './types';\n\ntype AddedMembersTableProps = {\n selectedMembers: SelectedMember[];\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n};\n\nexport const AddedMembersTable = ({\n selectedMembers,\n setFieldValue,\n}: AddedMembersTableProps) => {\n return (\n <Table\n title={\n selectedMembers.length > 0\n ? `${getMembers(selectedMembers)}`\n : 'No users and groups selected'\n }\n data={selectedMembers}\n columns={selectedMembersColumns(selectedMembers, setFieldValue)}\n emptyContent={\n <Box sx={{ display: 'flex', justifyContent: 'center', p: 2 }}>\n Selected users and groups appear here.\n </Box>\n }\n options={{ emptyRowsWhenPaging: false }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAiCO,MAAM,oBAAoB,CAAC;AAAA,EAChC,eAAA;AAAA,EACA;AACF,CAA8B,KAAA;AAC5B,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAA,EACE,gBAAgB,MAAS,GAAA,CAAA,GACrB,GAAG,UAAW,CAAA,eAAe,CAAC,CAC9B,CAAA,GAAA,8BAAA;AAAA,MAEN,IAAM,EAAA,eAAA;AAAA,MACN,OAAA,EAAS,sBAAuB,CAAA,eAAA,EAAiB,aAAa,CAAA;AAAA,MAC9D,YACE,kBAAA,GAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,OAAA,EAAS,MAAQ,EAAA,cAAA,EAAgB,QAAU,EAAA,CAAA,EAAG,CAAE,EAAA,EAAG,QAE9D,EAAA,wCAAA,EAAA,CAAA;AAAA,MAEF,OAAA,EAAS,EAAE,mBAAA,EAAqB,KAAM;AAAA;AAAA,GACxC;AAEJ;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
3
|
-
import { useEffect } from 'react';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
4
|
import { PluginsDropdownOption } from './PluginsDropdownOption.esm.js';
|
|
5
5
|
import TextField from '@mui/material/TextField';
|
|
6
6
|
|
|
@@ -13,6 +13,7 @@ const PluginsDropdown = ({
|
|
|
13
13
|
onRemoveAllPlugins,
|
|
14
14
|
selectedPluginsError
|
|
15
15
|
}) => {
|
|
16
|
+
const [inputValue, setInputValue] = useState("");
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
if (selectedPlugins.length === allPlugins.length - 1)
|
|
18
19
|
setFieldValue(`selectedPlugins`, allPlugins, true);
|
|
@@ -21,11 +22,18 @@ const PluginsDropdown = ({
|
|
|
21
22
|
Autocomplete,
|
|
22
23
|
{
|
|
23
24
|
options: allPlugins,
|
|
25
|
+
inputValue,
|
|
26
|
+
onInputChange: (_, newInputValue, reason) => {
|
|
27
|
+
if (reason !== "reset") {
|
|
28
|
+
setInputValue(newInputValue);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
24
31
|
renderTags: () => "",
|
|
25
32
|
isOptionEqualToValue: (option, value) => option.label === value.label,
|
|
26
33
|
multiple: true,
|
|
27
34
|
disableCloseOnSelect: true,
|
|
28
35
|
getOptionLabel: (option) => option.label,
|
|
36
|
+
noOptionsText: "No plugins found.",
|
|
29
37
|
style: { width: "30%", flexGrow: "1" },
|
|
30
38
|
value: selectedPlugins || null,
|
|
31
39
|
onChange: (_e, selPlugins, reason, selOption) => {
|
|
@@ -56,6 +64,11 @@ const PluginsDropdown = ({
|
|
|
56
64
|
error: !!selectedPluginsError,
|
|
57
65
|
helperText: selectedPluginsError ?? "",
|
|
58
66
|
onBlur: handleBlur,
|
|
67
|
+
onKeyDown: (event) => {
|
|
68
|
+
if (event.key === "Backspace" && params.inputProps.value === "") {
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
59
72
|
required: true
|
|
60
73
|
}
|
|
61
74
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginsDropdown.esm.js","sources":["../../../src/components/CreateRole/PluginsDropdown.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 Autocomplete from '@mui/material/Autocomplete';\nimport type { FocusEventHandler } from 'react';\nimport { useEffect } from 'react';\nimport { SelectedPlugin } from '../../types';\nimport { PluginsDropdownOption } from './PluginsDropdownOption';\nimport TextField from '@mui/material/TextField';\nimport { FormikErrors } from 'formik';\nimport { RoleFormValues } from './types';\n\ntype PluginsDropdownProps = {\n allPlugins: SelectedPlugin[];\n selectedPlugins: SelectedPlugin[];\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n handleBlur: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n onRemoveAllPlugins: () => void;\n onRemovePlugin: (plugin: string) => void;\n selectedPluginsError: string;\n};\n\nconst PluginsDropdown = ({\n allPlugins,\n selectedPlugins,\n setFieldValue,\n handleBlur,\n onRemovePlugin,\n onRemoveAllPlugins,\n selectedPluginsError,\n}: PluginsDropdownProps) => {\n useEffect(() => {\n if (selectedPlugins.length === allPlugins.length - 1)\n setFieldValue(`selectedPlugins`, allPlugins, true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return (\n <Autocomplete\n options={allPlugins}\n renderTags={() => ''}\n isOptionEqualToValue={(option, value) => option.label === value.label}\n multiple\n disableCloseOnSelect\n getOptionLabel={option => option.label}\n style={{ width: '30%', flexGrow: '1' }}\n value={selectedPlugins || null}\n onChange={(_e, selPlugins, reason, selOption) => {\n const pVal = selOption?.option.value;\n if (pVal === '') {\n if (reason === 'selectOption') {\n setFieldValue(`selectedPlugins`, allPlugins, true);\n } else if (reason === 'removeOption') {\n onRemoveAllPlugins();\n }\n } else if (pVal) {\n if (reason === 'removeOption') {\n onRemovePlugin(pVal);\n } else if (reason === 'selectOption') {\n if (selPlugins.length === allPlugins.length - 1)\n setFieldValue(`selectedPlugins`, allPlugins, true);\n else setFieldValue(`selectedPlugins`, selPlugins, true);\n }\n }\n }}\n renderOption={(props, option: SelectedPlugin, state) => (\n <PluginsDropdownOption props={props} option={option} state={state} />\n )}\n renderInput={(params: any) => (\n <TextField\n {...params}\n label=\"Select plugins\"\n variant=\"outlined\"\n error={!!selectedPluginsError}\n helperText={selectedPluginsError ?? ''}\n onBlur={handleBlur}\n required\n />\n )}\n />\n );\n};\n\nexport default PluginsDropdown;\n"],"names":[],"mappings":";;;;;;AAsCA,MAAM,kBAAkB,CAAC;AAAA,EACvB,UAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,eAAA,CAAgB,MAAW,KAAA,UAAA,CAAW,MAAS,GAAA,CAAA;AACjD,MAAc,aAAA,CAAA,CAAA,eAAA,CAAA,EAAmB,YAAY,IAAI,CAAA;AAAA,GAErD,EAAG,EAAE,CAAA;AACL,EACE,uBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,UAAA;AAAA,MACT,YAAY,MAAM,EAAA;AAAA,MAClB,sBAAsB,CAAC,MAAA,EAAQ,KAAU,KAAA,MAAA,CAAO,UAAU,KAAM,CAAA,KAAA;AAAA,MAChE,QAAQ,EAAA,IAAA;AAAA,MACR,oBAAoB,EAAA,IAAA;AAAA,MACpB,cAAA,EAAgB,YAAU,MAAO,CAAA,KAAA;AAAA,MACjC,KAAO,EAAA,EAAE,KAAO,EAAA,KAAA,EAAO,UAAU,GAAI,EAAA;AAAA,MACrC,OAAO,eAAmB,IAAA,IAAA;AAAA,MAC1B,QAAU,EAAA,CAAC,EAAI,EAAA,UAAA,EAAY,QAAQ,SAA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*\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 Autocomplete from '@mui/material/Autocomplete';\nimport type { FocusEventHandler } from 'react';\nimport { useState, useEffect } from 'react';\nimport { SelectedPlugin } from '../../types';\nimport { PluginsDropdownOption } from './PluginsDropdownOption';\nimport TextField from '@mui/material/TextField';\nimport { FormikErrors } from 'formik';\nimport { RoleFormValues } from './types';\n\ntype PluginsDropdownProps = {\n allPlugins: SelectedPlugin[];\n selectedPlugins: SelectedPlugin[];\n setFieldValue: (\n field: string,\n value: any,\n shouldValidate?: boolean,\n ) => Promise<FormikErrors<RoleFormValues>> | Promise<void>;\n handleBlur: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n onRemoveAllPlugins: () => void;\n onRemovePlugin: (plugin: string) => void;\n selectedPluginsError: string;\n};\n\nconst PluginsDropdown = ({\n allPlugins,\n selectedPlugins,\n setFieldValue,\n handleBlur,\n onRemovePlugin,\n onRemoveAllPlugins,\n selectedPluginsError,\n}: PluginsDropdownProps) => {\n const [inputValue, setInputValue] = useState('');\n useEffect(() => {\n if (selectedPlugins.length === allPlugins.length - 1)\n setFieldValue(`selectedPlugins`, allPlugins, true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return (\n <Autocomplete\n options={allPlugins}\n inputValue={inputValue}\n onInputChange={(_, newInputValue, reason) => {\n if (reason !== 'reset') {\n setInputValue(newInputValue);\n }\n }}\n renderTags={() => ''}\n isOptionEqualToValue={(option, value) => option.label === value.label}\n multiple\n disableCloseOnSelect\n getOptionLabel={option => option.label}\n noOptionsText=\"No plugins found.\"\n style={{ width: '30%', flexGrow: '1' }}\n value={selectedPlugins || null}\n onChange={(_e, selPlugins, reason, selOption) => {\n const pVal = selOption?.option.value;\n if (pVal === '') {\n if (reason === 'selectOption') {\n setFieldValue(`selectedPlugins`, allPlugins, true);\n } else if (reason === 'removeOption') {\n onRemoveAllPlugins();\n }\n } else if (pVal) {\n if (reason === 'removeOption') {\n onRemovePlugin(pVal);\n } else if (reason === 'selectOption') {\n if (selPlugins.length === allPlugins.length - 1)\n setFieldValue(`selectedPlugins`, allPlugins, true);\n else setFieldValue(`selectedPlugins`, selPlugins, true);\n }\n }\n }}\n renderOption={(props, option: SelectedPlugin, state) => (\n <PluginsDropdownOption props={props} option={option} state={state} />\n )}\n renderInput={(params: any) => (\n <TextField\n {...params}\n label=\"Select plugins\"\n variant=\"outlined\"\n error={!!selectedPluginsError}\n helperText={selectedPluginsError ?? ''}\n onBlur={handleBlur}\n onKeyDown={event => {\n if (event.key === 'Backspace' && params.inputProps.value === '') {\n event.stopPropagation();\n }\n }}\n required\n />\n )}\n />\n );\n};\n\nexport default PluginsDropdown;\n"],"names":[],"mappings":";;;;;;AAsCA,MAAM,kBAAkB,CAAC;AAAA,EACvB,UAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,EAAE,CAAA;AAC/C,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,eAAA,CAAgB,MAAW,KAAA,UAAA,CAAW,MAAS,GAAA,CAAA;AACjD,MAAc,aAAA,CAAA,CAAA,eAAA,CAAA,EAAmB,YAAY,IAAI,CAAA;AAAA,GAErD,EAAG,EAAE,CAAA;AACL,EACE,uBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,UAAA;AAAA,MACT,UAAA;AAAA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ACxD;AACF,OACF;AAAA,MACA,YAAA,EAAc,CAAC,KAAO,EAAA,MAAA,EAAwB,0BAC3C,GAAA,CAAA,qBAAA,EAAA,EAAsB,KAAc,EAAA,MAAA,EAAgB,KAAc,EAAA,CAAA;AAAA,MAErE,WAAA,EAAa,CAAC,MACZ,qBAAA,GAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACE,GAAG,MAAA;AAAA,UACJ,KAAM,EAAA,gBAAA;AAAA,UACN,OAAQ,EAAA,UAAA;AAAA,UACR,KAAA,EAAO,CAAC,CAAC,oBAAA;AAAA,UACT,YAAY,oBAAwB,IAAA,EAAA;AAAA,UACpC,MAAQ,EAAA,UAAA;AAAA,UACR,WAAW,CAAS,KAAA,KAAA;AAClB,YAAA,IAAI,MAAM,GAAQ,KAAA,WAAA,IAAe,MAAO,CAAA,UAAA,CAAW,UAAU,EAAI,EAAA;AAC/D,cAAA,KAAA,CAAM,eAAgB,EAAA;AAAA;AACxB,WACF;AAAA,UACA,QAAQ,EAAA;AAAA;AAAA;AACV;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { parseEntityRef } from '@backstage/catalog-model';
|
|
3
|
-
import { Link } from '@backstage/core-components';
|
|
4
3
|
import EditIcon from '@mui/icons-material/Edit';
|
|
5
4
|
import IconButton from '@mui/material/IconButton';
|
|
6
5
|
import Tooltip from '@mui/material/Tooltip';
|
|
7
6
|
import Typography from '@mui/material/Typography';
|
|
8
7
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
9
8
|
import { policyEntityUpdatePermission } from '@backstage-community/plugin-rbac-common';
|
|
9
|
+
import { useNavigate } from 'react-router-dom';
|
|
10
10
|
|
|
11
11
|
const EditRole = ({
|
|
12
12
|
roleName,
|
|
@@ -15,6 +15,7 @@ const EditRole = ({
|
|
|
15
15
|
tooltip,
|
|
16
16
|
to
|
|
17
17
|
}) => {
|
|
18
|
+
const navigate = useNavigate();
|
|
18
19
|
const { name, namespace, kind } = parseEntityRef(roleName);
|
|
19
20
|
const editPermissionResult = usePermission({
|
|
20
21
|
permission: policyEntityUpdatePermission,
|
|
@@ -26,13 +27,17 @@ const EditRole = ({
|
|
|
26
27
|
return /* @__PURE__ */ jsx(Tooltip, { title: tooltip ?? tooltipText, children: /* @__PURE__ */ jsx(Typography, { component: "span", "data-testid": dataTestId ?? dataTestIdText, children: /* @__PURE__ */ jsx(
|
|
27
28
|
IconButton,
|
|
28
29
|
{
|
|
29
|
-
|
|
30
|
+
onClick: () => {
|
|
31
|
+
navigate(to ?? `../role/${kind}/${namespace}/${name}`);
|
|
32
|
+
},
|
|
30
33
|
"aria-label": "Update",
|
|
31
34
|
disabled: disable,
|
|
32
35
|
title: tooltip ?? "Edit Role",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
sx: {
|
|
37
|
+
p: 1,
|
|
38
|
+
borderRadius: "50%",
|
|
39
|
+
"&:hover": { borderRadius: "50%" }
|
|
40
|
+
},
|
|
36
41
|
children: /* @__PURE__ */ jsx(EditIcon, {})
|
|
37
42
|
}
|
|
38
43
|
) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditRole.esm.js","sources":["../../src/components/EditRole.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 { parseEntityRef } from '@backstage/catalog-model';\
|
|
1
|
+
{"version":3,"file":"EditRole.esm.js","sources":["../../src/components/EditRole.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 { parseEntityRef } from '@backstage/catalog-model';\n\nimport EditIcon from '@mui/icons-material/Edit';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { policyEntityUpdatePermission } from '@backstage-community/plugin-rbac-common';\nimport { useNavigate } from 'react-router-dom';\n\ntype EditRoleProps = {\n roleName: string;\n canEdit: boolean;\n dataTestId?: string;\n tooltip?: string;\n to?: string;\n};\n\nconst EditRole = ({\n roleName,\n canEdit,\n dataTestId,\n tooltip,\n to,\n}: EditRoleProps) => {\n const navigate = useNavigate();\n const { name, namespace, kind } = parseEntityRef(roleName);\n\n const editPermissionResult = usePermission({\n permission: policyEntityUpdatePermission,\n resourceRef: roleName,\n });\n\n const disable = !(editPermissionResult.allowed && canEdit);\n const dataTestIdText = disable\n ? `disable-update-role-${roleName}`\n : `update-role-${roleName}`;\n const tooltipText = disable ? 'Unauthorized to edit' : '';\n\n return (\n <Tooltip title={tooltip ?? tooltipText}>\n <Typography component=\"span\" data-testid={dataTestId ?? dataTestIdText}>\n <IconButton\n onClick={() => {\n navigate(to ?? `../role/${kind}/${namespace}/${name}`);\n }}\n aria-label=\"Update\"\n disabled={disable}\n title={tooltip ?? 'Edit Role'}\n sx={{\n p: 1,\n borderRadius: '50%',\n '&:hover': { borderRadius: '50%' },\n }}\n >\n <EditIcon />\n </IconButton>\n </Typography>\n </Tooltip>\n );\n};\n\nexport default EditRole;\n"],"names":[],"mappings":";;;;;;;;;;AAi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AS,EAAA,EAAA;AAAA;AAAA,KAEd,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -8,6 +8,7 @@ import { filterTableData } from '../../utils/filter-table-data.esm.js';
|
|
|
8
8
|
import { getMembers } from '../../utils/rbac-utils.esm.js';
|
|
9
9
|
import EditRole from '../EditRole.esm.js';
|
|
10
10
|
import { columns } from './MembersListColumns.esm.js';
|
|
11
|
+
import { StyledTableWrapper } from './StyledTableWrapper.esm.js';
|
|
11
12
|
|
|
12
13
|
const getRefreshIcon = () => /* @__PURE__ */ jsx(CachedIcon, {});
|
|
13
14
|
const getEditIcon = (isAllowed, roleName) => {
|
|
@@ -56,10 +57,10 @@ const MembersCard = ({ roleName, membersInfo }) => {
|
|
|
56
57
|
severity: "error"
|
|
57
58
|
}
|
|
58
59
|
) }),
|
|
59
|
-
/* @__PURE__ */ jsx(
|
|
60
|
+
/* @__PURE__ */ jsx(StyledTableWrapper, { children: /* @__PURE__ */ jsx(
|
|
60
61
|
Table,
|
|
61
62
|
{
|
|
62
|
-
title: !loading && data?.length ?
|
|
63
|
+
title: !loading && data?.length ? `${getMembers(filteredData)}` : "Users and groups",
|
|
63
64
|
actions,
|
|
64
65
|
options: { padding: "default", search: true, paging: true },
|
|
65
66
|
data: data ?? [],
|
|
@@ -75,7 +76,7 @@ const MembersCard = ({ roleName, membersInfo }) => {
|
|
|
75
76
|
),
|
|
76
77
|
onSearchChange: setSearchText
|
|
77
78
|
}
|
|
78
|
-
)
|
|
79
|
+
) })
|
|
79
80
|
] });
|
|
80
81
|
};
|
|
81
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MembersCard.esm.js","sources":["../../../src/components/RoleOverview/MembersCard.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 { useState, useMemo } from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Table, WarningPanel } from '@backstage/core-components';\n\nimport CachedIcon from '@mui/icons-material/Cached';\nimport Box from '@mui/material/Box';\n\nimport { MembersInfo } from '../../hooks/useMembers';\nimport { filterTableData } from '../../utils/filter-table-data';\nimport { getMembers } from '../../utils/rbac-utils';\nimport EditRole from '../EditRole';\nimport { columns } from './MembersListColumns';\n\ntype MembersCardProps = {\n roleName: string;\n membersInfo: MembersInfo;\n};\n\nconst getRefreshIcon = () => <CachedIcon />;\nconst getEditIcon = (isAllowed: boolean, roleName: string) => {\n const { kind, name, namespace } = parseEntityRef(roleName);\n\n return (\n <EditRole\n dataTestId={isAllowed ? 'update-members' : 'disable-update-members'}\n canEdit={isAllowed}\n roleName={roleName}\n to={`../../role/${kind}/${namespace}/${name}?activeStep=${1}`}\n />\n );\n};\n\nexport const MembersCard = ({ roleName, membersInfo }: MembersCardProps) => {\n const { data, loading, retry, error, canReadUsersAndGroups } = membersInfo;\n const [searchText, setSearchText] = useState<string>();\n\n const actions = [\n {\n icon: getRefreshIcon,\n tooltip: 'Refresh',\n isFreeAction: true,\n onClick: () => {\n retry.roleRetry();\n retry.membersRetry();\n },\n },\n {\n icon: () => getEditIcon(canReadUsersAndGroups, roleName),\n tooltip: canReadUsersAndGroups ? 'Edit' : 'Unauthorized to edit',\n isFreeAction: true,\n onClick: () => {},\n },\n ];\n\n const filteredData = useMemo(\n () => filterTableData({ data, columns, searchText }),\n [data, searchText],\n );\n\n return (\n <Box>\n {!loading && error && (\n <Box style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={(error as Error)?.message || (error as Error)?.name}\n title=\"Something went wrong while fetching the users and groups\"\n severity=\"error\"\n />\n </Box>\n )}\n <Table\n
|
|
1
|
+
{"version":3,"file":"MembersCard.esm.js","sources":["../../../src/components/RoleOverview/MembersCard.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 { useState, useMemo } from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Table, WarningPanel } from '@backstage/core-components';\n\nimport CachedIcon from '@mui/icons-material/Cached';\nimport Box from '@mui/material/Box';\n\nimport { MembersInfo } from '../../hooks/useMembers';\nimport { filterTableData } from '../../utils/filter-table-data';\nimport { getMembers } from '../../utils/rbac-utils';\nimport EditRole from '../EditRole';\nimport { columns } from './MembersListColumns';\nimport { StyledTableWrapper } from './StyledTableWrapper';\n\ntype MembersCardProps = {\n roleName: string;\n membersInfo: MembersInfo;\n};\n\nconst getRefreshIcon = () => <CachedIcon />;\nconst getEditIcon = (isAllowed: boolean, roleName: string) => {\n const { kind, name, namespace } = parseEntityRef(roleName);\n\n return (\n <EditRole\n dataTestId={isAllowed ? 'update-members' : 'disable-update-members'}\n canEdit={isAllowed}\n roleName={roleName}\n to={`../../role/${kind}/${namespace}/${name}?activeStep=${1}`}\n />\n );\n};\n\nexport const MembersCard = ({ roleName, membersInfo }: MembersCardProps) => {\n const { data, loading, retry, error, canReadUsersAndGroups } = membersInfo;\n const [searchText, setSearchText] = useState<string>();\n\n const actions = [\n {\n icon: getRefreshIcon,\n tooltip: 'Refresh',\n isFreeAction: true,\n onClick: () => {\n retry.roleRetry();\n retry.membersRetry();\n },\n },\n {\n icon: () => getEditIcon(canReadUsersAndGroups, roleName),\n tooltip: canReadUsersAndGroups ? 'Edit' : 'Unauthorized to edit',\n isFreeAction: true,\n onClick: () => {},\n },\n ];\n\n const filteredData = useMemo(\n () => filterTableData({ data, columns, searchText }),\n [data, searchText],\n );\n\n return (\n <Box>\n {!loading && error && (\n <Box style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={(error as Error)?.message || (error as Error)?.name}\n title=\"Something went wrong while fetching the users and groups\"\n severity=\"error\"\n />\n </Box>\n )}\n <StyledTableWrapper>\n <Table\n title={\n !loading && data?.length\n ? `${getMembers(filteredData)}`\n : 'Users and groups'\n }\n actions={actions}\n options={{ padding: 'default', search: true, paging: true }}\n data={data ?? []}\n isLoading={loading}\n columns={columns}\n emptyContent={\n <Box\n data-testid=\"members-table-empty\"\n sx={{ display: 'flex', justifyContent: 'center', p: 2 }}\n >\n No records found\n </Box>\n }\n onSearchChange={setSearchText}\n />\n </StyledTableWrapper>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAmCA,MAAM,cAAA,GAAiB,sBAAM,GAAA,CAAC,UAAW,EAAA,EAAA,CAAA;AACzC,MAAM,WAAA,GAAc,CAAC,SAAA,EAAoB,QAAqB,KAAA;AAC5D,EAAA,MAAM,EAAE,IAAM,EAAA,IAAA,EAAM,SAAU,EAAA,GAAI,eAAe,QAAQ,CAAA;AAEzD,EACE,uBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,UAAA,EAAY,YAAY,gBAAmB,GAAA,wBAAA;AAAA,MAC3C,OAAS,EAAA,SAAA;AAAA,MACT,QAAA;AAAA,MACA,EAAA,EAAI,cAAc,IAAI,CAAA,CAAA,EAAI,SAAS,CAAI,CAAA,EAAA,IAAI,eAAe,CAAC,CAAA;AAAA;AAAA,GAC7D;AAEJ,CAAA;AAEO,MAAM,WAAc,GAAA,CAAC,EAAE,QAAA,EAAU,aAAoC,KAAA;AAC1E,EAAA,MAAM,EAAE,IAAM,EAAA,OAAA,EAAS,KAAO,EAAA,KAAA,EAAO,uBAA0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AAA,QAEN,OAAA;AAAA,QACA,SAAS,EAAE,OAAA,EAAS,WAAW,MAAQ,EAAA,IAAA,EAAM,QAAQ,IAAK,EAAA;AAAA,QAC1D,IAAA,EAAM,QAAQ,EAAC;AAAA,QACf,SAAW,EAAA,OAAA;AAAA,QACX,OAAA;AAAA,QACA,YACE,kBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,aAAY,EAAA,qBAAA;AAAA,YACZ,IAAI,EAAE,OAAA,EAAS,QAAQ,cAAgB,EAAA,QAAA,EAAU,GAAG,CAAE,EAAA;AAAA,YACvD,QAAA,EAAA;AAAA;AAAA,SAED;AAAA,QAEF,cAAgB,EAAA;AAAA;AAAA,KAEpB,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -8,6 +8,7 @@ import { usePermissionPolicies } from '../../hooks/usePermissionPolicies.esm.js'
|
|
|
8
8
|
import { filterTableData } from '../../utils/filter-table-data.esm.js';
|
|
9
9
|
import EditRole from '../EditRole.esm.js';
|
|
10
10
|
import { columns } from './PermissionsListColumns.esm.js';
|
|
11
|
+
import { StyledTableWrapper } from './StyledTableWrapper.esm.js';
|
|
11
12
|
|
|
12
13
|
const getRefreshIcon = () => /* @__PURE__ */ jsx(CachedIcon, {});
|
|
13
14
|
const getEditIcon = (isAllowed, roleName) => {
|
|
@@ -59,6 +60,10 @@ const PermissionsCard = ({
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
];
|
|
63
|
+
let title = "Permission Policies";
|
|
64
|
+
if (!loading && data.length > 0) {
|
|
65
|
+
title = `${numberOfPolicies} permission${numberOfPolicies !== 1 ? "s" : ""}`;
|
|
66
|
+
}
|
|
62
67
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
63
68
|
error?.name && error.name !== 404 && /* @__PURE__ */ jsx(Box, { style: { paddingBottom: "16px" }, children: /* @__PURE__ */ jsx(
|
|
64
69
|
WarningPanel,
|
|
@@ -68,10 +73,10 @@ const PermissionsCard = ({
|
|
|
68
73
|
severity: "error"
|
|
69
74
|
}
|
|
70
75
|
) }),
|
|
71
|
-
/* @__PURE__ */ jsx(
|
|
76
|
+
/* @__PURE__ */ jsx(StyledTableWrapper, { children: /* @__PURE__ */ jsx(
|
|
72
77
|
Table,
|
|
73
78
|
{
|
|
74
|
-
title
|
|
79
|
+
title,
|
|
75
80
|
actions,
|
|
76
81
|
options: { padding: "default", search: true, paging: true },
|
|
77
82
|
data,
|
|
@@ -87,7 +92,7 @@ const PermissionsCard = ({
|
|
|
87
92
|
),
|
|
88
93
|
onSearchChange: setSearchText
|
|
89
94
|
}
|
|
90
|
-
)
|
|
95
|
+
) })
|
|
91
96
|
] });
|
|
92
97
|
};
|
|
93
98
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionsCard.esm.js","sources":["../../../src/components/RoleOverview/PermissionsCard.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 { useState, useMemo } from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Table, WarningPanel } from '@backstage/core-components';\n\nimport CachedIcon from '@mui/icons-material/Cached';\nimport Box from '@mui/material/Box';\n\nimport { usePermissionPolicies } from '../../hooks/usePermissionPolicies';\nimport { filterTableData } from '../../utils/filter-table-data';\nimport EditRole from '../EditRole';\nimport { columns } from './PermissionsListColumns';\n\ntype PermissionsCardProps = {\n entityReference: string;\n canReadUsersAndGroups: boolean;\n};\n\nconst getRefreshIcon = () => <CachedIcon />;\nconst getEditIcon = (isAllowed: boolean, roleName: string) => {\n const { kind, name, namespace } = parseEntityRef(roleName);\n\n return (\n <EditRole\n dataTestId={isAllowed ? 'update-policies' : 'disable-update-policies'}\n canEdit={isAllowed}\n roleName={roleName}\n to={`../../role/${kind}/${namespace}/${name}?activeStep=${2}`}\n />\n );\n};\n\nexport const PermissionsCard = ({\n entityReference,\n canReadUsersAndGroups,\n}: PermissionsCardProps) => {\n const { data, loading, retry, error } =\n usePermissionPolicies(entityReference);\n const [searchText, setSearchText] = useState<string>();\n\n const numberOfPolicies = useMemo(() => {\n const filteredPermissions = filterTableData({ data, columns, searchText });\n let policies = 0;\n filteredPermissions.forEach(p => {\n if (p.conditions) {\n policies++;\n return;\n }\n policies += p.policies.filter(pol => pol.effect === 'allow').length;\n });\n return policies;\n }, [data, searchText]);\n\n const actions = [\n {\n icon: getRefreshIcon,\n tooltip: 'Refresh',\n isFreeAction: true,\n onClick: () => {\n retry.permissionPoliciesRetry();\n retry.policiesRetry();\n retry.conditionalPoliciesRetry();\n },\n },\n {\n icon: () => getEditIcon(canReadUsersAndGroups, entityReference),\n tooltip: canReadUsersAndGroups ? 'Edit' : 'Unauthorized to edit',\n isFreeAction: true,\n onClick: () => {},\n },\n ];\n\n return (\n <Box>\n {error?.name && error.name !== 404 && (\n <Box style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={error?.message}\n title=\"Something went wrong while fetching the permission policies\"\n severity=\"error\"\n />\n </Box>\n )}\n <Table\n
|
|
1
|
+
{"version":3,"file":"PermissionsCard.esm.js","sources":["../../../src/components/RoleOverview/PermissionsCard.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 { useState, useMemo } from 'react';\n\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Table, WarningPanel } from '@backstage/core-components';\n\nimport CachedIcon from '@mui/icons-material/Cached';\nimport Box from '@mui/material/Box';\n\nimport { usePermissionPolicies } from '../../hooks/usePermissionPolicies';\nimport { filterTableData } from '../../utils/filter-table-data';\nimport EditRole from '../EditRole';\nimport { columns } from './PermissionsListColumns';\nimport { StyledTableWrapper } from './StyledTableWrapper';\n\ntype PermissionsCardProps = {\n entityReference: string;\n canReadUsersAndGroups: boolean;\n};\n\nconst getRefreshIcon = () => <CachedIcon />;\nconst getEditIcon = (isAllowed: boolean, roleName: string) => {\n const { kind, name, namespace } = parseEntityRef(roleName);\n\n return (\n <EditRole\n dataTestId={isAllowed ? 'update-policies' : 'disable-update-policies'}\n canEdit={isAllowed}\n roleName={roleName}\n to={`../../role/${kind}/${namespace}/${name}?activeStep=${2}`}\n />\n );\n};\n\nexport const PermissionsCard = ({\n entityReference,\n canReadUsersAndGroups,\n}: PermissionsCardProps) => {\n const { data, loading, retry, error } =\n usePermissionPolicies(entityReference);\n const [searchText, setSearchText] = useState<string>();\n\n const numberOfPolicies = useMemo(() => {\n const filteredPermissions = filterTableData({ data, columns, searchText });\n let policies = 0;\n filteredPermissions.forEach(p => {\n if (p.conditions) {\n policies++;\n return;\n }\n policies += p.policies.filter(pol => pol.effect === 'allow').length;\n });\n return policies;\n }, [data, searchText]);\n\n const actions = [\n {\n icon: getRefreshIcon,\n tooltip: 'Refresh',\n isFreeAction: true,\n onClick: () => {\n retry.permissionPoliciesRetry();\n retry.policiesRetry();\n retry.conditionalPoliciesRetry();\n },\n },\n {\n icon: () => getEditIcon(canReadUsersAndGroups, entityReference),\n tooltip: canReadUsersAndGroups ? 'Edit' : 'Unauthorized to edit',\n isFreeAction: true,\n onClick: () => {},\n },\n ];\n\n let title = 'Permission Policies';\n if (!loading && data.length > 0) {\n title = `${numberOfPolicies} permission${numberOfPolicies !== 1 ? 's' : ''}`;\n }\n\n return (\n <Box>\n {error?.name && error.name !== 404 && (\n <Box style={{ paddingBottom: '16px' }}>\n <WarningPanel\n message={error?.message}\n title=\"Something went wrong while fetching the permission policies\"\n severity=\"error\"\n />\n </Box>\n )}\n <StyledTableWrapper>\n <Table\n title={title}\n actions={actions}\n options={{ padding: 'default', search: true, paging: true }}\n data={data}\n columns={columns}\n isLoading={loading}\n emptyContent={\n <Box\n data-testid=\"permission-table-empty\"\n sx={{ display: 'flex', justifyContent: 'center', p: 2 }}\n >\n No records found\n </Box>\n }\n onSearchChange={setSearchText}\n />\n </StyledTableWrapper>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,MAAM,cAAA,GAAiB,sBAAM,GAAA,CAAC,UAAW,EAAA,EAAA,CAAA;AACzC,MAAM,WAAA,GAAc,CAAC,SAAA,EAAoB,QAAqB,KAAA;AAC5D,EAAA,MAAM,EAAE,IAAM,EAAA,IAAA,EAAM,SAAU,EAAA,GAAI,eAAe,QAAQ,CAAA;AAEzD,EACE,uBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,UAAA,EAAY,YAAY,iBAAoB,GAAA,yBAAA;AAAA,MAC5C,OAAS,EAAA,SAAA;AAAA,MACT,QAAA;AAAA,MACA,EAAA,EAAI,cAAc,IAAI,CAAA,CAAA,EAAI,SAAS,CAAI,CAAA,EAAA,IAAI,eAAe,CAAC,CAAA;AAAA;AAAA,GAC7D;AAEJ,CAAA;AAEO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,eAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,EAAA,MAAM,EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,KAAM,EAAA,GAClC,sBAAsB,eAAe,CAAA;AACvC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,QAAiB,EAAA;AAErD,EAAM,MAAA,gBAAA,GAAmB,QAAQ,MAAM;AACr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,IAAA,IAAQ,KAAM,CAAA,IAAA,KAAS,GAC7B,oBAAA,GAAA,CAAC,OAAI,KAAO,EAAA,EAAE,aAAe,EAAA,MAAA,EAC3B,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,SAAS,KAAO,EAAA,OAAA;AAAA,QAChB,KAAM,EAAA,6DAAA;AAAA,QACN,QAAS,EAAA;AAAA;AAAA,KAEb,EAAA,CAAA;AAAA,wBAED,kBACC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,KAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAS,EAAE,OAAA,EAAS,WAAW,MAAQ,EAAA,IAAA,EAAM,QAAQ,IAAK,EAAA;AAAA,QAC1D,IAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAW,EAAA,OAAA;AAAA,QACX,YACE,kBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,aAAY,EAAA,wBAAA;AAAA,YACZ,IAAI,EAAE,OAAA,EAAS,QAAQ,cAAgB,EAAA,QAAA,EAAU,GAAG,CAAE,EAAA;AAAA,YACvD,QAAA,EAAA;AAAA;AAAA,SAED;AAAA,QAEF,cAAgB,EAAA;AAAA;AAAA,KAEpB,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Box from '@mui/material/Box';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
|
|
4
|
+
const StyledTableWrapper = styled(Box)(() => ({
|
|
5
|
+
'& [class*="-spacer"]': {
|
|
6
|
+
display: "none !important"
|
|
7
|
+
},
|
|
8
|
+
'& [class*="BackstageTableToolbar-searchField"]': {
|
|
9
|
+
marginLeft: "auto !important"
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
export { StyledTableWrapper };
|
|
14
|
+
//# sourceMappingURL=StyledTableWrapper.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyledTableWrapper.esm.js","sources":["../../../src/components/RoleOverview/StyledTableWrapper.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 */\n\nimport Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\nexport const StyledTableWrapper = styled(Box)(() => ({\n '& [class*=\"-spacer\"]': {\n display: 'none !important',\n },\n '& [class*=\"BackstageTableToolbar-searchField\"]': {\n marginLeft: 'auto !important',\n },\n}));\n"],"names":[],"mappings":";;;AAmBO,MAAM,kBAAqB,GAAA,MAAA,CAAO,GAAG,CAAA,CAAE,OAAO;AAAA,EACnD,sBAAwB,EAAA;AAAA,IACtB,OAAS,EAAA;AAAA,GACX;AAAA,EACA,gDAAkD,EAAA;AAAA,IAChD,UAAY,EAAA;AAAA;AAEhB,CAAE,CAAA;;;;"}
|
|
@@ -32,8 +32,11 @@ const DeleteRole = ({
|
|
|
32
32
|
"aria-label": "Delete",
|
|
33
33
|
disabled: disable,
|
|
34
34
|
title: tooltip ?? "Delete Role",
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
sx: {
|
|
36
|
+
p: 1,
|
|
37
|
+
borderRadius: "50%",
|
|
38
|
+
"&:hover": { borderRadius: "50%" }
|
|
39
|
+
},
|
|
37
40
|
children: /* @__PURE__ */ jsx(Delete, {})
|
|
38
41
|
}
|
|
39
42
|
) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteRole.esm.js","sources":["../../../src/components/RolesList/DeleteRole.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 { useDeleteDialog } from '@janus-idp/shared-react';\nimport Delete from '@mui/icons-material/Delete';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { policyEntityDeletePermission } from '@backstage-community/plugin-rbac-common';\nimport { usePermission } from '@backstage/plugin-permission-react';\n\ntype DeleteRoleProps = {\n roleName: string;\n canEdit: boolean;\n dataTestId?: string;\n tooltip?: string;\n};\n\nconst DeleteRole = ({\n roleName,\n canEdit,\n dataTestId,\n tooltip,\n}: DeleteRoleProps) => {\n const { setDeleteComponent, setOpenDialog } = useDeleteDialog();\n\n const openDialog = (name: string) => {\n setDeleteComponent({ roleName: name });\n setOpenDialog(true);\n };\n\n const deletePermissionResult = usePermission({\n permission: policyEntityDeletePermission,\n resourceRef: roleName,\n });\n\n const disable = !(deletePermissionResult.allowed && canEdit);\n const dataTestIdText = disable\n ? `disable-delete-role-${roleName}`\n : `delete-role-${roleName}`;\n const tooltipText = disable ? 'Role cannot be deleted' : '';\n\n return (\n <Tooltip title={tooltip ?? tooltipText}>\n <Typography component=\"span\" data-testid={dataTestId ?? dataTestIdText}>\n <IconButton\n onClick={() => openDialog(roleName)}\n aria-label=\"Delete\"\n disabled={disable}\n title={tooltip ?? 'Delete Role'}\n
|
|
1
|
+
{"version":3,"file":"DeleteRole.esm.js","sources":["../../../src/components/RolesList/DeleteRole.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 { useDeleteDialog } from '@janus-idp/shared-react';\nimport Delete from '@mui/icons-material/Delete';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { policyEntityDeletePermission } from '@backstage-community/plugin-rbac-common';\nimport { usePermission } from '@backstage/plugin-permission-react';\n\ntype DeleteRoleProps = {\n roleName: string;\n canEdit: boolean;\n dataTestId?: string;\n tooltip?: string;\n};\n\nconst DeleteRole = ({\n roleName,\n canEdit,\n dataTestId,\n tooltip,\n}: DeleteRoleProps) => {\n const { setDeleteComponent, setOpenDialog } = useDeleteDialog();\n\n const openDialog = (name: string) => {\n setDeleteComponent({ roleName: name });\n setOpenDialog(true);\n };\n\n const deletePermissionResult = usePermission({\n permission: policyEntityDeletePermission,\n resourceRef: roleName,\n });\n\n const disable = !(deletePermissionResult.allowed && canEdit);\n const dataTestIdText = disable\n ? `disable-delete-role-${roleName}`\n : `delete-role-${roleName}`;\n const tooltipText = disable ? 'Role cannot be deleted' : '';\n\n return (\n <Tooltip title={tooltip ?? tooltipText}>\n <Typography component=\"span\" data-testid={dataTestId ?? dataTestIdText}>\n <IconButton\n onClick={() => openDialog(roleName)}\n aria-label=\"Delete\"\n disabled={disable}\n title={tooltip ?? 'Delete Role'}\n sx={{\n p: 1,\n borderRadius: '50%',\n '&:hover': { borderRadius: '50%' },\n }}\n >\n <Delete />\n </IconButton>\n </Typography>\n </Tooltip>\n );\n};\nexport default DeleteRole;\n"],"names":[],"mappings":";;;;;;;;;AA8BA,MAAM,aAAa,CAAC;AAAA,EAClB,Q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EZ,CACF,EAAA,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-rbac",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.4",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"ui-test": "start-server-and-test start localhost:3000 'playwright test'"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@backstage-community/plugin-rbac-common": "^1.16.
|
|
39
|
+
"@backstage-community/plugin-rbac-common": "^1.16.1",
|
|
40
40
|
"@backstage/catalog-model": "^1.7.3",
|
|
41
41
|
"@backstage/core-components": "^0.17.1",
|
|
42
42
|
"@backstage/core-plugin-api": "^1.10.6",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@backstage/test-utils": "^1.7.7",
|
|
70
70
|
"@playwright/test": "^1.52.0",
|
|
71
71
|
"@redhat-developer/red-hat-developer-hub-theme": "0.4.0",
|
|
72
|
-
"@spotify/prettier-config": "^15.0.0",
|
|
73
72
|
"@testing-library/dom": "^10.0.0",
|
|
74
73
|
"@testing-library/jest-dom": "^6.0.0",
|
|
75
74
|
"@testing-library/react": "^15.0.0",
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
"@PatAKnight"
|
|
105
104
|
],
|
|
106
105
|
"author": "Red Hat",
|
|
107
|
-
"prettier": "@
|
|
106
|
+
"prettier": "@backstage/cli/config/prettier",
|
|
108
107
|
"lint-staged": {
|
|
109
108
|
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
110
109
|
"eslint --fix",
|