Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nav): Move stats to settings #84804

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions static/app/components/nav/primary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
IconQuestion,
IconSearch,
IconSettings,
IconStats,
} from 'sentry/icons';
import {t} from 'sentry/locale';
import ConfigStore from 'sentry/stores/configStore';
Expand Down Expand Up @@ -226,16 +225,7 @@ export function PrimaryNavigationItems() {
</SidebarMenu>

<SidebarLink
to={`/${prefix}/stats/`}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes stats in new nav component

analyticsKey="stats"
linkProps={!includeFooterLabels ? {'aria-label': t('Stats')} : undefined}
>
<IconStats />
{includeFooterLabels && <span>{t('Stats')}</span>}
</SidebarLink>

<SidebarLink
to={`/${prefix}/settings/`}
to={`/${prefix}/settings/${organization.slug}/`}
activeTo={`/${prefix}/settings/`}
analyticsKey="settings"
linkProps={!includeFooterLabels ? {'aria-label': t('Settings')} : undefined}
Expand Down
65 changes: 37 additions & 28 deletions static/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {IssueNavigation} from 'sentry/views/issues/navigation';
import OrganizationContainer from 'sentry/views/organizationContainer';
import OrganizationLayout from 'sentry/views/organizationLayout';
import OrganizationRoot from 'sentry/views/organizationRoot';
import {OrganizationStatsWrapper} from 'sentry/views/organizationStats/organizationStatsWrapper';
import ProjectEventRedirect from 'sentry/views/projectEventRedirect';
import redirectDeprecatedProjectRoute from 'sentry/views/projects/redirectDeprecatedProjectRoute';
import RouteNotFound from 'sentry/views/routeNotFound';
Expand Down Expand Up @@ -695,6 +696,39 @@ function buildRoutes() {
</Route>
);

const statsChildRoutes = (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor so that we can use the statsChildRoutes in two places

<Fragment>
<IndexRoute component={make(() => import('sentry/views/organizationStats'))} />
<Route
component={make(() => import('sentry/views/organizationStats/teamInsights'))}
>
<Route
path="issues/"
component={make(
() => import('sentry/views/organizationStats/teamInsights/issues')
)}
/>
<Route
path="health/"
component={make(
() => import('sentry/views/organizationStats/teamInsights/health')
)}
/>
</Route>
</Fragment>
);
const statsRoutes = (
<Fragment>
<Route path="/stats/" withOrgPath component={OrganizationStatsWrapper}>
{statsChildRoutes}
</Route>
<Redirect
from="/organizations/:orgId/stats/team/"
to="/organizations/:orgId/stats/issues/"
/>
</Fragment>
);

const orgSettingsRoutes = (
<Route
component={make(
Expand Down Expand Up @@ -998,6 +1032,9 @@ function buildRoutes() {
)}
/>
</Route>
<Route path="stats/" name={t('Stats')}>
{statsChildRoutes}
</Route>
</Route>
);

Expand Down Expand Up @@ -1485,34 +1522,6 @@ function buildRoutes() {
</Fragment>
);

const statsRoutes = (
<Fragment>
<Route path="/stats/" withOrgPath>
<IndexRoute component={make(() => import('sentry/views/organizationStats'))} />
<Route
component={make(() => import('sentry/views/organizationStats/teamInsights'))}
>
<Route
path="issues/"
component={make(
() => import('sentry/views/organizationStats/teamInsights/issues')
)}
/>
<Route
path="health/"
component={make(
() => import('sentry/views/organizationStats/teamInsights/health')
)}
/>
</Route>
</Route>
<Redirect
from="/organizations/:orgId/stats/team/"
to="/organizations/:orgId/stats/issues/"
/>
</Fragment>
);

const discoverChildRoutes = (
<Fragment>
<IndexRedirect to="queries/" />
Expand Down
21 changes: 21 additions & 0 deletions static/app/views/organizationStats/organizationStatsWrapper.tsx
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New wrapper for stats routes to provide redirect from /stats/ -> /settings/stats/ (redirect only happens when feature flag is on)

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {useRedirectNavV2Routes} from 'sentry/components/nav/useRedirectNavV2Routes';
import Redirect from 'sentry/components/redirect';

type OrganizationStatsWrapperProps = {
children: React.ReactNode;
};

// Wraps all routes under /stats/ to redirect to /settings/stats/
// Can be removed once navigation-sidebar-v2 is fully launched
export function OrganizationStatsWrapper({children}: OrganizationStatsWrapperProps) {
const redirectPath = useRedirectNavV2Routes({
oldPathPrefix: '/stats/',
newPathPrefix: '/settings/stats/',
});

if (redirectPath) {
return <Redirect to={redirectPath} />;
}

return children;
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ const organizationNavigation: NavigationSection[] = [
show: ({organization}) =>
!!organization && organization.features.includes('feature-flag-ui'),
},
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds stats item in settings menu (feature flagged)

path: `${organizationSettingsPathPrefix}/stats/`,
title: t('Stats & Usage'),
description: t('View organization stats and usage'),
id: 'stats',
show: ({organization}) =>
organization?.features.includes('navigation-sidebar-v2') ?? false,
},
],
},
{
Expand Down
Loading