Skip to content

Commit

Permalink
DRAFT updating run and result components
Browse files Browse the repository at this point in the history
currently getRuns is not filtering correctly and is displaying runs from
all projects.
  • Loading branch information
mshriver committed Jul 17, 2024
1 parent 4db3840 commit 81334a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
10 changes: 6 additions & 4 deletions frontend/src/result-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { HttpClient } from './services/http';
import { Settings } from './settings';
import {
buildParams,
getActiveProject,
getFilterMode,
getOperationMode,
getOperationsFromField,
Expand All @@ -38,8 +37,11 @@ import {
} from './utilities';
import { FilterTable, MultiValueInput } from './components';
import { OPERATIONS, RESULT_FIELDS } from './constants';
import { IbutsuContext } from './services/context';

export class ResultList extends React.Component {
static contextType = IbutsuContext;

static propTypes = {
location: PropTypes.object,
navigate: PropTypes.func,
Expand Down Expand Up @@ -378,9 +380,9 @@ export class ResultList extends React.Component {
this.setState({rows: [getSpinnerRow(5)], isEmpty: false, isError: false});
let params = {filter: []};
let filters = this.state.filters;
const project = getActiveProject();
if (project) {
filters['project_id'] = {'val': project.id, 'op': 'eq'};
const { primaryObject } = this.context;
if (primaryObject) {
filters['project_id'] = {'val': primaryObject.id, 'op': 'eq'};
}
else if (Object.prototype.hasOwnProperty.call(filters, 'project_id')) {
delete filters['project_id']
Expand Down
21 changes: 11 additions & 10 deletions frontend/src/run-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { Settings } from './settings';
import {
buildBadge,
buildParams,
getActiveProject,
getFilterMode,
getOperationMode,
getOperationsFromField,
Expand All @@ -38,6 +37,7 @@ import {
} from './utilities';
import { MultiValueInput, FilterTable, RunSummary } from './components';
import { OPERATIONS, RUN_FIELDS } from './constants';
import { IbutsuContext } from './services/context';


function runToRow(run, filterFunc) {
Expand Down Expand Up @@ -85,6 +85,8 @@ function runToRow(run, filterFunc) {
}

export class RunList extends React.Component {
static contextType = IbutsuContext;

static propTypes = {
location: PropTypes.object,
navigate: PropTypes.func,
Expand Down Expand Up @@ -136,8 +138,8 @@ export class RunList extends React.Component {
isBoolOpen: false,
};
this.params = new URLSearchParams(props.location.search);
props.eventEmitter.on('projectChange', () => {
this.getRuns();
props.eventEmitter.on('projectChange', (value) => {
this.getRuns(value);
});
}

Expand Down Expand Up @@ -265,7 +267,6 @@ export class RunList extends React.Component {
this.setState({filters: filters, page: 1}, callback);
}


setFilter = (field, value) => {
this.updateFilters(field, 'eq', value, () => {
this.updateUrl();
Expand All @@ -280,7 +281,6 @@ export class RunList extends React.Component {
});
}


removeFilter = id => {
this.updateFilters(id, null, null, () => {
this.updateUrl();
Expand Down Expand Up @@ -309,14 +309,15 @@ export class RunList extends React.Component {
});
}

getRuns() {
getRuns = (handledOject = null) => {
// First, show a spinner
this.setState({rows: [getSpinnerRow(5)], isEmpty: false, isError: false});
let params = {filter: []};
let filters = this.state.filters;
const project = getActiveProject();
if (project) {
filters['project_id'] = {'val': project.id, 'op': 'eq'};
const { primaryObject } = this.context;
const targetObject = handledOject ?? primaryObject;
if (targetObject) {
filters['project_id'] = {'val': targetObject.id, 'op': 'eq'};
}
else if (Object.prototype.hasOwnProperty.call(filters, 'project_id')) {
delete filters['project_id']
Expand Down Expand Up @@ -346,7 +347,7 @@ export class RunList extends React.Component {
console.error('Error fetching run data:', error);
this.setState({rows: [], isEmpty: false, isError: true});
});
}
};

clearFilters = () => {
this.setState({
Expand Down

0 comments on commit 81334a0

Please sign in to comment.