hooks.tsx 23 KB

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