123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import {ComponentProps, Fragment, ReactNode} from 'react';
- import styled from '@emotion/styled';
- import {Location} from 'history';
- import {LinkButton} from 'sentry/components/button';
- import {hydratedSelectorData} from 'sentry/components/replays/utils';
- import {IconCursorArrow, IconShow} from 'sentry/icons';
- import {t} from 'sentry/locale';
- import {space} from 'sentry/styles/space';
- import useDeadRageSelectors from 'sentry/utils/replays/hooks/useDeadRageSelectors';
- import {useLocation} from 'sentry/utils/useLocation';
- import useOrganization from 'sentry/utils/useOrganization';
- import {normalizeUrl} from 'sentry/utils/withDomainRequired';
- import SelectorTable from 'sentry/views/replays/deadRageClick/selectorTable';
- function DeadRageSelectorCards() {
- const location = useLocation();
- return (
- <SplitCardContainer>
- <DeadClickTable location={location} />
- <RageClickTable location={location} />
- </SplitCardContainer>
- );
- }
- function DeadClickTable({location}: {location: Location<any>}) {
- const {isLoading, isError, data} = useDeadRageSelectors({
- per_page: 3,
- sort: '-count_dead_clicks',
- cursor: undefined,
- prefix: 'selector_',
- });
- return (
- <SelectorTable
- data={hydratedSelectorData(data, 'count_dead_clicks')}
- isError={isError}
- isLoading={isLoading}
- location={location}
- clickCountColumn={{key: 'count_dead_clicks', name: 'dead clicks'}}
- clickCountSortable={false}
- title={
- <Fragment>
- <IconContainer>
- <IconCursorArrow size="xs" color="yellow300" />
- </IconContainer>
- {t('Most Dead Clicks')}
- </Fragment>
- }
- headerButtons={
- <SearchButton
- label={t('Show all')}
- sort="-count_dead_clicks"
- path="dead-clicks"
- />
- }
- customHandleResize={() => {}}
- />
- );
- }
- function RageClickTable({location}: {location: Location<any>}) {
- const {isLoading, isError, data} = useDeadRageSelectors({
- per_page: 3,
- sort: '-count_rage_clicks',
- cursor: undefined,
- prefix: 'selector_',
- });
- return (
- <SelectorTable
- data={hydratedSelectorData(data, 'count_rage_clicks')}
- isError={isError}
- isLoading={isLoading}
- location={location}
- clickCountColumn={{key: 'count_rage_clicks', name: 'rage clicks'}}
- clickCountSortable={false}
- title={
- <Fragment>
- <IconContainer>
- <IconCursorArrow size="xs" color="red300" />
- </IconContainer>
- {t('Most Rage Clicks')}
- </Fragment>
- }
- headerButtons={
- <SearchButton
- label={t('Show all')}
- sort="-count_rage_clicks"
- path="rage-clicks"
- />
- }
- customHandleResize={() => {}}
- />
- );
- }
- function SearchButton({
- label,
- sort,
- path,
- ...props
- }: {
- label: ReactNode;
- path: string;
- sort: string;
- } & Omit<ComponentProps<typeof LinkButton>, 'size' | 'to'>) {
- const location = useLocation();
- const organization = useOrganization();
- return (
- <LinkButton
- {...props}
- size="xs"
- to={{
- pathname: normalizeUrl(`/organizations/${organization.slug}/replays/${path}/`),
- query: {
- ...location.query,
- sort,
- query: undefined,
- cursor: undefined,
- },
- }}
- icon={<IconShow size="xs" />}
- >
- {label}
- </LinkButton>
- );
- }
- const SplitCardContainer = styled('div')`
- display: grid;
- grid-template-columns: 1fr 1fr;
- grid-template-rows: max-content max-content;
- grid-auto-flow: column;
- gap: 0 ${space(2)};
- align-items: stretch;
- padding-top: ${space(1)};
- `;
- const IconContainer = styled('span')`
- margin-right: ${space(1)};
- `;
- export default DeadRageSelectorCards;
|