hooks.tsx 23 KB

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