Skip to content

Commit 54c196a

Browse files
ref(replays): hide selector widgets and disable tab if only mobile proj selected (#67173)
- If only mobile projects are selected, disable the selectors tab & hide the widgets - New hook! https://github.com/getsentry/sentry/assets/56095982/d9e1d579-3900-4ce6-b111-32ffffdd051a
1 parent 6187f3f commit 54c196a

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {mobile} from 'sentry/data/platformCategories';
2+
import useOrganization from 'sentry/utils/useOrganization';
3+
import usePageFilters from 'sentry/utils/usePageFilters';
4+
import useProjects from 'sentry/utils/useProjects';
5+
6+
export default function useAllMobileProj() {
7+
const organization = useOrganization();
8+
const {
9+
selection: {projects: projectIds},
10+
} = usePageFilters();
11+
12+
const {projects} = useProjects();
13+
const projectsSelected = projects.filter(p => projectIds.map(String).includes(p.id));
14+
const allMobileProj =
15+
organization.features.includes('session-replay-mobile-player') &&
16+
projectsSelected.every(p => mobile.includes(p.platform ?? 'other'));
17+
18+
return {allMobileProj};
19+
}

static/app/views/replays/list/listContent.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import useOrganization from 'sentry/utils/useOrganization';
1212
import usePageFilters from 'sentry/utils/usePageFilters';
1313
import useProjectSdkNeedsUpdate from 'sentry/utils/useProjectSdkNeedsUpdate';
1414
import DeadRageSelectorCards from 'sentry/views/replays/deadRageClick/deadRageSelectorCards';
15+
import useAllMobileProj from 'sentry/views/replays/detail/useAllMobileProj';
1516
import ReplaysFilters from 'sentry/views/replays/list/filters';
1617
import ReplayOnboardingPanel from 'sentry/views/replays/list/replayOnboardingPanel';
1718
import ReplaysList from 'sentry/views/replays/list/replaysList';
@@ -30,6 +31,9 @@ export default function ListContent() {
3031
organization,
3132
projectId: projects.map(String),
3233
});
34+
35+
const {allMobileProj} = useAllMobileProj();
36+
3337
const [widgetIsOpen, setWidgetIsOpen] = useState(true);
3438

3539
useRouteAnalyticsParams({
@@ -73,12 +77,14 @@ export default function ListContent() {
7377
<ReplaysFilters />
7478
<SearchWrapper>
7579
<ReplaysSearch />
76-
<Button onClick={() => setWidgetIsOpen(!widgetIsOpen)}>
77-
{widgetIsOpen ? t('Hide Widgets') : t('Show Widgets')}
78-
</Button>
80+
{!allMobileProj && (
81+
<Button onClick={() => setWidgetIsOpen(!widgetIsOpen)}>
82+
{widgetIsOpen ? t('Hide Widgets') : t('Show Widgets')}
83+
</Button>
84+
)}
7985
</SearchWrapper>
8086
</FiltersContainer>
81-
{widgetIsOpen ? <DeadRageSelectorCards /> : null}
87+
{widgetIsOpen && !allMobileProj ? <DeadRageSelectorCards /> : null}
8288
<ReplaysList />
8389
</Fragment>
8490
);

static/app/views/replays/list/replaysList.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import styled from '@emotion/styled';
44
import type {Location} from 'history';
55

66
import Pagination from 'sentry/components/pagination';
7-
import {mobile} from 'sentry/data/platformCategories';
87
import {t, tct} from 'sentry/locale';
98
import type {Organization} from 'sentry/types';
109
import {trackAnalytics} from 'sentry/utils/analytics';
@@ -16,8 +15,8 @@ import {MutableSearch} from 'sentry/utils/tokenizeSearch';
1615
import {useLocation} from 'sentry/utils/useLocation';
1716
import useOrganization from 'sentry/utils/useOrganization';
1817
import usePageFilters from 'sentry/utils/usePageFilters';
19-
import useProjects from 'sentry/utils/useProjects';
2018
import useProjectSdkNeedsUpdate from 'sentry/utils/useProjectSdkNeedsUpdate';
19+
import useAllMobileProj from 'sentry/views/replays/detail/useAllMobileProj';
2120
import ReplayTable from 'sentry/views/replays/replayTable';
2221
import {ReplayColumn} from 'sentry/views/replays/replayTable/types';
2322
import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
@@ -72,16 +71,15 @@ function ReplaysListTable({
7271
});
7372

7473
const {
75-
selection: {projects: projectIds},
74+
selection: {projects},
7675
} = usePageFilters();
7776

78-
const {projects} = useProjects();
79-
const projectsSelected = projects.filter(p => projectIds.map(String).includes(p.id));
77+
const {allMobileProj} = useAllMobileProj();
8078

8179
const {needsUpdate: allSelectedProjectsNeedUpdates} = useProjectSdkNeedsUpdate({
8280
minVersion: MIN_REPLAY_CLICK_SDK,
8381
organization,
84-
projectId: projectIds.map(String),
82+
projectId: projects.map(String),
8583
});
8684

8785
const conditions = useMemo(() => {
@@ -90,10 +88,6 @@ function ReplaysListTable({
9088

9189
const hasReplayClick = conditions.getFilterKeys().some(k => k.startsWith('click.'));
9290

93-
const allMobileProj =
94-
organization.features.includes('session-replay-mobile-player') &&
95-
projectsSelected.every(p => mobile.includes(p.platform ?? 'other'));
96-
9791
// browser isn't applicable for mobile projects
9892
// rage and dead clicks not available yet
9993
const visibleCols = allMobileProj

static/app/views/replays/tabs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {t} from 'sentry/locale';
55
import {useLocation} from 'sentry/utils/useLocation';
66
import useOrganization from 'sentry/utils/useOrganization';
77
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
8+
import useAllMobileProj from 'sentry/views/replays/detail/useAllMobileProj';
89

910
interface Props {
1011
selected: 'replays' | 'selectors';
@@ -13,6 +14,7 @@ interface Props {
1314
export default function ReplayTabs({selected}: Props) {
1415
const organization = useOrganization();
1516
const location = useLocation();
17+
const {allMobileProj} = useAllMobileProj();
1618

1719
const tabs = useMemo(
1820
() => [
@@ -43,6 +45,7 @@ export default function ReplayTabs({selected}: Props) {
4345
pathname: tab.pathname,
4446
query: tab.query,
4547
}}
48+
disabled={tab.key === 'selectors' && allMobileProj}
4649
>
4750
{tab.label}
4851
</TabList.Item>

0 commit comments

Comments
 (0)