зеркало из https://github.com/mozilla/treeherder.git
Bug 1721330 - Alerts View - Refresh in place reassigned alerts (#7223)
* Bug 1721330 - Refresh in place reassigned alerts * Bug 1721330 - Removed unnecessary logic * Bug 1721330 - Address change request
This commit is contained in:
Родитель
f1b5e84eb1
Коммит
94bfedefd1
|
@ -407,6 +407,20 @@ test('selecting the alert summary checkbox then deselecting one alert only updat
|
|||
modifyAlertSpy.mockClear();
|
||||
});
|
||||
|
||||
test('selecting the alert summary checkbox then clicking on the reassign button opens the alert modal', async () => {
|
||||
const { getByTestId, getByText } = alertsViewControls();
|
||||
|
||||
// select summary
|
||||
const summaryCheckbox = getByTestId('alert summary 20174 checkbox');
|
||||
fireEvent.click(summaryCheckbox);
|
||||
|
||||
const reassignButton = await waitFor(() => getByText('Reassign'));
|
||||
fireEvent.click(reassignButton);
|
||||
|
||||
const alertModal = await waitFor(() => getByText('Reassign Alerts'));
|
||||
expect(alertModal).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("display of alert summaries's assignee badge", async () => {
|
||||
const { getAllByTitle, getAllByText } = alertsViewControls();
|
||||
|
||||
|
|
|
@ -53,6 +53,14 @@ export default class AlertActionPanel extends React.Component {
|
|||
return updateViewState({ errorMessages });
|
||||
}
|
||||
|
||||
// update field related summary id for each alert of the summary
|
||||
alertSummary.alerts.forEach((alertFromSummary) => {
|
||||
selectedAlerts.forEach((selectedAlert) => {
|
||||
if (alertFromSummary.id === selectedAlert.id)
|
||||
alertFromSummary.related_summary_id = alertId;
|
||||
});
|
||||
});
|
||||
|
||||
if (alertId) {
|
||||
otherAlertSummaries = alertSummaries.filter(
|
||||
(summary) => summary.id === alertId,
|
||||
|
@ -66,13 +74,32 @@ export default class AlertActionPanel extends React.Component {
|
|||
)
|
||||
.filter((summary) => summary !== undefined);
|
||||
}
|
||||
|
||||
const summariesToUpdate = [...[alertSummary], ...otherAlertSummaries];
|
||||
const summariesToUpdate = [
|
||||
...new Set([...[alertSummary], ...otherAlertSummaries]),
|
||||
];
|
||||
|
||||
// when an alert status is updated via the API, the corresponding
|
||||
// alertSummary status and any related summaries are updated (in the backend)
|
||||
// so we need to fetch them in order to capture the changes in the UI
|
||||
summariesToUpdate.forEach((summary) => fetchAlertSummaries(summary.id));
|
||||
|
||||
// summaries from current page need to be fetched again if all alerts
|
||||
// from a summary were reassigned or if a summary was reset
|
||||
let refreshAlertsSummaries = true; // determines when summaries need to be refreshed
|
||||
alertSummary.alerts.forEach((summary) => {
|
||||
if (summary.related_summary_id === null) refreshAlertsSummaries = false;
|
||||
});
|
||||
|
||||
if (
|
||||
(newStatus === 'reassigned' && refreshAlertsSummaries) || // check if all alerts from summary were reassigned
|
||||
newStatus === 'untriaged' // or check if alert summary was reset
|
||||
) {
|
||||
// refresh all summaries for current page
|
||||
fetchAlertSummaries(undefined, false);
|
||||
} else {
|
||||
// refresh in place targeted summaries
|
||||
summariesToUpdate.forEach((summary) => fetchAlertSummaries(summary.id));
|
||||
}
|
||||
|
||||
this.clearSelectedAlerts();
|
||||
};
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ class AlertsView extends React.Component {
|
|||
|
||||
// used with the id argument to update one specific alert summary in the array of
|
||||
// alert summaries that's been updated based on an action taken in the AlertActionPanel
|
||||
if (update) {
|
||||
if (update && summary.results.length !== 0) {
|
||||
const index = alertSummaries.findIndex(
|
||||
(item) => item.id === summary.results[0].id,
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче