hooks.tsx 23 KB

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