hooks.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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';
  14. import type {UseExperiment} from 'sentry/utils/useExperiment';
  15. import type {StatusToggleButtonProps} from 'sentry/views/monitors/components/statusToggleButton';
  16. import type {OrganizationStatsProps} from 'sentry/views/organizationStats/index';
  17. import type {RouteAnalyticsContext} from 'sentry/views/routeAnalyticsContextProvider';
  18. import type {NavigationItem, NavigationSection} from 'sentry/views/settings/types';
  19. import type {ExperimentKey} from './experiments';
  20. import type {Integration, IntegrationProvider} from './integrations';
  21. import type {Member, Organization} from './organization';
  22. import type {Project} from './project';
  23. import type {User} from './user';
  24. // XXX(epurkhiser): A Note about `_`.
  25. //
  26. // We add the `_: any` type int our hooks list to stop
  27. // typescript from doing too much type tightening. We should absolutely revisit
  28. // this in the future because all callbacks _should_ be allowed to be
  29. // functions, but doing so causes some unexpected issues and makes typescript
  30. // not happy. We still get a huge advantage of typing just by having each hook
  31. // type here however.
  32. /**
  33. * The Hooks type mapping is the master interface for all external Hooks into
  34. * the sentry frontend application.
  35. */
  36. export interface Hooks
  37. extends RouteHooks,
  38. ComponentHooks,
  39. CustomizationHooks,
  40. AnalyticsHooks,
  41. FeatureDisabledHooks,
  42. InterfaceChromeHooks,
  43. OnboardingHooks,
  44. SettingsHooks,
  45. FeatureSpecificHooks,
  46. ReactHooks,
  47. CallbackHooks {
  48. _: any;
  49. }
  50. export type HookName = keyof Hooks;
  51. /**
  52. * Route hooks.
  53. */
  54. export type RouteHooks = {
  55. 'routes:api': RoutesHook;
  56. 'routes:organization': RoutesHook;
  57. 'routes:root': RoutesHook;
  58. };
  59. /**
  60. * Component specific hooks for DateRange and SelectorItems
  61. * These components have plan specific overrides in getsentry
  62. */
  63. type DateRangeProps = React.ComponentProps<typeof DateRange>;
  64. type SelectorItemsProps = React.ComponentProps<typeof SelectorItems>;
  65. type DisabledMemberViewProps = RouteComponentProps<{orgId: string}, {}>;
  66. type MemberListHeaderProps = {
  67. members: Member[];
  68. organization: Organization;
  69. };
  70. type DisabledAppStoreConnectMultiple = {
  71. children: React.ReactNode;
  72. organization: Organization;
  73. };
  74. type DisabledCustomSymbolSources = {
  75. children: React.ReactNode;
  76. organization: Organization;
  77. };
  78. type DisabledMemberTooltipProps = {children: React.ReactNode};
  79. type DashboardHeadersProps = {organization: Organization};
  80. type DDMMetricsSamplesListProps = {children: React.ReactNode; organization: Organization};
  81. type ReplayFeedbackButton = {children: React.ReactNode};
  82. type ReplayListPageHeaderProps = {children?: React.ReactNode};
  83. type ReplayOnboardingAlertProps = {children: React.ReactNode};
  84. type ReplayOnboardingCTAProps = {children: React.ReactNode; organization: Organization};
  85. type ProductUnavailableCTAProps = {organization: Organization};
  86. type ProfilingBetaAlertBannerProps = {
  87. organization: Organization;
  88. };
  89. type ProfilingUpgradePlanButtonProps = ButtonProps & {
  90. children: React.ReactNode;
  91. fallback: React.ReactNode;
  92. organization: Organization;
  93. };
  94. type ProfilingAM1OrMMXUpgradeProps = {
  95. fallback: React.ReactNode;
  96. organization: Organization;
  97. };
  98. type CronsBillingBannerProps = {
  99. organization: Organization;
  100. };
  101. type OrganizationHeaderProps = {
  102. organization: Organization;
  103. };
  104. type ProductSelectionAvailabilityProps = Pick<
  105. ProductSelectionProps,
  106. 'lazyLoader' | 'skipLazyLoader' | 'platform' | 'withBottomMargin'
  107. > & {
  108. organization: Organization;
  109. };
  110. type FirstPartyIntegrationAlertProps = {
  111. integrations: Integration[];
  112. hideCTA?: boolean;
  113. wrapWithContainer?: boolean;
  114. };
  115. type FirstPartyIntegrationAdditionalCTAProps = {
  116. integrations: Integration[];
  117. };
  118. type AttemptCloseAttemptProps = {
  119. handleRemoveAccount: () => void;
  120. organizationSlugs: string[];
  121. };
  122. type CodecovLinkProps = {
  123. organization: Organization;
  124. };
  125. type QualitativeIssueFeedbackProps = {
  126. group: Group;
  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 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. /**
  148. * Component wrapping hooks
  149. */
  150. export type ComponentHooks = {
  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:dashboards-header': () => React.ComponentType<DashboardHeadersProps>;
  155. 'component:data-consent-banner': () => React.ComponentType<{source: string}> | null;
  156. 'component:data-consent-priority-learn-more': () => React.ComponentType<{}> | null;
  157. 'component:ddm-metrics-samples-list': () => React.ComponentType<DDMMetricsSamplesListProps>;
  158. 'component:disabled-app-store-connect-multiple': () => React.ComponentType<DisabledAppStoreConnectMultiple>;
  159. 'component:disabled-custom-symbol-sources': () => React.ComponentType<DisabledCustomSymbolSources>;
  160. 'component:disabled-member': () => React.ComponentType<DisabledMemberViewProps>;
  161. 'component:disabled-member-tooltip': () => React.ComponentType<DisabledMemberTooltipProps>;
  162. 'component:enhanced-org-stats': () => React.ComponentType<OrganizationStatsProps>;
  163. 'component:escalating-issues-banner-feedback': () => React.ComponentType<QualitativeIssueFeedbackProps>;
  164. 'component:first-party-integration-additional-cta': () => React.ComponentType<FirstPartyIntegrationAdditionalCTAProps>;
  165. 'component:first-party-integration-alert': () => React.ComponentType<FirstPartyIntegrationAlertProps>;
  166. 'component:header-date-range': () => React.ComponentType<DateRangeProps>;
  167. 'component:header-selector-items': () => React.ComponentType<SelectorItemsProps>;
  168. 'component:issue-priority-feedback': () => React.ComponentType<QualitativeIssueFeedbackProps>;
  169. 'component:member-list-header': () => React.ComponentType<MemberListHeaderProps>;
  170. 'component:monitor-status-toggle': () => React.ComponentType<StatusToggleButtonProps>;
  171. 'component:org-stats-banner': () => React.ComponentType<DashboardHeadersProps>;
  172. 'component:organization-header': () => React.ComponentType<OrganizationHeaderProps>;
  173. 'component:partnership-agreement': React.ComponentType<PartnershipAgreementProps>;
  174. 'component:product-selection-availability': () => React.ComponentType<ProductSelectionAvailabilityProps>;
  175. 'component:product-unavailable-cta': () => React.ComponentType<ProductUnavailableCTAProps>;
  176. 'component:profiling-am1-or-mmx-upgrade': () => React.ComponentType<ProfilingAM1OrMMXUpgradeProps>;
  177. 'component:profiling-billing-banner': () => React.ComponentType<ProfilingBetaAlertBannerProps>;
  178. 'component:profiling-upgrade-plan-button': () => React.ComponentType<ProfilingUpgradePlanButtonProps>;
  179. 'component:replay-feedback-button': () => React.ComponentType<ReplayFeedbackButton>;
  180. 'component:replay-list-page-header': () => React.ComponentType<ReplayListPageHeaderProps> | null;
  181. 'component:replay-onboarding-alert': () => React.ComponentType<ReplayOnboardingAlertProps>;
  182. 'component:replay-onboarding-cta': () => React.ComponentType<ReplayOnboardingCTAProps>;
  183. 'component:replay-onboarding-cta-button': () => React.ComponentType<{}> | null;
  184. 'component:sentry-logo': () => React.ComponentType<SentryLogoProps>;
  185. 'component:superuser-access-category': React.ComponentType<any>;
  186. 'component:superuser-warning': React.ComponentType<any>;
  187. 'component:superuser-warning-excluded': SuperuserWarningExcluded;
  188. };
  189. /**
  190. * Customization hooks are advanced hooks that return render-prop style
  191. * components the allow for specific customizations of components.
  192. *
  193. * These are very similar to the component wrapping hooks
  194. */
  195. export type CustomizationHooks = {
  196. 'integrations:feature-gates': IntegrationsFeatureGatesHook;
  197. 'member-invite-button:customization': InviteButtonCustomizationHook;
  198. 'member-invite-modal:customization': InviteModalCustomizationHook;
  199. };
  200. /**
  201. * Analytics / tracking / and operational metrics backend hooks.
  202. */
  203. export type AnalyticsHooks = {
  204. 'analytics:init-user': AnalyticsInitUser;
  205. 'analytics:log-experiment': AnalyticsLogExperiment;
  206. 'analytics:raw-track-event': AnalyticsRawTrackEvent;
  207. 'metrics:event': MetricsEvent;
  208. };
  209. /**
  210. * feature-disabled:<feature-flag> hooks return components that will be
  211. * rendered in place for Feature components when the feature is not enabled.
  212. */
  213. export type FeatureDisabledHooks = {
  214. 'feature-disabled:alert-wizard-performance': FeatureDisabledHook;
  215. 'feature-disabled:alerts-page': FeatureDisabledHook;
  216. 'feature-disabled:codecov-integration-setting': 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:extra-chrome': GenericComponentHook;
  270. 'onboarding:targeted-onboarding-header': (opts: {source: string}) => React.ReactNode;
  271. };
  272. /**
  273. * Settings navigation hooks.
  274. */
  275. export type SettingsHooks = {
  276. 'settings:api-navigation-config': SettingsItemsHook;
  277. 'settings:organization-navigation': OrganizationSettingsHook;
  278. 'settings:organization-navigation-config': SettingsConfigHook;
  279. };
  280. /**
  281. * Feature Specific Hooks
  282. */
  283. export interface FeatureSpecificHooks extends SpendVisibilityHooks {}
  284. /**
  285. * Hooks related to Spend Visibitlity
  286. * (i.e. Per-Project Spike Protection + Spend Allocations)
  287. */
  288. export type SpendVisibilityHooks = {
  289. 'spend-visibility:spike-protection-project-settings': GenericProjectComponentHook;
  290. };
  291. /**
  292. * Hooks that are actually React Hooks as well
  293. */
  294. export type ReactHooks = {
  295. 'react-hook:route-activated': (
  296. props: RouteContextInterface
  297. ) => React.ContextType<typeof RouteAnalyticsContext>;
  298. 'react-hook:use-button-tracking': (props: ButtonProps) => () => void;
  299. 'react-hook:use-experiment': UseExperiment;
  300. };
  301. /**
  302. * Callback hooks.
  303. * These hooks just call a function that has no return value
  304. * and perform some sort of callback logic
  305. */
  306. type CallbackHooks = {
  307. 'callback:on-create-project-product-selection': CreateProjectProductSelectionChangedCallback;
  308. 'callback:on-guide-update': GuideUpdateCallback;
  309. 'callback:on-monitor-created': MonitorCreatedCallback;
  310. };
  311. /**
  312. * Renders a React node with no props
  313. */
  314. type GenericComponentHook = () => React.ReactNode;
  315. /**
  316. * A route hook provides an injection point for a list of routes.
  317. */
  318. type RoutesHook = () => Route[];
  319. /**
  320. * Receives an organization object and should return a React node.
  321. */
  322. type GenericOrganizationComponentHook = (opts: {
  323. organization: Organization;
  324. }) => React.ReactNode;
  325. /**
  326. * Receives a project object and should return a React node.
  327. */
  328. type GenericProjectComponentHook = (opts: {project: Project}) => React.ReactNode;
  329. /**
  330. * A FeatureDisabledHook returns a react element when a feature is not enabled.
  331. */
  332. type FeatureDisabledHook = (opts: {
  333. /**
  334. * Children can either be a node, or a function that accepts a renderDisabled prop containing
  335. * a function/component to render when the feature is not enabled.
  336. */
  337. children: React.ReactNode | ChildrenRenderFn;
  338. /**
  339. * The list of features that are controlled by this hook.
  340. */
  341. features: string[];
  342. /**
  343. * Weather the feature is or is not enabled.
  344. */
  345. hasFeature: boolean;
  346. /**
  347. * The organization that is associated to this feature.
  348. */
  349. organization: Organization;
  350. /**
  351. * The project that is associated to this feature.
  352. */
  353. project?: Project;
  354. }) => React.ReactNode;
  355. /**
  356. * Called to check if the superuser warning should be excluded for the given organization.
  357. */
  358. type SuperuserWarningExcluded = (organization: Organization | null) => boolean;
  359. /**
  360. * Called when the app is mounted.
  361. */
  362. type AnalyticsInitUser = (user: User) => void;
  363. /**
  364. * Trigger analytics tracking in the hook store.
  365. */
  366. type AnalyticsRawTrackEvent = (
  367. data: {
  368. /**
  369. * Arbitrary data to track
  370. */
  371. [key: string]: any;
  372. /**
  373. * The Reload event key.
  374. */
  375. eventKey: string;
  376. /**
  377. * The Amplitude event name. Set to null if event should not go to Amplitude.
  378. */
  379. eventName: string | null;
  380. /**
  381. * Organization to pass in. If full org object not available, pass in just the Id.
  382. * If no org, pass in null.
  383. */
  384. organization: Organization | string | null;
  385. },
  386. options?: {
  387. /**
  388. * An arbitrary function to map the parameters to new parameters
  389. */
  390. mapValuesFn?: (params: Record<string, any>) => Record<string, any>;
  391. /**
  392. * If true, starts an analytics session. This session can be used
  393. * to construct funnels. The start of the funnel should have
  394. * startSession set to true.
  395. */
  396. startSession?: boolean;
  397. /**
  398. * Optional unix timestamp
  399. */
  400. time?: number;
  401. }
  402. ) => void;
  403. /**
  404. * Trigger experiment observed logging.
  405. */
  406. type AnalyticsLogExperiment = (opts: {
  407. /**
  408. * The experiment key
  409. */
  410. key: ExperimentKey;
  411. /**
  412. * The organization. Must be provided for organization experiments.
  413. */
  414. organization?: Organization;
  415. }) => void;
  416. /**
  417. * Trigger recording a metric in the hook store.
  418. */
  419. type MetricsEvent = (
  420. /**
  421. * Metric name
  422. */
  423. name: string,
  424. /**
  425. * Value to record for this metric
  426. */
  427. value: number,
  428. /**
  429. * An additional tags object
  430. */
  431. tags?: object
  432. ) => void;
  433. /**
  434. * Provides additional navigation components
  435. */
  436. type OrganizationSettingsHook = (organization: Organization) => React.ReactElement;
  437. /**
  438. * Provides additional setting configurations
  439. */
  440. type SettingsConfigHook = (organization: Organization) => NavigationSection;
  441. /**
  442. * Provides additional setting navigation items
  443. */
  444. type SettingsItemsHook = (organization?: Organization) => NavigationItem[];
  445. /**
  446. * Each sidebar label is wrapped with this hook, to allow sidebar item
  447. * augmentation.
  448. */
  449. type SidebarItemLabelHook = () => React.ComponentType<{
  450. /**
  451. * The item label being wrapped
  452. */
  453. children: React.ReactNode;
  454. /**
  455. * The key of the item label currently being rendered. If no id is provided
  456. * the hook will have no effect.
  457. */
  458. id?: string;
  459. }>;
  460. type SidebarProps = Pick<
  461. React.ComponentProps<typeof SidebarItem>,
  462. 'orientation' | 'collapsed' | 'hasPanel'
  463. >;
  464. /**
  465. * Returns an additional list of sidebar items.
  466. */
  467. type SidebarBottomItemsHook = (
  468. opts: SidebarProps & {organization: Organization}
  469. ) => React.ReactNode;
  470. /**
  471. * Provides augmentation of the help modal footer
  472. */
  473. type HelpModalFooterHook = (opts: {
  474. closeModal: () => void;
  475. organization: Organization;
  476. }) => React.ReactNode;
  477. /**
  478. * The DecoratedIntegrationFeature differs from the IntegrationFeature as it is
  479. * expected to have been transformed into marked up content.
  480. */
  481. type DecoratedIntegrationFeature = {
  482. /**
  483. * Marked up description
  484. */
  485. description: React.ReactNode;
  486. featureGate: string;
  487. };
  488. type IntegrationFeatureGroup = {
  489. /**
  490. * The list of features within this group
  491. */
  492. features: DecoratedIntegrationFeature[];
  493. /**
  494. * Weather the group has all of the features enabled within this group
  495. * or not.
  496. */
  497. hasFeatures: boolean;
  498. };
  499. type FeatureGateSharedProps = {
  500. /**
  501. * The list of features, typically this is provided by the backend.
  502. */
  503. features: DecoratedIntegrationFeature[];
  504. /**
  505. * Organization of the integration we're querying feature gate details for.
  506. */
  507. organization: Organization;
  508. };
  509. type IntegrationFeaturesProps = FeatureGateSharedProps & {
  510. /**
  511. * The children function which will be provided with gating details.
  512. */
  513. children: (opts: {
  514. /**
  515. * Is the integration disabled for installation because of feature gating?
  516. */
  517. disabled: boolean;
  518. /**
  519. * The translated reason that the integration is disabled.
  520. */
  521. disabledReason: React.ReactNode;
  522. /**
  523. * Features grouped based on specific gating criteria (for example, in
  524. * sentry.io this is features grouped by plans).
  525. */
  526. gatedFeatureGroups: IntegrationFeatureGroup[];
  527. /**
  528. * This is the list of features which have *not* been gated in any way.
  529. */
  530. ungatedFeatures: DecoratedIntegrationFeature[];
  531. }) => React.ReactElement;
  532. };
  533. type IntegrationFeatureListProps = FeatureGateSharedProps & {
  534. provider: Pick<IntegrationProvider, 'key'>;
  535. };
  536. /**
  537. * The integration features gate hook provides components to customize
  538. * integration feature lists.
  539. */
  540. type IntegrationsFeatureGatesHook = () => {
  541. /**
  542. * This component renders the list of integration features.
  543. */
  544. FeatureList: React.ComponentType<IntegrationFeatureListProps>;
  545. /**
  546. * This is a render-prop style component that given a set of integration
  547. * features will call the children function with gating details about the
  548. * features.
  549. */
  550. IntegrationFeatures: React.ComponentType<IntegrationFeaturesProps>;
  551. };
  552. /**
  553. * Invite Button customization allows for a render-props component to replace
  554. * or intercept props of the button element.
  555. */
  556. type InviteButtonCustomizationHook = () => React.ComponentType<{
  557. children: (opts: {
  558. /**
  559. * Whether the Invite Members button is active or not
  560. */
  561. disabled: boolean;
  562. onTriggerModal: () => void;
  563. }) => React.ReactElement;
  564. onTriggerModal: () => void;
  565. organization: Organization;
  566. }>;
  567. /**
  568. * Invite Modal customization allows for a render-prop component to add
  569. * additional react elements into the modal, and add invite-send middleware.
  570. */
  571. type InviteModalCustomizationHook = () => React.ComponentType<{
  572. children: (opts: {
  573. /**
  574. * Indicates that the modal's send invites button should be enabled and
  575. * invites may currently be sent.
  576. */
  577. canSend: boolean;
  578. /**
  579. * Trigger sending invites
  580. */
  581. sendInvites: () => void;
  582. /**
  583. * Additional react elements to render in the header of the modal, just
  584. * under the description.
  585. */
  586. headerInfo?: React.ReactNode;
  587. }) => React.ReactElement;
  588. /**
  589. * When the children's sendInvites renderProp is called, this will also be
  590. * triggered.
  591. */
  592. onSendInvites: () => void;
  593. /**
  594. * The organization that members will be invited to.
  595. */
  596. organization: Organization;
  597. /**
  598. * Indicates if clicking 'send invites' will immediately send invites, or
  599. * would just create invite requests.
  600. */
  601. willInvite: boolean;
  602. }>;