Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/ActionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -22,7 +23,7 @@ const ActionDeleteRow = async (
): Promise<boolean> => {

const action = await apiFetch(
deleteURL,
URLSanitize(deleteURL),
null,
"DELETE",
null,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ export const Comment = ({

{ (comment_page_data?._urls?.threads || start_thread ) &&
<ExpandableSection
isExpanded = { isExpanded }
isExpanded = { ! comment_page_data.is_closed }
onToggle={onToggle}
style={{
borderBottom: "1px groove var(--pf-t--global--border--color--subtle",
Expand Down
49 changes: 28 additions & 21 deletions src/components/DisplayFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ export const Fields = ({

return fields.map((field) => {

if( ! Object(objectData).hasOwnProperty(field) && ! isCreate ) {
return;
}

if(
String(objectMetadata.fields[field]?.type).toLowerCase() == 'markdown'
&& field !== 'model_notes'
Expand Down Expand Up @@ -294,6 +298,7 @@ const Column = ({isEdit, isMobile, children}) => {
default: '1Col'
}}
aria-label="Model fields"
displaySize = "lg"
isCompact = {true}
isFillColumns = {true}
>
Expand Down Expand Up @@ -359,6 +364,7 @@ export type DisplayFieldsProps = {
* @since 0.9.0
*/
const DisplayFields = ({
errorState = undefined,
existingFormData = null,
FormComponent = Form,
isCreate = false,
Expand All @@ -367,7 +373,7 @@ const DisplayFields = ({
onClose = null,
}: DisplayFieldsProps): React.JSX.Element => {

const actionData = useActionData();
// const actionData = useActionData();

const [ data, setformData ] = useState(existingFormData);

Expand Down Expand Up @@ -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')
||
Expand All @@ -438,7 +444,7 @@ const DisplayFields = ({
return false;
})

}, [actionData, location.pathname])
}, [errorState, location.pathname])


let cardData;
Expand All @@ -463,7 +469,7 @@ const DisplayFields = ({
isMobile={isMobile}
>
<Fields
errorState={actionData}
errorState={errorState}
fields={layout.left}
formState={formState}
isCreate={isCreate}
Expand All @@ -487,7 +493,7 @@ const DisplayFields = ({
isMobile={isMobile}
>
<Fields
errorState={actionData}
errorState={errorState}
fields={layout.right}
formState={formState}
isCreate={isCreate}
Expand Down Expand Up @@ -518,7 +524,7 @@ const DisplayFields = ({
isMobile={isMobile}
>
<Fields
errorState={actionData}
errorState={errorState}
fields={columnFields}
formState={formState}
isCreate={isCreate}
Expand Down Expand Up @@ -598,7 +604,7 @@ const DisplayFields = ({
}}
navigate = {false}
>
{actionData?.errors &&
{errorState &&
<AlertGroup>
<Alert
variant="danger"
Expand All @@ -607,7 +613,7 @@ const DisplayFields = ({
timeout={false}
>
<List>
{Object.entries(actionData.errors).map(([fieldKey, fieldErrors]) => {
{Object.entries(errorState.errors).map(([fieldKey, fieldErrors]) => {

return (<ListItem>{pageMetadata.fields[fieldKey].label}</ListItem>);

Expand Down Expand Up @@ -769,6 +775,7 @@ export async function APISubmitAction({

break;

case 'json':
case 'relationship':

value = JSON.parse(fieldValue);
Expand Down
10 changes: 5 additions & 5 deletions src/components/DisplayTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

import {
Button,
Content,
Pagination,
PaginationVariant,
Toolbar,
Expand Down Expand Up @@ -439,9 +440,6 @@ const DisplayTable = ({
<Tr>
{collapsable_fields.length > 0 && <Th screenReaderText="Row expansion" />}
{tableHeaderColumns}
{ table_columns_count > 0 &&
<Th>&nbsp;</Th>
}
</Tr>
</Thead>

Expand Down Expand Up @@ -536,13 +534,14 @@ const DisplayTable = ({
<Td
dataLabel={key}
key={key}
>
><Content isEditorial={true}>
<FieldData
autolink = {autolink}
data={data}
field_name={key}
metadata={metadata}
/>
</Content>
</Td>
);
}
Expand All @@ -553,19 +552,20 @@ const DisplayTable = ({

return (
<Td dataLabel={key}>
<Content isEditorial={true}>
<FieldData
autolink = {true}
data={data}
field_name={key}
metadata={metadata}
/>
</Content>
</Td>
);
}
}
}
})}
<Td></Td>
</Tr>
{collapsable_fields.length > 0 &&
<Tr isExpanded={isTableRowExpanded(rowId)}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/DualFieldSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

});
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/page/detail/DetailSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import URLSanitize from "../../../functions/URLSanitize";
* @returns Card Component ready to be placed.
*/
const DetailSection = ({
errorState = undefined,
FormComponent = Form,
layout,
data,
Expand Down Expand Up @@ -70,6 +71,7 @@ const DetailSection = ({

cardData = (
<DisplayFields
errorState = {errorState}
existingFormData = {data}
FormComponent = {FormComponent}
isCreate = {String(location.pathname).endsWith('/add')}
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const DetailLayout = (): React.JSX.Element => {

<fetcher.Form
method = "POST"
action = {URLSanitize(page_data['_urls']['notes'])}
action = {URLSanitize(page_data['_urls']?.['notes'])}
>
<CardBody>
<MarkdownEditor
Expand Down Expand Up @@ -289,6 +289,7 @@ const DetailLayout = (): React.JSX.Element => {

<FlexItem>
<DetailSection
errorState = {fetcher.data}
FormComponent = {fetcher.Form}
index = { section_index }
layout = {section}
Expand Down
1 change: 1 addition & 0 deletions src/layouts/Ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ const Ticket = (): React.JSX.Element => {
>

<DescriptionList
displaySize = "lg"
style={{
...( isMobile ? {} : {maxHeight: "calc(100svh - 69px - 53px - 21px - 15px - 90px)"}),
minHeight: "0",
Expand Down
Loading