hooks.tsx 21 KB

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