Criação das rules no frontend para que somente o master possa visualizar os botões de inserção e exclusão

pull/1/head
adriano 2022-01-13 08:09:26 -03:00
parent 6c42e8e8c9
commit 3d0ae04abf
4 changed files with 86 additions and 38 deletions

View File

@ -126,11 +126,20 @@ const MainListItems = (props) => {
icon={<DashboardOutlinedIcon />} icon={<DashboardOutlinedIcon />}
/> />
<Can
role={user.profile}
perform="settings-view:show"
yes={() => (
<ListItemLink <ListItemLink
to="/settings" to="/settings"
primary={i18n.t("mainDrawer.listItems.settings")} primary={i18n.t("mainDrawer.listItems.settings")}
icon={<SettingsOutlinedIcon />} icon={<SettingsOutlinedIcon />}
/> />
)}
/>
</> </>
)} )}
/> />

View File

@ -329,13 +329,23 @@ const Connections = () => {
<MainHeader> <MainHeader>
<Title>{i18n.t("connections.title")}</Title> <Title>{i18n.t("connections.title")}</Title>
<MainHeaderButtonsWrapper> <MainHeaderButtonsWrapper>
<Can
role={user.profile}
perform="btn-add-whatsapp"
yes={() => (
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
onClick={handleOpenWhatsAppModal} onClick={handleOpenWhatsAppModal}>
>
{i18n.t("connections.buttons.add")} {i18n.t("connections.buttons.add")}
</Button> </Button>
)}
/>
</MainHeaderButtonsWrapper> </MainHeaderButtonsWrapper>
</MainHeader> </MainHeader>
<Paper className={classes.mainPaper} variant="outlined"> <Paper className={classes.mainPaper} variant="outlined">
@ -395,6 +405,12 @@ const Connections = () => {
<Edit /> <Edit />
</IconButton> </IconButton>
<Can
role={user.profile}
perform="btn-remove-whatsapp"
yes={() => (
<IconButton <IconButton
size="small" size="small"
onClick={e => { onClick={e => {
@ -403,6 +419,9 @@ const Connections = () => {
> >
<DeleteOutline /> <DeleteOutline />
</IconButton> </IconButton>
)}
/>
</TableCell> </TableCell>
</TableRow> </TableRow>
))} ))}

View File

@ -232,6 +232,11 @@ const Users = () => {
}} }}
/> />
<Can
role={userA.profile}
perform="btn-add-user"
yes={() => (
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
@ -239,6 +244,11 @@ const Users = () => {
> >
{i18n.t("users.buttons.add")} {i18n.t("users.buttons.add")}
</Button> </Button>
)}
/>
</MainHeaderButtonsWrapper> </MainHeaderButtonsWrapper>
</MainHeader> </MainHeader>
@ -281,6 +291,11 @@ const Users = () => {
<EditIcon /> <EditIcon />
</IconButton> </IconButton>
<Can
role={userA.profile}
perform="icon-remove-user"
yes={() => (
<IconButton <IconButton
size="small" size="small"
onClick={(e) => { onClick={(e) => {
@ -290,6 +305,8 @@ const Users = () => {
> >
<DeleteOutlineIcon /> <DeleteOutlineIcon />
</IconButton> </IconButton>
)}
/>
</TableCell> </TableCell>

View File

@ -16,7 +16,7 @@ const rules = {
"dashboard-view:show", "dashboard-view:show",
"queues-view:show", "queues-view:show",
"user-view:show", "user-view:show",
"settings-view:show", //"settings-view:show",
], ],
}, },
@ -35,7 +35,10 @@ const rules = {
"user-view:show", "user-view:show",
"settings-view:show", "settings-view:show",
//"remove-user-test" "btn-add-user",
"icon-remove-user",
"btn-add-whatsapp",
"btn-remove-whatsapp",
], ],
}, },
}; };