diff --git a/frontend/app/components/BugFinder/EventFilter/EventEditor.js b/frontend/app/components/BugFinder/EventFilter/EventEditor.js index def086416..29488a231 100644 --- a/frontend/app/components/BugFinder/EventFilter/EventEditor.js +++ b/frontend/app/components/BugFinder/EventFilter/EventEditor.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux'; -import { DNDSource, DNDTarget } from 'Components/hocs/dnd'; +// import { DNDSource, DNDTarget } from 'Components/hocs/dnd'; import Event, { TYPES } from 'Types/filter/event'; import { operatorOptions } from 'Types/filter'; import { editEvent, removeEvent, clearEvents, applyFilter } from 'Duck/filters'; @@ -25,8 +25,8 @@ const getLabel = ({ type }) => { return getPlaceholder({ type }); }; -@DNDTarget('event') -@DNDSource('event') +// @DNDTarget('event') +// @DNDSource('event') @connect(state => ({ isLastEvent: state.getIn([ 'filters', 'appliedFilter', 'events' ]).size === 1, }), { editEvent, removeEvent, clearEvents, applyFilter }) diff --git a/frontend/app/components/BugFinder/EventFilter/EventFilter.js b/frontend/app/components/BugFinder/EventFilter/EventFilter.js index 5bc1d1b32..5adc5a42e 100644 --- a/frontend/app/components/BugFinder/EventFilter/EventFilter.js +++ b/frontend/app/components/BugFinder/EventFilter/EventFilter.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { Input } from 'semantic-ui-react'; -import { DNDContext } from 'Components/hocs/dnd'; +// import { DNDContext } from 'Components/hocs/dnd'; import { addEvent, applyFilter, moveEvent, clearEvents, edit, addCustomFilter, addAttribute, setSearchQuery, setActiveFlow, setFilterOption @@ -45,7 +45,7 @@ import SaveFilterButton from 'Shared/SaveFilterButton'; setBlink, edit, }) -@DNDContext +// @DNDContext export default class EventFilter extends React.PureComponent { state = { search: '', showFilterModal: false, showPlacehoder: true } fetchEventList = debounce(this.props.fetchEventList, 500) diff --git a/frontend/app/components/Dashboard/NewDashboard.tsx b/frontend/app/components/Dashboard/NewDashboard.tsx index 46901a87f..5d51e5037 100644 --- a/frontend/app/components/Dashboard/NewDashboard.tsx +++ b/frontend/app/components/Dashboard/NewDashboard.tsx @@ -26,7 +26,10 @@ function NewDashboard(props) { }, []); useEffect(() => { - if (!dashboard || !dashboard.dashboardId) { + if (dashboardId) { + store.selectDashboardById(dashboardId); + } + if (!dashboardId) { if (dashboardId) { store.selectDashboardById(dashboardId); } else { @@ -35,19 +38,9 @@ function NewDashboard(props) { }); } } + }, []); - // if (dashboard) { - // if (dashboard.dashboardId !== dashboardId) { - // history.push(withSiteId(dashboardSelected(dashboard.dashboardId), parseInt(siteId))); - // } - - // history.replace(withSiteId(dashboardSelected(dashboard.dashboardId), parseInt(siteId))); - // } - - // console.log('dashboard', dashboard) - }, [dashboard]); - - console.log('rendering dashboard', props.match.params); + // console.log('rendering dashboard', props.match.params); return ( <> diff --git a/frontend/app/components/Dashboard/WidgetWrapper/WidgetWrapper.tsx b/frontend/app/components/Dashboard/WidgetWrapper/WidgetWrapper.tsx index d34eeb08d..d7f6e2fe4 100644 --- a/frontend/app/components/Dashboard/WidgetWrapper/WidgetWrapper.tsx +++ b/frontend/app/components/Dashboard/WidgetWrapper/WidgetWrapper.tsx @@ -1,18 +1,61 @@ -import React from 'react'; +import React, { useRef } from 'react'; import { useDashboardStore } from '../store/store'; import cn from 'classnames'; import { ItemMenu } from 'UI'; +import { useDrag, useDrop } from 'react-dnd'; function WidgetWrapper(props) { - const { widget } = props; - // const store: any = useDashboardStore(); - // const dashboard = store.selectedDashboard; - // const siteId = store.siteId; + const { widget, index, moveListItem } = props; + + // useDrag - the list item is draggable + const [{ opacity, isDragging }, dragRef] = useDrag({ + type: 'item', + item: { index }, + collect: (monitor) => ({ + isDragging: monitor.isDragging(), + opacity: monitor.isDragging() ? 0.5 : 1, + }), + }, [index]); + + // useDrop - the list item is also a drop area + const [spec, dropRef] = useDrop({ + accept: 'item', + drop: (item: any) => { + if (item.index === index) return; + moveListItem(item.index, index); + }, + // hover: (item: any, monitor: any) => { + // const dragIndex = item.index + // const hoverIndex = index + // const hoverBoundingRect = ref.current?.getBoundingClientRect() + // const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2 + // const hoverActualY = monitor.getClientOffset().y - hoverBoundingRect.top + + // // if dragging down, continue only when hover is smaller than middle Y + // if (dragIndex < hoverIndex && hoverActualY < hoverMiddleY) return + // // if dragging up, continue only when hover is bigger than middle Y + // if (dragIndex > hoverIndex && hoverActualY > hoverMiddleY) return + + // moveListItem(dragIndex, hoverIndex) + // item.index = hoverIndex + // }, + }, []) + + console.log('spec', spec) + + const ref: any = useRef(null) + const dragDropRef: any = dragRef(dropRef(ref)) return ( -
Metrics helps you visualize trends from sessions captured by OpenReplay
+ +