Skip to content

Commit

Permalink
Updates to address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <yicai@redhat.com>
  • Loading branch information
ciiay committed Jul 11, 2024
1 parent dd810f1 commit 81822c2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { PermissionCondition } from '@backstage/plugin-permission-common';
import {
FormControlLabel,
IconButton,
makeStyles,
Radio,
RadioGroup,
useTheme,
Expand All @@ -21,6 +20,7 @@ import {
getDefaultRule,
nestedConditionButtons,
ruleOptionDisabled,
useConditionsFormRowStyles,
} from '../../utils/conditional-access-utils';
import { AddNestedConditionButton } from './AddNestedConditionButton';
import { ConditionsFormRowFields } from './ConditionsFormRowFields';
Expand All @@ -33,67 +33,6 @@ import {
NotConditionType,
} from './types';

const useStyles = makeStyles(theme => ({
conditionRow: {
padding: '20px',
border: `1px solid ${theme.palette.border}`,
borderRadius: '4px',
backgroundColor: theme.palette.background.default,
'& input': {
backgroundColor: `${theme.palette.background.paper}!important`,
},
},
nestedConditionRow: {
padding: '20px',
marginLeft: theme.spacing(3),
border: `1px solid ${theme.palette.border}`,
borderRadius: '4px',
backgroundColor: theme.palette.background.default,
'& input': {
backgroundColor: `${theme.palette.background.paper}!important`,
},
},
criteriaButtonGroup: {
backgroundColor: theme.palette.background.paper,
width: '80%',
},
nestedConditioncriteriaButtonGroup: {
backgroundColor: theme.palette.background.paper,
width: '60%',
height: '100%',
},
addRuleButton: {
display: 'flex',
color: theme.palette.primary.light,
textTransform: 'none',
marginTop: theme.spacing(2),
},
addNestedConditionButton: {
display: 'flex',
color: theme.palette.primary.light,
textTransform: 'none',
marginTop: theme.spacing(1),
marginBottom: theme.spacing(2),
},
removeRuleButton: {
color: theme.palette.grey[500],
flexGrow: 0,
alignSelf: 'baseline',
marginTop: theme.spacing(3.3),
},
removeNestedRuleButton: {
color: theme.palette.grey[500],
flexGrow: 0,
alignSelf: 'baseline',
},
radioGroup: {
margin: theme.spacing(1),
},
radioLabel: {
marginTop: theme.spacing(1),
},
}));

export const ConditionsFormRow = ({
conditionRulesData,
conditionRow,
Expand All @@ -104,7 +43,7 @@ export const ConditionsFormRow = ({
handleSetErrors,
setRemoveAllClicked,
}: ConditionFormRowProps) => {
const classes = useStyles();
const classes = useConditionsFormRowStyles();
const theme = useTheme();
const [nestedConditionRow, setNestedConditionRow] = React.useState<
Condition[]
Expand Down
63 changes: 63 additions & 0 deletions plugins/rbac/src/utils/conditional-access-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PermissionCondition } from '@backstage/plugin-permission-common';

import { makeStyles } from '@material-ui/core';

import { conditionButtons } from '../components/ConditionalAccess/const';
import { Condition } from '../components/ConditionalAccess/types';

Expand Down Expand Up @@ -33,3 +35,64 @@ export const getDefaultRule = (selPluginResourceType: string) => ({
resourceType: selPluginResourceType,
params: {},
});

export const useConditionsFormRowStyles = makeStyles(theme => ({
conditionRow: {
padding: '20px',
border: `1px solid ${theme.palette.border}`,
borderRadius: '4px',
backgroundColor: theme.palette.background.default,
'& input': {
backgroundColor: `${theme.palette.background.paper}!important`,
},
},
nestedConditionRow: {
padding: '20px',
marginLeft: theme.spacing(3),
border: `1px solid ${theme.palette.border}`,
borderRadius: '4px',
backgroundColor: theme.palette.background.default,
'& input': {
backgroundColor: `${theme.palette.background.paper}!important`,
},
},
criteriaButtonGroup: {
backgroundColor: theme.palette.background.paper,
width: '80%',
},
nestedConditioncriteriaButtonGroup: {
backgroundColor: theme.palette.background.paper,
width: '60%',
height: '100%',
},
addRuleButton: {
display: 'flex',
color: theme.palette.primary.light,
textTransform: 'none',
marginTop: theme.spacing(2),
},
addNestedConditionButton: {
display: 'flex',
color: theme.palette.primary.light,
textTransform: 'none',
marginTop: theme.spacing(1),
marginBottom: theme.spacing(2),
},
removeRuleButton: {
color: theme.palette.grey[500],
flexGrow: 0,
alignSelf: 'baseline',
marginTop: theme.spacing(3.3),
},
removeNestedRuleButton: {
color: theme.palette.grey[500],
flexGrow: 0,
alignSelf: 'baseline',
},
radioGroup: {
margin: theme.spacing(1),
},
radioLabel: {
marginTop: theme.spacing(1),
},
}));

0 comments on commit 81822c2

Please sign in to comment.