mobilePageHeader.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  2. import useOrganization from 'sentry/utils/useOrganization';
  3. import {
  4. DomainViewHeader,
  5. type Props as HeaderProps,
  6. } from 'sentry/views/insights/pages/domainViewHeader';
  7. import {
  8. MOBILE_LANDING_SUB_PATH,
  9. MOBILE_LANDING_TITLE,
  10. } from 'sentry/views/insights/pages/mobile/settings';
  11. import {DOMAIN_VIEW_BASE_URL} from 'sentry/views/insights/pages/settings';
  12. import {isModuleEnabled} from 'sentry/views/insights/pages/utils';
  13. import {ModuleName} from 'sentry/views/insights/types';
  14. type Props = {
  15. headerTitle: HeaderProps['headerTitle'];
  16. breadcrumbs?: HeaderProps['additionalBreadCrumbs'];
  17. headerActions?: HeaderProps['additonalHeaderActions'];
  18. hideDefaultTabs?: HeaderProps['hideDefaultTabs'];
  19. module?: HeaderProps['selectedModule'];
  20. tabs?: HeaderProps['tabs'];
  21. };
  22. export function MobileHeader({
  23. module,
  24. hideDefaultTabs,
  25. headerActions,
  26. headerTitle,
  27. tabs,
  28. breadcrumbs,
  29. }: Props) {
  30. const organization = useOrganization();
  31. const mobileBaseUrl = normalizeUrl(
  32. `/organizations/${organization.slug}/${DOMAIN_VIEW_BASE_URL}/${MOBILE_LANDING_SUB_PATH}/`
  33. );
  34. const hasMobileScreens = isModuleEnabled(ModuleName.MOBILE_SCREENS, organization);
  35. const hasMobileUi = isModuleEnabled(ModuleName.MOBILE_UI, organization);
  36. const modules = hasMobileScreens
  37. ? [ModuleName.MOBILE_SCREENS]
  38. : [ModuleName.APP_START, ModuleName.SCREEN_LOAD, ModuleName.SCREEN_RENDERING];
  39. if (!hasMobileScreens && hasMobileUi) {
  40. modules.push(ModuleName.MOBILE_UI);
  41. }
  42. return (
  43. <DomainViewHeader
  44. domainBaseUrl={mobileBaseUrl}
  45. domainTitle={MOBILE_LANDING_TITLE}
  46. headerTitle={headerTitle}
  47. modules={modules}
  48. selectedModule={module}
  49. tabs={tabs}
  50. hideDefaultTabs={hideDefaultTabs}
  51. additonalHeaderActions={headerActions}
  52. additionalBreadCrumbs={breadcrumbs}
  53. />
  54. );
  55. }