mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 20:15:44 +00:00
Cleanup imgae hover
This commit is contained in:
@ -14,7 +14,7 @@ import {
|
|||||||
import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
||||||
import { useDisclosure, useHover } from '@mantine/hooks';
|
import { useDisclosure, useHover } from '@mantine/hooks';
|
||||||
import { modals } from '@mantine/modals';
|
import { modals } from '@mantine/modals';
|
||||||
import { useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
@ -340,6 +340,15 @@ export function DetailsImage(props: DetailImageProps) {
|
|||||||
|
|
||||||
const permissions = useUserState();
|
const permissions = useUserState();
|
||||||
|
|
||||||
|
const hasOverlay: boolean = useMemo(() => {
|
||||||
|
return (
|
||||||
|
props.imageActions?.selectExisting ||
|
||||||
|
props.imageActions?.uploadFile ||
|
||||||
|
props.imageActions?.deleteFile ||
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}, [props.imageActions]);
|
||||||
|
|
||||||
const expandImage = (event: any) => {
|
const expandImage = (event: any) => {
|
||||||
event?.preventDefault();
|
event?.preventDefault();
|
||||||
event?.stopPropagation();
|
event?.stopPropagation();
|
||||||
@ -360,7 +369,9 @@ export function DetailsImage(props: DetailImageProps) {
|
|||||||
width={IMAGE_DIMENSION}
|
width={IMAGE_DIMENSION}
|
||||||
onClick={expandImage}
|
onClick={expandImage}
|
||||||
/>
|
/>
|
||||||
{permissions.hasChangeRole(props.appRole) && hovered && (
|
{permissions.hasChangeRole(props.appRole) &&
|
||||||
|
hasOverlay &&
|
||||||
|
hovered && (
|
||||||
<Overlay color="black" opacity={0.8} onClick={expandImage}>
|
<Overlay color="black" opacity={0.8} onClick={expandImage}>
|
||||||
<ImageActionButtons
|
<ImageActionButtons
|
||||||
visible={hovered}
|
visible={hovered}
|
||||||
|
Reference in New Issue
Block a user