Bug 1571409 - Add a "My alert summaries" checkbox on Alerts view

This commit is contained in:
octavian-negru 2019-10-03 08:46:39 +03:00 коммит произвёл ionutgoldan
Родитель 778cad87b8
Коммит 851b54f298
2 изменённых файлов: 46 добавлений и 12 удалений

Просмотреть файл

@ -89,20 +89,37 @@ export default class AlertTable extends React.Component {
};
filterAlert = alert => {
const { hideImprovements, hideDownstream, filterText } = this.props.filters;
const {
hideImprovements,
hideDownstream,
hideAssignedToOthers,
filterText,
} = this.props.filters;
const { username } = this.props.user;
const { alertSummary } = this.state;
const unconcealableRegression = !hideImprovements || alert.is_regression;
const notRelatedDownstream =
alert.summary_id === alertSummary.id ||
alert.status !== alertStatusMap.downstream;
const concealableReassigned =
hideDownstream &&
alert.status === alertStatusMap.reassigned &&
alert.related_summary_id !== alertSummary.id;
const concealableDownstream =
hideDownstream && alert.status === alertStatusMap.downstream;
const concealableInvalid =
hideDownstream && alert.status === alertStatusMap.invalid;
const concealableAssignedToOthers =
hideAssignedToOthers && alertSummary.assignee_username !== username;
const matchesFilters =
(!hideImprovements || alert.is_regression) &&
(alert.summary_id === alertSummary.id ||
alert.status !== alertStatusMap.downstream) &&
!(
hideDownstream &&
alert.status === alertStatusMap.reassigned &&
alert.related_summary_id !== alertSummary.id
) &&
!(hideDownstream && alert.status === alertStatusMap.downstream) &&
!(hideDownstream && alert.status === alertStatusMap.invalid);
unconcealableRegression &&
notRelatedDownstream &&
!concealableReassigned &&
!concealableDownstream &&
!concealableInvalid &&
!concealableAssignedToOthers;
if (!filterText) return matchesFilters;
@ -320,6 +337,7 @@ AlertTable.propTypes = {
filterText: PropTypes.string,
hideDownstream: PropTypes.bool,
hideImprovements: PropTypes.bool,
hideAssignedToOthers: PropTypes.bool,
}).isRequired,
fetchAlertSummaries: PropTypes.func.isRequired,
updateViewState: PropTypes.func.isRequired,

Просмотреть файл

@ -13,6 +13,10 @@ export default class AlertsViewControls extends React.Component {
this.state = {
hideImprovements: convertParams(this.validated, 'hideImprovements'),
hideDownstream: convertParams(this.validated, 'hideDwnToInv'),
hideAssignedToOthers: convertParams(
this.validated,
'hideAssignedToOthers',
),
filterText: '',
};
}
@ -54,7 +58,11 @@ export default class AlertsViewControls extends React.Component {
fetchAlertSummaries,
user,
} = this.props;
const { hideImprovements, hideDownstream } = this.state;
const {
hideImprovements,
hideDownstream,
hideAssignedToOthers,
} = this.state;
const alertFilters = [
{
@ -69,6 +77,14 @@ export default class AlertsViewControls extends React.Component {
},
];
if (user.isLoggedIn) {
alertFilters.push({
text: 'My alerts',
state: hideAssignedToOthers,
stateName: 'hideAssignedToOthers',
});
}
return (
<React.Fragment>
<FilterControls