Skip to content

Commit

Permalink
Fix(CanvasForm): Fix commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamG640 committed Jan 14, 2025
1 parent a8a104a commit 314ea7f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/Form/CustomAutoFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function CustomAutoFields({
cleanQueryTerm,
omitFields,
);
const propertiesArray = getFieldGroups(filteredProperties!);
const propertiesArray = getFieldGroups(filteredProperties);

if (
canvasFormTabsContext?.selectedTab !== 'All' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const CustomNestField = connectField(
props.properties as KaotoSchemaDefinition['schema']['properties'],
cleanQueryTerm,
);
const propertiesArray = getFieldGroups(filteredProperties!);
const propertiesArray = getFieldGroups(filteredProperties);
if (propertiesArray.common.length === 0 && Object.keys(propertiesArray.groups).length === 0) return null;

return (
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/utils/get-field-groups.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { getValue } from './get-value';
import { isDefined } from './is-defined';

export const getFieldGroups = (fields?: { [name: string]: unknown }) => {
if (!isDefined(fields)) return { common: [], groups: {} };

export const getFieldGroups = (fields: { [name: string]: unknown }) => {
const propertiesArray = Object.entries(fields).reduce(
(acc, [name, definition]) => {
const group: string = getValue(definition, 'group', '');
Expand Down
14 changes: 7 additions & 7 deletions packages/ui/src/utils/get-filtered-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export function getFilteredProperties(

const filteredFormSchema = Object.entries(properties).reduce(
(acc, [property, definition]) => {
if (definition['type'] === 'object' && 'properties' in definition) {
const subFilteredSchema = getFilteredProperties(definition['properties'], filter);
if (Object.keys(subFilteredSchema!).length > 0) {
acc![property] = { ...definition, properties: subFilteredSchema };
}
} else {
if ((!omitFields || !omitFields.includes(property)) && property.toLowerCase().includes(filter)) {
if (!omitFields?.includes(property)) {
if (definition['type'] === 'object' && 'properties' in definition) {
const subFilteredSchema = getFilteredProperties(definition['properties'], filter);
if (Object.keys(subFilteredSchema!).length > 0) {
acc![property] = { ...definition, properties: subFilteredSchema };
}
} else if (property.toLowerCase().includes(filter)) {
acc![property] = definition;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/utils/get-required-properties-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function getRequiredPropertiesSchema(
if (Object.keys(subSchema.properties as object).length > 0) {
acc[property] = subSchema;
}
} else {
if (isDefined(requiredProperties) && requiredProperties.indexOf(property) > -1) acc[property] = definition;
} else if (isDefined(requiredProperties) && requiredProperties.indexOf(property) > -1) {
acc[property] = definition;
}

return acc;
Expand Down

0 comments on commit 314ea7f

Please sign in to comment.