2
0

🚸 (editor) Remove blocks pointer events only in analytics

This commit is contained in:
Baptiste Arnaud
2024-01-26 10:38:44 +01:00
parent b68f16f4f7
commit c23e760b39
5 changed files with 21 additions and 2 deletions

View File

@ -49,7 +49,7 @@ export const AnalyticsGraphContainer = ({ stats }: { stats?: Stats }) => {
justifyContent="center"
>
{publishedTypebot && stats ? (
<GraphProvider isReadOnly>
<GraphProvider isReadOnly isAnalytics>
<EventsCoordinatesProvider events={publishedTypebot?.events}>
<Graph
flex="1"

View File

@ -69,6 +69,7 @@ export const BlockNode = ({
setFocusedGroupId,
previewingEdge,
isReadOnly,
isAnalytics,
previewingBlock,
} = useGraph()
const { mouseOverBlock, setMouseOverBlock } = useBlockDnd()
@ -215,7 +216,7 @@ export const BlockNode = ({
data-testid={`block ${block.id}`}
w="full"
className="prevent-group-drag"
pointerEvents={isReadOnly || isDraggingGraph ? 'none' : 'auto'}
pointerEvents={isAnalytics || isDraggingGraph ? 'none' : 'auto'}
>
<HStack
flex="1"

View File

@ -32,6 +32,7 @@ const graphContext = createContext<{
openedItemId?: string
setOpenedItemId: Dispatch<SetStateAction<string | undefined>>
isReadOnly: boolean
isAnalytics: boolean
focusedGroupId?: string
setFocusedGroupId: Dispatch<SetStateAction<string | undefined>>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ -44,9 +45,11 @@ const graphContext = createContext<{
export const GraphProvider = ({
children,
isReadOnly = false,
isAnalytics = false,
}: {
children: ReactNode
isReadOnly?: boolean
isAnalytics?: boolean
}) => {
const [graphPosition, setGraphPosition] = useState(
graphPositionDefaultValue({ x: 0, y: 0 })
@ -76,6 +79,7 @@ export const GraphProvider = ({
setFocusedGroupId,
setPreviewingBlock,
previewingBlock,
isAnalytics,
}}
>
{children}

View File

@ -36,6 +36,16 @@ const inspectTypebot = async () => {
id: true,
name: true,
plan: true,
members: {
select: {
role: true,
user: {
select: {
email: true,
},
},
},
},
},
},
},

View File

@ -24,7 +24,11 @@ const inspectWorkspace = async () => {
},
include: {
typebots: {
orderBy: {
updatedAt: 'desc',
},
select: {
updatedAt: true,
id: true,
name: true,
},