hooks.tsx 23 KB

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