|
@@ -3,6 +3,7 @@ import {browserHistory, RouteComponentProps} from 'react-router';
|
|
|
import styled from '@emotion/styled';
|
|
|
import {AnimatePresence, motion, MotionProps, useAnimation} from 'framer-motion';
|
|
|
|
|
|
+import {removeProject} from 'sentry/actionCreators/projects';
|
|
|
import {Button, ButtonProps} from 'sentry/components/button';
|
|
|
import Hook from 'sentry/components/hook';
|
|
|
import Link from 'sentry/components/links/link';
|
|
@@ -15,6 +16,7 @@ import {Organization, Project} from 'sentry/types';
|
|
|
import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
|
|
|
import Redirect from 'sentry/utils/redirect';
|
|
|
import testableTransition from 'sentry/utils/testableTransition';
|
|
|
+import useApi from 'sentry/utils/useApi';
|
|
|
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
|
|
|
import withOrganization from 'sentry/utils/withOrganization';
|
|
|
import withProjects from 'sentry/utils/withProjects';
|
|
@@ -73,6 +75,8 @@ function getOrganizationOnboardingSteps(singleSelectPlatform: boolean): StepDesc
|
|
|
}
|
|
|
|
|
|
function Onboarding(props: Props) {
|
|
|
+ const api = useApi();
|
|
|
+
|
|
|
const {
|
|
|
organization,
|
|
|
params: {step: stepId},
|
|
@@ -94,6 +98,10 @@ function Onboarding(props: Props) {
|
|
|
'onboarding-remove-multiselect-platform'
|
|
|
);
|
|
|
|
|
|
+ const projectDeletionOnBackClick = !!props.organization?.features.includes(
|
|
|
+ 'onboarding-project-deletion-on-back-click'
|
|
|
+ );
|
|
|
+
|
|
|
const onboardingSteps = getOrganizationOnboardingSteps(singleSelectPlatform);
|
|
|
const stepObj = onboardingSteps.find(({id}) => stepId === id);
|
|
|
const stepIndex = onboardingSteps.findIndex(({id}) => stepId === id);
|
|
@@ -151,6 +159,19 @@ function Onboarding(props: Props) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // The user is going back to select a new platform,
|
|
|
+ // so we silently delete the last created project
|
|
|
+ if (projectDeletionOnBackClick && stepIndex === onboardingSteps.length - 1) {
|
|
|
+ const selectedPlatforms = clientState?.selectedPlatforms || [];
|
|
|
+ const platformToProjectIdMap = clientState?.platformToProjectIdMap || {};
|
|
|
+
|
|
|
+ const selectedProjectSlugs = selectedPlatforms
|
|
|
+ .map(platform => platformToProjectIdMap[platform])
|
|
|
+ .filter((slug): slug is string => slug !== undefined);
|
|
|
+
|
|
|
+ removeProject(api, organization.slug, selectedProjectSlugs[0]);
|
|
|
+ }
|
|
|
+
|
|
|
if (stepObj.cornerVariant !== previousStep.cornerVariant) {
|
|
|
cornerVariantControl.start('none');
|
|
|
}
|