♿ (editor) Allow empty group titles
This commit is contained in:
@ -3,7 +3,7 @@ import { canReadTypebots } from '@/utils/api/dbRules'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Group, Typebot, Webhook, WebhookBlock } from 'models'
|
||||
import { byId, isWebhookBlock } from 'utils'
|
||||
import { byId, isWebhookBlock, parseGroupTitle } from 'utils'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const listWebhookBlocksProcedure = authenticatedProcedure
|
||||
@ -55,7 +55,7 @@ export const listWebhookBlocksProcedure = authenticatedProcedure
|
||||
...webhookBlocks,
|
||||
...blocks.map((b) => ({
|
||||
id: b.id,
|
||||
label: `${group.title} > ${b.id}`,
|
||||
label: `${parseGroupTitle(group.title)} > ${b.id}`,
|
||||
url: typebot?.webhooks.find(byId(b.webhookId))?.url ?? undefined,
|
||||
})),
|
||||
]
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import { Tag, Text } from '@chakra-ui/react'
|
||||
import { useTypebot } from '@/features/editor'
|
||||
import { byId, isDefined } from 'utils'
|
||||
import { byId, isDefined, parseGroupTitle } from 'utils'
|
||||
import { JumpBlock } from 'models/features/blocks/logic/jump'
|
||||
|
||||
type Props = {
|
||||
@ -15,7 +15,8 @@ export const JumpNodeBody = ({ options }: Props) => {
|
||||
if (!selectedGroup) return <Text color="gray.500">Configure...</Text>
|
||||
return (
|
||||
<Text>
|
||||
Jump to <Tag colorScheme="blue">{selectedGroup.title}</Tag>{' '}
|
||||
Jump to{' '}
|
||||
<Tag colorScheme="blue">{parseGroupTitle(selectedGroup.title)}</Tag>{' '}
|
||||
{isDefined(blockIndex) && blockIndex >= 0 ? (
|
||||
<>
|
||||
at block <Tag colorScheme="blue">{blockIndex + 1}</Tag>
|
||||
|
@ -3,7 +3,7 @@ import { useTypebot } from '@/features/editor'
|
||||
import { Stack } from '@chakra-ui/react'
|
||||
import { JumpBlock } from 'models/features/blocks/logic/jump'
|
||||
import React from 'react'
|
||||
import { byId } from 'utils'
|
||||
import { byId, parseGroupTitle } from 'utils'
|
||||
|
||||
type Props = {
|
||||
groupId: string
|
||||
@ -32,7 +32,7 @@ export const JumpSettings = ({ groupId, options, onOptionsChange }: Props) => {
|
||||
items={typebot.groups
|
||||
.filter((group) => group.id !== currentGroupId)
|
||||
.map((group) => ({
|
||||
label: group.title,
|
||||
label: parseGroupTitle(group.title),
|
||||
value: group.id,
|
||||
}))}
|
||||
selectedItem={selectedGroup?.id}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Select } from '@/components/inputs/Select'
|
||||
import { Input } from '@chakra-ui/react'
|
||||
import { Group } from 'models'
|
||||
import { parseGroupTitle } from 'utils'
|
||||
|
||||
type Props = {
|
||||
groups: Group[]
|
||||
@ -22,7 +23,7 @@ export const GroupsDropdown = ({
|
||||
<Select
|
||||
selectedItem={groupId}
|
||||
items={(groups ?? []).map((group) => ({
|
||||
label: group.title,
|
||||
label: parseGroupTitle(group.title),
|
||||
value: group.id,
|
||||
}))}
|
||||
onSelect={onGroupIdSelected}
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
WebhookCallBacks,
|
||||
} from './blocks'
|
||||
import { Coordinates } from '@/features/graph'
|
||||
import { parseGroupTitle } from 'utils'
|
||||
|
||||
export type GroupsActions = {
|
||||
createGroup: (
|
||||
@ -69,7 +70,7 @@ const groupsActions = (
|
||||
const id = createId()
|
||||
const newGroup: Group = {
|
||||
...group,
|
||||
title: `${group.title} copy`,
|
||||
title: `${parseGroupTitle(group.title)} copy`,
|
||||
id,
|
||||
blocks: group.blocks.map((block) =>
|
||||
duplicateBlockDraft(id)(block, onWebhookBlockDuplicated)
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
useBlockDnd,
|
||||
} from '../../../providers'
|
||||
import { BlockNodesList } from '../BlockNode/BlockNodesList'
|
||||
import { isDefined, isNotDefined } from 'utils'
|
||||
import { isDefined, isEmpty, isNotDefined } from 'utils'
|
||||
import { useTypebot, RightPanel, useEditor } from '@/features/editor'
|
||||
import { GroupNodeContextMenu } from './GroupNodeContextMenu'
|
||||
import { useDebounce } from 'use-debounce'
|
||||
@ -108,6 +108,7 @@ const NonMemoizedDraggableGroupNode = ({
|
||||
useEffect(() => {
|
||||
setGroupTitle(group.title)
|
||||
}, [group.title])
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentCoordinates || isReadOnly) return
|
||||
if (
|
||||
@ -127,7 +128,7 @@ const NonMemoizedDraggableGroupNode = ({
|
||||
}, [connectingIds, group.id])
|
||||
|
||||
const handleTitleSubmit = (title: string) =>
|
||||
title.length > 0 ? updateGroup(groupIndex, { title }) : undefined
|
||||
updateGroup(groupIndex, { title })
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
if (isReadOnly) return
|
||||
@ -226,6 +227,16 @@ const NonMemoizedDraggableGroupNode = ({
|
||||
}}
|
||||
px="1"
|
||||
userSelect={'none'}
|
||||
style={
|
||||
isEmpty(groupTitle)
|
||||
? {
|
||||
display: 'block',
|
||||
position: 'absolute',
|
||||
top: '10px',
|
||||
width: '100px',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<EditableInput minW="0" px="1" className="prevent-group-drag" />
|
||||
</Editable>
|
||||
|
@ -43,10 +43,7 @@ export const AvatarForm = ({
|
||||
|
||||
useOutsideClick({
|
||||
ref: popoverContainerRef,
|
||||
handler: () => {
|
||||
console.log('close')
|
||||
onClose()
|
||||
},
|
||||
handler: onClose,
|
||||
})
|
||||
|
||||
const isDefaultAvatar = !avatarProps?.url || avatarProps.url.includes('{{')
|
||||
|
Reference in New Issue
Block a user