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 />}
/> />
<ListItemLink
to="/settings" <Can
primary={i18n.t("mainDrawer.listItems.settings")} role={user.profile}
icon={<SettingsOutlinedIcon />} perform="settings-view:show"
yes={() => (
<ListItemLink
to="/settings"
primary={i18n.t("mainDrawer.listItems.settings")}
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>
<Button
variant="contained"
color="primary" <Can
onClick={handleOpenWhatsAppModal} role={user.profile}
> perform="btn-add-whatsapp"
{i18n.t("connections.buttons.add")} yes={() => (
</Button> <Button
variant="contained"
color="primary"
onClick={handleOpenWhatsAppModal}>
{i18n.t("connections.buttons.add")}
</Button>
)}
/>
</MainHeaderButtonsWrapper> </MainHeaderButtonsWrapper>
</MainHeader> </MainHeader>
<Paper className={classes.mainPaper} variant="outlined"> <Paper className={classes.mainPaper} variant="outlined">
@ -395,14 +405,23 @@ const Connections = () => {
<Edit /> <Edit />
</IconButton> </IconButton>
<IconButton
size="small"
onClick={e => { <Can
handleOpenConfirmationModal("delete", whatsApp.id); role={user.profile}
}} perform="btn-remove-whatsapp"
> yes={() => (
<DeleteOutline /> <IconButton
</IconButton> size="small"
onClick={e => {
handleOpenConfirmationModal("delete", whatsApp.id);
}}
>
<DeleteOutline />
</IconButton>
)}
/>
</TableCell> </TableCell>
</TableRow> </TableRow>
))} ))}

View File

@ -231,14 +231,24 @@ const Users = () => {
), ),
}} }}
/> />
<Can
role={userA.profile}
perform="btn-add-user"
yes={() => (
<Button
variant="contained"
color="primary"
onClick={handleOpenUserModal}
>
{i18n.t("users.buttons.add")}
</Button>
)}
/>
<Button
variant="contained"
color="primary"
onClick={handleOpenUserModal}
>
{i18n.t("users.buttons.add")}
</Button>
</MainHeaderButtonsWrapper> </MainHeaderButtonsWrapper>
</MainHeader> </MainHeader>
@ -280,16 +290,23 @@ const Users = () => {
> >
<EditIcon /> <EditIcon />
</IconButton> </IconButton>
<IconButton
size="small" <Can
onClick={(e) => { role={userA.profile}
setConfirmModalOpen(true); perform="icon-remove-user"
setDeletingUser(user); yes={() => (
}} <IconButton
> size="small"
<DeleteOutlineIcon /> onClick={(e) => {
</IconButton> setConfirmModalOpen(true);
setDeletingUser(user);
}}
>
<DeleteOutlineIcon />
</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",
], ],
}, },
}; };