Skip to content

Commit 1d1e408

Browse files
authored
feat(autofix): Move autofix settings into project settings (#90640)
1 parent 937ee35 commit 1d1e408

16 files changed

+953
-744
lines changed

static/app/components/events/autofix/preferences/autofixPreferenceDropdown.tsx

Lines changed: 0 additions & 592 deletions
This file was deleted.

static/app/components/events/autofix/preferences/hooks/useProjectPreferences.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type {
2+
ProjectSeerPreferences,
3+
SeerRepoDefinition,
4+
} from 'sentry/components/events/autofix/types';
5+
import type {Project} from 'sentry/types/project';
6+
import {useApiQuery} from 'sentry/utils/queryClient';
7+
import useOrganization from 'sentry/utils/useOrganization';
8+
9+
export interface SeerPreferencesResponse {
10+
code_mapping_repos: SeerRepoDefinition[];
11+
preference?: ProjectSeerPreferences | null;
12+
}
13+
14+
export function useProjectSeerPreferences(project: Project) {
15+
const organization = useOrganization();
16+
17+
const {data, ...rest} = useApiQuery<SeerPreferencesResponse>(
18+
[`/projects/${organization.slug}/${project.slug}/seer/preferences/`],
19+
{
20+
staleTime: 60000, // 1 minute
21+
}
22+
);
23+
24+
return {
25+
preference: data?.preference,
26+
codeMappingRepos: data?.code_mapping_repos,
27+
...rest,
28+
};
29+
}

static/app/components/events/autofix/preferences/hooks/useSaveProjectPreferences.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type {ProjectSeerPreferences} from 'sentry/components/events/autofix/types';
2+
import type {Project} from 'sentry/types/project';
3+
import {useMutation} from 'sentry/utils/queryClient';
4+
import useApi from 'sentry/utils/useApi';
5+
import useOrganization from 'sentry/utils/useOrganization';
6+
7+
export function useUpdateProjectSeerPreferences(project: Project) {
8+
const organization = useOrganization();
9+
const api = useApi({persistInFlight: true});
10+
11+
return useMutation({
12+
mutationFn: (data: ProjectSeerPreferences) => {
13+
return api.requestPromise(
14+
`/projects/${organization.slug}/${project.slug}/seer/preferences/`,
15+
{
16+
method: 'POST',
17+
data,
18+
}
19+
);
20+
},
21+
});
22+
}

static/app/components/events/autofix/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,6 @@ export interface SeerRepoDefinition {
248248
provider_raw?: string;
249249
}
250250

251-
export interface ProjectPreferences {
251+
export interface ProjectSeerPreferences {
252252
repositories: SeerRepoDefinition[];
253253
}

static/app/routes.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ function buildRoutes() {
527527
name={t('Data Forwarding')}
528528
component={make(() => import('sentry/views/settings/projectDataForwarding'))}
529529
/>
530+
<Route
531+
path="seer/"
532+
name={t('Seer')}
533+
component={make(() => import('sentry/views/settings/projectSeer/index'))}
534+
/>
530535
<Route
531536
path="user-feedback/"
532537
name={t('User Feedback')}

static/app/views/issueDetails/streamline/sidebar/seerDrawer.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import {Breadcrumbs as NavigationBreadcrumbs} from 'sentry/components/breadcrumb
77
import {Flex} from 'sentry/components/container/flex';
88
import {ProjectAvatar} from 'sentry/components/core/avatar/projectAvatar';
99
import {FeatureBadge} from 'sentry/components/core/badge/featureBadge';
10-
import {Button} from 'sentry/components/core/button';
10+
import {Button, LinkButton} from 'sentry/components/core/button';
1111
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
1212
import {DateTime} from 'sentry/components/dateTime';
1313
import AutofixFeedback from 'sentry/components/events/autofix/autofixFeedback';
1414
import {AutofixProgressBar} from 'sentry/components/events/autofix/autofixProgressBar';
1515
import {AutofixStartBox} from 'sentry/components/events/autofix/autofixStartBox';
1616
import {AutofixSteps} from 'sentry/components/events/autofix/autofixSteps';
17-
import AutofixPreferenceDropdown from 'sentry/components/events/autofix/preferences/autofixPreferenceDropdown';
1817
import {useAiAutofix} from 'sentry/components/events/autofix/useAutofix';
1918
import useDrawer from 'sentry/components/globalDrawer';
2019
import {DrawerBody, DrawerHeader} from 'sentry/components/globalDrawer/components';
@@ -24,6 +23,7 @@ import ExternalLink from 'sentry/components/links/externalLink';
2423
import Link from 'sentry/components/links/link';
2524
import LoadingIndicator from 'sentry/components/loadingIndicator';
2625
import QuestionTooltip from 'sentry/components/questionTooltip';
26+
import {IconSettings} from 'sentry/icons';
2727
import {t, tct} from 'sentry/locale';
2828
import {space} from 'sentry/styles/space';
2929
import type {Event} from 'sentry/types/event';
@@ -155,7 +155,13 @@ export function SeerDrawer({group, project, event}: SeerDrawerProps) {
155155
<ButtonBarWrapper data-test-id="autofix-button-bar">
156156
<ButtonBar gap={1}>
157157
<Feature features={['organizations:autofix-seer-preferences']}>
158-
<AutofixPreferenceDropdown project={project} />
158+
<LinkButton
159+
to={`/settings/${organization.slug}/projects/${project.slug}/seer/`}
160+
size="xs"
161+
title={t('Project Settings for Autofix')}
162+
aria-label={t('Project Settings for Autofix')}
163+
icon={<IconSettings />}
164+
/>
159165
</Feature>
160166
<AutofixFeedback />
161167
{aiConfig.hasAutofix && (

static/app/views/issueDetails/streamline/sidebar/seerNotices.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import onboardingInstall from 'sentry-images/spot/onboarding-install.svg';
55

66
import {Alert} from 'sentry/components/core/alert';
77
import {LinkButton} from 'sentry/components/core/button';
8-
import {useProjectPreferences} from 'sentry/components/events/autofix/preferences/hooks/useProjectPreferences';
8+
import {useProjectSeerPreferences} from 'sentry/components/events/autofix/preferences/hooks/useProjectSeerPreferences';
99
import {useAutofixRepos} from 'sentry/components/events/autofix/useAutofix';
1010
import ExternalLink from 'sentry/components/links/externalLink';
1111
import {t, tct} from 'sentry/locale';
@@ -110,7 +110,7 @@ export function SeerNotices({groupId, hasGithubIntegration, project}: SeerNotice
110110
preference,
111111
codeMappingRepos,
112112
isLoading: isLoadingPreferences,
113-
} = useProjectPreferences(project);
113+
} = useProjectSeerPreferences(project);
114114

115115
const unreadableRepos = repos.filter(repo => repo.is_readable === false);
116116
const notices: React.JSX.Element[] = [];

static/app/views/settings/project/navigationConfiguration.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export default function getConfiguration({
6060
path: `${pathPrefix}/data-forwarding/`,
6161
title: t('Data Forwarding'),
6262
},
63+
{
64+
path: `${pathPrefix}/seer/`,
65+
title: t('Seer'),
66+
show: () => !organization?.hideAiFeatures,
67+
},
6368
{
6469
path: `${pathPrefix}/user-feedback/`,
6570
title: t('User Feedback'),

0 commit comments

Comments
 (0)