Skip to content

Commit 3a8b25a

Browse files
committed
Count occurrences when classifying a pinned issue
1 parent 3172265 commit 3a8b25a

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

ui/helpers/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export const thEvents = {
341341
applyNewJobs: 'apply-new-jobs-EVT',
342342
filtersUpdated: 'filters-updated-EVT',
343343
clearPinboard: 'clear-pinboard-EVT',
344+
internalIssueClassification: 'internal-issue-classification-EVT',
344345
};
345346

346347
export const thBugSuggestionLimit = 20;

ui/job-view/details/PinBoard.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ class PinBoard extends React.Component {
166166
const message = `Error saving bug association for ${job.platform} ${job.job_type_name}`;
167167
notify(formatModelError(response, message), 'danger');
168168
});
169+
170+
// In case the bug is still an internal issue, check if the required number of occurrence is reached to open a bug
171+
if (!bug.id) {
172+
window.dispatchEvent(
173+
new CustomEvent(thEvents.internalIssueClassification, {
174+
detail: { internalBugId: bug.internal_id },
175+
}),
176+
);
177+
}
169178
});
170179
};
171180

ui/shared/tabs/failureSummary/FailureSummaryTab.jsx

+16-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class FailureSummaryTab extends React.Component {
3434

3535
componentDidMount() {
3636
this.loadBugSuggestions();
37+
38+
window.addEventListener(thEvents.internalIssueClassification, (event) =>
39+
this.checkInternalFailureOccurrences(event.detail.internalBugId),
40+
);
3741
}
3842

3943
componentDidUpdate(prevProps) {
@@ -89,20 +93,16 @@ class FailureSummaryTab extends React.Component {
8993
window.open(data.url);
9094
};
9195

92-
internalIssueFilerCallback = async (data) => {
93-
const { addBug } = this.props;
96+
checkInternalFailureOccurrences = (bugInternalId) => {
97+
// Try matching an internal bug already fetched with enough occurences
9498
const { suggestion, suggestions } = this.state;
9599

96-
await addBug({ ...data, newBug: `i${data.internal_id}` });
97-
window.dispatchEvent(new CustomEvent(thEvents.saveClassification));
98-
99-
// Try matching an internal bug already fetched with enough occurences
100100
const internalBugs = suggestions
101101
.map((s) => s.bugs.open_recent)
102102
.flat()
103103
.filter((bug) => bug.id === null);
104104
const existingBug = internalBugs.filter(
105-
(bug) => bug.internal_id === data.internal_id,
105+
(bug) => bug.internal_id === bugInternalId,
106106
)[0];
107107
// Check if we reached the required number of occurrence to open a bug in Bugzilla
108108
if (
@@ -114,6 +114,15 @@ class FailureSummaryTab extends React.Component {
114114
}
115115
};
116116

117+
internalIssueFilerCallback = async (data) => {
118+
const { addBug } = this.props;
119+
120+
await addBug({ ...data, newBug: `i${data.internal_id}` });
121+
window.dispatchEvent(new CustomEvent(thEvents.saveClassification));
122+
123+
this.checkInternalFailureOccurrences(data.internal_id);
124+
};
125+
117126
loadBugSuggestions = () => {
118127
const { selectedJob } = this.props;
119128

0 commit comments

Comments
 (0)