Skip to content

Commit b60c72d

Browse files
authored
ref(ownership): Update ownership data after mutation (#67651)
Closes the modal and updates the cache when saving ownership rules.
1 parent 42daa2d commit b60c72d

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

static/app/actionCreators/modal.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,6 @@ type CreateOwnershipRuleModalOptions = {
116116
eventData?: Event;
117117
};
118118

119-
export type EditOwnershipRulesModalOptions = {
120-
onSave: (text: string | null) => void;
121-
organization: Organization;
122-
ownership: IssueOwnership;
123-
project: Project;
124-
};
125-
126119
/**
127120
* Open the edit ownership modal within issue details
128121
*/
@@ -135,6 +128,13 @@ export async function openIssueOwnershipRuleModal(
135128
openModal(deps => <Modal {...deps} {...options} />, {modalCss});
136129
}
137130

131+
export type EditOwnershipRulesModalOptions = {
132+
onSave: (ownership: IssueOwnership) => void;
133+
organization: Organization;
134+
ownership: IssueOwnership;
135+
project: Project;
136+
};
137+
138138
export async function openEditOwnershipRules(options: EditOwnershipRulesModalOptions) {
139139
const mod = await import('sentry/components/modals/editOwnershipRulesModal');
140140
const {default: Modal, modalCss} = mod;

static/app/views/settings/project/projectOwnership/index.tsx

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Fragment} from 'react';
22
import type {RouteComponentProps} from 'react-router';
33

4-
import {openEditOwnershipRules, openModal} from 'sentry/actionCreators/modal';
4+
import {closeModal, openEditOwnershipRules, openModal} from 'sentry/actionCreators/modal';
55
import Access, {hasEveryAccess} from 'sentry/components/acl/access';
66
import {Button} from 'sentry/components/button';
77
import ButtonBar from 'sentry/components/buttonBar';
@@ -76,17 +76,12 @@ url:http://example.com/settings/* #product
7676
tags.sku_class:enterprise #enterprise`;
7777
}
7878

79-
handleOwnershipSave = (text: string | null) => {
79+
handleOwnershipSave = (ownership: IssueOwnership) => {
8080
this.setState(prevState => ({
81-
...(prevState.ownership
82-
? {
83-
ownership: {
84-
...prevState.ownership,
85-
raw: text || '',
86-
},
87-
}
88-
: {}),
81+
...prevState,
82+
ownership,
8983
}));
84+
closeModal();
9085
};
9186

9287
handleCodeOwnerAdded = (data: CodeOwner) => {

static/app/views/settings/project/projectOwnership/ownerInput.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import TimeSince from 'sentry/components/timeSince';
1313
import {t} from 'sentry/locale';
1414
import MemberListStore from 'sentry/stores/memberListStore';
1515
import ProjectsStore from 'sentry/stores/projectsStore';
16-
import type {Organization, Project, Team} from 'sentry/types';
16+
import type {IssueOwnership, Organization, Project, Team} from 'sentry/types';
1717
import {defined} from 'sentry/utils';
1818
import {trackIntegrationAnalytics} from 'sentry/utils/integrationUtil';
1919

@@ -33,7 +33,7 @@ type Props = {
3333
*/
3434
page: 'issue_details' | 'project_settings';
3535
project: Project;
36-
onSave?: (text: string | null) => void;
36+
onSave?: (ownership: IssueOwnership) => void;
3737
} & typeof defaultProps;
3838

3939
type State = {
@@ -82,14 +82,14 @@ class OwnerInput extends Component<Props, State> {
8282
);
8383

8484
request
85-
.then(() => {
85+
.then(ownership => {
8686
addSuccessMessage(t('Updated issue ownership rules'));
8787
this.setState(
8888
{
8989
hasChanges: false,
9090
text,
9191
},
92-
() => onSave?.(text)
92+
() => onSave?.(ownership)
9393
);
9494
trackIntegrationAnalytics('project_ownership.saved', {
9595
page,

0 commit comments

Comments
 (0)