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

View File

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