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 itemIndex = indices.itemIndex + 1
createItem(
{ blockId: item.blockId, type: ItemType.BUTTON },
{ ...indices, itemIndex }
)
createItem({ type: ItemType.BUTTON }, { ...indices, itemIndex })
}
const updateItemSettings = (settings: Omit<ButtonItem, 'content'>) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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