mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-21 14:19:26 +00:00
chore: update shortcut permission button
This commit is contained in:
parent
9d5766b411
commit
96e858f08c
@ -17,10 +17,7 @@ interface Props {
|
||||
const ShortcutView = (props: Props) => {
|
||||
const { shortcut, handleEdit } = props;
|
||||
const user = useAppSelector((state) => state.user.user as User);
|
||||
|
||||
const havePermission = (shortcut: Shortcut) => {
|
||||
return user.role === "ADMIN" || shortcut.creatorId === user.id;
|
||||
};
|
||||
const havePermission = user.role === "ADMIN" || shortcut.creatorId === user.id;
|
||||
|
||||
const handleCopyButtonClick = (shortcut: Shortcut) => {
|
||||
copy(absolutifyLink(`/s/${shortcut.name}`));
|
||||
@ -58,19 +55,18 @@ const ShortcutView = (props: Props) => {
|
||||
<Icon.ExternalLink className="w-5 h-auto text-gray-600" />
|
||||
</a>
|
||||
</Tooltip>
|
||||
{havePermission && (
|
||||
<Dropdown
|
||||
actionsClassName="!w-24"
|
||||
actions={
|
||||
<>
|
||||
<button
|
||||
disabled={!havePermission(shortcut)}
|
||||
className="w-full px-2 flex flex-row justify-start items-center text-left leading-8 cursor-pointer rounded hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||
onClick={() => handleEdit()}
|
||||
>
|
||||
<Icon.Edit className="w-4 h-auto mr-2" /> Edit
|
||||
</button>
|
||||
<button
|
||||
disabled={!havePermission(shortcut)}
|
||||
className="w-full px-2 flex flex-row justify-start items-center text-left leading-8 cursor-pointer rounded text-red-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||
onClick={() => {
|
||||
handleDeleteShortcutButtonClick(shortcut);
|
||||
@ -81,6 +77,7 @@ const ShortcutView = (props: Props) => {
|
||||
</>
|
||||
}
|
||||
></Dropdown>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{shortcut.description && <p className="mt-1 text-gray-400 text-sm">{shortcut.description}</p>}
|
||||
|
Loading…
x
Reference in New Issue
Block a user