mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
fix various sonarlint warnings (#8479)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
9d8f874bf3
commit
ee01ac592f
@ -30,14 +30,14 @@ export default function DashboardMenu({
|
||||
onStartEdit,
|
||||
onStartRemove,
|
||||
onAcceptLayout
|
||||
}: {
|
||||
}: Readonly<{
|
||||
editing: boolean;
|
||||
removing: boolean;
|
||||
onAddWidget: () => void;
|
||||
onStartEdit: () => void;
|
||||
onStartRemove: () => void;
|
||||
onAcceptLayout: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
const user = useUserState();
|
||||
const instanceName = useInstanceName();
|
||||
|
||||
|
@ -29,12 +29,12 @@ export default function DashboardWidget({
|
||||
editing,
|
||||
removing,
|
||||
onRemove
|
||||
}: {
|
||||
}: Readonly<{
|
||||
item: DashboardWidgetProps;
|
||||
editing: boolean;
|
||||
removing: boolean;
|
||||
onRemove: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
// TODO: Implement visibility check
|
||||
// if (!props?.visible?.() == false) {
|
||||
// return null;
|
||||
|
@ -26,12 +26,12 @@ export default function DashboardWidgetDrawer({
|
||||
onClose,
|
||||
onAddWidget,
|
||||
currentWidgets
|
||||
}: {
|
||||
}: Readonly<{
|
||||
opened: boolean;
|
||||
onClose: () => void;
|
||||
onAddWidget: (widget: string) => void;
|
||||
currentWidgets: string[];
|
||||
}) {
|
||||
}>) {
|
||||
// Load available widgets
|
||||
const availableWidgets = useDashboardItems();
|
||||
|
||||
|
@ -24,7 +24,7 @@ import { StylishText } from '../../items/StylishText';
|
||||
/**
|
||||
* Render a link to an external news item
|
||||
*/
|
||||
function NewsLink({ item }: { item: any }) {
|
||||
function NewsLink({ item }: Readonly<{ item: any }>) {
|
||||
let link: string = item.link;
|
||||
|
||||
if (link?.startsWith('/')) {
|
||||
@ -45,10 +45,10 @@ function NewsLink({ item }: { item: any }) {
|
||||
function NewsItem({
|
||||
item,
|
||||
onMarkRead
|
||||
}: {
|
||||
}: Readonly<{
|
||||
item: any;
|
||||
onMarkRead: (id: number) => void;
|
||||
}) {
|
||||
}>) {
|
||||
const date: string = item.published?.split(' ')[0] ?? '';
|
||||
return (
|
||||
<Table.Tr>
|
||||
|
@ -25,12 +25,12 @@ function QueryCountWidget({
|
||||
title,
|
||||
icon,
|
||||
params
|
||||
}: {
|
||||
}: Readonly<{
|
||||
modelType: ModelType;
|
||||
title: string;
|
||||
icon?: InvenTreeIconType;
|
||||
params: any;
|
||||
}): ReactNode {
|
||||
}>): ReactNode {
|
||||
const user = useUserState();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -8,10 +8,10 @@ import { LanguageToggle } from '../items/LanguageToggle';
|
||||
export function AuthFormOptions({
|
||||
hostname,
|
||||
toggleHostEdit
|
||||
}: {
|
||||
}: Readonly<{
|
||||
hostname: string;
|
||||
toggleHostEdit: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
const [server] = useServerApiState((state) => [state.server]);
|
||||
|
||||
return (
|
||||
|
@ -26,7 +26,7 @@ function TableFieldRow({
|
||||
control,
|
||||
changeFn,
|
||||
removeFn
|
||||
}: {
|
||||
}: Readonly<{
|
||||
item: any;
|
||||
idx: number;
|
||||
errors: any;
|
||||
@ -34,7 +34,7 @@ function TableFieldRow({
|
||||
control: UseControllerReturn<FieldValues, any>;
|
||||
changeFn: (idx: number, key: string, value: any) => void;
|
||||
removeFn: (idx: number) => void;
|
||||
}) {
|
||||
}>) {
|
||||
// Table fields require render function
|
||||
if (!definition.modelRenderer) {
|
||||
return (
|
||||
@ -62,11 +62,11 @@ export function TableFieldErrorWrapper({
|
||||
props,
|
||||
errorKey,
|
||||
children
|
||||
}: {
|
||||
}: Readonly<{
|
||||
props: TableFieldRowProps;
|
||||
errorKey: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
}>) {
|
||||
const msg = props?.rowErrors?.[errorKey];
|
||||
|
||||
return (
|
||||
|
@ -6,7 +6,7 @@ import * as classes from './GettingStartedCarousel.css';
|
||||
import type { MenuLinkItem } from './MenuLinks';
|
||||
import { StylishText } from './StylishText';
|
||||
|
||||
function StartedCard({ title, description, link }: MenuLinkItem) {
|
||||
function StartedCard({ title, description, link }: Readonly<MenuLinkItem>) {
|
||||
return (
|
||||
<Paper shadow='md' p='xl' radius='md' className={classes.card}>
|
||||
<div>
|
||||
|
@ -17,7 +17,7 @@ import { api } from '../../App';
|
||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||
import { apiUrl } from '../../states/ApiState';
|
||||
|
||||
export function LicenceView(entries: any[]) {
|
||||
export function LicenceView(entries: Readonly<any[]>) {
|
||||
return (
|
||||
<Stack gap='xs'>
|
||||
<Divider />
|
||||
|
@ -46,7 +46,7 @@ export function NavigationDrawer({
|
||||
);
|
||||
}
|
||||
|
||||
function DrawerContent({ closeFunc }: { closeFunc?: () => void }) {
|
||||
function DrawerContent({ closeFunc }: Readonly<{ closeFunc?: () => void }>) {
|
||||
const user = useUserState();
|
||||
|
||||
const globalSettings = useGlobalSettingsState();
|
||||
@ -186,13 +186,11 @@ function DrawerContent({ closeFunc }: { closeFunc?: () => void }) {
|
||||
/>
|
||||
<Space h='md' />
|
||||
{plugins.length > 0 ? (
|
||||
<>
|
||||
<MenuLinks
|
||||
title={t`Plugins`}
|
||||
links={plugins}
|
||||
beforeClick={closeFunc}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
@ -36,10 +36,10 @@ import { ModelInformationDict } from '../render/ModelType';
|
||||
function NotificationEntry({
|
||||
notification,
|
||||
onRead
|
||||
}: {
|
||||
}: Readonly<{
|
||||
notification: any;
|
||||
onRead: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
let link = notification.target?.link;
|
||||
|
@ -7,10 +7,10 @@ import { useGlobalSettingsState } from '../../states/SettingsState';
|
||||
export default function PageTitle({
|
||||
title,
|
||||
subtitle
|
||||
}: {
|
||||
}: Readonly<{
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
}) {
|
||||
}>) {
|
||||
const globalSettings = useGlobalSettingsState();
|
||||
|
||||
const pageTitle = useMemo(() => {
|
||||
|
@ -12,10 +12,10 @@ import type { PluginInterface } from './PluginInterface';
|
||||
export default function LocateItemButton({
|
||||
stockId,
|
||||
locationId
|
||||
}: {
|
||||
}: Readonly<{
|
||||
stockId?: number;
|
||||
locationId?: number;
|
||||
}) {
|
||||
}>) {
|
||||
const locatePlugins = usePluginsWithMixin('locate');
|
||||
|
||||
const [selectedPlugin, setSelectedPlugin] = useState<string | undefined>(
|
||||
|
@ -18,10 +18,10 @@ import PluginSettingsPanel from './PluginSettingsPanel';
|
||||
export default function PluginDrawer({
|
||||
pluginKey,
|
||||
pluginInstance
|
||||
}: {
|
||||
}: Readonly<{
|
||||
pluginKey?: string;
|
||||
pluginInstance: PluginInterface;
|
||||
}) {
|
||||
}>) {
|
||||
const { id } = useParams();
|
||||
|
||||
const pluginPrimaryKey: string = useMemo(() => {
|
||||
@ -53,7 +53,6 @@ export default function PluginDrawer({
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Accordion defaultValue={['plugin-details', 'plugin-settings']} multiple>
|
||||
<Accordion.Item value='plugin-details'>
|
||||
<Accordion.Control>
|
||||
@ -153,6 +152,5 @@ export default function PluginDrawer({
|
||||
</Accordion.Item>
|
||||
)}
|
||||
</Accordion>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ export interface PluginAdminInterface {
|
||||
*/
|
||||
export default function PluginSettingsPanel({
|
||||
pluginAdmin
|
||||
}: {
|
||||
}: Readonly<{
|
||||
pluginAdmin: PluginAdminInterface;
|
||||
}) {
|
||||
}>) {
|
||||
const pluginContext = useInvenTreeContext();
|
||||
|
||||
return (
|
||||
|
@ -21,11 +21,11 @@ export default function RemoteComponent({
|
||||
source,
|
||||
defaultFunctionName,
|
||||
context
|
||||
}: {
|
||||
}: Readonly<{
|
||||
source: string;
|
||||
defaultFunctionName: string;
|
||||
context: InvenTreeContext;
|
||||
}) {
|
||||
}>) {
|
||||
const componentRef = useRef<HTMLDivElement>();
|
||||
|
||||
const [renderingError, setRenderingError] = useState<string | undefined>(
|
||||
@ -78,11 +78,8 @@ export default function RemoteComponent({
|
||||
}, [sourceFile, functionName, context]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Boundary
|
||||
label={identifierString(
|
||||
`RemoteComponent-${sourceFile}-${functionName}`
|
||||
)}
|
||||
label={identifierString(`RemoteComponent-${sourceFile}-${functionName}`)}
|
||||
>
|
||||
<Stack gap='xs'>
|
||||
{renderingError && (
|
||||
@ -92,14 +89,12 @@ export default function RemoteComponent({
|
||||
icon={<IconExclamationCircle />}
|
||||
>
|
||||
<Text>
|
||||
{t`Error occurred while loading plugin content`}:{' '}
|
||||
{renderingError}
|
||||
{t`Error occurred while loading plugin content`}: {renderingError}
|
||||
</Text>
|
||||
</Alert>
|
||||
)}
|
||||
<div ref={componentRef as any} />
|
||||
</Stack>
|
||||
</Boundary>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ function SalesOrderAllocateLineRow({
|
||||
props,
|
||||
record,
|
||||
sourceLocation
|
||||
}: {
|
||||
}: Readonly<{
|
||||
props: TableFieldRowProps;
|
||||
record: any;
|
||||
sourceLocation?: number | null;
|
||||
}) {
|
||||
}>) {
|
||||
// Statically defined field for selecting the stock item
|
||||
const stockItemField: ApiFormFieldType = useMemo(() => {
|
||||
return {
|
||||
@ -360,7 +360,7 @@ export function useSalesOrderAllocationFields({
|
||||
shipment
|
||||
}: {
|
||||
orderId?: number;
|
||||
shipment: any | null;
|
||||
shipment: any;
|
||||
}): ApiFormFieldSet {
|
||||
return useMemo(() => {
|
||||
return {
|
||||
|
@ -7,11 +7,10 @@ import { useUserState } from '../../states/UserState';
|
||||
import PartBuildAllocationsTable from '../../tables/part/PartBuildAllocationsTable';
|
||||
import PartSalesAllocationsTable from '../../tables/part/PartSalesAllocationsTable';
|
||||
|
||||
export default function PartAllocationPanel({ part }: { part: any }) {
|
||||
export default function PartAllocationPanel({ part }: Readonly<{ part: any }>) {
|
||||
const user = useUserState();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Accordion
|
||||
multiple={true}
|
||||
defaultValue={['buildallocations', 'salesallocations']}
|
||||
@ -37,6 +36,5 @@ export default function PartAllocationPanel({ part }: { part: any }) {
|
||||
</Accordion.Item>
|
||||
)}
|
||||
</Accordion>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import { TableHoverCard } from '../../tables/TableHoverCard';
|
||||
/*
|
||||
* Render a tooltip for the chart, with correct date information
|
||||
*/
|
||||
function ChartTooltip({ label, payload }: ChartTooltipProps) {
|
||||
function ChartTooltip({ label, payload }: Readonly<ChartTooltipProps>) {
|
||||
if (!payload) {
|
||||
return null;
|
||||
}
|
||||
@ -56,7 +56,9 @@ function ChartTooltip({ label, payload }: ChartTooltipProps) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function PartSchedulingDetail({ part }: { part: any }) {
|
||||
export default function PartSchedulingDetail({
|
||||
part
|
||||
}: Readonly<{ part: any }>) {
|
||||
const table = useTable('part-scheduling');
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -33,7 +33,7 @@ import { RowDeleteAction, RowEditAction } from '../../tables/RowActions';
|
||||
/*
|
||||
* Render a tooltip for the chart, with correct date information
|
||||
*/
|
||||
function ChartTooltip({ label, payload }: ChartTooltipProps) {
|
||||
function ChartTooltip({ label, payload }: Readonly<ChartTooltipProps>) {
|
||||
const formattedLabel: string = useMemo(() => {
|
||||
if (label && typeof label === 'number') {
|
||||
return formatDate(new Date(label).toISOString()) ?? label;
|
||||
@ -66,7 +66,9 @@ function ChartTooltip({ label, payload }: ChartTooltipProps) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function PartStocktakeDetail({ partId }: { partId: number }) {
|
||||
export default function PartStocktakeDetail({
|
||||
partId
|
||||
}: Readonly<{ partId: number }>) {
|
||||
const user = useUserState();
|
||||
const table = useTable('part-stocktake');
|
||||
|
||||
|
@ -5,7 +5,9 @@ import { StylishText } from '../../components/items/StylishText';
|
||||
import { ManufacturerPartTable } from '../../tables/purchasing/ManufacturerPartTable';
|
||||
import { SupplierPartTable } from '../../tables/purchasing/SupplierPartTable';
|
||||
|
||||
export default function PartSupplierDetail({ partId }: { partId: number }) {
|
||||
export default function PartSupplierDetail({
|
||||
partId
|
||||
}: Readonly<{ partId: number }>) {
|
||||
return (
|
||||
<Accordion multiple defaultValue={['part-suppliers', 'part-manufacturers']}>
|
||||
<Accordion.Item value='part-suppliers'>
|
||||
|
@ -41,7 +41,7 @@ export default function InvenTreeTableHeader({
|
||||
columns,
|
||||
filters,
|
||||
toggleColumn
|
||||
}: {
|
||||
}: Readonly<{
|
||||
tableUrl: string;
|
||||
tableState: TableState;
|
||||
tableProps: InvenTreeTableProps<any>;
|
||||
@ -49,7 +49,7 @@ export default function InvenTreeTableHeader({
|
||||
columns: any;
|
||||
filters: TableFilter[];
|
||||
toggleColumn: (column: string) => void;
|
||||
}) {
|
||||
}>) {
|
||||
// Filter list visibility
|
||||
const [filtersVisible, setFiltersVisible] = useState<boolean>(false);
|
||||
|
||||
|
@ -4,10 +4,10 @@ import { IconChevronDown, IconChevronRight } from '@tabler/icons-react';
|
||||
export default function RowExpansionIcon({
|
||||
enabled,
|
||||
expanded
|
||||
}: {
|
||||
}: Readonly<{
|
||||
enabled: boolean;
|
||||
expanded: boolean;
|
||||
}) {
|
||||
}>) {
|
||||
return (
|
||||
<ActionIcon size='sm' variant='transparent' disabled={!enabled}>
|
||||
{expanded ? <IconChevronDown /> : <IconChevronRight />}
|
||||
|
@ -56,11 +56,11 @@ export function BuildLineSubTable({
|
||||
lineItem,
|
||||
onEditAllocation,
|
||||
onDeleteAllocation
|
||||
}: {
|
||||
}: Readonly<{
|
||||
lineItem: any;
|
||||
onEditAllocation?: (pk: number) => void;
|
||||
onDeleteAllocation?: (pk: number) => void;
|
||||
}) {
|
||||
}>) {
|
||||
const user = useUserState();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -61,14 +61,13 @@ function OutputAllocationDrawer({
|
||||
output,
|
||||
opened,
|
||||
close
|
||||
}: {
|
||||
}: Readonly<{
|
||||
build: any;
|
||||
output: any;
|
||||
opened: boolean;
|
||||
close: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
position='bottom'
|
||||
size='lg'
|
||||
@ -115,7 +114,6 @@ function OutputAllocationDrawer({
|
||||
/>
|
||||
</Paper>
|
||||
</Drawer>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,9 @@ import { BuildLineSubTable } from '../build/BuildLineTable';
|
||||
*/
|
||||
export default function PartBuildAllocationsTable({
|
||||
partId
|
||||
}: {
|
||||
}: Readonly<{
|
||||
partId: number;
|
||||
}) {
|
||||
}>) {
|
||||
const user = useUserState();
|
||||
const navigate = useNavigate();
|
||||
const table = useTable('part-build-allocations');
|
||||
@ -106,7 +106,6 @@ export default function PartBuildAllocationsTable({
|
||||
}, [table.isRowExpanded]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<InvenTreeTable
|
||||
url={apiUrl(ApiEndpoints.build_line_list)}
|
||||
tableState={table}
|
||||
@ -125,6 +124,5 @@ export default function PartBuildAllocationsTable({
|
||||
rowExpansion: rowExpansion
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ import SalesOrderAllocationTable from '../sales/SalesOrderAllocationTable';
|
||||
|
||||
export default function PartSalesAllocationsTable({
|
||||
partId
|
||||
}: {
|
||||
}: Readonly<{
|
||||
partId: number;
|
||||
}) {
|
||||
}>) {
|
||||
const user = useUserState();
|
||||
const navigate = useNavigate();
|
||||
const table = useTable('part-sales-allocations');
|
||||
@ -109,7 +109,6 @@ export default function PartSalesAllocationsTable({
|
||||
}, [table.isRowExpanded]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<InvenTreeTable
|
||||
url={apiUrl(ApiEndpoints.sales_order_line_list)}
|
||||
tableState={table}
|
||||
@ -127,6 +126,5 @@ export default function PartSalesAllocationsTable({
|
||||
rowActions: rowActions
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import { RowDeleteAction } from '../RowActions';
|
||||
/*
|
||||
* Render detail information for a particular barcode scan result.
|
||||
*/
|
||||
function BarcodeScanDetail({ scan }: { scan: any }) {
|
||||
function BarcodeScanDetail({ scan }: Readonly<{ scan: any }>) {
|
||||
const dataStyle: MantineStyleProp = {
|
||||
textWrap: 'wrap',
|
||||
lineBreak: 'auto',
|
||||
@ -51,7 +51,6 @@ function BarcodeScanDetail({ scan }: { scan: any }) {
|
||||
}, [scan.context]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack gap='xs'>
|
||||
<Divider />
|
||||
<Table>
|
||||
@ -137,7 +136,6 @@ function BarcodeScanDetail({ scan }: { scan: any }) {
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import type { TableColumn } from '../Column';
|
||||
import { InvenTreeTable } from '../InvenTreeTable';
|
||||
import { type RowAction, RowDeleteAction } from '../RowActions';
|
||||
|
||||
function ErrorDetail({ errorId }: { errorId?: number }) {
|
||||
function ErrorDetail({ errorId }: Readonly<{ errorId?: number }>) {
|
||||
const { id } = useParams();
|
||||
|
||||
const errorPrimaryKey = useMemo(() => {
|
||||
|
@ -15,9 +15,9 @@ import { InvenTreeTable } from '../InvenTreeTable';
|
||||
|
||||
export default function FailedTasksTable({
|
||||
onRecordsUpdated
|
||||
}: {
|
||||
}: Readonly<{
|
||||
onRecordsUpdated: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
const table = useTable('tasks-failed');
|
||||
const user = useUserState();
|
||||
|
||||
|
@ -10,9 +10,9 @@ import { InvenTreeTable } from '../InvenTreeTable';
|
||||
|
||||
export default function PendingTasksTable({
|
||||
onRecordsUpdated
|
||||
}: {
|
||||
}: Readonly<{
|
||||
onRecordsUpdated: () => void;
|
||||
}) {
|
||||
}>) {
|
||||
const table = useTable('tasks-pending');
|
||||
const user = useUserState();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user