From 3467fca4f78b6e6b95aa59c7b84905860dc39123 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 25 Jun 2024 15:54:18 -0700 Subject: [PATCH] Add exclude_results to web UI buildset filtering Building on the previous change to add exclude_results to the api, this change adds implicit filtering of buildsets with results of NO_JOBS or DEQUEUED. If a user explicitly filters for results, the implicit exclusions are dropped so that a user may still see a list of DEQUEUED results if desired. The feature to drop the implicit exclusion of SKIPPED results was broken; this change fixes that as well. Change-Id: I5319edb2546a93e3a62e21a76f330e5f8e81548b --- web/src/containers/BuildQuery.jsx | 27 +++++++++++++++------------ web/src/pages/Builds.jsx | 2 +- web/src/pages/Buildsets.jsx | 7 ++++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/web/src/containers/BuildQuery.jsx b/web/src/containers/BuildQuery.jsx index e5f6bc050b..663e96d865 100644 --- a/web/src/containers/BuildQuery.jsx +++ b/web/src/containers/BuildQuery.jsx @@ -15,21 +15,24 @@ import { makeQueryString } from './FilterToolbar' -function makeBuildQueryString(filters, excludeResults) { +function makeBuildQueryString(filters) { let queryString = makeQueryString(filters) - let resultFilter = false - if (filters) { - Object.keys(filters).forEach((key) => { - if (filters[key] === 'result') { - resultFilter = true - } - }) - } - if (excludeResults && !resultFilter) { - queryString += '&exclude_result=SKIPPED' + const resultFilter = filters && filters['result'].length > 0 + if (!resultFilter) { + queryString += '&exclude_result=SKIPPED' } queryString += '&complete=true' return queryString } -export { makeBuildQueryString } +function makeBuildsetQueryString(filters) { + let queryString = makeQueryString(filters) + const resultFilter = filters && filters['result'].length > 0 + if (!resultFilter) { + queryString += '&exclude_result=NO_JOBS&exclude_result=DEQUEUED' + } + queryString += '&complete=true' + return queryString +} + +export { makeBuildQueryString, makeBuildsetQueryString } diff --git a/web/src/pages/Builds.jsx b/web/src/pages/Builds.jsx index 404af00cc1..db115eeceb 100644 --- a/web/src/pages/Builds.jsx +++ b/web/src/pages/Builds.jsx @@ -158,7 +158,7 @@ class BuildsPage extends React.Component { limit: filters.limit.length > 0 ? filters.limit : [50,] } let _filters = { ...filters, ...paginationOptions } - const queryString = makeBuildQueryString(_filters, true) + const queryString = makeBuildQueryString(_filters) this.setState({ fetching: true }) // TODO (felix): What happens in case of a broken network connection? Is the // fetching shows infinitely or can we catch this and show an erro state in diff --git a/web/src/pages/Buildsets.jsx b/web/src/pages/Buildsets.jsx index ab6b9d3369..72f52b3a9f 100644 --- a/web/src/pages/Buildsets.jsx +++ b/web/src/pages/Buildsets.jsx @@ -24,7 +24,7 @@ import { getFiltersFromUrl, writeFiltersToUrl, } from '../containers/FilterToolbar' -import { makeBuildQueryString } from '../containers/BuildQuery' +import { makeBuildsetQueryString } from '../containers/BuildQuery' import BuildsetTable from '../containers/build/BuildsetTable' class BuildsetsPage extends React.Component { @@ -67,13 +67,14 @@ class BuildsetsPage extends React.Component { title: 'Result', placeholder: 'Filter by Result...', type: 'select', - // are there more? options: [ 'SUCCESS', 'FAILURE', 'MERGE_CONFLICT', 'MERGE_FAILURE', 'DEQUEUED', + 'CONFIG_ERROR', + 'NO_JOBS', ] }, { @@ -115,7 +116,7 @@ class BuildsetsPage extends React.Component { limit: filters.limit.length > 0 ? filters.limit : [50,] } let _filters = { ...filters, ...paginationOptions } - const queryString = makeBuildQueryString(_filters) + const queryString = makeBuildsetQueryString(_filters) this.setState({ fetching: true }) fetchBuildsets(this.props.tenant.apiPrefix, queryString).then( (response) => {