summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-08-31 19:13:43 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-08-31 19:20:34 -0500
commitf925d7748076a3c1c22e8881101b3480711e113c (patch)
tree7319e54b26547030780262a42a6e2fb9bedd4d0b
parent9aef0427eb9986fc27a399ea6b47e1518d6ebdac (diff)
downloadgitlab-ce-add-external-ci-support-to-mr-widget.tar.gz
WIP: Add external pipeline support to MR widgetadd-external-ci-support-to-mr-widget
See https://gitlab.com/gitlab-org/gitlab-ce/issues/30714 Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/33287
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js61
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js2
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js1
-rw-r--r--app/assets/javascripts/vue_shared/components/ci_icon.vue2
-rw-r--r--app/helpers/ci_status_helper.rb49
-rw-r--r--app/serializers/merge_request_entity.rb36
6 files changed, 114 insertions, 37 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js
index 6c2e9ba1d30..2e41c147932 100644
--- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js
+++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.js
@@ -21,10 +21,38 @@ export default {
return statusIconEntityMap.icon_status_failed;
},
stageText() {
- return this.mr.pipeline.details.stages.length > 1 ? 'stages' : 'stage';
+ let stageText = 'stage';
+ if (
+ this.mr.pipeline &&
+ this.mr.pipeline.details &&
+ this.mr.pipeline.details.stages &&
+ this.mr.pipeline.details.stages.length > 1
+ ) {
+ stageText = 'stages';
+ }
+
+ return stageText;
+ },
+ stages() {
+ let stages = [];
+ if (this.mr.pipeline.details && this.mr.pipeline.details.stages) {
+ stages = this.mr.pipeline.details.stages;
+ }
+
+ return stages;
},
status() {
- return this.mr.pipeline.details.status || {};
+ console.log('mr', this.mr);
+ console.log('mr pipeline', this.mr.pipeline);
+ let status = {
+ group: this.mr.ciStatus,
+ };
+ if (this.mr.pipeline && this.mr.pipeline.details) {
+ status = this.mr.pipeline.details.status;
+ }
+
+ console.log('mr status', status);
+ return status;
},
},
template: `
@@ -44,33 +72,42 @@ export default {
<div class="ci-status-icon append-right-10">
<a
class="icon-link"
- :href="this.status.details_path">
+ :href="status.details_path">
<ci-icon :status="status" />
</a>
</div>
<div class="media-body">
- <span>
+ <span v-if="mr.pipeline.id">
Pipeline
<a
:href="mr.pipeline.path"
class="pipeline-id">#{{mr.pipeline.id}}</a>
</span>
- <span class="mr-widget-pipeline-graph">
+ <span v-else>
+ External pipeline
+ </span>
+ <span
+ v-if="stages.length > 0"
+ class="mr-widget-pipeline-graph">
<span class="stage-cell">
<div
- v-if="mr.pipeline.details.stages.length > 0"
- v-for="stage in mr.pipeline.details.stages"
+ v-for="stage in stages"
class="stage-container dropdown js-mini-pipeline-graph">
<pipeline-stage :stage="stage" />
</div>
</span>
</span>
+ <span v-else>
+ <pipeline-stage :stage="status" disable-dropdown="true" />
+ </span>
<span>
- {{mr.pipeline.details.status.label}} for
- <a
- :href="mr.pipeline.commit.commit_path"
- class="commit-sha js-commit-link">
- {{mr.pipeline.commit.short_id}}</a>.
+ {{status.label}}
+ <template v-if="mr.pipeline.commit">for
+ <a
+ :href="mr.pipeline.commit.commit_path"
+ class="commit-sha js-commit-link">
+ {{mr.pipeline.commit.short_id}}</a>.
+ </template>
</span>
<span
v-if="mr.pipeline.coverage"
diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
index 0042c48816f..92d9b8be130 100644
--- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
+++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
@@ -85,6 +85,7 @@ export default {
.then(res => res.json())
.then((res) => {
this.handleNotification(res);
+ console.log('checkStatus request', res);
this.mr.setData(res);
this.setFavicon();
@@ -177,6 +178,7 @@ export default {
});
eventHub.$on('UpdateWidgetData', (data) => {
+ console.log('UpdateWidgetData', data);
this.mr.setData(data);
});
diff --git a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
index fbea764b739..bb40d9e29b9 100644
--- a/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
+++ b/app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
@@ -11,6 +11,7 @@ export default class MergeRequestStore {
}
setData(data) {
+ console.log('setData', data);
const currentUser = data.current_user;
const pipelineStatus = data.pipeline ? data.pipeline.details.status : null;
diff --git a/app/assets/javascripts/vue_shared/components/ci_icon.vue b/app/assets/javascripts/vue_shared/components/ci_icon.vue
index ec88119e16c..71b3ec10ea2 100644
--- a/app/assets/javascripts/vue_shared/components/ci_icon.vue
+++ b/app/assets/javascripts/vue_shared/components/ci_icon.vue
@@ -32,7 +32,7 @@
computed: {
statusIconSvg() {
- return statusIconEntityMap[this.status.icon];
+ return statusIconEntityMap[this.status.icon || `icon_status_${this.status.group}`];
},
cssClass() {
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index 8022547a6ad..65d18cd9a35 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -61,34 +61,37 @@ module CiStatusHelper
status.humanize
end
+ def ci_icon_name_for_status(status)
+ case status
+ when 'success'
+ 'icon_status_success'
+ when 'success_with_warnings'
+ 'icon_status_warning'
+ when 'failed'
+ 'icon_status_failed'
+ when 'pending'
+ 'icon_status_pending'
+ when 'running'
+ 'icon_status_running'
+ when 'play'
+ 'icon_play'
+ when 'created'
+ 'icon_status_created'
+ when 'skipped'
+ 'icon_status_skipped'
+ when 'manual'
+ 'icon_status_manual'
+ else
+ 'icon_status_canceled'
+ end
+ end
+
def ci_icon_for_status(status)
if detailed_status?(status)
return custom_icon(status.icon)
end
- icon_name =
- case status
- when 'success'
- 'icon_status_success'
- when 'success_with_warnings'
- 'icon_status_warning'
- when 'failed'
- 'icon_status_failed'
- when 'pending'
- 'icon_status_pending'
- when 'running'
- 'icon_status_running'
- when 'play'
- 'icon_play'
- when 'created'
- 'icon_status_created'
- when 'skipped'
- 'icon_status_skipped'
- when 'manual'
- 'icon_status_manual'
- else
- 'icon_status_canceled'
- end
+ icon_name = ci_icon_name_for_status(status)
custom_icon(icon_name)
end
diff --git a/app/serializers/merge_request_entity.rb b/app/serializers/merge_request_entity.rb
index 07650ce6f20..5362597c5d8 100644
--- a/app/serializers/merge_request_entity.rb
+++ b/app/serializers/merge_request_entity.rb
@@ -1,5 +1,7 @@
class MergeRequestEntity < IssuableEntity
include RequestAwareEntity
+ include MergeRequestsHelper
+ include CiStatusHelper
expose :in_progress_merge_commit_sha
expose :merge_commit_sha
@@ -28,7 +30,6 @@ class MergeRequestEntity < IssuableEntity
expose :merge_commit_sha
expose :merge_commit_message
- expose :head_pipeline, with: PipelineDetailsEntity, as: :pipeline
# Booleans
expose :merge_ongoing?, as: :merge_ongoing
@@ -54,6 +55,39 @@ class MergeRequestEntity < IssuableEntity
expose :ci_status do |merge_request|
presenter(merge_request).ci_status
end
+ #expose :head_pipeline, with: PipelineDetailsEntity, as: :pipeline
+ expose :pipeline do |merge_request|
+ ci_service = merge_request.source_project.try(:ci_service)
+ if ci_service
+ group_status = presenter(merge_request).ci_status
+ details_path = ci_build_details_path(merge_request)
+
+ status_map = {
+ icon: ci_icon_name_for_status(group_status),
+ text: ci_text_for_status(group_status),
+ label: ci_label_for_status(group_status),
+ group: group_status,
+ has_details: !details_path.nil?,
+ details_path: details_path
+ }
+
+ {
+ details: {
+ status: status_map,
+ stages: [{
+ name: 'Build',
+ title: "Build: #{ci_label_for_status(group_status)}",
+ status: status_map
+ }]
+ }
+ }
+ else
+ # Currently doesn't work, `undefined method expose for #<MergeRequestEntity:xxx>`
+ # https://github.com/ruby-grape/grape-entity#merge-fields
+ # https://github.com/ruby-grape/grape-entity/issues/191
+ expose :head_pipeline, merge: true, with: PipelineDetailsEntity
+ end
+ end
expose :issues_links do
expose :assign_to_closing do |merge_request|