diff --git a/src/components/ActionDialog.tsx b/src/components/ActionDialog.tsx index b748011d..cb1e1325 100644 --- a/src/components/ActionDialog.tsx +++ b/src/components/ActionDialog.tsx @@ -3,6 +3,7 @@ import { Button, ButtonVariant, Spinner } from "@patternfly/react-core"; import React, { useState } from "react"; import { apiFetch } from "../hooks/apiFetch"; import { apiObject } from "../types/backend/apiObject/object"; +import URLSanitize from "../functions/URLSanitize"; const sleep = ms => new Promise(r => setTimeout(r, ms)) @@ -22,7 +23,7 @@ const ActionDeleteRow = async ( ): Promise => { const action = await apiFetch( - deleteURL, + URLSanitize(deleteURL), null, "DELETE", null, diff --git a/src/components/Comment.tsx b/src/components/Comment.tsx index 5d0848e2..9876d786 100644 --- a/src/components/Comment.tsx +++ b/src/components/Comment.tsx @@ -874,7 +874,7 @@ export const Comment = ({ { (comment_page_data?._urls?.threads || start_thread ) && { + if( ! Object(objectData).hasOwnProperty(field) && ! isCreate ) { + return; + } + if( String(objectMetadata.fields[field]?.type).toLowerCase() == 'markdown' && field !== 'model_notes' @@ -294,6 +298,7 @@ const Column = ({isEdit, isMobile, children}) => { default: '1Col' }} aria-label="Model fields" + displaySize = "lg" isCompact = {true} isFillColumns = {true} > @@ -359,6 +364,7 @@ export type DisplayFieldsProps = { * @since 0.9.0 */ const DisplayFields = ({ + errorState = undefined, existingFormData = null, FormComponent = Form, isCreate = false, @@ -367,7 +373,7 @@ const DisplayFields = ({ onClose = null, }: DisplayFieldsProps): React.JSX.Element => { - const actionData = useActionData(); + // const actionData = useActionData(); const [ data, setformData ] = useState(existingFormData); @@ -400,33 +406,33 @@ const DisplayFields = ({ }, [existingFormData]); - useEffect(() => { + // useEffect(() => { - if(actionData?.body && actionData?.ok) { + // if(actionData?.body && actionData?.ok) { - setformData(actionData?.body); + // setformData(actionData?.body); - if( isCreate && isLoading ) { + // if( isCreate && isLoading ) { - delete actionData.body; - delete actionData.errors; - delete actionData.ok; + // delete actionData.body; + // delete actionData.errors; + // delete actionData.ok; - if( onClose ) { - onClose(true) - } + // if( onClose ) { + // onClose(true) + // } - } + // } - } - }, [actionData]) + // } + // }, [actionData]) useEffect(() => { setIsEdit(() => { if( - actionData?.errors + errorState || String(location.pathname).endsWith('/add') || @@ -438,7 +444,7 @@ const DisplayFields = ({ return false; }) - }, [actionData, location.pathname]) + }, [errorState, location.pathname]) let cardData; @@ -463,7 +469,7 @@ const DisplayFields = ({ isMobile={isMobile} > - {actionData?.errors && + {errorState && - {Object.entries(actionData.errors).map(([fieldKey, fieldErrors]) => { + {Object.entries(errorState.errors).map(([fieldKey, fieldErrors]) => { return ({pageMetadata.fields[fieldKey].label}); @@ -769,6 +775,7 @@ export async function APISubmitAction({ break; + case 'json': case 'relationship': value = JSON.parse(fieldValue); diff --git a/src/components/DisplayTable.jsx b/src/components/DisplayTable.jsx index 382bfc5e..2c5aa0a8 100644 --- a/src/components/DisplayTable.jsx +++ b/src/components/DisplayTable.jsx @@ -10,6 +10,7 @@ import { import { Button, + Content, Pagination, PaginationVariant, Toolbar, @@ -439,9 +440,6 @@ const DisplayTable = ({ {collapsable_fields.length > 0 && } {tableHeaderColumns} - { table_columns_count > 0 && -   - } @@ -536,13 +534,14 @@ const DisplayTable = ({ + > + ); } @@ -553,19 +552,20 @@ const DisplayTable = ({ return ( + + ); } } } })} - {collapsable_fields.length > 0 && diff --git a/src/components/form/DualFieldSelector.jsx b/src/components/form/DualFieldSelector.jsx index d1bbba81..9b0da714 100644 --- a/src/components/form/DualFieldSelector.jsx +++ b/src/components/form/DualFieldSelector.jsx @@ -96,7 +96,9 @@ const DualFieldSelector = ({ pageData[name]?.map((permission) => { - data[permission.id]["selected"] = true + if( ! data?.[permission.id] ) console.error(`permission "${permission.display_name}" id "${permission.id} does not exist in data."`) + + if( data?.[permission.id] ) data[permission.id]["selected"] = true }); } diff --git a/src/components/page/detail/DetailSection.jsx b/src/components/page/detail/DetailSection.jsx index bc7c1f39..20d4f454 100644 --- a/src/components/page/detail/DetailSection.jsx +++ b/src/components/page/detail/DetailSection.jsx @@ -38,6 +38,7 @@ import URLSanitize from "../../../functions/URLSanitize"; * @returns Card Component ready to be placed. */ const DetailSection = ({ + errorState = undefined, FormComponent = Form, layout, data, @@ -70,6 +71,7 @@ const DetailSection = ({ cardData = ( { { { >