Skip to content

ref(insights): remove insights-domin-view flag from sidebar #81247

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

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
130 changes: 39 additions & 91 deletions static/app/components/nav/config.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {openHelpSearchModal} from 'sentry/actionCreators/modal';
import type {NavConfig, NavSidebarItem} from 'sentry/components/nav/utils';
import type {NavConfig} from 'sentry/components/nav/utils';
import {
IconDashboard,
IconGraph,
Expand All @@ -15,26 +15,23 @@ import {t} from 'sentry/locale';
import ConfigStore from 'sentry/stores/configStore';
import type {Organization} from 'sentry/types/organization';
import {getDiscoverLandingUrl} from 'sentry/utils/discover/urls';
import {MODULE_BASE_URLS} from 'sentry/views/insights/common/utils/useModuleURL';
import {MODULE_SIDEBAR_TITLE as MODULE_TITLE_HTTP} from 'sentry/views/insights/http/settings';
import {
AI_LANDING_SUB_PATH,
AI_LANDING_TITLE,
AI_SIDEBAR_LABEL,
} from 'sentry/views/insights/pages/ai/settings';
import {
BACKEND_LANDING_SUB_PATH,
BACKEND_LANDING_TITLE,
BACKEND_SIDEBAR_LABEL,
} from 'sentry/views/insights/pages/backend/settings';
import {
FRONTEND_LANDING_SUB_PATH,
FRONTEND_LANDING_TITLE,
FRONTEND_SIDEBAR_LABEL,
} from 'sentry/views/insights/pages/frontend/settings';
import {
MOBILE_LANDING_SUB_PATH,
MOBILE_LANDING_TITLE,
MOBILE_SIDEBAR_LABEL,
} from 'sentry/views/insights/pages/mobile/settings';
import {DOMAIN_VIEW_BASE_URL} from 'sentry/views/insights/pages/settings';
import {INSIGHTS_BASE_URL, MODULE_TITLES} from 'sentry/views/insights/settings';
import {getSearchForIssueGroup, IssueGroup} from 'sentry/views/issueList/utils';

/**
Expand All @@ -45,88 +42,6 @@ import {getSearchForIssueGroup, IssueGroup} from 'sentry/views/issueList/utils';
*/
export function createNavConfig({organization}: {organization: Organization}): NavConfig {
const prefix = `organizations/${organization.slug}`;
const insightsPrefix = `${prefix}/${INSIGHTS_BASE_URL}`;
const hasPerfDomainViews = organization.features.includes('insights-domain-view');

const insights: NavSidebarItem = {
label: t('Insights'),
icon: <IconGraph />,
feature: {features: 'insights-entry-points'},
analyticsKey: 'insights',
submenu: [
{
label: MODULE_TITLE_HTTP,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.http}/`,
},
{label: MODULE_TITLES.db, to: `/${insightsPrefix}/${MODULE_BASE_URLS.db}/`},
{
label: MODULE_TITLES.resource,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.resource}/`,
},
{
label: MODULE_TITLES.app_start,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.app_start}/`,
},
{
label: MODULE_TITLES['mobile-screens'],
to: `/${insightsPrefix}/${MODULE_BASE_URLS['mobile-screens']}/`,
feature: {features: 'insights-mobile-screens-module'},
},
{
label: MODULE_TITLES.vital,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.vital}/`,
},
{
label: MODULE_TITLES.cache,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.cache}/`,
},
{
label: MODULE_TITLES.queue,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.queue}/`,
},
{
label: MODULE_TITLES.ai,
to: `/${insightsPrefix}/${MODULE_BASE_URLS.ai}/`,
feature: {features: 'insights-entry-points'},
},
],
};

const perf: NavSidebarItem = {
label: t('Perf.'),
to: '/performance/',
analyticsKey: 'performance',
icon: <IconLightning />,
feature: {
features: 'performance-view',
hookName: 'feature-disabled:performance-sidebar-item',
},
};

const perfDomainViews: NavSidebarItem = {
label: t('Perf.'),
icon: <IconLightning />,
analyticsKey: 'insights-domains',
feature: {features: ['insights-domain-view', 'performance-view']},
submenu: [
{
label: FRONTEND_LANDING_TITLE,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${FRONTEND_LANDING_SUB_PATH}/`,
},
{
label: BACKEND_LANDING_TITLE,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${BACKEND_LANDING_SUB_PATH}/`,
},
{
label: AI_LANDING_TITLE,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${AI_LANDING_SUB_PATH}/`,
},
{
label: MOBILE_LANDING_TITLE,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${MOBILE_LANDING_SUB_PATH}/`,
},
],
};

return {
main: [
Expand Down Expand Up @@ -208,7 +123,40 @@ export function createNavConfig({organization}: {organization: Organization}): N
{label: t('Crons'), to: `/${prefix}/crons/`},
],
},
...(hasPerfDomainViews ? [perfDomainViews, perf] : [insights, perf]),
{
label: t('Insights'),
icon: <IconGraph />,
analyticsKey: 'insights-domains',
feature: {features: ['performance-view']},
submenu: [
{
label: FRONTEND_SIDEBAR_LABEL,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${FRONTEND_LANDING_SUB_PATH}/`,
},
{
label: BACKEND_SIDEBAR_LABEL,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${BACKEND_LANDING_SUB_PATH}/`,
},
{
label: MOBILE_SIDEBAR_LABEL,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${MOBILE_LANDING_SUB_PATH}/`,
},
{
label: AI_SIDEBAR_LABEL,
to: `/${prefix}/${DOMAIN_VIEW_BASE_URL}/${AI_LANDING_SUB_PATH}/`,
},
],
},
{
label: t('Perf.'),
to: '/performance/',
analyticsKey: 'performance',
icon: <IconLightning />,
feature: {
features: 'performance-view',
hookName: 'feature-disabled:performance-sidebar-item',
},
},
{
label: t('Boards'),
analyticsKey: 'customizable-dashboards',
Expand Down
17 changes: 5 additions & 12 deletions static/app/components/nav/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ describe('Nav', function () {
beforeEach(() => {
render(<Nav />, {
router: RouterFixture({
location: LocationFixture({pathname: '/organizations/org-slug/insights/http/'}),
location: LocationFixture({
pathname: '/organizations/org-slug/insights/backend/',
}),
}),
organization: OrganizationFixture({features: ALL_AVAILABLE_FEATURES}),
});
Expand All @@ -122,17 +124,8 @@ describe('Nav', function () {
it('includes expected submenu items', function () {
const container = screen.getByRole('navigation', {name: 'Secondary Navigation'});
const links = getAllByRole(container, 'link');
expect(links).toHaveLength(8);
[
'Requests',
'Queries',
'Assets',
'App Starts',
'Web Vitals',
'Caches',
'Queues',
'LLM Monitoring',
].forEach((title, index) => {
expect(links).toHaveLength(4);
['Frontend', 'Backend', 'Mobile', 'AI'].forEach((title, index) => {
expect(links[index]).toHaveAccessibleName(title);
});
});
Expand Down
43 changes: 11 additions & 32 deletions static/app/components/sidebar/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ describe('Sidebar', function () {
});

const links = screen.getAllByRole('link');
expect(links).toHaveLength(31);
expect(links).toHaveLength(25);

[
'Issues',
Expand All @@ -381,16 +381,10 @@ describe('Sidebar', function () {
'Replays',
'Discover',
/Insights/,
'Requests',
'Queries',
'Assets',
'App Starts',
'Screen Loads',
'Web Vitals',
/Caches/,
/Queues/,
/Mobile UI/,
/LLM Monitoring/,
'Frontend',
'Backend',
'Mobile',
'AI',
'Performance',
'User Feedback',
'Crons',
Expand All @@ -407,35 +401,20 @@ describe('Sidebar', function () {
});
});

it('mobile screens module hides all other mobile modules', async function () {
localStorage.setItem('sidebar-accordion-insights:expanded', 'true');
renderSidebarWithFeatures([
'insights-entry-points',
'starfish-mobile-ui-module',
'insights-mobile-screens-module',
]);

await waitFor(function () {
expect(apiMocks.broadcasts).toHaveBeenCalled();
});

['App Starts', 'Screen Loads', /Mobile UI/].forEach(title => {
expect(screen.queryByText(title)).not.toBeInTheDocument();
});

expect(screen.getByText(/Mobile Screens/)).toBeInTheDocument();
});

it('should not render floating accordion when expanded', async () => {
renderSidebarWithFeatures(ALL_AVAILABLE_FEATURES);
await userEvent.click(screen.getByTestId('sidebar-accordion-insights-item'));
await userEvent.click(
screen.getByTestId('sidebar-accordion-insights-domains-item')
);
expect(screen.queryByTestId('floating-accordion')).not.toBeInTheDocument();
});

it('should render floating accordion when collapsed', async () => {
renderSidebarWithFeatures(ALL_AVAILABLE_FEATURES);
await userEvent.click(screen.getByTestId('sidebar-collapse'));
await userEvent.click(screen.getByTestId('sidebar-accordion-insights-item'));
await userEvent.click(
screen.getByTestId('sidebar-accordion-insights-domains-item')
);
expect(await screen.findByTestId('floating-accordion')).toBeInTheDocument();
});
});
Expand Down
Loading
Loading