hooks.tsx 23 KB

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