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" justifyContent="center"
> >
{publishedTypebot && stats ? ( {publishedTypebot && stats ? (
<GraphProvider isReadOnly> <GraphProvider isReadOnly isAnalytics>
<EventsCoordinatesProvider events={publishedTypebot?.events}> <EventsCoordinatesProvider events={publishedTypebot?.events}>
<Graph <Graph
flex="1" flex="1"

View File

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

View File

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

View File

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

View File

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