Skip to content

Commit

Permalink
added some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gmin2 committed May 21, 2024
1 parent 398711b commit d05bf8a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages/ui/components/VisualEditor/PropertyControls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import _ from 'lodash';
import { DropdownMenu, DropdownMenuItem } from '../DropdownMenu';
import { AddIcon } from '../icons';

interface PropertyControlsProps {
onAdd: (path: string, property: { name: string; schema: any }) => void;
Expand Down Expand Up @@ -30,7 +31,6 @@ const PropertyControls: React.FC<PropertyControlsProps> = ({ onAdd, schemaPath,
}

const fullPath = schemaPath ? `${schemaPath}.properties.${key}` : `properties.${key}`;
console.log('Full Full Path :)', fullPath);
console.log(`Adding new property at: ${fullPath}`);

const newProperty = {
Expand Down Expand Up @@ -98,8 +98,8 @@ const PropertyControls: React.FC<PropertyControlsProps> = ({ onAdd, schemaPath,
/>
{!showInputs && (
<button onClick={() => setShowInputs(true)} className='text-[#808080] px-2 py-2 rounded-md flex items-center gap-2 font-inter text-sm'>
<div className="text-[#808080] border-2 border-[#808080] h-5 w-5 rounded-full flex items-center justify-center">
<span>&#43;</span>
<div className="text-[#808080] h-5 w-5 rounded-full flex items-center justify-center font-bold">
<AddIcon className='font-bold' />
</div>
Add Property
</button>
Expand Down
7 changes: 0 additions & 7 deletions packages/ui/components/VisualEditor/SchemaObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const SchemaObject: React.FC<SchemaObjectProps> = ({
const handleAddProperty = (fullPath: string, propertySchema: any) => {
const updatedSchema = _.cloneDeep(schema);
const normalizedPath = fullPath.startsWith('.') ? fullPath.slice(1) : fullPath;
console.log('Normalised path',normalizedPath);

if (normalizedPath.startsWith('items.properties')) {
const itemsPath = normalizedPath.split('.properties')[0];
Expand All @@ -38,8 +37,6 @@ const SchemaObject: React.FC<SchemaObjectProps> = ({
const handleRemoveProperty = (propertyPath: string) => {
const updatedSchema = _.cloneDeep(schema);
const normalizedPath = propertyPath.startsWith('.') ? propertyPath.slice(1) : propertyPath;
console.log("normalizedPath: ",normalizedPath)
console.log("propertyPath: ",propertyPath)
_.unset(updatedSchema, normalizedPath);
onSchemaChange(updatedSchema);
};
Expand All @@ -52,7 +49,6 @@ const SchemaObject: React.FC<SchemaObjectProps> = ({

if(newType.type == "array") {
const itemType = newType.items;
console.log("itemType",itemType)
_.set(currentSchema, typePath, 'array');
_.set(currentSchema, `${normalizedPath}.items`, itemType);
} else {
Expand All @@ -70,7 +66,6 @@ const SchemaObject: React.FC<SchemaObjectProps> = ({
const updatedSchema = _.cloneDeep(schema);
const existingRequired = _.get(updatedSchema, `required`, []);
const isRequirePresent = existingRequired.includes(name);
console.log("isRequired",isRequirePresent);
if(!isRequirePresent) {
const newRequired = _.uniq([...existingRequired, name]);
_.set(updatedSchema, `required`, newRequired);
Expand All @@ -86,9 +81,7 @@ const SchemaObject: React.FC<SchemaObjectProps> = ({
const updatedSchema = _.cloneDeep(schema);
const normalizedPath = path.startsWith('.') ? path.slice(1) : path;
const schemaPath = normalizedPath.split('.properties');
console.log("schemaPath",schemaPath)
const requiredPath = schemaPath.slice(0, -1).join('.properties') + '.required';
console.log("requiredPath",requiredPath)

const existingRequired = _.get(updatedSchema, requiredPath, []);
const isRequirePresent = existingRequired.includes(name);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/icons/AddIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const AddIcon = (props: any) => (
id="Vector"
d="M19.5 14.625V24.375M24.375 19.5H14.625M34.125 19.5C34.125 27.5772 27.5772 34.125 19.5 34.125C11.4228 34.125 4.875 27.5772 4.875 19.5C4.875 11.4228 11.4228 4.875 19.5 4.875C27.5772 4.875 34.125 11.4228 34.125 19.5Z"
stroke="#64748B"
strokeWidth="1.5"
strokeWidth="3"
strokeLinecap="round"
strokeLinejoin="round"
/>
Expand Down
7 changes: 4 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
"dependencies": {
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"classnames": "^2.3.2",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-form": "^0.0.3",
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-toolbar": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@radix-ui/react-switch": "^1.0.3",
"classnames": "^2.3.2",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-icons": "^5.2.1"
},
"devDependencies": {
"@types/lodash": "^4.17.0",
Expand Down

0 comments on commit d05bf8a

Please sign in to comment.