hooks.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. import type {ChildrenRenderFn} from 'sentry/components/acl/feature';
  2. import type {Guide} from 'sentry/components/assistant/types';
  3. import type {ButtonProps} from 'sentry/components/button';
  4. import type {FormPanelProps} from 'sentry/components/forms/formPanel';
  5. import type {JsonFormObject} from 'sentry/components/forms/types';
  6. import type {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import type {ProductSelectionProps} from 'sentry/components/onboarding/productSelection';
  8. import type SidebarItem from 'sentry/components/sidebar/sidebarItem';
  9. import type DateRange from 'sentry/components/timeRangeSelector/dateRange';
  10. import type SelectorItems from 'sentry/components/timeRangeSelector/selectorItems';
  11. import type {SVGIconProps} from 'sentry/icons/svgIcon';
  12. import type {UseExperiment} from 'sentry/utils/useExperiment';
  13. import type {TitleableModuleNames} from 'sentry/views/insights/common/components/modulePageProviders';
  14. import type {OrganizationStatsProps} from 'sentry/views/organizationStats';
  15. import type {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider';
  16. import type {NavigationItem, NavigationSection} from 'sentry/views/settings/types';
  17. import type {ExperimentKey} from './experiments';
  18. import type {Integration, IntegrationProvider} from './integrations';
  19. import type {
  20. Route,
  21. RouteComponentProps,
  22. RouteContextInterface,
  23. } from './legacyReactRouter';
  24. import type {Member, Organization, OrgRole} from './organization';
  25. import type {Project} from './project';
  26. import type {User} from './user';
  27. // XXX(epurkhiser): A Note about `_`.
  28. //
  29. // We add the `_: any` type int our hooks list to stop
  30. // typescript from doing too much type tightening. We should absolutely revisit
  31. // this in the future because all callbacks _should_ be allowed to be
  32. // functions, but doing so causes some unexpected issues and makes typescript
  33. // not happy. We still get a huge advantage of typing just by having each hook
  34. // type here however.
  35. /**
  36. * The Hooks type mapping is the master interface for all external Hooks into
  37. * the sentry frontend application.
  38. */
  39. export interface Hooks
  40. extends RouteHooks,
  41. ComponentHooks,
  42. CustomizationHooks,
  43. AnalyticsHooks,
  44. FeatureDisabledHooks,
  45. InterfaceChromeHooks,
  46. OnboardingHooks,
  47. SettingsHooks,
  48. FeatureSpecificHooks,
  49. ReactHooks,
  50. CallbackHooks {
  51. _: any;
  52. }
  53. export type HookName = keyof Hooks;
  54. /**
  55. * Route hooks.
  56. */
  57. export type RouteHooks = {
  58. 'routes:legacy-organization-redirects': RoutesHook;
  59. 'routes:root': RoutesHook;
  60. 'routes:settings': RoutesHook;
  61. };
  62. /**
  63. * Component specific hooks for DateRange and SelectorItems
  64. * These components have plan specific overrides in getsentry
  65. */
  66. type AiSetupDataConsentProps = {
  67. groupId: string;
  68. };
  69. type DateRangeProps = React.ComponentProps<typeof DateRange>;
  70. type SelectorItemsProps = React.ComponentProps<typeof SelectorItems>;
  71. type DisabledMemberViewProps = RouteComponentProps<{orgId: string}>;
  72. type MemberListHeaderProps = {
  73. members: Member[];
  74. organization: Organization;
  75. };
  76. type DisabledCustomSymbolSources = {
  77. children: React.ReactNode;
  78. organization: Organization;
  79. };
  80. type DisabledMemberTooltipProps = {children: React.ReactNode};
  81. type DashboardHeadersProps = {organization: Organization};
  82. type MetricsSamplesListProps = {children: React.ReactNode; organization: Organization};
  83. type ReplayFeedbackButton = {children: React.ReactNode};
  84. type ReplayListPageHeaderProps = {children?: React.ReactNode};
  85. type ReplayOnboardingAlertProps = {children: React.ReactNode};
  86. type ReplayOnboardingCTAProps = {children: React.ReactNode; organization: Organization};
  87. type ProductUnavailableCTAProps = {organization: Organization};
  88. type ProfilingBetaAlertBannerProps = {
  89. organization: Organization;
  90. };
  91. type ProfilingUpgradePlanButtonProps = ButtonProps & {
  92. children: React.ReactNode;
  93. fallback: React.ReactNode;
  94. organization: Organization;
  95. };
  96. type ProfilingAM1OrMMXUpgradeProps = {
  97. fallback: React.ReactNode;
  98. organization: Organization;
  99. };
  100. type CronsBillingBannerProps = {
  101. organization: Organization;
  102. };
  103. type OrganizationHeaderProps = {
  104. organization: Organization;
  105. };
  106. type ProductSelectionAvailabilityProps = Omit<ProductSelectionProps, 'disabledProducts'>;
  107. type FirstPartyIntegrationAlertProps = {
  108. integrations: Integration[];
  109. hideCTA?: boolean;
  110. wrapWithContainer?: boolean;
  111. };
  112. type FirstPartyIntegrationAdditionalCTAProps = {
  113. integrations: Integration[];
  114. };
  115. type AttemptCloseAttemptProps = {
  116. handleRemoveAccount: () => void;
  117. organizationSlugs: string[];
  118. };
  119. type CodecovLinkProps = {
  120. organization: Organization;
  121. };
  122. // on-create-project-product-selection
  123. type CreateProjectProductSelectionChangedCallback = (options: {
  124. defaultProducts: ProductSolution[];
  125. organization: Organization;
  126. selectedProducts: ProductSolution[];
  127. }) => void;
  128. type GuideUpdateCallback = (nextGuide: Guide | null, opts: {dismissed?: boolean}) => void;
  129. type MonitorCreatedCallback = (organization: Organization) => void;
  130. type CronsOnboardingPanelProps = {children: React.ReactNode};
  131. type SentryLogoProps = SVGIconProps & {
  132. pride?: boolean;
  133. };
  134. export type ParntershipAgreementType = 'standard' | 'partner_presence';
  135. export type PartnershipAgreementProps = {
  136. agreements: ParntershipAgreementType[];
  137. partnerDisplayName: string;
  138. onSubmitSuccess?: () => void;
  139. organizationSlug?: string;
  140. };
  141. export type MembershipSettingsProps = {
  142. forms: JsonFormObject[];
  143. jsonFormSettings: Omit<
  144. FormPanelProps,
  145. 'highlighted' | 'fields' | 'additionalFieldProps'
  146. >;
  147. };
  148. /**
  149. * Component wrapping hooks
  150. */
  151. export type ComponentHooks = {
  152. 'component:ai-setup-data-consent': () => React.ComponentType<AiSetupDataConsentProps> | null;
  153. 'component:codecov-integration-settings-link': () => React.ComponentType<CodecovLinkProps>;
  154. 'component:confirm-account-close': () => React.ComponentType<AttemptCloseAttemptProps>;
  155. 'component:crons-list-page-header': () => React.ComponentType<CronsBillingBannerProps>;
  156. 'component:crons-onboarding-panel': () => React.ComponentType<CronsOnboardingPanelProps>;
  157. 'component:dashboards-header': () => React.ComponentType<DashboardHeadersProps>;
  158. 'component:data-consent-banner': () => React.ComponentType<{source: string}> | null;
  159. 'component:data-consent-org-creation-checkbox': () => React.ComponentType | null;
  160. 'component:data-consent-priority-learn-more': () => React.ComponentType | null;
  161. 'component:ddm-metrics-samples-list': () => React.ComponentType<MetricsSamplesListProps>;
  162. 'component:disabled-custom-symbol-sources': () => React.ComponentType<DisabledCustomSymbolSources>;
  163. 'component:disabled-member': () => React.ComponentType<DisabledMemberViewProps>;
  164. 'component:disabled-member-tooltip': () => React.ComponentType<DisabledMemberTooltipProps>;
  165. 'component:enhanced-org-stats': () => React.ComponentType<OrganizationStatsProps>;
  166. 'component:first-party-integration-additional-cta': () => React.ComponentType<FirstPartyIntegrationAdditionalCTAProps>;
  167. 'component:first-party-integration-alert': () => React.ComponentType<FirstPartyIntegrationAlertProps>;
  168. 'component:header-date-range': () => React.ComponentType<DateRangeProps>;
  169. 'component:header-selector-items': () => React.ComponentType<SelectorItemsProps>;
  170. 'component:insights-date-range-query-limit-footer': () => React.ComponentType;
  171. 'component:insights-upsell-page': () => React.ComponentType<InsightsUpsellHook>;
  172. 'component:member-list-header': () => React.ComponentType<MemberListHeaderProps>;
  173. 'component:org-stats-banner': () => React.ComponentType<DashboardHeadersProps>;
  174. 'component:organization-header': () => React.ComponentType<OrganizationHeaderProps>;
  175. 'component:organization-membership-settings': () => React.ComponentType<MembershipSettingsProps>;
  176. 'component:partnership-agreement': React.ComponentType<PartnershipAgreementProps>;
  177. 'component:product-selection-availability': () => React.ComponentType<ProductSelectionAvailabilityProps>;
  178. 'component:product-unavailable-cta': () => React.ComponentType<ProductUnavailableCTAProps>;
  179. 'component:profiling-am1-or-mmx-upgrade': () => React.ComponentType<ProfilingAM1OrMMXUpgradeProps>;
  180. 'component:profiling-billing-banner': () => React.ComponentType<ProfilingBetaAlertBannerProps>;
  181. 'component:profiling-upgrade-plan-button': () => React.ComponentType<ProfilingUpgradePlanButtonProps>;
  182. 'component:replay-feedback-button': () => React.ComponentType<ReplayFeedbackButton>;
  183. 'component:replay-list-page-header': () => React.ComponentType<ReplayListPageHeaderProps> | null;
  184. 'component:replay-onboarding-alert': () => React.ComponentType<ReplayOnboardingAlertProps>;
  185. 'component:replay-onboarding-cta': () => React.ComponentType<ReplayOnboardingCTAProps>;
  186. 'component:replay-settings-alert': () => React.ComponentType | null;
  187. 'component:sentry-logo': () => React.ComponentType<SentryLogoProps>;
  188. 'component:superuser-access-category': React.ComponentType<any>;
  189. 'component:superuser-warning': React.ComponentType<any>;
  190. 'component:superuser-warning-excluded': SuperuserWarningExcluded;
  191. };
  192. /**
  193. * Customization hooks are advanced hooks that return render-prop style
  194. * components the allow for specific customizations of components.
  195. *
  196. * These are very similar to the component wrapping hooks
  197. */
  198. export type CustomizationHooks = {
  199. 'integrations:feature-gates': IntegrationsFeatureGatesHook;
  200. 'member-invite-button:customization': InviteButtonCustomizationHook;
  201. 'member-invite-modal:customization': InviteModalCustomizationHook;
  202. 'member-invite-modal:organization-roles': (organization: Organization) => OrgRole[];
  203. 'sidebar:navigation-item': SidebarNavigationItemHook;
  204. };
  205. /**
  206. * Analytics / tracking / and operational metrics backend hooks.
  207. */
  208. export type AnalyticsHooks = {
  209. 'analytics:init-user': AnalyticsInitUser;
  210. 'analytics:log-experiment': AnalyticsLogExperiment;
  211. 'analytics:raw-track-event': AnalyticsRawTrackEvent;
  212. 'metrics:event': MetricsEvent;
  213. };
  214. /**
  215. * feature-disabled:<feature-flag> hooks return components that will be
  216. * rendered in place for Feature components when the feature is not enabled.
  217. */
  218. export type FeatureDisabledHooks = {
  219. 'feature-disabled:alert-wizard-performance': FeatureDisabledHook;
  220. 'feature-disabled:alerts-page': FeatureDisabledHook;
  221. 'feature-disabled:codecov-integration-setting': FeatureDisabledHook;
  222. 'feature-disabled:create-metrics-alert-tooltip': FeatureDisabledHook;
  223. 'feature-disabled:custom-inbound-filters': FeatureDisabledHook;
  224. 'feature-disabled:dashboards-edit': FeatureDisabledHook;
  225. 'feature-disabled:dashboards-page': FeatureDisabledHook;
  226. 'feature-disabled:dashboards-sidebar-item': FeatureDisabledHook;
  227. 'feature-disabled:data-forwarding': FeatureDisabledHook;
  228. 'feature-disabled:discard-groups': FeatureDisabledHook;
  229. 'feature-disabled:discover-page': FeatureDisabledHook;
  230. 'feature-disabled:discover-saved-query-create': FeatureDisabledHook;
  231. 'feature-disabled:discover-sidebar-item': FeatureDisabledHook;
  232. 'feature-disabled:discover2-page': FeatureDisabledHook;
  233. 'feature-disabled:discover2-sidebar-item': FeatureDisabledHook;
  234. 'feature-disabled:events-page': FeatureDisabledHook;
  235. 'feature-disabled:events-sidebar-item': FeatureDisabledHook;
  236. 'feature-disabled:grid-editable-actions': FeatureDisabledHook;
  237. 'feature-disabled:incidents-sidebar-item': FeatureDisabledHook;
  238. 'feature-disabled:open-discover': FeatureDisabledHook;
  239. 'feature-disabled:open-in-discover': FeatureDisabledHook;
  240. 'feature-disabled:performance-new-project': FeatureDisabledHook;
  241. 'feature-disabled:performance-page': FeatureDisabledHook;
  242. 'feature-disabled:performance-quick-trace': FeatureDisabledHook;
  243. 'feature-disabled:performance-sidebar-item': FeatureDisabledHook;
  244. 'feature-disabled:profiling-page': FeatureDisabledHook;
  245. 'feature-disabled:profiling-sidebar-item': FeatureDisabledHook;
  246. 'feature-disabled:project-performance-score-card': FeatureDisabledHook;
  247. 'feature-disabled:project-selector-all-projects': FeatureDisabledHook;
  248. 'feature-disabled:project-selector-checkbox': FeatureDisabledHook;
  249. 'feature-disabled:rate-limits': FeatureDisabledHook;
  250. 'feature-disabled:relay': FeatureDisabledHook;
  251. 'feature-disabled:replay-sidebar-item': FeatureDisabledHook;
  252. 'feature-disabled:sso-basic': FeatureDisabledHook;
  253. 'feature-disabled:sso-saml2': FeatureDisabledHook;
  254. 'feature-disabled:starfish-view': FeatureDisabledHook;
  255. 'feature-disabled:trace-view-link': FeatureDisabledHook;
  256. };
  257. /**
  258. * Interface chrome hooks.
  259. */
  260. export type InterfaceChromeHooks = {
  261. footer: GenericComponentHook;
  262. 'help-modal:footer': HelpModalFooterHook;
  263. 'sidebar:bottom-items': SidebarBottomItemsHook;
  264. 'sidebar:help-menu': GenericOrganizationComponentHook;
  265. 'sidebar:item-label': SidebarItemLabelHook;
  266. 'sidebar:organization-dropdown-menu': GenericOrganizationComponentHook;
  267. 'sidebar:organization-dropdown-menu-bottom': GenericOrganizationComponentHook;
  268. };
  269. /**
  270. * Onboarding experience hooks
  271. */
  272. export type OnboardingHooks = {
  273. 'onboarding-wizard:skip-help': () => React.ComponentType;
  274. 'onboarding:block-hide-sidebar': () => boolean;
  275. 'onboarding:targeted-onboarding-header': (opts: {source: string}) => React.ReactNode;
  276. };
  277. /**
  278. * Settings navigation hooks.
  279. */
  280. export type SettingsHooks = {
  281. 'settings:api-navigation-config': SettingsItemsHook;
  282. 'settings:organization-navigation': OrganizationSettingsHook;
  283. 'settings:organization-navigation-config': SettingsConfigHook;
  284. };
  285. /**
  286. * Feature Specific Hooks
  287. */
  288. export interface FeatureSpecificHooks extends SpendVisibilityHooks {}
  289. /**
  290. * Hooks related to Spend Visibitlity
  291. * (i.e. Per-Project Spike Protection + Spend Allocations)
  292. */
  293. export type SpendVisibilityHooks = {
  294. 'spend-visibility:spike-protection-project-settings': GenericProjectComponentHook;
  295. };
  296. /**
  297. * Hooks that are actually React Hooks as well
  298. */
  299. export type ReactHooks = {
  300. 'react-hook:route-activated': (
  301. props: RouteContextInterface
  302. ) => React.ContextType<typeof RouteAnalyticsContext>;
  303. 'react-hook:use-button-tracking': (props: ButtonProps) => () => void;
  304. 'react-hook:use-experiment': UseExperiment;
  305. 'react-hook:use-get-max-retention-days': () => number | undefined;
  306. };
  307. /**
  308. * Callback hooks.
  309. * These hooks just call a function that has no return value
  310. * and perform some sort of callback logic
  311. */
  312. type CallbackHooks = {
  313. 'callback:on-create-project-product-selection': CreateProjectProductSelectionChangedCallback;
  314. 'callback:on-guide-update': GuideUpdateCallback;
  315. 'callback:on-monitor-created': MonitorCreatedCallback;
  316. };
  317. /**
  318. * Renders a React node with no props
  319. */
  320. type GenericComponentHook = () => React.ReactNode;
  321. /**
  322. * A route hook provides an injection point for a list of routes.
  323. */
  324. type RoutesHook = () => Route[];
  325. /**
  326. * Receives an organization object and should return a React node.
  327. */
  328. type GenericOrganizationComponentHook = (opts: {
  329. organization: Organization;
  330. }) => React.ReactNode;
  331. /**
  332. * Receives a project object and should return a React node.
  333. */
  334. type GenericProjectComponentHook = (opts: {project: Project}) => React.ReactNode;
  335. /**
  336. * A FeatureDisabledHook returns a react element when a feature is not enabled.
  337. */
  338. type FeatureDisabledHook = (opts: {
  339. /**
  340. * Children can either be a node, or a function that accepts a renderDisabled prop containing
  341. * a function/component to render when the feature is not enabled.
  342. */
  343. children: React.ReactNode | ChildrenRenderFn;
  344. /**
  345. * The list of features that are controlled by this hook.
  346. */
  347. features: string[];
  348. /**
  349. * Weather the feature is or is not enabled.
  350. */
  351. hasFeature: boolean;
  352. /**
  353. * The organization that is associated to this feature.
  354. */
  355. organization: Organization;
  356. /**
  357. * The project that is associated to this feature.
  358. */
  359. project?: Project;
  360. }) => React.ReactNode;
  361. /**
  362. * Called to check if the superuser warning should be excluded for the given organization.
  363. */
  364. type SuperuserWarningExcluded = (organization: Organization | null) => boolean;
  365. /**
  366. * Called when the app is mounted.
  367. */
  368. type AnalyticsInitUser = (user: User) => void;
  369. /**
  370. * Trigger analytics tracking in the hook store.
  371. */
  372. type AnalyticsRawTrackEvent = (
  373. data: {
  374. /**
  375. * Arbitrary data to track
  376. */
  377. [key: string]: any;
  378. /**
  379. * The Reload event key.
  380. */
  381. eventKey: string;
  382. /**
  383. * The Amplitude event name. Set to null if event should not go to Amplitude.
  384. */
  385. eventName: string | null;
  386. /**
  387. * Organization to pass in. If full org object not available, pass in just the Id.
  388. * If no org, pass in null.
  389. */
  390. organization: Organization | string | null;
  391. },
  392. options?: {
  393. /**
  394. * An arbitrary function to map the parameters to new parameters
  395. */
  396. mapValuesFn?: (params: Record<string, any>) => Record<string, any>;
  397. /**
  398. * If true, starts an analytics session. This session can be used
  399. * to construct funnels. The start of the funnel should have
  400. * startSession set to true.
  401. */
  402. startSession?: boolean;
  403. /**
  404. * Optional unix timestamp
  405. */
  406. time?: number;
  407. }
  408. ) => void;
  409. /**
  410. * Trigger experiment observed logging.
  411. */
  412. type AnalyticsLogExperiment = (opts: {
  413. /**
  414. * The experiment key
  415. */
  416. key: ExperimentKey;
  417. /**
  418. * The organization. Must be provided for organization experiments.
  419. */
  420. organization?: Organization;
  421. }) => void;
  422. /**
  423. * Trigger recording a metric in the hook store.
  424. */
  425. type MetricsEvent = (
  426. /**
  427. * Metric name
  428. */
  429. name: string,
  430. /**
  431. * Value to record for this metric
  432. */
  433. value: number,
  434. /**
  435. * An additional tags object
  436. */
  437. tags?: Record<PropertyKey, unknown>
  438. ) => void;
  439. /**
  440. * Provides additional navigation components
  441. */
  442. type OrganizationSettingsHook = (organization: Organization) => React.ReactElement;
  443. /**
  444. * Provides additional setting configurations
  445. */
  446. type SettingsConfigHook = (organization: Organization) => NavigationSection;
  447. /**
  448. * Provides additional setting navigation items
  449. */
  450. type SettingsItemsHook = (organization?: Organization) => NavigationItem[];
  451. /**
  452. * Each sidebar label is wrapped with this hook, to allow sidebar item
  453. * augmentation.
  454. */
  455. type SidebarItemLabelHook = () => React.ComponentType<{
  456. /**
  457. * The item label being wrapped
  458. */
  459. children: React.ReactNode;
  460. /**
  461. * The key of the item label currently being rendered. If no id is provided
  462. * the hook will have no effect.
  463. */
  464. id?: string;
  465. }>;
  466. type SidebarProps = Pick<
  467. React.ComponentProps<typeof SidebarItem>,
  468. 'orientation' | 'collapsed' | 'hasPanel'
  469. >;
  470. /**
  471. * Returns an additional list of sidebar items.
  472. */
  473. type SidebarBottomItemsHook = (
  474. opts: SidebarProps & {organization: Organization}
  475. ) => React.ReactNode;
  476. /**
  477. * Provides augmentation of the help modal footer
  478. */
  479. type HelpModalFooterHook = (opts: {
  480. closeModal: () => void;
  481. organization: Organization;
  482. }) => React.ReactNode;
  483. /**
  484. * The DecoratedIntegrationFeature differs from the IntegrationFeature as it is
  485. * expected to have been transformed into marked up content.
  486. */
  487. type DecoratedIntegrationFeature = {
  488. /**
  489. * Marked up description
  490. */
  491. description: React.ReactNode;
  492. featureGate: string;
  493. };
  494. type IntegrationFeatureGroup = {
  495. /**
  496. * The list of features within this group
  497. */
  498. features: DecoratedIntegrationFeature[];
  499. /**
  500. * Weather the group has all of the features enabled within this group
  501. * or not.
  502. */
  503. hasFeatures: boolean;
  504. };
  505. type FeatureGateSharedProps = {
  506. /**
  507. * The list of features, typically this is provided by the backend.
  508. */
  509. features: DecoratedIntegrationFeature[];
  510. /**
  511. * Organization of the integration we're querying feature gate details for.
  512. */
  513. organization: Organization;
  514. };
  515. type IntegrationFeaturesProps = FeatureGateSharedProps & {
  516. /**
  517. * The children function which will be provided with gating details.
  518. */
  519. children: (opts: {
  520. /**
  521. * Is the integration disabled for installation because of feature gating?
  522. */
  523. disabled: boolean;
  524. /**
  525. * The translated reason that the integration is disabled.
  526. */
  527. disabledReason: React.ReactNode;
  528. /**
  529. * Features grouped based on specific gating criteria (for example, in
  530. * sentry.io this is features grouped by plans).
  531. */
  532. gatedFeatureGroups: IntegrationFeatureGroup[];
  533. /**
  534. * This is the list of features which have *not* been gated in any way.
  535. */
  536. ungatedFeatures: DecoratedIntegrationFeature[];
  537. }) => React.ReactElement;
  538. };
  539. type IntegrationFeatureListProps = FeatureGateSharedProps & {
  540. provider: Pick<IntegrationProvider, 'key'>;
  541. };
  542. /**
  543. * The integration features gate hook provides components to customize
  544. * integration feature lists.
  545. */
  546. type IntegrationsFeatureGatesHook = () => {
  547. /**
  548. * This component renders the list of integration features.
  549. */
  550. FeatureList: React.ComponentType<IntegrationFeatureListProps>;
  551. /**
  552. * This is a render-prop style component that given a set of integration
  553. * features will call the children function with gating details about the
  554. * features.
  555. */
  556. IntegrationFeatures: React.ComponentType<IntegrationFeaturesProps>;
  557. };
  558. /**
  559. * Invite Button customization allows for a render-props component to replace
  560. * or intercept props of the button element.
  561. */
  562. type InviteButtonCustomizationHook = () => React.ComponentType<{
  563. children: (opts: {
  564. /**
  565. * Whether the Invite Members button is active or not
  566. */
  567. disabled: boolean;
  568. onTriggerModal: () => void;
  569. /**
  570. * Whether to display a message that new members must be registered via SSO
  571. */
  572. isSsoRequired?: boolean;
  573. }) => React.ReactElement;
  574. onTriggerModal: () => void;
  575. organization: Organization;
  576. }>;
  577. /**
  578. * Sidebar navigation item customization allows passing render props to disable
  579. * the link, wrap it in an upsell modal, and give it some additional content
  580. * (e.g., a Business Icon) to render.
  581. *
  582. * TODO: We can use this to replace the sidebar label hook `sidebar:item-label`,
  583. * too, since this is a more generic version.
  584. */
  585. type SidebarNavigationItemHook = () => React.ComponentType<{
  586. children: (opts: {
  587. Wrapper: React.FunctionComponent<{children: React.ReactElement}>;
  588. additionalContent: React.ReactElement | null;
  589. disabled: boolean;
  590. }) => React.ReactElement;
  591. id: string;
  592. }>;
  593. /**
  594. * Insights upsell hook takes in a insights module name
  595. * and renders either the applicable upsell page or the children inside the hook.
  596. */
  597. type InsightsUpsellHook = {
  598. children: React.ReactNode;
  599. moduleName: TitleableModuleNames;
  600. fullPage?: boolean;
  601. };
  602. /**
  603. * Invite Modal customization allows for a render-prop component to add
  604. * additional react elements into the modal, and add invite-send middleware.
  605. */
  606. type InviteModalCustomizationHook = () => React.ComponentType<{
  607. children: (opts: {
  608. /**
  609. * Indicates that the modal's send invites button should be enabled and
  610. * invites may currently be sent.
  611. */
  612. canSend: boolean;
  613. /**
  614. * Indicates that the account has reached the maximum member limit. Future invitations
  615. * are limited to Billing roles
  616. */
  617. isOverMemberLimit: boolean;
  618. /**
  619. * Trigger sending invites
  620. */
  621. sendInvites: () => void;
  622. /**
  623. * Additional react elements to render in the header of the modal, just
  624. * under the description.
  625. */
  626. headerInfo?: React.ReactNode;
  627. }) => React.ReactElement;
  628. /**
  629. * When the children's sendInvites renderProp is called, this will also be
  630. * triggered.
  631. */
  632. onSendInvites: () => void;
  633. /**
  634. * The organization that members will be invited to.
  635. */
  636. organization: Organization;
  637. /**
  638. * Indicates if clicking 'send invites' will immediately send invites, or
  639. * would just create invite requests.
  640. */
  641. willInvite: boolean;
  642. }>;