Skip to content

Commit 5176ac2

Browse files
priscilawebdevandrewshie-sentry
authored andcommitted
fix(project-creation): Prefill form when project ID in URL matches localStorage data (#91517)
- Fixes the issue where the form wasn’t pre-filled with data from a previously deleted project ( we want this when users go back in the flow) - Replaces the GettingStartedWithProject context with a simpler localStorage-based solution - Refactors the code to improve readability and clarity - Cleans up unused code and unnecessary logic - closes TET-369
1 parent 19198f0 commit 5176ac2

File tree

8 files changed

+376
-382
lines changed

8 files changed

+376
-382
lines changed

static/app/components/modals/projectCreationModal.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ import {trackAnalytics} from 'sentry/utils/analytics';
2727
import slugify from 'sentry/utils/slugify';
2828
import useApi from 'sentry/utils/useApi';
2929
import useOrganization from 'sentry/utils/useOrganization';
30-
import type {IssueAlertFragment} from 'sentry/views/projectInstall/createProject';
31-
import IssueAlertOptions from 'sentry/views/projectInstall/issueAlertOptions';
30+
import type {RequestDataFragment} from 'sentry/views/projectInstall/issueAlertOptions';
31+
import IssueAlertOptions, {
32+
MetricValues,
33+
RuleAction,
34+
} from 'sentry/views/projectInstall/issueAlertOptions';
3235

3336
type Props = ModalRenderProps & {
3437
defaultCategory?: Category;
@@ -41,7 +44,7 @@ export default function ProjectCreationModal({
4144
}: Props) {
4245
const [platform, setPlatform] = useState<OnboardingSelectedSDK | undefined>(undefined);
4346
const [step, setStep] = useState(0);
44-
const [alertRuleConfig, setAlertRuleConfig] = useState<IssueAlertFragment | undefined>(
47+
const [alertRuleConfig, setAlertRuleConfig] = useState<RequestDataFragment | undefined>(
4548
undefined
4649
);
4750
const [projectName, setProjectName] = useState('');
@@ -152,7 +155,23 @@ export default function ProjectCreationModal({
152155
{step === 1 && (
153156
<Fragment>
154157
<Subtitle>{t('Set your alert frequency')}</Subtitle>
155-
<IssueAlertOptions onChange={updatedData => setAlertRuleConfig(updatedData)} />
158+
<IssueAlertOptions
159+
alertSetting={
160+
alertRuleConfig?.shouldCreateCustomRule
161+
? RuleAction.CUSTOMIZED_ALERTS
162+
: alertRuleConfig?.shouldCreateRule
163+
? RuleAction.DEFAULT_ALERT
164+
: RuleAction.CREATE_ALERT_LATER
165+
}
166+
interval={alertRuleConfig?.conditions?.[0]?.interval}
167+
threshold={alertRuleConfig?.conditions?.[0]?.value}
168+
metric={
169+
alertRuleConfig?.conditions?.[0]?.id.endsWith('EventFrequencyCondition')
170+
? MetricValues.ERRORS
171+
: MetricValues.USERS
172+
}
173+
onChange={setAlertRuleConfig}
174+
/>
156175
<Subtitle>{t('Name your project and assign it a team')}</Subtitle>
157176
<ProjectNameTeamSection>
158177
<div>

static/app/components/platformPicker.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class PlatformPicker extends Component<PlatformPickerProps, State> {
8282
filter: this.props.noAutoFilter ? '' : (this.props.platform || '').split('-')[0]!,
8383
};
8484

85+
componentDidUpdate(prevProps: Readonly<PlatformPickerProps>): void {
86+
if (this.props.defaultCategory !== prevProps.defaultCategory) {
87+
this.setState({category: this.props.defaultCategory ?? categoryList[0]!.id});
88+
}
89+
}
90+
8591
get platformList() {
8692
const {category} = this.state;
8793

0 commit comments

Comments
 (0)