diff --git a/src/frontend/src/components/images/DetailsImage.tsx b/src/frontend/src/components/images/DetailsImage.tsx index 44f896e031..4eda7d0809 100644 --- a/src/frontend/src/components/images/DetailsImage.tsx +++ b/src/frontend/src/components/images/DetailsImage.tsx @@ -1,9 +1,11 @@ import { Trans, t } from '@lingui/macro'; import { + AspectRatio, Button, Group, Image, Modal, + Overlay, Paper, Text, rem, @@ -20,6 +22,7 @@ import { InvenTreeIcon } from '../../functions/icons'; import { useUserState } from '../../states/UserState'; import { PartThumbTable } from '../../tables/part/PartThumbTable'; import { ActionButton } from '../buttons/ActionButton'; +import { StylishText } from '../items/StylishText'; import { ApiImage } from './ApiImage'; /** @@ -58,9 +61,9 @@ const backup_image = '/static/img/blank_image.png'; */ const removeModal = (apiPath: string, setImage: (image: string) => void) => modals.openConfirmModal({ - title: t`Remove Image`, + title: {t`Remove Image`}, children: ( - + Remove the associated image from this item? ), @@ -245,13 +248,8 @@ function ImageActionButtons({ pk: string; setImage: (image: string) => void; }) { - const [opened, { open, close }] = useDisclosure(false); - return ( <> - - - {visible && ( {actions.selectExisting && ( } + icon={ + + } tooltip={t`Select from existing images`} variant="outline" size="lg" tooltipAlignment="top" - onClick={open} + onClick={() => { + modals.open({ + title: {t`Select Image`}, + size: 'xxl', + children: + }); + }} /> )} {actions.uploadFile && ( } + icon={ + + } tooltip={t`Upload new image`} variant="outline" size="lg" tooltipAlignment="top" onClick={() => { modals.open({ - title: t`Upload Image`, + title: {t`Upload Image`}, children: ( ) @@ -320,39 +331,33 @@ export function DetailsImage(props: DetailImageProps) { return ( <> - - { - modals.open({ - children: , - withCloseButton: false - }); - }} - /> - {permissions.hasChangeRole(props.appRole) && ( - + <> + { + modals.open({ + children: , + withCloseButton: false + }); + }} /> - )} - + {permissions.hasChangeRole(props.appRole) && hovered && ( + + + + )} + + ); } diff --git a/src/frontend/src/tables/Details.tsx b/src/frontend/src/tables/Details.tsx index d32dba6fbc..b062635f5f 100644 --- a/src/frontend/src/tables/Details.tsx +++ b/src/frontend/src/tables/Details.tsx @@ -5,6 +5,7 @@ import { Badge, CopyButton, Group, + Paper, Skeleton, Table, Text, @@ -437,7 +438,7 @@ export function DetailsTable({ partIcons?: boolean; }) { return ( - + {partIcons && ( @@ -475,6 +476,6 @@ export function DetailsTable({ })}
-
+ ); } diff --git a/src/frontend/src/tables/ItemDetails.tsx b/src/frontend/src/tables/ItemDetails.tsx index 76e08296df..1ffc49473f 100644 --- a/src/frontend/src/tables/ItemDetails.tsx +++ b/src/frontend/src/tables/ItemDetails.tsx @@ -1,4 +1,4 @@ -import { Paper } from '@mantine/core'; +import { Grid, Group, Paper, SimpleGrid } from '@mantine/core'; import { DetailImageButtonProps, @@ -50,48 +50,39 @@ export function ItemDetails({ partModel: boolean; }) { return ( - - - {fields.image && ( -
- -
- )} - {fields.left && ( -
- -
- )} -
- {fields.right && ( - - - - )} - {fields.bottom_left && ( - + + + + {fields.image && ( + + + + )} + + {fields.left && ( + + )} + + + {fields.right && } + {fields.bottom_left && ( - - )} - {fields.bottom_right && ( - + )} + {fields.bottom_right && ( - - )} + )} + ); } diff --git a/src/frontend/src/tables/part/PartThumbTable.tsx b/src/frontend/src/tables/part/PartThumbTable.tsx index 0d18becfc9..e110250de8 100644 --- a/src/frontend/src/tables/part/PartThumbTable.tsx +++ b/src/frontend/src/tables/part/PartThumbTable.tsx @@ -1,6 +1,18 @@ -import { t } from '@lingui/macro'; -import { Button, Paper, Skeleton, Text, TextInput } from '@mantine/core'; +import { Trans, t } from '@lingui/macro'; +import { + AspectRatio, + Button, + Divider, + Group, + Paper, + SimpleGrid, + Skeleton, + Stack, + Text, + TextInput +} from '@mantine/core'; import { useHover } from '@mantine/hooks'; +import { modals } from '@mantine/modals'; import { useQuery } from '@tanstack/react-query'; import React, { Suspense, useEffect, useState } from 'react'; @@ -17,7 +29,6 @@ export type ThumbTableProps = { limit?: number; offset?: number; search?: string; - close: () => void; setImage: (image: string) => void; }; @@ -62,29 +73,19 @@ function PartThumbComponent({ selected, element, selectImage }: ThumbProps) { return ( selectImage(element.image)} > -
- -
- - {element.image.split('/')[1]} ({element.count}) - + + + + + + {element.image.split('/')[1]} ({element.count}) + +
); } @@ -95,7 +96,6 @@ function PartThumbComponent({ selected, element, selectImage }: ThumbProps) { async function setNewImage( image: string | null, pk: string, - close: () => void, setImage: (image: string) => void ) { // No need to do anything if no image is selected @@ -110,7 +110,7 @@ async function setNewImage( // Update image component and close modal if update was successful if (response.data.image.includes(image)) { setImage(response.data.image); - close(); + modals.closeAll(); } } @@ -118,11 +118,10 @@ async function setNewImage( * Renders a "table" of thumbnails */ export function PartThumbTable({ - limit = 25, + limit = 24, offset = 0, search = '', pk, - close, setImage }: ThumbTableProps) { const [img, selectImage] = useState(null); @@ -155,61 +154,51 @@ export function PartThumbTable({ return ( <> - - {!thumbQuery.isFetching - ? thumbQuery.data?.data.map((data: ImageElement, index: number) => ( - - )) - : [...Array(limit)].map((elem, idx) => ( - - ))} + + + <> + + {!thumbQuery.isFetching + ? thumbQuery.data?.data.map( + (data: ImageElement, index: number) => ( + + ) + ) + : [...Array(limit)].map((elem, idx) => ( + + ))} + + - - { - setFilterInput(event.currentTarget.value); - }} - /> - + + + + + { + setFilterInput(event.currentTarget.value); + }} + /> + + );