diff --git a/frontend/.unimportedrc.json b/frontend/.unimportedrc.json new file mode 100644 index 000000000..0bc91c4e3 --- /dev/null +++ b/frontend/.unimportedrc.json @@ -0,0 +1,3 @@ +{ + "entry": ["./app/initialize.tsx"] +} \ No newline at end of file diff --git a/frontend/app/components/Alerts/Alerts.js b/frontend/app/components/Alerts/Alerts.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/frontend/app/components/Client/Client.tsx b/frontend/app/components/Client/Client.tsx index 45e7dfa08..be2bfd3cf 100644 --- a/frontend/app/components/Client/Client.tsx +++ b/frontend/app/components/Client/Client.tsx @@ -10,9 +10,6 @@ import AuditView from './Audit/AuditView'; import Sites from './Sites'; import CustomFields from './CustomFields'; import Webhooks from './Webhooks'; -import styles from './client.module.css'; -import cn from 'classnames'; -import PreferencesMenu from './PreferencesMenu'; import Notifications from './Notifications'; import Roles from './Roles'; import SessionsListingSettings from 'Components/Client/SessionsListingSettings'; diff --git a/frontend/app/components/Session_/StackEvents/StackEvents.DEPRECATED.js b/frontend/app/components/Session_/StackEvents/StackEvents.DEPRECATED.js deleted file mode 100644 index 66850af2e..000000000 --- a/frontend/app/components/Session_/StackEvents/StackEvents.DEPRECATED.js +++ /dev/null @@ -1,180 +0,0 @@ -import { error as errorRoute } from 'App/routes'; -import JsonViewer from 'Components/Session_/StackEvents/UserEvent/JsonViewer'; -import Sentry from 'Components/Session_/StackEvents/UserEvent/Sentry'; -import { hideHint } from 'Duck/components/player'; -import withEnumToggle from 'HOCs/withEnumToggle'; -import { connectPlayer, jump } from 'Player'; -import React from 'react'; -import { connect } from 'react-redux'; -import StackEventRow from 'Shared/DevTools/StackEventRow'; -import { DATADOG, SENTRY, STACKDRIVER, typeList } from 'Types/session/stackEvent'; -import { NoContent, SlideModal, Tabs, Link } from 'UI'; -import Autoscroll from '../Autoscroll'; -import BottomBlock from '../BottomBlock'; - -const ALL = 'ALL'; - -const TABS = [ALL, ...typeList].map((tab) => ({ text: tab, key: tab })); - -@withEnumToggle('activeTab', 'setActiveTab', ALL) -@connectPlayer((state) => ({ - stackEvents: state.stackList, - // stackEventsNow: state.stackListNow, -})) -@connect( - (state) => ({ - hintIsHidden: - state.getIn(['components', 'player', 'hiddenHints', 'stack']) || - !state.getIn(['site', 'list']).some((s) => s.stackIntegrations), - }), - { - hideHint, - } -) -export default class StackEvents extends React.PureComponent { - // onFilterChange = (e, { value }) => this.setState({ filter: value }) - - state = { - currentEvent: null, - }; - - onDetailsClick(userEvent) { - this.setState({ currentEvent: userEvent }); - } - - closeModal() { - this.setState({ currentEvent: undefined }); - } - - renderPopupContent(userEvent) { - const { source, payload, name } = userEvent; - switch (source) { - case SENTRY: - return ; - case DATADOG: - return ; - case STACKDRIVER: - return ; - default: - return ; - } - } - - render() { - const { stackEvents, activeTab, setActiveTab, hintIsHidden } = this.props; - //const filterRE = new RegExp(filter, 'i'); - const { currentEvent } = this.state; - - const tabs = TABS.filter( - ({ key }) => key === ALL || stackEvents.some(({ source }) => key === source) - ); - - const filteredStackEvents = stackEvents.filter( - ({ source }) => activeTab === ALL || activeTab === source - ); - - // let lastIndex = -1; - // // TODO: Need to do filtering in store, or preferably in a selector - // filteredStackEvents.forEach((item, index) => { - // if ( - // this.props.stackEventsNow.length > 0 && - // item.time <= this.props.stackEventsNow[this.props.stackEventsNow.length - 1].time - // ) { - // lastIndex = index; - // } - // }); - - return ( - <> - -
- - {currentEvent.name} - - {currentEvent.function} -
-
{currentEvent.message}
- - ) - } - isDisplayed={currentEvent != null} - content={ - currentEvent &&
{this.renderPopupContent(currentEvent)}
- } - onClose={this.closeModal.bind(this)} - /> - - -
- Events - -
-
- - - - Integrations - - {' and '} - - Events - - { - ' make debugging easier. Sync your backend logs and custom events with session replay.' - } -
-
- - - ) : null - } - size="small" - show={filteredStackEvents.length === 0} - > - - {filteredStackEvents.map((userEvent, index) => ( - jump(userEvent.time)} - /> - // lastIndex} - // // selected={lastIndex === index} - // userEvent={userEvent} - // onJump={() => jump(userEvent.time)} - // /> - ))} - -
-
-
- - ); - } -} diff --git a/frontend/app/components/hocs/dnd.js b/frontend/app/components/hocs/dnd.js deleted file mode 100644 index 3e4f42e8e..000000000 --- a/frontend/app/components/hocs/dnd.js +++ /dev/null @@ -1,62 +0,0 @@ -import { HTML5Backend } from 'react-dnd-html5-backend'; -import { findDOMNode } from 'react-dom'; -import { DragSource, DropTarget, DndContext } from 'react-dnd'; - -const cardSource = { - beginDrag(props) { - return { - id: props.key, - index: props.index, - prevIndex: props.index, - }; - }, -}; - -const cardTarget = { - // eslint-disable-next-line complexity - hover(props, monitor, component) { - const dragIndex = monitor.getItem().index; - const hoverIndex = props.index; - - if (dragIndex === hoverIndex) { - return; - } - /* eslint-disable react/no-find-dom-node */ - const hoverBoundingRect = findDOMNode(component).getBoundingClientRect(); - const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2; - const clientOffset = monitor.getClientOffset(); - const hoverClientY = clientOffset.y - hoverBoundingRect.top; - - // Dragging downwards - if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) { - return; - } - - // Dragging upwards - if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) { - return; - } - - props.onDNDMove(dragIndex, hoverIndex); - monitor.getItem().index = hoverIndex; - }, - - drop(props, monitor) { - const dragIndex = monitor.getItem().prevIndex; - const dropIndex = props.index; - if (props.onDNDDrop) { - props.onDNDDrop(dragIndex, dropIndex); - } - }, -}; - -export const DNDContext = DndContext(HTML5Backend); - -export const DNDSource = name => DragSource(name, cardSource, (connect, monitor) => ({ - connectDragSource: connect.dragSource(), - isDragging: monitor.isDragging(), -})); - -export const DNDTarget = name => DropTarget(name, cardTarget, connect => ({ - connectDropTarget: connect.dropTarget(), -})); diff --git a/frontend/app/components/hocs/userDrawer.tsx b/frontend/app/components/hocs/userDrawer.tsx deleted file mode 100644 index 7f7e49ce7..000000000 --- a/frontend/app/components/hocs/userDrawer.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useState } from 'react'; -import { Drawer, DrawerProps } from 'antd'; - - -interface ExtendedDrawerProps extends DrawerProps { - visible: boolean; - onClose: any; -} - -const DrawerComponent: React.FC = ({ - visible, - onClose, - title, - placement, - children - }) => { - return ( - - {children} - - ); -}; - -const useDrawer = () => { - const [visible, setVisible] = useState(false); - const [content, setContent] = useState(null); - const [drawerProps, setDrawerProps] = useState({ - title: '', - children: null, - placement: 'right' - }); - - const showDrawer = (component: React.ReactNode, props: DrawerProps) => { - setContent(component); - setDrawerProps(props); - setVisible(true); - }; - - - const DrawerWrapper: React.FC = () => { - return ( - setVisible(false)} - {...drawerProps} - > - {content} - - ); - }; - - return { - showDrawer, - // hideDrawer, - DrawerWrapper - }; -}; - -export default useDrawer; \ No newline at end of file diff --git a/frontend/app/components/hocs/withCacheState.js b/frontend/app/components/hocs/withCacheState.js deleted file mode 100644 index 0bfe7feb1..000000000 --- a/frontend/app/components/hocs/withCacheState.js +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -export default (propNames) => BaseComponent => class extends React.PureComponent { - state = { - obj: this.getObjFromProps(), - changed: false, - } - - getObjFromProps() { - const obj = {} - propNames.forEach(propName => { - obj[ propName ] = this.props[ propName ] || null; - }); - return obj; - } - - componentDidUpdate(prevProps) { - if (propNames.some(propName => prevProps[ propName ] !== this.props[ propName ])){ - this.setState({ - obj: this.getObjFromProps(), - changed: false, - }) - } - } - - _onChange = ({ name, value, type, checked }) => { - if ([ 'radio', 'checkbox' ].includes(type)) { - this.edit(name, checked); - } else { - this.edit(name, value); - } - } - - onChange = ({ target }) => this._onChange(target) - - onChangeSemantic = (e, target) => this._onChange(target) - - edit = (name, value) => { - this.setState({ - obj: { - ...this.state.obj, - [ name ]: value, - }, - changed: true, - }); - } - - update = (name, updateFunction = a => a) => { - this.setState({ - obj: { - ...this.state.obj, - [ name ]: updateFunction(this.state.obj[ name ]), - }, - changed: true, - }); - } - - render() { - - return ( - - ); - } -} \ No newline at end of file diff --git a/frontend/app/components/hocs/withEnumToggle.js b/frontend/app/components/hocs/withEnumToggle.js deleted file mode 100644 index 2137335fc..000000000 --- a/frontend/app/components/hocs/withEnumToggle.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -const withEnumToggle = (stateName = 'active', handlerName = 'setActive', initial) => BaseComponent => - class extends React.Component { - state = { - active: initial, - }; - - setActive = state => this.setState({ - active: state, - }) - - render() { - const newProps = { - [ handlerName ]: this.setActive, - [ stateName ]: this.state.active, - }; - return ; - } - }; - -export default withEnumToggle; diff --git a/frontend/package.json b/frontend/package.json index 9710d02b9..344667458 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -21,7 +21,8 @@ "cy:open": "cypress open", "cy:test": "cypress install && cypress run --browser chrome", "cy:test-firefox": "cypress install && cypress run --browser firefox", - "cy:test-edge": "cypress install && cypress run --browser edge" + "cy:test-edge": "cypress install && cypress run --browser edge", + "check-unimported": "npx unimported" }, "dependencies": { "@ant-design/icons": "^5.2.5",