From 64857a9bf3bd64eaf543ae1d43e02344e287403b Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 1 Mar 2018 17:40:00 +0000 Subject: Manage empty states in Pipelines page Adds i18n Adds test Fix broken tests Fixes empty tab state for external CI --- .../commit/pipelines/pipelines_table.vue | 38 +- .../pages/projects/pipelines/index/index.js | 14 + .../pipelines/components/blank_state.vue | 32 + .../pipelines/components/empty_state.vue | 49 +- .../pipelines/components/error_state.vue | 26 - .../pipelines/components/nav_controls.vue | 81 +-- .../javascripts/pipelines/components/pipelines.vue | 250 +++++--- .../javascripts/pipelines/mixins/pipelines.js | 25 +- .../pipelines/stores/pipelines_store.js | 7 +- app/views/projects/pipelines/index.html.haml | 9 +- .../unreleased/38587-pipelines-empty-state.yml | 5 + spec/features/projects/pipelines/pipelines_spec.rb | 39 +- spec/javascripts/pipelines/blank_state_spec.js | 29 + spec/javascripts/pipelines/empty_state_spec.js | 28 +- spec/javascripts/pipelines/error_state_spec.js | 27 - spec/javascripts/pipelines/nav_controls_spec.js | 84 +-- spec/javascripts/pipelines/pipelines_spec.js | 677 ++++++++++++++++++--- spec/javascripts/pipelines/pipelines_store_spec.js | 7 +- 18 files changed, 996 insertions(+), 431 deletions(-) create mode 100644 app/assets/javascripts/pipelines/components/blank_state.vue delete mode 100644 app/assets/javascripts/pipelines/components/error_state.vue create mode 100644 changelogs/unreleased/38587-pipelines-empty-state.yml create mode 100644 spec/javascripts/pipelines/blank_state_spec.js delete mode 100644 spec/javascripts/pipelines/error_state_spec.js diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.vue b/app/assets/javascripts/commit/pipelines/pipelines_table.vue index ce19069f103..3b3072ebd3e 100644 --- a/app/assets/javascripts/commit/pipelines/pipelines_table.vue +++ b/app/assets/javascripts/commit/pipelines/pipelines_table.vue @@ -20,10 +20,6 @@ type: String, required: true, }, - emptyStateSvgPath: { - type: String, - required: true, - }, errorStateSvgPath: { type: String, required: true, @@ -45,23 +41,14 @@ }, computed: { - /** - * Empty state is only rendered if after the first request we receive no pipelines. - * - * @return {Boolean} - */ - shouldRenderEmptyState() { - return !this.state.pipelines.length && - !this.isLoading && - this.hasMadeRequest && - !this.hasError; - }, - shouldRenderTable() { return !this.isLoading && this.state.pipelines.length > 0 && !this.hasError; }, + shouldRenderErrorState() { + return this.hasError && !this.isLoading; + }, }, created() { this.service = new PipelinesService(this.endpoint); @@ -92,25 +79,22 @@
- - -
new Vue({ return { store, + dataset: document.querySelector(this.$options.el).dataset, }; }, + render(createElement) { return createElement('pipelines-component', { props: { store: this.store, + endpoint: this.dataset.endpoint, + helpPagePath: this.dataset.helpPagePath, + emptyStateSvgPath: this.dataset.emptyStateSvgPath, + errorStateSvgPath: this.dataset.errorStateSvgPath, + noPipelinesSvgPath: this.dataset.noPipelinesSvgPath, + autoDevopsPath: this.dataset.helpAutoDevopsPath, + newPipelinePath: this.dataset.newPipelinePath, + canCreatePipeline: convertPermissionToBoolean(this.dataset.canCreatePipeline), + hasGitlabCi: convertPermissionToBoolean(this.dataset.hasGitlabCi), + ciLintPath: this.dataset.ciLintPath, + resetCachePath: this.dataset.resetCachePath, }, }); }, diff --git a/app/assets/javascripts/pipelines/components/blank_state.vue b/app/assets/javascripts/pipelines/components/blank_state.vue new file mode 100644 index 00000000000..8d3d6223d7b --- /dev/null +++ b/app/assets/javascripts/pipelines/components/blank_state.vue @@ -0,0 +1,32 @@ + + + diff --git a/app/assets/javascripts/pipelines/components/empty_state.vue b/app/assets/javascripts/pipelines/components/empty_state.vue index dfaa2574091..51f05c7827e 100644 --- a/app/assets/javascripts/pipelines/components/empty_state.vue +++ b/app/assets/javascripts/pipelines/components/empty_state.vue @@ -1,5 +1,6 @@ @@ -22,22 +27,36 @@
-

- {{ s__("Pipelines|Build with confidence") }} -

-

- {{ s__(`Pipelines|Continous Integration can help -catch bugs by running your tests automatically, -while Continuous Deployment can help you deliver code to your product environment.`) }} + + + +

+ {{ s__('Pipelines|This project is not currently set up to run pipelines.') }}

- +
diff --git a/app/assets/javascripts/pipelines/components/error_state.vue b/app/assets/javascripts/pipelines/components/error_state.vue deleted file mode 100644 index 012853b201d..00000000000 --- a/app/assets/javascripts/pipelines/components/error_state.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/app/assets/javascripts/pipelines/components/nav_controls.vue b/app/assets/javascripts/pipelines/components/nav_controls.vue index f31a91c3403..383ab51fe56 100644 --- a/app/assets/javascripts/pipelines/components/nav_controls.vue +++ b/app/assets/javascripts/pipelines/components/nav_controls.vue @@ -1,67 +1,52 @@ diff --git a/app/assets/javascripts/pipelines/components/pipelines.vue b/app/assets/javascripts/pipelines/components/pipelines.vue index 90930d5ff44..d983d8c0af8 100644 --- a/app/assets/javascripts/pipelines/components/pipelines.vue +++ b/app/assets/javascripts/pipelines/components/pipelines.vue @@ -1,12 +1,12 @@