[Canvas] Fix context elements issue with Element Stats (#32510) (#32540)

## Summary

(closes #32512, closes #32508)

This fixes a bug where element stats was causing a failure due to not every element being an `expressionRenderable` all the time... when first added, `TimeFilter` is `expressionContext` and should be considered `pending`.

This PR also fixes an issue where `resolvedArgs` was not being reset between workpad loads, causing element stats to be compounded.

Co-authored-by: Spencer <email@spalger.com>
This commit is contained in:
Clint Andrew Hall 2019-03-05 21:50:41 -06:00 committed by GitHub
parent da4d4643eb
commit 53d41bfcbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View file

@ -14,7 +14,7 @@ export const ElementConfig = ({ elementStats }) => {
}
const { total, ready, error } = elementStats;
const progress = Math.round(((ready + error) / total) * 100);
const progress = total > 0 ? Math.round(((ready + error) / total) * 100) : 100;
return (
<Fragment>

View file

@ -10,6 +10,7 @@ import { get } from 'lodash';
import { prepend } from '../../lib/modify_path';
import * as actions from '../actions/resolved_args';
import { flushContext, flushContextAfterIndex } from '../actions/elements';
import { setWorkpad } from '../actions/workpad';
/*
Resolved args are a way to handle async values. They track the status, value, and error
@ -130,6 +131,9 @@ export const resolvedArgsReducer = handleActions(
return state;
}, transientState);
},
[setWorkpad]: (transientState, {}) => {
return set(transientState, 'resolvedArgs', {});
},
},
{}
);

View file

@ -90,6 +90,12 @@ export function getElementCounts(state) {
Object.keys(resolvedArgs).forEach(resolvedArg => {
const arg = resolvedArgs[resolvedArg];
const { expressionRenderable } = arg;
if (!expressionRenderable) {
results.pending++;
return;
}
const { value, state } = expressionRenderable;
if (value && value.as === 'error') {