feat: strict "show all" option to admin only

This commit is contained in:
canove
2021-01-13 16:02:05 -03:00
parent aac6d30083
commit c61c993572
2 changed files with 23 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ const rules = {
}, },
admin: { admin: {
static: ["drawer-admin-items:view"], static: ["drawer-admin-items:view", "tickets-manager:showall"],
}, },
}; };

View File

@@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { useContext, useState } from "react";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import Paper from "@material-ui/core/Paper"; import Paper from "@material-ui/core/Paper";
@@ -18,6 +18,8 @@ import TicketsList from "../TicketsList";
import TabPanel from "../TabPanel"; import TabPanel from "../TabPanel";
import { i18n } from "../../translate/i18n"; import { i18n } from "../../translate/i18n";
import { AuthContext } from "../../context/Auth/AuthContext";
import Can from "../Can";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
ticketsWrapper: { ticketsWrapper: {
@@ -88,6 +90,7 @@ const TicketsManager = () => {
const [tab, setTab] = useState("open"); const [tab, setTab] = useState("open");
const [newTicketModalOpen, setNewTicketModalOpen] = useState(false); const [newTicketModalOpen, setNewTicketModalOpen] = useState(false);
const [showAllTickets, setShowAllTickets] = useState(false); const [showAllTickets, setShowAllTickets] = useState(false);
const { user } = useContext(AuthContext);
const handleSearchContact = e => { const handleSearchContact = e => {
if (e.target.value === "") { if (e.target.value === "") {
@@ -149,6 +152,10 @@ const TicketsManager = () => {
/> />
</div> </div>
<div className={classes.ticketsListActions}> <div className={classes.ticketsListActions}>
<Can
role={user.profile}
perform="tickets-manager:showall"
yes={() => (
<FormControlLabel <FormControlLabel
label={i18n.t("tickets.buttons.showAll")} label={i18n.t("tickets.buttons.showAll")}
labelPlacement="start" labelPlacement="start"
@@ -162,6 +169,9 @@ const TicketsManager = () => {
/> />
} }
/> />
)}
/>
<IconButton <IconButton
aria-label="add ticket" aria-label="add ticket"
size="small" size="small"