Error message fix (#6393)

* Remove debug error

* Hide errors
This commit is contained in:
Oliver 2024-02-02 22:20:38 +11:00 committed by GitHub
parent be30cec2ad
commit 538ff9be7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 18 deletions

View File

@ -34,7 +34,8 @@ export function constructFormUrl(
*/
export function extractAvailableFields(
response: AxiosResponse,
method?: string
method?: string,
hideErrors?: boolean
): Record<string, ApiFormFieldType> | null {
// OPTIONS request *must* return 200 status
if (response.status !== 200) {
@ -44,21 +45,7 @@ export function extractAvailableFields(
let actions: any = response.data?.actions ?? null;
if (!method) {
notifications.show({
title: t`Form Error`,
message: t`Form method not provided`,
color: 'red'
});
return null;
}
if (!actions) {
notifications.show({
title: t`Form Error`,
message: t`Response did not contain action data`,
color: 'red'
});
if (!method || !actions) {
return null;
}
@ -71,7 +58,9 @@ export function extractAvailableFields(
if (!(method in actions)) {
// Missing method - this means user does not have appropriate permission
permissionDenied();
if (!hideErrors) {
permissionDenied();
}
return null;
}

View File

@ -145,7 +145,7 @@ export function InvenTreeTable<T = any>({
let names: Record<string, string> = {};
let fields: ApiFormFieldSet =
extractAvailableFields(response, 'POST') || {};
extractAvailableFields(response, 'POST', true) || {};
// Extract flattened map of fields
mapFields(fields, (path, field) => {