import {Fragment} from 'react'; // eslint-disable-next-line no-restricted-imports import {withRouter, WithRouterProps} from 'react-router'; import {css} from '@emotion/react'; import {ModalRenderProps} from 'sentry/actionCreators/modal'; import Feature from 'sentry/components/acl/feature'; import FeatureDisabled from 'sentry/components/acl/featureDisabled'; import FieldFromConfig from 'sentry/components/forms/fieldFromConfig'; import Form from 'sentry/components/forms/form'; import HookOrDefault from 'sentry/components/hookOrDefault'; import {getDebugSourceName} from 'sentry/data/debugFileSources'; import {t, tct} from 'sentry/locale'; import {Organization} from 'sentry/types'; import {AppStoreConnectStatusData, CustomRepoType} from 'sentry/types/debugFiles'; import AppStoreConnect from './appStoreConnect'; import Http from './http'; import {getFinalData, getFormFieldsAndInitialData} from './utils'; type AppStoreConnectInitialData = React.ComponentProps< typeof AppStoreConnect >['initialData']; type HttpInitialData = React.ComponentProps['initialData']; type RouteParams = { orgId: string; projectId: string; }; type Props = WithRouterProps & { appStoreConnectSourcesQuantity: number; /** * Callback invoked with the updated config value. */ onSave: (data: Record) => Promise; organization: Organization; /** * Type of this source. */ sourceType: CustomRepoType; appStoreConnectStatusData?: AppStoreConnectStatusData; /** * The sourceConfig. May be empty to create a new one. */ sourceConfig?: Record; } & Pick; const HookedAppStoreConnectMultiple = HookOrDefault({ hookName: 'component:disabled-app-store-connect-multiple', defaultComponent: ({children}) => {children}, }); const HookedCustomSymbolSources = HookOrDefault({ hookName: 'component:disabled-custom-symbol-sources', defaultComponent: ({children}) => {children}, }); function DebugFileCustomRepository({ Header, Body, Footer, CloseButton, onSave, sourceConfig, sourceType, params: {orgId, projectId: projectSlug}, appStoreConnectStatusData, closeModal, organization, appStoreConnectSourcesQuantity, }: Props) { function handleSave(data?: Record) { if (!data) { closeModal(); window.location.reload(); return; } onSave({...getFinalData(sourceType, data), type: sourceType}).then(() => { closeModal(); }); } if (sourceType === CustomRepoType.APP_STORE_CONNECT) { return ( {({hasFeature, features}) => { if ( hasFeature || (appStoreConnectSourcesQuantity === 1 && sourceConfig) || appStoreConnectSourcesQuantity === 0 ) { return ( ); } return ( ); }} ); } return ( {({hasFeature, features}) => { if (hasFeature) { if (sourceType === CustomRepoType.HTTP) { return ( ); } const {initialData, fields} = getFormFieldsAndInitialData( sourceType, sourceConfig ); return (
{sourceConfig ? tct('Update [name] Repository', { name: getDebugSourceName(sourceType), }) : tct('Add [name] Repository', {name: getDebugSourceName(sourceType)})}
{fields && (
{fields.map((field, i) => ( ))} )}
); } return ( ); }}
); } export default withRouter(DebugFileCustomRepository); export const modalCss = css` width: 100%; max-width: 680px; `;