Skip to content

Commit c1a1dba

Browse files
fix(prevent): Update frontend for unnested api structure (#102627)
1 parent 0d20e6e commit c1a1dba

File tree

7 files changed

+16
-31
lines changed

7 files changed

+16
-31
lines changed

static/app/views/prevent/preventAI/hooks/usePreventAIConfig.spec.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ describe('usePreventAIGitHubConfig', () => {
3232
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
3333
},
3434
organization: {
35-
'octo-corp': {
36-
org_defaults: {
37-
vanilla: {enabled: false, sensitivity: 'low'},
38-
test_generation: {enabled: true, sensitivity: 'medium'},
39-
bug_prediction: {enabled: true, sensitivity: 'high'},
40-
},
41-
repo_overrides: {},
42-
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
35+
org_defaults: {
36+
vanilla: {enabled: false, sensitivity: 'low'},
37+
test_generation: {enabled: true, sensitivity: 'medium'},
38+
bug_prediction: {enabled: true, sensitivity: 'high'},
4339
},
40+
repo_overrides: {},
41+
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
4442
},
4543
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
4644
};

static/app/views/prevent/preventAI/hooks/usePreventAIConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface UsePreventAIGitHubConfigOptions {
1010
interface UsePreventAIGitHubConfigResult {
1111
default_org_config: PreventAIConfig;
1212
schema_version: string;
13-
organization?: Record<string, PreventAIConfig>;
13+
organization?: PreventAIConfig;
1414
}
1515

1616
export function usePreventAIGitHubConfig({gitOrgName}: UsePreventAIGitHubConfigOptions) {

static/app/views/prevent/preventAI/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Feature from 'sentry/components/acl/feature';
22
import LoadingError from 'sentry/components/loadingError';
33
import LoadingIndicator from 'sentry/components/loadingIndicator';
44
import {t} from 'sentry/locale';
5-
import PreventAIManageRepos from 'sentry/views/prevent/preventAI/manageRepos';
5+
import PreventAIManageRepos from 'sentry/views/prevent/preventAI/manageReposPage';
66
import PreventAIOnboarding from 'sentry/views/prevent/preventAI/onboarding';
77

88
import {usePreventAIOrgs} from './hooks/usePreventAIOrgRepos';

static/app/views/prevent/preventAI/manageRepos.spec.tsx renamed to static/app/views/prevent/preventAI/manageReposPage.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {PreventAIConfigFixture} from 'sentry-fixture/prevent';
44

55
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
66

7-
import ManageReposPage from './manageRepos';
7+
import ManageReposPage from './manageReposPage';
88

99
describe('PreventAIManageRepos', () => {
1010
const integratedOrgs = [

static/app/views/prevent/preventAI/manageReposPanel.spec.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ describe('ManageReposPanel', () => {
8686
body: {
8787
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
8888
default_org_config: PreventAIConfigFixture(),
89-
organization: {
90-
'org-1': PreventAIConfigFixture(),
91-
},
89+
organization: PreventAIConfigFixture(),
9290
},
9391
});
9492
});
@@ -156,9 +154,7 @@ describe('ManageReposPanel', () => {
156154
body: {
157155
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
158156
default_org_config: PreventAIConfigFixture(),
159-
organization: {
160-
'org-1': configWithOverride,
161-
},
157+
organization: configWithOverride,
162158
},
163159
});
164160

@@ -186,9 +182,7 @@ describe('ManageReposPanel', () => {
186182
body: {
187183
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
188184
default_org_config: PreventAIConfigFixture(),
189-
organization: {
190-
'org-1': configWithOverride,
191-
},
185+
organization: configWithOverride,
192186
},
193187
});
194188

@@ -229,9 +223,7 @@ describe('ManageReposPanel', () => {
229223
body: {
230224
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
231225
default_org_config: PreventAIConfigFixture(),
232-
organization: {
233-
'org-1': configWithOverride,
234-
},
226+
organization: configWithOverride,
235227
},
236228
});
237229

@@ -265,9 +257,7 @@ describe('ManageReposPanel', () => {
265257
body: {
266258
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
267259
default_org_config: PreventAIConfigFixture(),
268-
organization: {
269-
'org-1': configWithOverride,
270-
},
260+
organization: configWithOverride,
271261
},
272262
});
273263

@@ -350,9 +340,7 @@ describe('ManageReposPanel', () => {
350340
body: {
351341
schema_version: PREVENT_AI_CONFIG_SCHEMA_VERSION_DEFAULT,
352342
default_org_config: PreventAIConfigFixture(),
353-
organization: {
354-
'org-1': configWithOverride,
355-
},
343+
organization: configWithOverride,
356344
},
357345
});
358346

static/app/views/prevent/preventAI/manageReposPanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ function ManageReposPanel({
9797
);
9898
}
9999

100-
const orgConfig =
101-
githubConfigData.organization?.[org.name] ?? githubConfigData.default_org_config;
100+
const orgConfig = githubConfigData.organization ?? githubConfigData.default_org_config;
102101

103102
const {doesUseOrgDefaults, repoConfig} = isEditingOrgDefaults
104103
? {doesUseOrgDefaults: true, repoConfig: orgConfig.org_defaults}

0 commit comments

Comments
 (0)