-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(setup-wizard): Allow project creation (#83811)
Allow creating Sentry projects in the setup wizard workflow. It is only enabled if the wizard passes the `project_platform` URL param which is used to define the projects platform. - part of getsentry/sentry-wizard#549
- Loading branch information
1 parent
45ce4c3
commit da017ea
Showing
5 changed files
with
261 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type {Organization} from 'sentry/types/organization'; | ||
|
||
export function hasSetupWizardCreateProjectFeature(organization: Organization) { | ||
return organization.features.includes('setup-wizard-create-project'); | ||
} |
28 changes: 28 additions & 0 deletions
28
static/app/views/setupWizard/utils/useCreateProjectFromWizard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type {Project} from 'sentry/types/project'; | ||
import {useMutation} from 'sentry/utils/queryClient'; | ||
import useApi from 'sentry/utils/useApi'; | ||
import type {OrganizationWithRegion} from 'sentry/views/setupWizard/types'; | ||
|
||
export function useCreateProjectFromWizard() { | ||
const api = useApi(); | ||
return useMutation({ | ||
mutationFn: (params: { | ||
name: string; | ||
organization: OrganizationWithRegion; | ||
platform: string; | ||
team: string; | ||
}): Promise<Project> => { | ||
const url = `/teams/${params.organization.slug}/${params.team}/projects/`; | ||
return api.requestPromise(url, { | ||
method: 'POST', | ||
host: params.organization.region.url, | ||
data: { | ||
name: params.name, | ||
platform: params.platform, | ||
default_rules: true, | ||
origin: 'ui', | ||
}, | ||
}); | ||
}, | ||
}); | ||
} |
28 changes: 28 additions & 0 deletions
28
static/app/views/setupWizard/utils/useOrganizationDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type {Organization} from 'sentry/types/organization'; | ||
import {useQuery} from 'sentry/utils/queryClient'; | ||
import type RequestError from 'sentry/utils/requestError/requestError'; | ||
import useApi from 'sentry/utils/useApi'; | ||
import type {OrganizationWithRegion} from 'sentry/views/setupWizard/types'; | ||
|
||
export function useOrganizationDetails({ | ||
organization, | ||
}: { | ||
organization?: OrganizationWithRegion; | ||
}) { | ||
const api = useApi(); | ||
|
||
return useQuery<Organization, RequestError>({ | ||
queryKey: [`/organizations/${organization?.slug}/`], | ||
queryFn: () => { | ||
return api.requestPromise(`/organizations/${organization?.slug}/`, { | ||
host: organization?.region.url, | ||
query: { | ||
include_feature_flags: 1, | ||
}, | ||
}); | ||
}, | ||
enabled: !!organization, | ||
refetchOnWindowFocus: true, | ||
retry: false, | ||
}); | ||
} |
25 changes: 25 additions & 0 deletions
25
static/app/views/setupWizard/utils/useOrganizationTeams.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type {Team} from 'sentry/types/organization'; | ||
import {useQuery} from 'sentry/utils/queryClient'; | ||
import type RequestError from 'sentry/utils/requestError/requestError'; | ||
import useApi from 'sentry/utils/useApi'; | ||
import type {OrganizationWithRegion} from 'sentry/views/setupWizard/types'; | ||
|
||
export function useOrganizationTeams({ | ||
organization, | ||
}: { | ||
organization?: OrganizationWithRegion; | ||
}) { | ||
const api = useApi(); | ||
|
||
return useQuery<Team[], RequestError>({ | ||
queryKey: [`/organizations/${organization?.slug}/teams/`], | ||
queryFn: () => { | ||
return api.requestPromise(`/organizations/${organization?.slug}/teams/`, { | ||
host: organization?.region.url, | ||
}); | ||
}, | ||
enabled: !!organization, | ||
refetchOnWindowFocus: true, | ||
retry: false, | ||
}); | ||
} |
Oops, something went wrong.