hooks.tsx 22 KB

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