Unverified Commit b924a864 authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #13728 from davelopez/21.09_fix_collection_error_handling

[21.09] Fix collection population error handling
parents 3403972c d33b5634
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
<template>
    <div v-if="!jobSourceType || jobSourceType == 'Job' || isTerminal">
    <div v-if="!jobSourceType || jobSourceType == 'Job' || (isTerminal && !isErrored)">
        {{ simpleDescription }}
    </div>
    <div v-else-if="!jobStatesSummary || !jobStatesSummary.hasDetails()">
@@ -52,6 +52,9 @@ export default {
            return DC_VIEW.collectionDescription(this.collection);
        },
        errorDescription() {
            if (this.isPopulationFailed) {
                return `${this.collection.get("populated_state_message")}`;
            }
            var jobCount = this.jobCount;
            var errorCount = this.jobStatesSummary.numInError();
            return `a ${this.collectionTypeDescription} with ${errorCount} / ${jobCount} jobs in error`;
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@ export default {
        isErrored() {
            return this.jobStatesSummary && this.jobStatesSummary.errored();
        },
        isPopulationFailed() {
            return this.jobStatesSummary && this.jobStatesSummary.populationFailed();
        },
        isTerminal() {
            return this.jobStatesSummary && this.jobStatesSummary.terminal();
        },
+9 −0
Original line number Diff line number Diff line
@@ -252,6 +252,15 @@ var DatasetCollection = Backbone.Model.extend(BASE_MVC.LoggableMixin)
                    _.extend(element, {
                        parent_hdca_id: parentHdcaId,
                    });

                    // Warning: MEGA-hack ahead...
                    if (!element.element_type && !element.object) {
                        // The DCE has to be in error state... so we simulate it
                        _.extend(element, {
                            element_type: "hda",
                            object: { state: "error" },
                        });
                    }
                });
                this.elements = new collectionClass(elements);
                //this.debug( 'collectionClass:', this.collectionClass + '', this.elements );
+6 −1
Original line number Diff line number Diff line
@@ -62,11 +62,16 @@ var CollectionView = _super.extend(
        },

        handleWarning: function ($newRender) {
            var $warns = $newRender.find(".elements-warning");
            if (this.model.get("populated_state") === "failed") {
                var error = _l(`${this.model.get("populated_state_message")}`);
                $warns.html(`<div class="errormessagesmall">${error}</div>`);
                return;
            }
            var viewLength = this.views.length;
            var elementCount = this.model.get("element_count");
            if (elementCount && elementCount !== viewLength) {
                var warning = _l(`displaying only ${viewLength} of ${elementCount} items`);
                var $warns = $newRender.find(".elements-warning");
                $warns.html(`<div class="warningmessagesmall">${warning}</div>`);
            }
        },
+6 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ var UPDATE_DELAY = 2000;
var NON_TERMINAL_STATES = ["new", "queued", "running", "waiting"];
var ERROR_STATES = ["error", "deleted"];
var TERMINAL_STATES = ["ok"].concat(ERROR_STATES);
const POPULATED_STATE_FAILED = "failed";
/** Fetch state on add or just wait for polling to start. */
var FETCH_STATE_ON_ADD = false;
var BATCH_FETCH_STATE = true;
@@ -26,8 +27,12 @@ var JobStatesSummary = Backbone.Model.extend({
        return !this.hasDetails() || this.get("populated_state") == "new";
    },

    populationFailed: function () {
        return this.get("populated_state") === POPULATED_STATE_FAILED;
    },

    errored: function () {
        return this.get("populated_state") === "error" || this.anyWithStates(ERROR_STATES);
        return this.populationFailed() || this.anyWithStates(ERROR_STATES);
    },

    states: function () {