hooks.tsx 23 KB

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