2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Various SAST fixes (#7644)

* cleanup auth

* clean Unexpected empty object pattern

* clenaup empty object patterns

* fix identical sub-expressions

* fix missing title on iframe

* Do not pass children as props

* update node assigment

* fix typing

* fix variables that shadow builtins

* revert StylishText change
This commit is contained in:
Matthias Mair
2024-07-17 15:45:11 +02:00
committed by GitHub
parent 234b0ed72c
commit 547fa179c5
16 changed files with 38 additions and 34 deletions

View File

@ -81,7 +81,9 @@ export const PdfPreviewComponent: PreviewAreaComponent = forwardRef(
<Trans>Preview not available, click "Reload Preview".</Trans>
</div>
)}
{pdfUrl && <iframe src={pdfUrl} width="100%" height="100%" />}
{pdfUrl && (
<iframe src={pdfUrl} width="100%" height="100%" title="PDF Preview" />
)}
</>
);
}

View File

@ -117,7 +117,7 @@ export function usePartFields({
/**
* Construct a set of fields for creating / editing a PartCategory instance
*/
export function partCategoryFields({}: {}): ApiFormFieldSet {
export function partCategoryFields(): ApiFormFieldSet {
let fields: ApiFormFieldSet = {
parent: {
description: t`Parent part category`,

View File

@ -902,7 +902,7 @@ export function useDeleteStockItem(props: StockOperationProps) {
});
}
export function stockLocationFields({}: {}): ApiFormFieldSet {
export function stockLocationFields(): ApiFormFieldSet {
let fields: ApiFormFieldSet = {
parent: {
description: t`Parent stock location`,

View File

@ -5,7 +5,7 @@ import { NavigateFunction } from 'react-router-dom';
import { api, setApiDefaults } from '../App';
import { ApiEndpoints } from '../enums/ApiEndpoints';
import { apiUrl, useServerApiState } from '../states/ApiState';
import { apiUrl } from '../states/ApiState';
import { useLocalState } from '../states/LocalState';
import { useUserState } from '../states/UserState';
import { fetchGlobalStates } from '../states/states';
@ -47,8 +47,7 @@ function post(path: string, params: any, method = 'post') {
*/
export const doBasicLogin = async (username: string, password: string) => {
const { host } = useLocalState.getState();
const { clearUserState, setToken, fetchUserState, isLoggedIn } =
useUserState.getState();
const { clearUserState, setToken, fetchUserState } = useUserState.getState();
if (username.length == 0 || password.length == 0) {
return;
@ -96,7 +95,7 @@ export const doBasicLogin = async (username: string, password: string) => {
if (result) {
await fetchUserState();
await fetchGlobalStates();
fetchGlobalStates();
} else {
clearUserState();
}

View File

@ -27,7 +27,7 @@ import {
} from '../../hooks/UseForm';
// Generate some example forms using the modal API forms interface
const fields = partCategoryFields({});
const fields = partCategoryFields();
function ApiFormsPlayground() {
const editCategory = useEditApiFormModal({

View File

@ -89,7 +89,7 @@ export function SecurityContent() {
);
}
function EmailContent({}: {}) {
function EmailContent() {
const [value, setValue] = useState<string>('');
const [newEmailValue, setNewEmailValue] = useState('');
const [user] = useUserState((state) => [state.user]);
@ -321,7 +321,7 @@ function SsoContent({ dataProvider }: { dataProvider: any | undefined }) {
);
}
function MfaContent({}: {}) {
function MfaContent() {
return (
<>
MFA Details

View File

@ -42,7 +42,7 @@ import { PartListTable } from '../../tables/part/PartTable';
*
* Note: If no category ID is supplied, this acts as the top-level part category page
*/
export default function CategoryDetail({}: {}) {
export default function CategoryDetail() {
const { id: _id } = useParams();
const id = useMemo(
() => (!isNaN(parseInt(_id || '')) ? _id : undefined),
@ -158,7 +158,7 @@ export default function CategoryDetail({}: {}) {
url: ApiEndpoints.category_list,
pk: id,
title: t`Edit Part Category`,
fields: partCategoryFields({}),
fields: partCategoryFields(),
onFormSuccess: refreshInstance
});

View File

@ -21,10 +21,9 @@ function AccordionControl(props: AccordionControlProps) {
return (
<Box style={{ display: 'flex', alignItems: 'center' }}>
{props.disabled && (
<Tooltip
label={t`No data available`}
children={<IconAlertCircle size="1rem" color="gray" />}
/>
<Tooltip label={t`No data available`}>
<IconAlertCircle size="1rem" color="gray" />
</Tooltip>
)}
<Accordion.Control
{...props}

View File

@ -210,7 +210,7 @@ export default function Stock() {
url: ApiEndpoints.stock_location_list,
pk: id,
title: t`Edit Stock Location`,
fields: stockLocationFields({}),
fields: stockLocationFields(),
onFormSuccess: refreshInstance
});

View File

@ -608,7 +608,7 @@ export function InvenTreeTable<T = any>({
enableLabels={tableProps.enableLabels}
enableReports={tableProps.enableReports}
/>
{(tableProps.barcodeActions?.length ?? 0 > 0) && (
{(tableProps.barcodeActions?.length ?? 0) > 0 && (
<ButtonMenu
key="barcode-actions"
icon={<IconBarcode />}

View File

@ -76,7 +76,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
const newCategory = useCreateApiFormModal({
url: ApiEndpoints.category_list,
title: t`New Part Category`,
fields: partCategoryFields({}),
fields: partCategoryFields(),
initialData: {
parent: parentId
},
@ -91,7 +91,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
url: ApiEndpoints.category_list,
pk: selectedCategory,
title: t`Edit Part Category`,
fields: partCategoryFields({}),
fields: partCategoryFields(),
onFormSuccess: (record: any) => table.updateRecord(record)
});

View File

@ -19,7 +19,7 @@ import { TableFilter } from '../Filter';
import { InvenTreeTable } from '../InvenTreeTable';
import { RowDeleteAction, RowEditAction } from '../RowActions';
export default function PartCategoryTemplateTable({}: {}) {
export default function PartCategoryTemplateTable() {
const table = useTable('part-category-parameter-templates');
const user = useUserState();

View File

@ -97,7 +97,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
const newLocation = useCreateApiFormModal({
url: ApiEndpoints.stock_location_list,
title: t`Add Stock Location`,
fields: stockLocationFields({}),
fields: stockLocationFields(),
initialData: {
parent: parentId
},
@ -112,7 +112,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
url: ApiEndpoints.stock_location_list,
pk: selectedLocation,
title: t`Edit Stock Location`,
fields: stockLocationFields({}),
fields: stockLocationFields(),
onFormSuccess: (record: any) => table.updateRecord(record)
});