123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- import type {ModalTypes} from 'sentry/components/globalModal';
- import type {CreateNewIntegrationModalOptions} from 'sentry/components/modals/createNewIntegrationModal';
- import type {CreateReleaseIntegrationModalOptions} from 'sentry/components/modals/createReleaseIntegrationModal';
- import type {DashboardWidgetQuerySelectorModalOptions} from 'sentry/components/modals/dashboardWidgetQuerySelectorModal';
- import {InviteRow} from 'sentry/components/modals/inviteMembersModal/types';
- import type {ReprocessEventModalOptions} from 'sentry/components/modals/reprocessEventModal';
- import {OverwriteWidgetModalProps} from 'sentry/components/modals/widgetBuilder/overwriteWidgetModal';
- import type {WidgetViewerModalOptions} from 'sentry/components/modals/widgetViewerModal';
- import ModalStore from 'sentry/stores/modalStore';
- import {
- Group,
- IssueOwnership,
- Organization,
- Project,
- SentryApp,
- Team,
- } from 'sentry/types';
- import {AppStoreConnectStatusData, CustomRepoType} from 'sentry/types/debugFiles';
- import {Event} from 'sentry/types/event';
- export type ModalOptions = ModalTypes['options'];
- export type ModalRenderProps = ModalTypes['renderProps'];
- /**
- * Show a modal
- */
- export function openModal(
- renderer: (renderProps: ModalRenderProps) => React.ReactNode,
- options?: ModalOptions
- ) {
- ModalStore.openModal(renderer, options ?? {});
- }
- /**
- * Close modal
- */
- export function closeModal() {
- ModalStore.closeModal();
- }
- type OpenSudoModalOptions = {
- isSuperuser?: boolean;
- needsReload?: boolean;
- onClose?: () => void;
- retryRequest?: () => Promise<any>;
- sudo?: boolean;
- };
- type emailVerificationModalOptions = {
- actionMessage?: string;
- emailVerified?: boolean;
- onClose?: () => void;
- };
- type inviteMembersModalOptions = {
- initialData?: Partial<InviteRow>[];
- onClose?: () => void;
- source?: string;
- };
- export async function openSudo({onClose, ...args}: OpenSudoModalOptions = {}) {
- const mod = await import('sentry/components/modals/sudoModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...args} />, {onClose});
- }
- export async function openEmailVerification({
- onClose,
- ...args
- }: emailVerificationModalOptions = {}) {
- const mod = await import('sentry/components/modals/emailVerificationModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...args} />, {onClose});
- }
- type OpenDiffModalOptions = {
- baseIssueId: Group['id'];
- orgId: Organization['id'];
- project: Project;
- targetIssueId: string;
- baseEventId?: Event['id'];
- targetEventId?: string;
- };
- export async function openDiffModal(options: OpenDiffModalOptions) {
- const mod = await import('sentry/components/modals/diffModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- type CreateTeamModalOptions = {
- /**
- * The organization to create a team for
- */
- organization: Organization;
- onClose?: (team: Team) => void;
- /**
- * An initial project to add the team to. This may be deprecated soon as we may add a project selection inside of the modal flow
- */
- project?: Project;
- };
- export async function openCreateTeamModal(options: CreateTeamModalOptions) {
- const mod = await import('sentry/components/modals/createTeamModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />);
- }
- type CreateOwnershipRuleModalOptions = {
- issueId: string;
- /**
- * The organization to create a rules for
- */
- organization: Organization;
- /**
- * The project to create a rules for
- */
- project: Project;
- };
- export type EditOwnershipRulesModalOptions = {
- onSave: (text: string | null) => void;
- organization: Organization;
- ownership: IssueOwnership;
- project: Project;
- };
- export async function openCreateOwnershipRule(options: CreateOwnershipRuleModalOptions) {
- const mod = await import('sentry/components/modals/createOwnershipRuleModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- export async function openEditOwnershipRules(options: EditOwnershipRulesModalOptions) {
- const mod = await import('sentry/components/modals/editOwnershipRulesModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {backdrop: 'static', modalCss});
- }
- export async function openCommandPalette(options: ModalOptions = {}) {
- const mod = await import('sentry/components/modals/commandPalette');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- type RecoveryModalOptions = {
- authenticatorName: string;
- };
- export async function openRecoveryOptions(options: RecoveryModalOptions) {
- const mod = await import('sentry/components/modals/recoveryOptionsModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />);
- }
- export type TeamAccessRequestModalOptions = {
- memberId: string;
- orgId: string;
- teamId: string;
- };
- export async function openTeamAccessRequestModal(options: TeamAccessRequestModalOptions) {
- const mod = await import('sentry/components/modals/teamAccessRequestModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />);
- }
- export async function redirectToProject(newProjectSlug: string) {
- const mod = await import('sentry/components/modals/redirectToProject');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} slug={newProjectSlug} />, {});
- }
- type HelpSearchModalOptions = {
- organization?: Organization;
- placeholder?: string;
- };
- export async function openHelpSearchModal(options?: HelpSearchModalOptions) {
- const mod = await import('sentry/components/modals/helpSearchModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- export type SentryAppDetailsModalOptions = {
- isInstalled: boolean;
- onInstall: () => Promise<void>;
- organization: Organization;
- sentryApp: SentryApp;
- onCloseModal?: () => void; // used for analytics
- };
- type DebugFileSourceModalOptions = {
- appStoreConnectSourcesQuantity: number;
- onSave: (data: Record<string, any>) => Promise<void>;
- organization: Organization;
- sourceType: CustomRepoType;
- appStoreConnectStatusData?: AppStoreConnectStatusData;
- onClose?: () => void;
- sourceConfig?: Record<string, any>;
- };
- export async function openDebugFileSourceModal({
- onClose,
- ...restOptions
- }: DebugFileSourceModalOptions) {
- const mod = await import('sentry/components/modals/debugFileCustomRepository');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...restOptions} />, {
- modalCss,
- onClose,
- });
- }
- export async function openInviteMembersModal({
- onClose,
- ...args
- }: inviteMembersModalOptions = {}) {
- const mod = await import('sentry/components/modals/inviteMembersModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...args} />, {modalCss, onClose});
- }
- export async function openWidgetBuilderOverwriteModal(
- options: OverwriteWidgetModalProps
- ) {
- const mod = await import('sentry/components/modals/widgetBuilder/overwriteWidgetModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {backdrop: 'static', modalCss});
- }
- export async function openAddToDashboardModal(options) {
- const mod = await import('sentry/components/modals/widgetBuilder/addToDashboardModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {backdrop: 'static', modalCss});
- }
- export async function openReprocessEventModal({
- onClose,
- ...options
- }: ReprocessEventModalOptions & {onClose?: () => void}) {
- const mod = await import('sentry/components/modals/reprocessEventModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {onClose});
- }
- export async function demoSignupModal(options: ModalOptions = {}) {
- const mod = await import('sentry/components/modals/demoSignUp');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- export async function demoSignupModalV2(options: ModalOptions = {}) {
- const mod = await import('sentry/components/modals/demoSignUpV2');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {modalCss});
- }
- export async function openDashboardWidgetQuerySelectorModal(
- options: DashboardWidgetQuerySelectorModalOptions
- ) {
- const mod = await import('sentry/components/modals/dashboardWidgetQuerySelectorModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {backdrop: 'static', modalCss});
- }
- export async function openWidgetViewerModal({
- onClose,
- ...options
- }: WidgetViewerModalOptions & {onClose?: () => void}) {
- const mod = await import('sentry/components/modals/widgetViewerModal');
- const {default: Modal, modalCss} = mod;
- openModal(deps => <Modal {...deps} {...options} />, {
- backdrop: 'static',
- modalCss,
- onClose,
- });
- }
- export async function openCreateNewIntegrationModal(
- options: CreateNewIntegrationModalOptions
- ) {
- const mod = await import('sentry/components/modals/createNewIntegrationModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />);
- }
- export async function openCreateReleaseIntegration(
- options: CreateReleaseIntegrationModalOptions
- ) {
- const mod = await import('sentry/components/modals/createReleaseIntegrationModal');
- const {default: Modal} = mod;
- openModal(deps => <Modal {...deps} {...options} />);
- }
|