2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

[PUI] More style fixes (#7142)

* fix interface names

* use Readonly for props

* fix typescript:S3863

* require hashes in package installer too
This commit is contained in:
Matthias Mair 2024-04-30 11:24:52 +02:00 committed by GitHub
parent a9b932cc32
commit 7e9d2f79ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 174 additions and 127 deletions

View File

@ -90,7 +90,7 @@ function detect_envs() {
echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}" echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}"
# Install parser # Install parser
pip install -r ${APP_HOME}/.github/requirements.txt -q pip install --require-hashes -r ${APP_HOME}/.github/requirements.txt -q
# Load config # Load config
local CONF=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml) local CONF=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml)

View File

@ -5,6 +5,6 @@ import { ActionButton, ActionButtonProps } from './ActionButton';
/** /**
* A generic icon button which is used to add or create a new item * A generic icon button which is used to add or create a new item
*/ */
export function AddItemButton(props: ActionButtonProps) { export function AddItemButton(props: Readonly<ActionButtonProps>) {
return <ActionButton {...props} color="green" icon={<IconPlus />} />; return <ActionButton {...props} color="green" icon={<IconPlus />} />;
} }

View File

@ -52,7 +52,7 @@ export function SplitButton({
selected, selected,
setSelected, setSelected,
loading loading
}: SplitButtonProps) { }: Readonly<SplitButtonProps>) {
const [current, setCurrent] = useState<string>(defaultSelected); const [current, setCurrent] = useState<string>(defaultSelected);
const { classes } = useStyles(); const { classes } = useStyles();

View File

@ -180,7 +180,7 @@ function NameBadge({ pk, type }: { pk: string | number; type: BadgeType }) {
* If owner is defined, only renders a badge * If owner is defined, only renders a badge
* If user is defined, a badge is rendered in addition to main value * If user is defined, a badge is rendered in addition to main value
*/ */
function TableStringValue(props: FieldProps) { function TableStringValue(props: Readonly<FieldProps>) {
let value = props?.field_value; let value = props?.field_value;
if (value === undefined) { if (value === undefined) {
@ -217,11 +217,11 @@ function TableStringValue(props: FieldProps) {
); );
} }
function BooleanValue(props: FieldProps) { function BooleanValue(props: Readonly<FieldProps>) {
return <YesNoButton value={props.field_value} />; return <YesNoButton value={props.field_value} />;
} }
function TableAnchorValue(props: FieldProps) { function TableAnchorValue(props: Readonly<FieldProps>) {
if (props.field_data.external) { if (props.field_data.external) {
return ( return (
<Anchor <Anchor
@ -303,7 +303,7 @@ function TableAnchorValue(props: FieldProps) {
); );
} }
function ProgressBarValue(props: FieldProps) { function ProgressBarValue(props: Readonly<FieldProps>) {
return ( return (
<ProgressBar <ProgressBar
value={props.field_data.progress} value={props.field_data.progress}
@ -313,7 +313,7 @@ function ProgressBarValue(props: FieldProps) {
); );
} }
function StatusValue(props: FieldProps) { function StatusValue(props: Readonly<FieldProps>) {
return ( return (
<StatusRenderer type={props.field_data.model} status={props.field_value} /> <StatusRenderer type={props.field_data.model} status={props.field_value} />
); );

View File

@ -7,7 +7,7 @@ export type DetailsBadgeProps = {
visible?: boolean; visible?: boolean;
}; };
export default function DetailsBadge(props: DetailsBadgeProps) { export default function DetailsBadge(props: Readonly<DetailsBadgeProps>) {
if (props.visible == false) { if (props.visible == false) {
return null; return null;
} }

View File

@ -322,7 +322,7 @@ function ImageActionButtons({
/** /**
* Renders an image with action buttons for display on Details panels * Renders an image with action buttons for display on Details panels
*/ */
export function DetailsImage(props: DetailImageProps) { export function DetailsImage(props: Readonly<DetailImageProps>) {
// Displays a group of ActionButtons on hover // Displays a group of ActionButtons on hover
const { hovered, ref } = useHover(); const { hovered, ref } = useHover();
const [img, setImg] = useState<string>(props.src ?? backup_image); const [img, setImg] = useState<string>(props.src ?? backup_image);

View File

@ -87,7 +87,7 @@ type TemplateEditorProps = {
template: TemplateI; template: TemplateI;
}; };
export function TemplateEditor(props: TemplateEditorProps) { export function TemplateEditor(props: Readonly<TemplateEditorProps>) {
const { downloadUrl, editors, previewAreas, preview } = props; const { downloadUrl, editors, previewAreas, preview } = props;
const editorRef = useRef<EditorRef>(); const editorRef = useRef<EditorRef>();
const previewRef = useRef<PreviewAreaRef>(); const previewRef = useRef<PreviewAreaRef>();

View File

@ -10,8 +10,7 @@ import {
import { UseFormReturnType } from '@mantine/form'; import { UseFormReturnType } from '@mantine/form';
import { useId } from '@mantine/hooks'; import { useId } from '@mantine/hooks';
import { IconX } from '@tabler/icons-react'; import { IconX } from '@tabler/icons-react';
import { ReactNode, useCallback, useEffect } from 'react'; import { ReactNode, useCallback, useEffect, useMemo } from 'react';
import { useMemo } from 'react';
import { Control, FieldValues, useController } from 'react-hook-form'; import { Control, FieldValues, useController } from 'react-hook-form';
import { ModelType } from '../../../enums/ModelType'; import { ModelType } from '../../../enums/ModelType';

View File

@ -1,7 +1,6 @@
import { Select } from '@mantine/core'; import { Select } from '@mantine/core';
import { useId } from '@mantine/hooks'; import { useId } from '@mantine/hooks';
import { useCallback } from 'react'; import { useCallback, useMemo } from 'react';
import { useMemo } from 'react';
import { FieldValues, UseControllerReturn } from 'react-hook-form'; import { FieldValues, UseControllerReturn } from 'react-hook-form';
import { ApiFormFieldType } from './ApiFormField'; import { ApiFormFieldType } from './ApiFormField';

View File

@ -1,7 +1,6 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Input, useMantineTheme } from '@mantine/core'; import { Input, useMantineTheme } from '@mantine/core';
import { useDebouncedValue } from '@mantine/hooks'; import { useDebouncedValue, useId } from '@mantine/hooks';
import { useId } from '@mantine/hooks';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { import {

View File

@ -1,7 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Anchor, Skeleton } from '@mantine/core'; import { Anchor, Group, Skeleton, Text } from '@mantine/core';
import { Group } from '@mantine/core';
import { Text } from '@mantine/core';
import { ReactNode, useMemo } from 'react'; import { ReactNode, useMemo } from 'react';
import { ApiImage } from './ApiImage'; import { ApiImage } from './ApiImage';

View File

@ -6,7 +6,12 @@ interface DocInfoProps extends BaseDocProps {
size?: number; size?: number;
} }
export function DocInfo({ size = 18, text, detail, link }: DocInfoProps) { export function DocInfo({
size = 18,
text,
detail,
link
}: Readonly<DocInfoProps>) {
return ( return (
<DocTooltip text={text} detail={detail} link={link}> <DocTooltip text={text} detail={detail} link={link}>
<IconInfoCircle size={size} /> <IconInfoCircle size={size} />

View File

@ -21,7 +21,7 @@ export function DocTooltip({
detail, detail,
link, link,
docchildren docchildren
}: DocTooltipProps) { }: Readonly<DocTooltipProps>) {
const { classes } = InvenTreeStyle(); const { classes } = InvenTreeStyle();
return ( return (

View File

@ -13,7 +13,7 @@ export type ProgressBarProps = {
* A progress bar element, built on mantine.Progress * A progress bar element, built on mantine.Progress
* The color of the bar is determined based on the value * The color of the bar is determined based on the value
*/ */
export function ProgressBar(props: ProgressBarProps) { export function ProgressBar(props: Readonly<ProgressBarProps>) {
const progress = useMemo(() => { const progress = useMemo(() => {
let maximum = props.maximum ?? 100; let maximum = props.maximum ?? 100;
let value = Math.max(props.value, 0); let value = Math.max(props.value, 0);

View File

@ -14,7 +14,7 @@ export function TitleWithDoc({
size, size,
text, text,
detail detail
}: DocTitleProps) { }: Readonly<DocTitleProps>) {
return ( return (
<Group> <Group>
<Title variant={variant} order={order} size={size}> <Title variant={variant} order={order} size={size}>

View File

@ -43,7 +43,7 @@ function DetailDrawerComponent({
size, size,
closeOnEscape = true, closeOnEscape = true,
renderContent renderContent
}: DrawerProps) { }: Readonly<DrawerProps>) {
const navigate = useNavigate(); const navigate = useNavigate();
const { id } = useParams(); const { id } = useParams();
const { classes } = useStyles(); const { classes } = useStyles();
@ -95,7 +95,7 @@ function DetailDrawerComponent({
); );
} }
export function DetailDrawer(props: DrawerProps) { export function DetailDrawer(props: Readonly<DrawerProps>) {
return ( return (
<Routes> <Routes>
<Route path=":id?/" element={<DetailDrawerComponent {...props} />} /> <Route path=":id?/" element={<DetailDrawerComponent {...props} />} />

View File

@ -4,15 +4,16 @@ import {
Alert, Alert,
Divider, Divider,
Drawer, Drawer,
Group,
LoadingOverlay, LoadingOverlay,
Space, Space,
Stack,
Text,
Tooltip Tooltip
} from '@mantine/core'; } from '@mantine/core';
import { Group, Stack, Text } from '@mantine/core';
import { IconBellCheck, IconBellPlus } from '@tabler/icons-react'; import { IconBellCheck, IconBellPlus } from '@tabler/icons-react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { api } from '../../App'; import { api } from '../../App';
import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ApiEndpoints } from '../../enums/ApiEndpoints';

View File

@ -5,6 +5,17 @@ import { ApiImage } from '../images/ApiImage';
import { StylishText } from '../items/StylishText'; import { StylishText } from '../items/StylishText';
import { Breadcrumb, BreadcrumbList } from './BreadcrumbList'; import { Breadcrumb, BreadcrumbList } from './BreadcrumbList';
interface PageDetailInterface {
title?: string;
subtitle?: string;
imageUrl?: string;
detail?: ReactNode;
badges?: ReactNode[];
breadcrumbs?: Breadcrumb[];
breadcrumbAction?: () => void;
actions?: ReactNode[];
}
/** /**
* Construct a "standard" page detail for common display between pages. * Construct a "standard" page detail for common display between pages.
* *
@ -20,16 +31,7 @@ export function PageDetail({
breadcrumbs, breadcrumbs,
breadcrumbAction, breadcrumbAction,
actions actions
}: { }: Readonly<PageDetailInterface>) {
title?: string;
subtitle?: string;
imageUrl?: string;
detail?: ReactNode;
badges?: ReactNode[];
breadcrumbs?: Breadcrumb[];
breadcrumbAction?: () => void;
actions?: ReactNode[];
}) {
return ( return (
<Stack spacing="xs"> <Stack spacing="xs">
{breadcrumbs && breadcrumbs.length > 0 && ( {breadcrumbs && breadcrumbs.length > 0 && (

View File

@ -10,8 +10,7 @@ import {
IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftCollapse,
IconLayoutSidebarRightCollapse IconLayoutSidebarRightCollapse
} from '@tabler/icons-react'; } from '@tabler/icons-react';
import { ReactNode, useMemo } from 'react'; import { ReactNode, useEffect, useMemo, useState } from 'react';
import { useEffect, useState } from 'react';
import { import {
Navigate, Navigate,
Route, Route,
@ -51,7 +50,7 @@ function BasePanelGroup({
onPanelChange, onPanelChange,
selectedPanel, selectedPanel,
collapsible = true collapsible = true
}: PanelProps): ReactNode { }: Readonly<PanelProps>): ReactNode {
const navigate = useNavigate(); const navigate = useNavigate();
const { panel } = useParams(); const { panel } = useParams();
@ -178,7 +177,11 @@ function BasePanelGroup({
); );
} }
function IndexPanelComponent({ pageKey, selectedPanel, panels }: PanelProps) { function IndexPanelComponent({
pageKey,
selectedPanel,
panels
}: Readonly<PanelProps>) {
const lastUsedPanel = useLocalState((state) => { const lastUsedPanel = useLocalState((state) => {
const panelName = const panelName =
selectedPanel || state.lastUsedPanels[pageKey] || panels[0]?.name; selectedPanel || state.lastUsedPanels[pageKey] || panels[0]?.name;
@ -203,7 +206,7 @@ function IndexPanelComponent({ pageKey, selectedPanel, panels }: PanelProps) {
* @param onPanelChange - Callback when the active panel changes * @param onPanelChange - Callback when the active panel changes
* @param collapsible - If true, the panel group can be collapsed (defaults to true) * @param collapsible - If true, the panel group can be collapsed (defaults to true)
*/ */
export function PanelGroup(props: PanelProps) { export function PanelGroup(props: Readonly<PanelProps>) {
return ( return (
<Routes> <Routes>
<Route index element={<IndexPanelComponent {...props} />} /> <Route index element={<IndexPanelComponent {...props} />} />

View File

@ -8,6 +8,7 @@ import {
Divider, Divider,
Drawer, Drawer,
Group, Group,
Loader,
Menu, Menu,
Paper, Paper,
Space, Space,
@ -15,7 +16,6 @@ import {
Text, Text,
TextInput TextInput
} from '@mantine/core'; } from '@mantine/core';
import { Loader } from '@mantine/core';
import { useDebouncedValue } from '@mantine/hooks'; import { useDebouncedValue } from '@mantine/hooks';
import { import {
IconAlertCircle, IconAlertCircle,

View File

@ -3,6 +3,15 @@ import { IconSwitch } from '@tabler/icons-react';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
interface SettingsHeaderInterface {
title: string | ReactNode;
shorthand?: string;
subtitle?: string | ReactNode;
switch_condition?: boolean;
switch_text?: string | ReactNode;
switch_link?: string;
}
/** /**
* Construct a settings page header with interlinks to one other settings page * Construct a settings page header with interlinks to one other settings page
*/ */
@ -13,14 +22,7 @@ export function SettingsHeader({
switch_condition = true, switch_condition = true,
switch_text, switch_text,
switch_link switch_link
}: { }: Readonly<SettingsHeaderInterface>) {
title: string | ReactNode;
shorthand?: string;
subtitle?: string | ReactNode;
switch_condition?: boolean;
switch_text?: string | ReactNode;
switch_link?: string;
}) {
return ( return (
<Stack spacing="0" ml={'sm'}> <Stack spacing="0" ml={'sm'}>
<Group> <Group>

View File

@ -1,13 +1,15 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
import { StatusRenderer } from './StatusRenderer'; import { StatusRenderer } from './StatusRenderer';
/** /**
* Inline rendering of a single BuildOrder instance * Inline rendering of a single BuildOrder instance
*/ */
export function RenderBuildOrder({ instance }: { instance: any }): ReactNode { export function RenderBuildOrder({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return ( return (
<RenderInlineModel <RenderInlineModel
primary={instance.reference} primary={instance.reference}
@ -24,7 +26,9 @@ export function RenderBuildOrder({ instance }: { instance: any }): ReactNode {
/* /*
* Inline rendering of a single BuildLine instance * Inline rendering of a single BuildLine instance
*/ */
export function RenderBuildLine({ instance }: { instance: any }): ReactNode { export function RenderBuildLine({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return ( return (
<RenderInlineModel <RenderInlineModel
primary={instance.part_detail.full_name} primary={instance.part_detail.full_name}

View File

@ -1,11 +1,13 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
/** /**
* Inline rendering of a single Address instance * Inline rendering of a single Address instance
*/ */
export function RenderAddress({ instance }: { instance: any }): ReactNode { export function RenderAddress({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
let text = [ let text = [
instance.country, instance.country,
instance.postal_code, instance.postal_code,
@ -23,7 +25,9 @@ export function RenderAddress({ instance }: { instance: any }): ReactNode {
/** /**
* Inline rendering of a single Company instance * Inline rendering of a single Company instance
*/ */
export function RenderCompany({ instance }: { instance: any }): ReactNode { export function RenderCompany({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
// TODO: Handle URL // TODO: Handle URL
return ( return (
@ -38,14 +42,18 @@ export function RenderCompany({ instance }: { instance: any }): ReactNode {
/** /**
* Inline rendering of a single Contact instance * Inline rendering of a single Contact instance
*/ */
export function RenderContact({ instance }: { instance: any }): ReactNode { export function RenderContact({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return <RenderInlineModel primary={instance.name} />; return <RenderInlineModel primary={instance.name} />;
} }
/** /**
* Inline rendering of a single SupplierPart instance * Inline rendering of a single SupplierPart instance
*/ */
export function RenderSupplierPart({ instance }: { instance: any }): ReactNode { export function RenderSupplierPart({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
// TODO: handle URL // TODO: handle URL
let supplier = instance.supplier_detail ?? {}; let supplier = instance.supplier_detail ?? {};
@ -66,9 +74,7 @@ export function RenderSupplierPart({ instance }: { instance: any }): ReactNode {
*/ */
export function RenderManufacturerPart({ export function RenderManufacturerPart({
instance instance
}: { }: Readonly<InstanceRenderInterface>): ReactNode {
instance: any;
}): ReactNode {
let part = instance.part_detail ?? {}; let part = instance.part_detail ?? {};
let manufacturer = instance.manufacturer_detail ?? {}; let manufacturer = instance.manufacturer_detail ?? {};

View File

@ -1,8 +1,10 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
export function RenderProjectCode({ instance }: { instance: any }): ReactNode { export function RenderProjectCode({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return ( return (
instance && ( instance && (
<RenderInlineModel <RenderInlineModel

View File

@ -1,6 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Alert, Space } from '@mantine/core'; import { Alert, Group, Space, Text } from '@mantine/core';
import { Group, Text } from '@mantine/core';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
@ -38,7 +37,7 @@ type EnumDictionary<T extends string | symbol | number, U> = {
*/ */
const RendererLookup: EnumDictionary< const RendererLookup: EnumDictionary<
ModelType, ModelType,
(props: { instance: any }) => ReactNode (props: Readonly<InstanceRenderInterface>) => ReactNode
> = { > = {
[ModelType.address]: RenderAddress, [ModelType.address]: RenderAddress,
[ModelType.build]: RenderBuildOrder, [ModelType.build]: RenderBuildOrder,
@ -140,3 +139,7 @@ export function UnknownRenderer({
</Alert> </Alert>
); );
} }
export interface InstanceRenderInterface {
instance: any;
}

View File

@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
import { StatusRenderer } from './StatusRenderer'; import { StatusRenderer } from './StatusRenderer';
/** /**
@ -10,9 +10,7 @@ import { StatusRenderer } from './StatusRenderer';
*/ */
export function RenderPurchaseOrder({ export function RenderPurchaseOrder({
instance instance
}: { }: Readonly<InstanceRenderInterface>): ReactNode {
instance: any;
}): ReactNode {
let supplier = instance.supplier_detail || {}; let supplier = instance.supplier_detail || {};
// TODO: Handle URL // TODO: Handle URL
@ -32,7 +30,9 @@ export function RenderPurchaseOrder({
/** /**
* Inline rendering of a single ReturnOrder instance * Inline rendering of a single ReturnOrder instance
*/ */
export function RenderReturnOrder({ instance }: { instance: any }): ReactNode { export function RenderReturnOrder({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
let customer = instance.customer_detail || {}; let customer = instance.customer_detail || {};
return ( return (
@ -51,7 +51,9 @@ export function RenderReturnOrder({ instance }: { instance: any }): ReactNode {
/** /**
* Inline rendering of a single SalesOrder instance * Inline rendering of a single SalesOrder instance
*/ */
export function RenderSalesOrder({ instance }: { instance: any }): ReactNode { export function RenderSalesOrder({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
let customer = instance.customer_detail || {}; let customer = instance.customer_detail || {};
// TODO: Handle URL // TODO: Handle URL

View File

@ -1,12 +1,14 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
/** /**
* Inline rendering of a single Part instance * Inline rendering of a single Part instance
*/ */
export function RenderPart({ instance }: { instance: any }): ReactNode { export function RenderPart({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
const stock = t`Stock` + `: ${instance.in_stock}`; const stock = t`Stock` + `: ${instance.in_stock}`;
return ( return (
@ -22,7 +24,9 @@ export function RenderPart({ instance }: { instance: any }): ReactNode {
/** /**
* Inline rendering of a PartCategory instance * Inline rendering of a PartCategory instance
*/ */
export function RenderPartCategory({ instance }: { instance: any }): ReactNode { export function RenderPartCategory({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
// TODO: Handle URL // TODO: Handle URL
let lvl = '-'.repeat(instance.level || 0); let lvl = '-'.repeat(instance.level || 0);

View File

@ -14,7 +14,7 @@ export interface StatusCodeListInterface {
[key: string]: StatusCodeInterface; [key: string]: StatusCodeInterface;
} }
interface renderStatusLabelOptionsInterface { interface RenderStatusLabelOptionsInterface {
size?: MantineSize; size?: MantineSize;
} }
@ -24,7 +24,7 @@ interface renderStatusLabelOptionsInterface {
function renderStatusLabel( function renderStatusLabel(
key: string | number, key: string | number,
codes: StatusCodeListInterface, codes: StatusCodeListInterface,
options: renderStatusLabelOptionsInterface = {} options: RenderStatusLabelOptionsInterface = {}
) { ) {
let text = null; let text = null;
let color = null; let color = null;
@ -70,7 +70,7 @@ export const StatusRenderer = ({
}: { }: {
status: string | number; status: string | number;
type: ModelType | string; type: ModelType | string;
options?: renderStatusLabelOptionsInterface; options?: RenderStatusLabelOptionsInterface;
}) => { }) => {
const statusCodeList = useGlobalStatusState.getState().status; const statusCodeList = useGlobalStatusState.getState().status;

View File

@ -1,16 +1,14 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
/** /**
* Inline rendering of a single StockLocation instance * Inline rendering of a single StockLocation instance
*/ */
export function RenderStockLocation({ export function RenderStockLocation({
instance instance
}: { }: Readonly<InstanceRenderInterface>): ReactNode {
instance: any;
}): ReactNode {
return ( return (
<RenderInlineModel <RenderInlineModel
primary={instance.name} primary={instance.name}
@ -19,7 +17,9 @@ export function RenderStockLocation({
); );
} }
export function RenderStockItem({ instance }: { instance: any }): ReactNode { export function RenderStockItem({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
let quantity_string = ''; let quantity_string = '';
if (instance?.serial !== null && instance?.serial !== undefined) { if (instance?.serial !== null && instance?.serial !== undefined) {

View File

@ -1,9 +1,11 @@
import { IconUser, IconUsersGroup } from '@tabler/icons-react'; import { IconUser, IconUsersGroup } from '@tabler/icons-react';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { RenderInlineModel } from './Instance'; import { InstanceRenderInterface, RenderInlineModel } from './Instance';
export function RenderOwner({ instance }: { instance: any }): ReactNode { export function RenderOwner({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return ( return (
instance && ( instance && (
<RenderInlineModel <RenderInlineModel
@ -14,7 +16,9 @@ export function RenderOwner({ instance }: { instance: any }): ReactNode {
); );
} }
export function RenderUser({ instance }: { instance: any }): ReactNode { export function RenderUser({
instance
}: Readonly<InstanceRenderInterface>): ReactNode {
return ( return (
instance && ( instance && (
<RenderInlineModel <RenderInlineModel

View File

@ -2,8 +2,7 @@ import { t } from '@lingui/macro';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import EasyMDE from 'easymde'; import EasyMDE from 'easymde';
import 'easymde/dist/easymde.min.css'; import 'easymde/dist/easymde.min.css';
import { ReactNode, useCallback, useMemo } from 'react'; import { ReactNode, useCallback, useMemo, useState } from 'react';
import { useState } from 'react';
import SimpleMDE from 'react-simplemde-editor'; import SimpleMDE from 'react-simplemde-editor';
import { api } from '../../App'; import { api } from '../../App';

View File

@ -4,9 +4,10 @@ import {
Container, Container,
Group, Group,
Indicator, Indicator,
Menu,
Text,
createStyles createStyles
} from '@mantine/core'; } from '@mantine/core';
import { Menu, Text } from '@mantine/core';
import { useDisclosure, useHotkeys } from '@mantine/hooks'; import { useDisclosure, useHotkeys } from '@mantine/hooks';
import { import {
IconArrowBackUpDouble, IconArrowBackUpDouble,

View File

@ -5,13 +5,13 @@ import {
useUserSettingsState useUserSettingsState
} from '../states/SettingsState'; } from '../states/SettingsState';
interface formatDecmimalOptionsType { interface FormatDecmimalOptionsInterface {
digits?: number; digits?: number;
minDigits?: number; minDigits?: number;
locale?: string; locale?: string;
} }
interface formatCurrencyOptionsType { interface FormatCurrencyOptionsInterface {
digits?: number; digits?: number;
minDigits?: number; minDigits?: number;
currency?: string; currency?: string;
@ -21,7 +21,7 @@ interface formatCurrencyOptionsType {
export function formatDecimal( export function formatDecimal(
value: number | null | undefined, value: number | null | undefined,
options: formatDecmimalOptionsType = {} options: FormatDecmimalOptionsInterface = {}
) { ) {
let locale = options.locale || navigator.language || 'en-US'; let locale = options.locale || navigator.language || 'en-US';
@ -44,7 +44,7 @@ export function formatDecimal(
*/ */
export function formatCurrency( export function formatCurrency(
value: number | string | null | undefined, value: number | string | null | undefined,
options: formatCurrencyOptionsType = {} options: FormatCurrencyOptionsInterface = {}
) { ) {
if (value == null || value == undefined) { if (value == null || value == undefined) {
return null; return null;
@ -89,7 +89,7 @@ export function formatCurrency(
export function formatPriceRange( export function formatPriceRange(
minValue: number | null, minValue: number | null,
maxValue: number | null, maxValue: number | null,
options: formatCurrencyOptionsType = {} options: FormatCurrencyOptionsInterface = {}
) { ) {
// If neither values are provided, return a dash // If neither values are provided, return a dash
if (minValue == null && maxValue == null) { if (minValue == null && maxValue == null) {
@ -116,7 +116,7 @@ export function formatPriceRange(
)}`; )}`;
} }
interface renderDateOptionsType { interface RenderDateOptionsInterface {
showTime?: boolean; showTime?: boolean;
showSeconds?: boolean; showSeconds?: boolean;
} }
@ -127,7 +127,10 @@ interface renderDateOptionsType {
* The provided "date" variable is a string, nominally ISO format e.g. 2022-02-22 * The provided "date" variable is a string, nominally ISO format e.g. 2022-02-22
* The user-configured setting DATE_DISPLAY_FORMAT determines how the date should be displayed. * The user-configured setting DATE_DISPLAY_FORMAT determines how the date should be displayed.
*/ */
export function renderDate(date: string, options: renderDateOptionsType = {}) { export function renderDate(
date: string,
options: RenderDateOptionsInterface = {}
) {
if (!date) { if (!date) {
return '-'; return '-';
} }

View File

@ -217,7 +217,7 @@ type InvenTreeIconProps = {
iconProps?: TablerIconProps; iconProps?: TablerIconProps;
}; };
export function InvenTreeIcon(props: InvenTreeIconProps) { export function InvenTreeIcon(props: Readonly<InvenTreeIconProps>) {
let Icon: React.ForwardRefExoticComponent<React.RefAttributes<any>>; let Icon: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
if (props.icon in icons) { if (props.icon in icons) {

View File

@ -1,7 +1,13 @@
import { Trans } from '@lingui/macro'; import { Trans } from '@lingui/macro';
import { Button, Card, Stack, TextInput } from '@mantine/core'; import {
import { Group, Text } from '@mantine/core'; Accordion,
import { Accordion } from '@mantine/core'; Button,
Card,
Group,
Stack,
Text,
TextInput
} from '@mantine/core';
import { spotlight } from '@mantine/spotlight'; import { spotlight } from '@mantine/spotlight';
import { IconAlien } from '@tabler/icons-react'; import { IconAlien } from '@tabler/icons-react';
import { ReactNode, useMemo, useState } from 'react'; import { ReactNode, useMemo, useState } from 'react';

View File

@ -1,9 +1,11 @@
import { Trans, t } from '@lingui/macro'; import { Trans, t } from '@lingui/macro';
import { import {
ActionIcon, ActionIcon,
Badge,
Button, Button,
Checkbox, Checkbox,
Col, Col,
Container,
Grid, Grid,
Group, Group,
ScrollArea, ScrollArea,
@ -15,15 +17,14 @@ import {
TextInput, TextInput,
rem rem
} from '@mantine/core'; } from '@mantine/core';
import { Badge, Container } from '@mantine/core';
import { import {
getHotkeyHandler, getHotkeyHandler,
randomId, randomId,
useDocumentVisibility,
useFullscreen, useFullscreen,
useListState, useListState,
useLocalStorage useLocalStorage
} from '@mantine/hooks'; } from '@mantine/hooks';
import { useDocumentVisibility } from '@mantine/hooks';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { import {
IconAlertCircle, IconAlertCircle,
@ -36,9 +37,9 @@ import {
IconPlus, IconPlus,
IconQuestionMark, IconQuestionMark,
IconSearch, IconSearch,
IconTrash IconTrash,
IconX
} from '@tabler/icons-react'; } from '@tabler/icons-react';
import { IconX } from '@tabler/icons-react';
import { Html5Qrcode } from 'html5-qrcode'; import { Html5Qrcode } from 'html5-qrcode';
import { CameraDevice } from 'html5-qrcode/camera/core'; import { CameraDevice } from 'html5-qrcode/camera/core';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
@ -470,11 +471,11 @@ enum InputMethod {
ImageBarcode = 'imageBarcode' ImageBarcode = 'imageBarcode'
} }
interface inputProps { interface ScanInputInterface {
action: (items: ScanItem[]) => void; action: (items: ScanItem[]) => void;
} }
function InputManual({ action }: inputProps) { function InputManual({ action }: Readonly<ScanInputInterface>) {
const [value, setValue] = useState<string>(''); const [value, setValue] = useState<string>('');
function btnAddItem() { function btnAddItem() {
@ -526,7 +527,7 @@ function InputManual({ action }: inputProps) {
} }
/* Input that uses QR code detection from images */ /* Input that uses QR code detection from images */
function InputImageBarcode({ action }: inputProps) { function InputImageBarcode({ action }: Readonly<ScanInputInterface>) {
const [qrCodeScanner, setQrCodeScanner] = useState<Html5Qrcode | null>(null); const [qrCodeScanner, setQrCodeScanner] = useState<Html5Qrcode | null>(null);
const [camId, setCamId] = useLocalStorage<CameraDevice | null>({ const [camId, setCamId] = useLocalStorage<CameraDevice | null>({
key: 'camId', key: 'camId',

View File

@ -29,8 +29,7 @@ import {
} from '../../components/items/ActionDropdown'; } from '../../components/items/ActionDropdown';
import { Breadcrumb } from '../../components/nav/BreadcrumbList'; import { Breadcrumb } from '../../components/nav/BreadcrumbList';
import { PageDetail } from '../../components/nav/PageDetail'; import { PageDetail } from '../../components/nav/PageDetail';
import { PanelGroup } from '../../components/nav/PanelGroup'; import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
import { PanelType } from '../../components/nav/PanelGroup';
import { NotesEditor } from '../../components/widgets/MarkdownEditor'; import { NotesEditor } from '../../components/widgets/MarkdownEditor';
import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { UserRoles } from '../../enums/Roles'; import { UserRoles } from '../../enums/Roles';
@ -57,7 +56,7 @@ export type CompanyDetailProps = {
/** /**
* Detail view for a single company instance * Detail view for a single company instance
*/ */
export default function CompanyDetail(props: CompanyDetailProps) { export default function CompanyDetail(props: Readonly<CompanyDetailProps>) {
const { id } = useParams(); const { id } = useParams();
const user = useUserState(); const user = useUserState();

View File

@ -1,6 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Checkbox, Menu, Tooltip } from '@mantine/core'; import { ActionIcon, Checkbox, Menu, Tooltip } from '@mantine/core';
import { ActionIcon } from '@mantine/core';
import { IconAdjustments } from '@tabler/icons-react'; import { IconAdjustments } from '@tabler/icons-react';
export function TableColumnSelect({ export function TableColumnSelect({

View File

@ -1,6 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { ActionIcon, Menu } from '@mantine/core'; import { ActionIcon, Menu, Tooltip } from '@mantine/core';
import { Tooltip } from '@mantine/core';
import { IconDownload } from '@tabler/icons-react'; import { IconDownload } from '@tabler/icons-react';
export function DownloadAction({ export function DownloadAction({

View File

@ -3,17 +3,22 @@ import {
ActionIcon, ActionIcon,
Alert, Alert,
Box, Box,
Group,
Indicator, Indicator,
LoadingOverlay, LoadingOverlay,
Space, Space,
Stack, Stack,
Tooltip Tooltip
} from '@mantine/core'; } from '@mantine/core';
import { Group } from '@mantine/core';
import { modals } from '@mantine/modals'; import { modals } from '@mantine/modals';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { IconFilter, IconRefresh, IconTrash } from '@tabler/icons-react'; import {
import { IconBarcode, IconPrinter } from '@tabler/icons-react'; IconBarcode,
IconFilter,
IconPrinter,
IconRefresh,
IconTrash
} from '@tabler/icons-react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { import {
DataTable, DataTable,

View File

@ -1,6 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { ActionIcon, Tooltip } from '@mantine/core'; import { ActionIcon, Menu, Tooltip } from '@mantine/core';
import { Menu } from '@mantine/core';
import { IconCopy, IconDots, IconEdit, IconTrash } from '@tabler/icons-react'; import { IconCopy, IconDots, IconEdit, IconTrash } from '@tabler/icons-react';
import { ReactNode, useMemo, useState } from 'react'; import { ReactNode, useMemo, useState } from 'react';
@ -105,7 +104,7 @@ export function RowActions({
}, [actions]); }, [actions]);
// Render a single action icon // Render a single action icon
function RowActionIcon(action: RowAction) { function RowActionIcon(action: Readonly<RowAction>) {
return ( return (
<Tooltip <Tooltip
withinPortal={true} withinPortal={true}

View File

@ -1,6 +1,5 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Badge, Group, Stack, Text, Tooltip } from '@mantine/core'; import { ActionIcon, Badge, Group, Stack, Text, Tooltip } from '@mantine/core';
import { ActionIcon } from '@mantine/core';
import { Dropzone } from '@mantine/dropzone'; import { Dropzone } from '@mantine/dropzone';
import { notifications } from '@mantine/notifications'; import { notifications } from '@mantine/notifications';
import { IconExternalLink, IconFileUpload } from '@tabler/icons-react'; import { IconExternalLink, IconFileUpload } from '@tabler/icons-react';

View File

@ -52,7 +52,11 @@ type ThumbProps = {
/** /**
* Renders a single image thumbnail * Renders a single image thumbnail
*/ */
function PartThumbComponent({ selected, element, selectImage }: ThumbProps) { function PartThumbComponent({
selected,
element,
selectImage
}: Readonly<ThumbProps>) {
const { hovered, ref } = useHover(); const { hovered, ref } = useHover();
const hoverColor = 'rgba(127,127,127,0.2)'; const hoverColor = 'rgba(127,127,127,0.2)';

View File

@ -15,12 +15,12 @@ import { notifications, showNotification } from '@mantine/notifications';
import { import {
IconCircleCheck, IconCircleCheck,
IconCircleX, IconCircleX,
IconDots,
IconHelpCircle, IconHelpCircle,
IconInfoCircle, IconInfoCircle,
IconPlaylistAdd, IconPlaylistAdd,
IconRefresh IconRefresh
} from '@tabler/icons-react'; } from '@tabler/icons-react';
import { IconDots } from '@tabler/icons-react';
import { useCallback, useMemo, useState } from 'react'; import { useCallback, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';