|
@@ -2,7 +2,6 @@ import {useCallback, useContext, useEffect, useRef, useState} from 'react';
|
|
|
import {RouteComponentProps} from 'react-router';
|
|
|
import styled from '@emotion/styled';
|
|
|
import {AnimatePresence, motion, MotionProps, useAnimation} from 'framer-motion';
|
|
|
-import moment from 'moment';
|
|
|
|
|
|
import {removeProject} from 'sentry/actionCreators/projects';
|
|
|
import {Button, ButtonProps} from 'sentry/components/button';
|
|
@@ -11,6 +10,7 @@ import Hook from 'sentry/components/hook';
|
|
|
import Link from 'sentry/components/links/link';
|
|
|
import LogoSentry from 'sentry/components/logoSentry';
|
|
|
import {OnboardingContext} from 'sentry/components/onboarding/onboardingContext';
|
|
|
+import {useRecentCreatedProject} from 'sentry/components/onboarding/useRecentCreatedProject';
|
|
|
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
|
|
|
import {IconArrow} from 'sentry/icons';
|
|
|
import {t} from 'sentry/locale';
|
|
@@ -23,7 +23,6 @@ import Redirect from 'sentry/utils/redirect';
|
|
|
import testableTransition from 'sentry/utils/testableTransition';
|
|
|
import useApi from 'sentry/utils/useApi';
|
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
-import useProjects from 'sentry/utils/useProjects';
|
|
|
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
|
|
|
import PageCorners from 'sentry/views/onboarding/components/pageCorners';
|
|
|
|
|
@@ -67,7 +66,6 @@ function getOrganizationOnboardingSteps(): StepDescriptor[] {
|
|
|
function Onboarding(props: Props) {
|
|
|
const api = useApi();
|
|
|
const organization = useOrganization();
|
|
|
- const projects = useProjects();
|
|
|
const onboardingContext = useContext(OnboardingContext);
|
|
|
const selectedSDK = onboardingContext.data.selectedSDK;
|
|
|
const selectedProjectSlug = selectedSDK?.key;
|
|
@@ -76,6 +74,16 @@ function Onboarding(props: Props) {
|
|
|
params: {step: stepId},
|
|
|
} = props;
|
|
|
|
|
|
+ const onboardingSteps = getOrganizationOnboardingSteps();
|
|
|
+ const stepObj = onboardingSteps.find(({id}) => stepId === id);
|
|
|
+ const stepIndex = onboardingSteps.findIndex(({id}) => stepId === id);
|
|
|
+
|
|
|
+ const recentCreatedProject = useRecentCreatedProject({
|
|
|
+ orgSlug: organization.slug,
|
|
|
+ projectSlug:
|
|
|
+ onboardingSteps[stepIndex].id === 'setup-docs' ? selectedProjectSlug : undefined,
|
|
|
+ });
|
|
|
+
|
|
|
const cornerVariantTimeoutRed = useRef<number | undefined>(undefined);
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -92,41 +100,20 @@ function Onboarding(props: Props) {
|
|
|
'onboarding-project-deletion-on-back-click'
|
|
|
);
|
|
|
|
|
|
- const onboardingSteps = getOrganizationOnboardingSteps();
|
|
|
- const stepObj = onboardingSteps.find(({id}) => stepId === id);
|
|
|
- const stepIndex = onboardingSteps.findIndex(({id}) => stepId === id);
|
|
|
-
|
|
|
- const loadingProjects = !projects.initiallyLoaded;
|
|
|
-
|
|
|
- const createdProjectId = Object.keys(onboardingContext.data.projects).find(
|
|
|
- key =>
|
|
|
- onboardingContext.data.projects[key].slug ===
|
|
|
- onboardingContext.data.selectedSDK?.key
|
|
|
- );
|
|
|
-
|
|
|
- const recentCreatedProject =
|
|
|
- !loadingProjects && createdProjectId
|
|
|
- ? projects.projects.find(p => p.id === createdProjectId)
|
|
|
- : undefined;
|
|
|
-
|
|
|
- const recentCreatedProjectOlderThanOneHour = recentCreatedProject
|
|
|
- ? moment.duration(moment().diff(recentCreatedProject.dateCreated)).asHours() > 1
|
|
|
- : false;
|
|
|
-
|
|
|
const shallProjectBeDeleted =
|
|
|
projectDeletionOnBackClick &&
|
|
|
onboardingSteps[stepIndex].id === 'setup-docs' &&
|
|
|
recentCreatedProject &&
|
|
|
// if the project has received a first error, we don't delete it
|
|
|
- Boolean(recentCreatedProject.firstEvent) === false &&
|
|
|
+ recentCreatedProject.firstError === false &&
|
|
|
// if the project has received a first transaction, we don't delete it
|
|
|
- Boolean(recentCreatedProject.firstTransactionEvent) === false &&
|
|
|
+ recentCreatedProject.firstTransaction === false &&
|
|
|
// if the project has replays, we don't delete it
|
|
|
- Boolean(recentCreatedProject.hasReplays) === false &&
|
|
|
+ recentCreatedProject.hasReplays === false &&
|
|
|
// if the project has sessions, we don't delete it
|
|
|
- Boolean(recentCreatedProject.hasSessions) === false &&
|
|
|
+ recentCreatedProject.hasSessions === false &&
|
|
|
// if the project is older than one hour, we don't delete it
|
|
|
- recentCreatedProjectOlderThanOneHour === false;
|
|
|
+ recentCreatedProject.olderThanOneHour === false;
|
|
|
|
|
|
const cornerVariantControl = useAnimation();
|
|
|
const updateCornerVariant = () => {
|
|
@@ -392,7 +379,7 @@ function Onboarding(props: Props) {
|
|
|
route={props.route}
|
|
|
router={props.router}
|
|
|
location={props.location}
|
|
|
- selectedProjectSlug={selectedProjectSlug}
|
|
|
+ recentCreatedProject={recentCreatedProject}
|
|
|
{...{
|
|
|
genSkipOnboardingLink,
|
|
|
}}
|