Add error state to commits and merge requests pipelines table

This commit is contained in:
Filipa Lacerda 2017-03-17 23:07:37 +00:00
parent 016602099b
commit 9d1ab1e9bd
2 changed files with 13 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import PipelinesTableComponent from '../../vue_shared/components/pipelines_table
import PipelinesService from '../../vue_pipelines_index/services/pipelines_service';
import PipelineStore from '../../vue_pipelines_index/stores/pipelines_store';
import eventHub from '../../vue_pipelines_index/event_hub';
import ErrorState from '../../vue_pipelines_index/components/error_state';
import '../../lib/utils/common_utils';
import '../../vue_shared/vue_resource_interceptor';
@ -22,6 +23,7 @@ import '../../vue_shared/vue_resource_interceptor';
export default Vue.component('pipelines-table', {
components: {
'pipelines-table-component': PipelinesTableComponent,
'error-state': ErrorState,
},
/**
@ -39,9 +41,16 @@ export default Vue.component('pipelines-table', {
store,
state: store.state,
isLoading: false,
hasError: false,
};
},
computed: {
shouldRenderErrorState() {
return this.hasError && !this.pageRequest;
},
},
/**
* When the component is about to be mounted, tell the service to fetch the data
*
@ -80,6 +89,7 @@ export default Vue.component('pipelines-table', {
this.isLoading = false;
})
.catch(() => {
this.hasError = true;
this.isLoading = false;
new Flash('An error occurred while fetching the pipelines, please reload the page again.');
});
@ -92,12 +102,7 @@ export default Vue.component('pipelines-table', {
<i class="fa fa-spinner fa-spin"></i>
</div>
<div class="blank-state blank-state-no-icon"
v-if="!isLoading && state.pipelines.length === 0">
<h2 class="blank-state-title js-blank-state-title">
No pipelines to show
</h2>
</div>
<error-state v-if="shouldRenderErrorState" />
<div class="table-holder pipelines"
v-if="!isLoading && state.pipelines.length > 0">

View File

@ -163,6 +163,7 @@ export default {
this.pageRequest = false;
})
.catch(() => {
this.hasError = true;
this.pageRequest = false;
new Flash('An error occurred while fetching the pipelines, please reload the page again.');
});
@ -196,7 +197,7 @@ export default {
<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
</div>
<empty-state v-if="shouldRenderEmptyState" />
<empty-state v-if="shouldRenderEmptyState" :helpPagePath="helpPagePath" />
<error-state v-if="shouldRenderErrorState" />