Skip to content

Commit

Permalink
update messages rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
breeg554 committed Nov 5, 2024
1 parent 3cd3fad commit 73dec62
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
6 changes: 3 additions & 3 deletions apps/api/lib/buildel/blocks/chat.ex
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ defmodule Buildel.Blocks.Chat do
"properties" => %{
"role" => %{
"type" => "string",
"title" => "Role",
"title" => "",
"enum" => ["user", "assistant"],
"enumPresentAs" => "radio",
"default" => "user"
},
"content" =>
EditorField.new(%{
title: "Content",
description: "The content of the message.",
title: "",
description: "",
suggestions: [
Suggestion.inputs(),
Suggestion.metadata(),
Expand Down
2 changes: 1 addition & 1 deletion apps/api/lib/buildel/blocks/fields/editor_field.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defmodule Buildel.Blocks.Fields.EditorField do
@type t :: %EditorField{}

@create_fields ~w(title description default min_length editor_language suggestions displayWhen readonly)a
@required_fields ~w(title description)a
@required_fields ~w()a

@spec new(attrs :: map()) :: t
def new(%{} = attrs \\ %{}) do
Expand Down
4 changes: 2 additions & 2 deletions apps/web-remix/app/components/form/fields/editor.field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const EditorField = ({
return (
<>
<HiddenField value={currentValue} {...getInputProps()} />
<div className="flex justify-between items-center">
<FieldLabel>{label}</FieldLabel>
<div className="flex justify-between items-center mb-1">
<FieldLabel className="mb-0">{label}</FieldLabel>

<IconButton
size="xxs"
Expand Down
63 changes: 36 additions & 27 deletions apps/web-remix/app/components/form/schema/SchemaFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { JSONSchemaField } from '~/components/form/schema/SchemaParser';
import { IconButton } from '~/components/iconButton';
import { Button } from '~/components/ui/button';
import { Collapsible, CollapsibleTrigger } from '~/components/ui/collapsible';
import { Label } from '~/components/ui/label';
import { InputMessage, Label } from '~/components/ui/label';
import { useOrganizationId } from '~/hooks/useOrganizationId';
import { usePipelineId } from '~/hooks/usePipelineId';
import { assert } from '~/utils/assert';
Expand Down Expand Up @@ -283,36 +283,45 @@ function RealArrayField({

return (
<div>
{rhfFields.map((item, index) => (
<div key={item.key} className="mt-2 flex flex-col gap-2">
<Field
key={item.key}
field={field.items}
name={`${name}[${index}]`}
fields={fields}
schema={schema}
{...rest}
/>
<IconButton
size="xxs"
variant="ghost"
aria-label="Remove field"
icon={<Trash />}
disabled={rhfFields.length <= field.minItems || rest.disabled}
onClick={(e) => {
e.preventDefault();
remove(index);
}}
/>
</div>
))}
<Label>{field.title}</Label>
<InputMessage className="mt-0">{field.description}</InputMessage>
<div
className={cn('flex flex-col gap-4', { 'mt-2': rhfFields.length > 0 })}
>
{rhfFields.map((item, index) => (
<div key={item.key} className="relative flex flex-col gap-1">
<IconButton
size="xxs"
variant="ghost"
className="absolute top-0 left-0"
aria-label="Remove field"
icon={<Trash />}
disabled={rhfFields.length <= field.minItems || rest.disabled}
onClick={(e) => {
e.preventDefault();
remove(index);
}}
/>

<Field
key={item.key}
field={field.items}
name={`${name}[${index}]`}
fields={fields}
schema={schema}
{...rest}
/>
</div>
))}
</div>
<Button
type="button"
size="xxs"
variant="secondary"
size="xs"
variant="outline"
onClick={() => push({})}
className="mt-2"
className="mt-4"
disabled={rest.disabled}
isFluid
>
Add item
</Button>
Expand Down

0 comments on commit 73dec62

Please sign in to comment.