runs: use local error alert and not global alert

In this way it'll continuw polling the backend and restore when the error
condition ends.
This commit is contained in:
Simone Gotti 2019-05-23 23:37:52 +02:00
parent a5bd93ead4
commit bcc00a3543
3 changed files with 34 additions and 4 deletions

View File

@ -1,5 +1,12 @@
<template> <template>
<div> <div>
<div
v-if="fetchRunError"
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
role="alert"
>
<div>{{ fetchRunError }}</div>
</div>
<RunDetail :run="run" :ownertype="ownertype" :ownername="ownername" :projectref="projectref"/> <RunDetail :run="run" :ownertype="ownertype" :ownername="ownername" :projectref="projectref"/>
<div v-if="run"> <div v-if="run">
<div v-if="run.phase != 'setuperror'"> <div v-if="run.phase != 'setuperror'">
@ -69,6 +76,7 @@ export default {
}, },
data() { data() {
return { return {
fetchRunError: null,
run: null, run: null,
polling: null polling: null
}; };
@ -102,9 +110,10 @@ export default {
async fetchRun() { async fetchRun() {
let { data, error } = await fetchRun(this.runid); let { data, error } = await fetchRun(this.runid);
if (error) { if (error) {
this.$store.dispatch("setError", error); this.fetchRunError = error;
return; return;
} }
this.fetchRunError = null;
this.run = data; this.run = data;
// sort tasks by level // sort tasks by level

View File

@ -1,5 +1,12 @@
<template> <template>
<div> <div>
<div
v-if="fetchRunsError"
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
role="alert"
>
<div>{{ fetchRunsError }}</div>
</div>
<div v-if="runs.length > 0"> <div v-if="runs.length > 0">
<ul> <ul>
<li <li
@ -94,6 +101,7 @@ export default {
}, },
data() { data() {
return { return {
fetchRunsError: null,
runs: [], runs: [],
wantedRunsNumber: 25, wantedRunsNumber: 25,
hasMoreRuns: false, hasMoreRuns: false,
@ -185,9 +193,10 @@ export default {
while (!stopFetch) { while (!stopFetch) {
let { data, error } = await fetchRuns(group, startRunID, lastrun); let { data, error } = await fetchRuns(group, startRunID, lastrun);
if (error) { if (error) {
this.$store.dispatch("setError", error); this.fetchRunsError = error;
return; return;
} }
this.fetchRunsError = null;
runCount += data.length; runCount += data.length;
if (runCount >= this.wantedRunsNumber || data.length == 0) { if (runCount >= this.wantedRunsNumber || data.length == 0) {
hasMoreRuns = data.length != 0; hasMoreRuns = data.length != 0;

View File

@ -1,5 +1,13 @@
<template> <template>
<div> <div>
<div
v-if="fetchRunError || fetchTaskError"
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
role="alert"
>
<div>Error fetching Run: {{ fetchRunError }}</div>
<div>Error fetching Task: {{ fetchTaskError }}</div>
</div>
<RunDetail :run="run" :ownertype="ownertype" :ownername="ownername" :projectref="projectref"/> <RunDetail :run="run" :ownertype="ownertype" :ownername="ownername" :projectref="projectref"/>
<div v-if="task != null"> <div v-if="task != null">
<div class="mt-8 mb-4 flex justify-between items-center"> <div class="mt-8 mb-4 flex justify-between items-center">
@ -56,6 +64,8 @@ export default {
}, },
data() { data() {
return { return {
fetchRunError: null,
fetchTaskError: null,
run: null, run: null,
task: null, task: null,
polling: null polling: null
@ -72,17 +82,19 @@ export default {
async fetchRun() { async fetchRun() {
let { data, error } = await fetchRun(this.runid); let { data, error } = await fetchRun(this.runid);
if (error) { if (error) {
this.$store.dispatch("setError", error); this.fetchRunError = error;
return; return;
} }
this.fetchRunError = error;
this.run = data; this.run = data;
}, },
async fetchTask() { async fetchTask() {
let { data, error } = await fetchTask(this.runid, this.taskid); let { data, error } = await fetchTask(this.runid, this.taskid);
if (error) { if (error) {
this.$store.dispatch("setError", error); this.fetchTaskError = error;
return; return;
} }
this.fetchTaskError = error;
this.task = data; this.task = data;
}, },
pollData() { pollData() {