hooks.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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 MetricsSamplesListProps = {children: React.ReactNode; organization: Organization};
  82. type ReplayFeedbackButton = {children: React.ReactNode};
  83. type ReplayListPageHeaderProps = {children?: React.ReactNode};
  84. type ReplayOnboardingAlertProps = {children: React.ReactNode};
  85. type ReplayOnboardingCTAProps = {children: React.ReactNode; organization: Organization};
  86. type ProductUnavailableCTAProps = {organization: Organization};
  87. type ProfilingBetaAlertBannerProps = {
  88. organization: Organization;
  89. };
  90. type ProfilingUpgradePlanButtonProps = ButtonProps & {
  91. children: React.ReactNode;
  92. fallback: React.ReactNode;
  93. organization: Organization;
  94. };
  95. type ProfilingAM1OrMMXUpgradeProps = {
  96. fallback: React.ReactNode;
  97. organization: Organization;
  98. };
  99. type CronsBillingBannerProps = {
  100. organization: Organization;
  101. };
  102. type OrganizationHeaderProps = {
  103. organization: Organization;
  104. };
  105. type ProductSelectionAvailabilityProps = Pick<
  106. ProductSelectionProps,
  107. 'lazyLoader' | 'skipLazyLoader' | 'platform' | 'withBottomMargin'
  108. > & {
  109. organization: Organization;
  110. };
  111. type FirstPartyIntegrationAlertProps = {
  112. integrations: Integration[];
  113. hideCTA?: boolean;
  114. wrapWithContainer?: boolean;
  115. };
  116. type FirstPartyIntegrationAdditionalCTAProps = {
  117. integrations: Integration[];
  118. };
  119. type AttemptCloseAttemptProps = {
  120. handleRemoveAccount: () => void;
  121. organizationSlugs: string[];
  122. };
  123. type CodecovLinkProps = {
  124. organization: Organization;
  125. };
  126. type QualitativeIssueFeedbackProps = {
  127. group: Group;
  128. organization: Organization;
  129. };
  130. // on-create-project-product-selection
  131. type CreateProjectProductSelectionChangedCallback = (options: {
  132. defaultProducts: ProductSolution[];
  133. organization: Organization;
  134. selectedProducts: ProductSolution[];
  135. }) => void;
  136. type GuideUpdateCallback = (nextGuide: Guide | null, opts: {dismissed?: boolean}) => void;
  137. type MonitorCreatedCallback = (organization: Organization) => void;
  138. type CronsOnboardingPanelProps = {children: React.ReactNode};
  139. type SentryLogoProps = SVGIconProps & {
  140. pride?: boolean;
  141. };
  142. export type ParntershipAgreementType = 'standard' | 'partner_presence';
  143. export type PartnershipAgreementProps = {
  144. agreements: Array<ParntershipAgreementType>;
  145. partnerDisplayName: string;
  146. onSubmitSuccess?: () => void;
  147. organizationSlug?: string;
  148. };
  149. /**
  150. * Component wrapping hooks
  151. */
  152. export type ComponentHooks = {
  153. 'component:autofix-setup-step-consent': () => React.ComponentType<AutofixSetupConsentStepProps> | null;
  154. 'component:codecov-integration-settings-link': () => React.ComponentType<CodecovLinkProps>;
  155. 'component:confirm-account-close': () => React.ComponentType<AttemptCloseAttemptProps>;
  156. 'component:crons-list-page-header': () => React.ComponentType<CronsBillingBannerProps>;
  157. 'component:crons-onboarding-panel': () => React.ComponentType<CronsOnboardingPanelProps>;
  158. 'component:dashboards-header': () => React.ComponentType<DashboardHeadersProps>;
  159. 'component:data-consent-banner': () => React.ComponentType<{source: string}> | null;
  160. 'component:data-consent-org-creation-checkbox': () => React.ComponentType<{}> | null;
  161. 'component:data-consent-priority-learn-more': () => React.ComponentType<{}> | null;
  162. 'component:ddm-metrics-samples-list': () => React.ComponentType<MetricsSamplesListProps>;
  163. 'component:disabled-app-store-connect-multiple': () => React.ComponentType<DisabledAppStoreConnectMultiple>;
  164. 'component:disabled-custom-symbol-sources': () => React.ComponentType<DisabledCustomSymbolSources>;
  165. 'component:disabled-member': () => React.ComponentType<DisabledMemberViewProps>;
  166. 'component:disabled-member-tooltip': () => React.ComponentType<DisabledMemberTooltipProps>;
  167. 'component:enhanced-org-stats': () => React.ComponentType<OrganizationStatsProps>;
  168. 'component:escalating-issues-banner-feedback': () => React.ComponentType<QualitativeIssueFeedbackProps>;
  169. 'component:first-party-integration-additional-cta': () => React.ComponentType<FirstPartyIntegrationAdditionalCTAProps>;
  170. 'component:first-party-integration-alert': () => React.ComponentType<FirstPartyIntegrationAlertProps>;
  171. 'component:header-date-range': () => React.ComponentType<DateRangeProps>;
  172. 'component:header-selector-items': () => React.ComponentType<SelectorItemsProps>;
  173. 'component:member-list-header': () => React.ComponentType<MemberListHeaderProps>;
  174. 'component:monitor-status-toggle': () => React.ComponentType<StatusToggleButtonProps>;
  175. 'component:org-stats-banner': () => React.ComponentType<DashboardHeadersProps>;
  176. 'component:organization-header': () => React.ComponentType<OrganizationHeaderProps>;
  177. 'component:partnership-agreement': React.ComponentType<PartnershipAgreementProps>;
  178. 'component:product-selection-availability': () => React.ComponentType<ProductSelectionAvailabilityProps>;
  179. 'component:product-unavailable-cta': () => React.ComponentType<ProductUnavailableCTAProps>;
  180. 'component:profiling-am1-or-mmx-upgrade': () => React.ComponentType<ProfilingAM1OrMMXUpgradeProps>;
  181. 'component:profiling-billing-banner': () => React.ComponentType<ProfilingBetaAlertBannerProps>;
  182. 'component:profiling-upgrade-plan-button': () => React.ComponentType<ProfilingUpgradePlanButtonProps>;
  183. 'component:replay-feedback-button': () => React.ComponentType<ReplayFeedbackButton>;
  184. 'component:replay-list-page-header': () => React.ComponentType<ReplayListPageHeaderProps> | null;
  185. 'component:replay-onboarding-alert': () => React.ComponentType<ReplayOnboardingAlertProps>;
  186. 'component:replay-onboarding-cta': () => React.ComponentType<ReplayOnboardingCTAProps>;
  187. 'component:replay-settings-alert': () => React.ComponentType<{}> | null;
  188. 'component:sentry-logo': () => React.ComponentType<SentryLogoProps>;
  189. 'component:superuser-access-category': React.ComponentType<any>;
  190. 'component:superuser-warning': React.ComponentType<any>;
  191. 'component:superuser-warning-excluded': SuperuserWarningExcluded;
  192. };
  193. /**
  194. * Customization hooks are advanced hooks that return render-prop style
  195. * components the allow for specific customizations of components.
  196. *
  197. * These are very similar to the component wrapping hooks
  198. */
  199. export type CustomizationHooks = {
  200. 'integrations:feature-gates': IntegrationsFeatureGatesHook;
  201. 'member-invite-button:customization': InviteButtonCustomizationHook;
  202. 'member-invite-modal:customization': InviteModalCustomizationHook;
  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. };
  306. /**
  307. * Callback hooks.
  308. * These hooks just call a function that has no return value
  309. * and perform some sort of callback logic
  310. */
  311. type CallbackHooks = {
  312. 'callback:on-create-project-product-selection': CreateProjectProductSelectionChangedCallback;
  313. 'callback:on-guide-update': GuideUpdateCallback;
  314. 'callback:on-monitor-created': MonitorCreatedCallback;
  315. };
  316. /**
  317. * Renders a React node with no props
  318. */
  319. type GenericComponentHook = () => React.ReactNode;
  320. /**
  321. * A route hook provides an injection point for a list of routes.
  322. */
  323. type RoutesHook = () => Route[];
  324. /**
  325. * Receives an organization object and should return a React node.
  326. */
  327. type GenericOrganizationComponentHook = (opts: {
  328. organization: Organization;
  329. }) => React.ReactNode;
  330. /**
  331. * Receives a project object and should return a React node.
  332. */
  333. type GenericProjectComponentHook = (opts: {project: Project}) => React.ReactNode;
  334. /**
  335. * A FeatureDisabledHook returns a react element when a feature is not enabled.
  336. */
  337. type FeatureDisabledHook = (opts: {
  338. /**
  339. * Children can either be a node, or a function that accepts a renderDisabled prop containing
  340. * a function/component to render when the feature is not enabled.
  341. */
  342. children: React.ReactNode | ChildrenRenderFn;
  343. /**
  344. * The list of features that are controlled by this hook.
  345. */
  346. features: string[];
  347. /**
  348. * Weather the feature is or is not enabled.
  349. */
  350. hasFeature: boolean;
  351. /**
  352. * The organization that is associated to this feature.
  353. */
  354. organization: Organization;
  355. /**
  356. * The project that is associated to this feature.
  357. */
  358. project?: Project;
  359. }) => React.ReactNode;
  360. /**
  361. * Called to check if the superuser warning should be excluded for the given organization.
  362. */
  363. type SuperuserWarningExcluded = (organization: Organization | null) => boolean;
  364. /**
  365. * Called when the app is mounted.
  366. */
  367. type AnalyticsInitUser = (user: User) => void;
  368. /**
  369. * Trigger analytics tracking in the hook store.
  370. */
  371. type AnalyticsRawTrackEvent = (
  372. data: {
  373. /**
  374. * Arbitrary data to track
  375. */
  376. [key: string]: any;
  377. /**
  378. * The Reload event key.
  379. */
  380. eventKey: string;
  381. /**
  382. * The Amplitude event name. Set to null if event should not go to Amplitude.
  383. */
  384. eventName: string | null;
  385. /**
  386. * Organization to pass in. If full org object not available, pass in just the Id.
  387. * If no org, pass in null.
  388. */
  389. organization: Organization | string | null;
  390. },
  391. options?: {
  392. /**
  393. * An arbitrary function to map the parameters to new parameters
  394. */
  395. mapValuesFn?: (params: Record<string, any>) => Record<string, any>;
  396. /**
  397. * If true, starts an analytics session. This session can be used
  398. * to construct funnels. The start of the funnel should have
  399. * startSession set to true.
  400. */
  401. startSession?: boolean;
  402. /**
  403. * Optional unix timestamp
  404. */
  405. time?: number;
  406. }
  407. ) => void;
  408. /**
  409. * Trigger experiment observed logging.
  410. */
  411. type AnalyticsLogExperiment = (opts: {
  412. /**
  413. * The experiment key
  414. */
  415. key: ExperimentKey;
  416. /**
  417. * The organization. Must be provided for organization experiments.
  418. */
  419. organization?: Organization;
  420. }) => void;
  421. /**
  422. * Trigger recording a metric in the hook store.
  423. */
  424. type MetricsEvent = (
  425. /**
  426. * Metric name
  427. */
  428. name: string,
  429. /**
  430. * Value to record for this metric
  431. */
  432. value: number,
  433. /**
  434. * An additional tags object
  435. */
  436. tags?: object
  437. ) => void;
  438. /**
  439. * Provides additional navigation components
  440. */
  441. type OrganizationSettingsHook = (organization: Organization) => React.ReactElement;
  442. /**
  443. * Provides additional setting configurations
  444. */
  445. type SettingsConfigHook = (organization: Organization) => NavigationSection;
  446. /**
  447. * Provides additional setting navigation items
  448. */
  449. type SettingsItemsHook = (organization?: Organization) => NavigationItem[];
  450. /**
  451. * Each sidebar label is wrapped with this hook, to allow sidebar item
  452. * augmentation.
  453. */
  454. type SidebarItemLabelHook = () => React.ComponentType<{
  455. /**
  456. * The item label being wrapped
  457. */
  458. children: React.ReactNode;
  459. /**
  460. * The key of the item label currently being rendered. If no id is provided
  461. * the hook will have no effect.
  462. */
  463. id?: string;
  464. }>;
  465. type SidebarProps = Pick<
  466. React.ComponentProps<typeof SidebarItem>,
  467. 'orientation' | 'collapsed' | 'hasPanel'
  468. >;
  469. /**
  470. * Returns an additional list of sidebar items.
  471. */
  472. type SidebarBottomItemsHook = (
  473. opts: SidebarProps & {organization: Organization}
  474. ) => React.ReactNode;
  475. /**
  476. * Provides augmentation of the help modal footer
  477. */
  478. type HelpModalFooterHook = (opts: {
  479. closeModal: () => void;
  480. organization: Organization;
  481. }) => React.ReactNode;
  482. /**
  483. * The DecoratedIntegrationFeature differs from the IntegrationFeature as it is
  484. * expected to have been transformed into marked up content.
  485. */
  486. type DecoratedIntegrationFeature = {
  487. /**
  488. * Marked up description
  489. */
  490. description: React.ReactNode;
  491. featureGate: string;
  492. };
  493. type IntegrationFeatureGroup = {
  494. /**
  495. * The list of features within this group
  496. */
  497. features: DecoratedIntegrationFeature[];
  498. /**
  499. * Weather the group has all of the features enabled within this group
  500. * or not.
  501. */
  502. hasFeatures: boolean;
  503. };
  504. type FeatureGateSharedProps = {
  505. /**
  506. * The list of features, typically this is provided by the backend.
  507. */
  508. features: DecoratedIntegrationFeature[];
  509. /**
  510. * Organization of the integration we're querying feature gate details for.
  511. */
  512. organization: Organization;
  513. };
  514. type IntegrationFeaturesProps = FeatureGateSharedProps & {
  515. /**
  516. * The children function which will be provided with gating details.
  517. */
  518. children: (opts: {
  519. /**
  520. * Is the integration disabled for installation because of feature gating?
  521. */
  522. disabled: boolean;
  523. /**
  524. * The translated reason that the integration is disabled.
  525. */
  526. disabledReason: React.ReactNode;
  527. /**
  528. * Features grouped based on specific gating criteria (for example, in
  529. * sentry.io this is features grouped by plans).
  530. */
  531. gatedFeatureGroups: IntegrationFeatureGroup[];
  532. /**
  533. * This is the list of features which have *not* been gated in any way.
  534. */
  535. ungatedFeatures: DecoratedIntegrationFeature[];
  536. }) => React.ReactElement;
  537. };
  538. type IntegrationFeatureListProps = FeatureGateSharedProps & {
  539. provider: Pick<IntegrationProvider, 'key'>;
  540. };
  541. /**
  542. * The integration features gate hook provides components to customize
  543. * integration feature lists.
  544. */
  545. type IntegrationsFeatureGatesHook = () => {
  546. /**
  547. * This component renders the list of integration features.
  548. */
  549. FeatureList: React.ComponentType<IntegrationFeatureListProps>;
  550. /**
  551. * This is a render-prop style component that given a set of integration
  552. * features will call the children function with gating details about the
  553. * features.
  554. */
  555. IntegrationFeatures: React.ComponentType<IntegrationFeaturesProps>;
  556. };
  557. /**
  558. * Invite Button customization allows for a render-props component to replace
  559. * or intercept props of the button element.
  560. */
  561. type InviteButtonCustomizationHook = () => React.ComponentType<{
  562. children: (opts: {
  563. /**
  564. * Whether the Invite Members button is active or not
  565. */
  566. disabled: boolean;
  567. onTriggerModal: () => void;
  568. }) => React.ReactElement;
  569. onTriggerModal: () => void;
  570. organization: Organization;
  571. }>;
  572. /**
  573. * Sidebar navigation item customization allows passing render props to disable
  574. * the link, wrap it in an upsell modal, and give it some additional content
  575. * (e.g., a Business Icon) to render.
  576. *
  577. * TODO: We can use this to replace the sidebar label hook `sidebar:item-label`,
  578. * too, since this is a more generic version.
  579. */
  580. type SidebarNavigationItemHook = () => React.ComponentType<{
  581. children: (opts: {
  582. Wrapper: React.FunctionComponent<{children: React.ReactElement}>;
  583. additionalContent: React.ReactElement | null;
  584. disabled: boolean;
  585. }) => React.ReactElement;
  586. id: string;
  587. }>;
  588. /**
  589. * Invite Modal customization allows for a render-prop component to add
  590. * additional react elements into the modal, and add invite-send middleware.
  591. */
  592. type InviteModalCustomizationHook = () => React.ComponentType<{
  593. children: (opts: {
  594. /**
  595. * Indicates that the modal's send invites button should be enabled and
  596. * invites may currently be sent.
  597. */
  598. canSend: boolean;
  599. /**
  600. * Trigger sending invites
  601. */
  602. sendInvites: () => void;
  603. /**
  604. * Additional react elements to render in the header of the modal, just
  605. * under the description.
  606. */
  607. headerInfo?: React.ReactNode;
  608. }) => React.ReactElement;
  609. /**
  610. * When the children's sendInvites renderProp is called, this will also be
  611. * triggered.
  612. */
  613. onSendInvites: () => void;
  614. /**
  615. * The organization that members will be invited to.
  616. */
  617. organization: Organization;
  618. /**
  619. * Indicates if clicking 'send invites' will immediately send invites, or
  620. * would just create invite requests.
  621. */
  622. willInvite: boolean;
  623. }>;