2
0

🐛 Deprecate blockId field in items

This commit is contained in:
Baptiste Arnaud
2023-08-16 09:15:19 +02:00
parent f508c97ee1
commit 019f72ac7e
9 changed files with 34 additions and 37 deletions

View File

@@ -54,10 +54,7 @@ export const ButtonsItemNode = ({ item, indices, isMouseOver }: Props) => {
const handlePlusClick = () => { const handlePlusClick = () => {
const itemIndex = indices.itemIndex + 1 const itemIndex = indices.itemIndex + 1
createItem( createItem({ type: ItemType.BUTTON }, { ...indices, itemIndex })
{ blockId: item.blockId, type: ItemType.BUTTON },
{ ...indices, itemIndex }
)
} }
const updateItemSettings = (settings: Omit<ButtonItem, 'content'>) => { const updateItemSettings = (settings: Omit<ButtonItem, 'content'>) => {

View File

@@ -40,10 +40,7 @@ export const PictureChoiceItemNode = ({
const handlePlusClick = (e: React.MouseEvent) => { const handlePlusClick = (e: React.MouseEvent) => {
e.stopPropagation() e.stopPropagation()
const itemIndex = indices.itemIndex + 1 const itemIndex = indices.itemIndex + 1
createItem( createItem({ type: ItemType.PICTURE_CHOICE }, { ...indices, itemIndex })
{ blockId: item.blockId, type: ItemType.PICTURE_CHOICE },
{ ...indices, itemIndex }
)
} }
const handleMouseDown = (e: React.MouseEvent) => e.stopPropagation() const handleMouseDown = (e: React.MouseEvent) => e.stopPropagation()
@@ -139,6 +136,10 @@ export const PictureChoiceItemNode = ({
<PictureChoiceItemSettings <PictureChoiceItemSettings
typebotId={typebot.id} typebotId={typebot.id}
item={item} item={item}
blockId={
typebot.groups[indices.groupIndex].blocks[indices.blockIndex]
.id
}
onItemChange={handleItemChange} onItemChange={handleItemChange}
/> />
)} )}

View File

@@ -17,12 +17,14 @@ import { Condition, LogicalOperator } from '@typebot.io/schemas'
type Props = { type Props = {
typebotId: string typebotId: string
blockId: string
item: PictureChoiceItem item: PictureChoiceItem
onItemChange: (updates: Partial<PictureChoiceItem>) => void onItemChange: (updates: Partial<PictureChoiceItem>) => void
} }
export const PictureChoiceItemSettings = ({ export const PictureChoiceItemSettings = ({
typebotId, typebotId,
blockId,
item, item,
onItemChange, onItemChange,
}: Props) => { }: Props) => {
@@ -67,7 +69,7 @@ export const PictureChoiceItemSettings = ({
</PopoverTrigger> </PopoverTrigger>
<PopoverContent p="4" w="500px"> <PopoverContent p="4" w="500px">
<ImageUploadContent <ImageUploadContent
filePath={`typebots/${typebotId}/blocks/${item.blockId}/items/${item.id}`} filePath={`typebots/${typebotId}/blocks/${blockId}/items/${item.id}`}
defaultUrl={item.pictureSrc} defaultUrl={item.pictureSrc}
onSubmit={(url) => { onSubmit={(url) => {
updateImage(url) updateImage(url)

View File

@@ -25,7 +25,6 @@ test.describe.parallel('Picture choice input block', () => {
items: [ items: [
{ {
id: 'choice1', id: 'choice1',
blockId: 'block1',
type: ItemType.PICTURE_CHOICE, type: ItemType.PICTURE_CHOICE,
}, },
], ],

View File

@@ -54,7 +54,6 @@ export const ConditionItemNode = ({ item, isMouseOver, indices }: Props) => {
const newItemId = createId() const newItemId = createId()
createItem( createItem(
{ {
blockId: item.blockId,
type: ItemType.CONDITION, type: ItemType.CONDITION,
id: newItemId, id: newItemId,
}, },

View File

@@ -117,7 +117,6 @@ const duplicateTypebot = (
...newIds, ...newIds,
items: block.items.map((item) => ({ items: block.items.map((item) => ({
...item, ...item,
blockId: blockIdsMapping.get(item.blockId) as string,
outgoingEdgeId: item.outgoingEdgeId outgoingEdgeId: item.outgoingEdgeId
? (edgeIdsMapping.get(item.outgoingEdgeId) as string) ? (edgeIdsMapping.get(item.outgoingEdgeId) as string)
: undefined, : undefined,

View File

@@ -846,7 +846,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -927,7 +928,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false
@@ -1608,7 +1608,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1695,7 +1696,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false
@@ -1826,7 +1826,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1895,7 +1896,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"content" "content"
], ],
@@ -2172,7 +2172,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -2192,7 +2193,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"path" "path"
], ],
@@ -2205,7 +2205,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -2225,7 +2226,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"path" "path"
], ],

View File

@@ -414,7 +414,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -495,7 +496,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false
@@ -1176,7 +1176,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1263,7 +1264,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false
@@ -1394,7 +1394,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1463,7 +1464,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"content" "content"
], ],
@@ -1740,7 +1740,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1760,7 +1761,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"path" "path"
], ],
@@ -1773,7 +1773,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -1793,7 +1794,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type", "type",
"path" "path"
], ],
@@ -4172,7 +4172,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -4253,7 +4254,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false
@@ -4934,7 +4934,8 @@
"type": "string" "type": "string"
}, },
"blockId": { "blockId": {
"type": "string" "type": "string",
"description": "Deprecated"
}, },
"outgoingEdgeId": { "outgoingEdgeId": {
"type": "string" "type": "string"
@@ -5021,7 +5022,6 @@
}, },
"required": [ "required": [
"id", "id",
"blockId",
"type" "type"
], ],
"additionalProperties": false "additionalProperties": false

View File

@@ -2,7 +2,7 @@ import { z } from 'zod'
export const itemBaseSchema = z.object({ export const itemBaseSchema = z.object({
id: z.string(), id: z.string(),
blockId: z.string(), blockId: z.string().optional().describe('Deprecated'),
outgoingEdgeId: z.string().optional(), outgoingEdgeId: z.string().optional(),
}) })