-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from zilliztech/user_roles
Support assign privilege
- Loading branch information
Showing
18 changed files
with
594 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
makeStyles, | ||
Theme, | ||
Typography, | ||
Checkbox, | ||
FormGroup, | ||
FormControlLabel, | ||
} from '@material-ui/core'; | ||
import { FC } from 'react'; | ||
import { Privilege, PrivilegeOptionsProps } from './Types'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
checkBox: { | ||
width: theme.spacing(24), | ||
}, | ||
formGrp: { | ||
marginBottom: theme.spacing(2), | ||
}, | ||
subTitle: { | ||
marginBottom: theme.spacing(0.5), | ||
}, | ||
})); | ||
|
||
const PrivilegeOptions: FC<PrivilegeOptionsProps> = ({ | ||
options, | ||
selection, | ||
onChange, | ||
title, | ||
roleName, | ||
object, | ||
objectName = '*', | ||
}) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<> | ||
<Typography variant="h6" component="h6" className={classes.subTitle}> | ||
{title} | ||
</Typography> | ||
<FormGroup row className={classes.formGrp}> | ||
{options.map((r: string) => ( | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
onChange={( | ||
e: React.ChangeEvent<HTMLInputElement>, | ||
checked: boolean | ||
) => { | ||
let newSelection = [...selection]; | ||
|
||
if (!checked) { | ||
newSelection = newSelection.filter( | ||
(n: Privilege) => n.privilegeName !== r | ||
); | ||
} else { | ||
newSelection.push({ | ||
privilegeName: r, | ||
object: object, | ||
objectName: objectName, | ||
roleName: roleName, | ||
}); | ||
} | ||
onChange(newSelection); | ||
}} | ||
/> | ||
} | ||
key={r} | ||
label={r} | ||
value={r} | ||
checked={selection.filter((s: Privilege) => s.privilegeName === r).length > 0} | ||
className={classes.checkBox} | ||
/> | ||
))} | ||
</FormGroup> | ||
</> | ||
); | ||
}; | ||
|
||
export default PrivilegeOptions; |
Oops, something went wrong.