summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/mixins
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2019-01-11 13:12:48 +0000
committerFilipa Lacerda <filipa@gitlab.com>2019-01-11 17:28:16 +0000
commit62707971d585d011f28a47e5e32f19f5c903a665 (patch)
treedd1703780c766230a7b2275a03457c4942fd06da /app/assets/javascripts/pipelines/mixins
parent0f71b4bcb3870710ae821ea111894fc7d95f2a1c (diff)
downloadgitlab-ce-62707971d585d011f28a47e5e32f19f5c903a665.tar.gz
Moves shared code into a mixin
To reduce code duplication between CE and EE components, creates a mixin with the common methods for the graph component
Diffstat (limited to 'app/assets/javascripts/pipelines/mixins')
-rw-r--r--app/assets/javascripts/pipelines/mixins/graph_component_mixin.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/assets/javascripts/pipelines/mixins/graph_component_mixin.js b/app/assets/javascripts/pipelines/mixins/graph_component_mixin.js
new file mode 100644
index 00000000000..66e9476dadf
--- /dev/null
+++ b/app/assets/javascripts/pipelines/mixins/graph_component_mixin.js
@@ -0,0 +1,44 @@
+import _ from 'underscore';
+
+export default {
+ props: {
+ isLoading: {
+ type: Boolean,
+ required: true,
+ },
+ pipeline: {
+ type: Object,
+ required: true,
+ },
+ },
+ computed: {
+ graph() {
+ return this.pipeline.details && this.pipeline.details.stages;
+ },
+ },
+ methods: {
+ capitalizeStageName(name) {
+ const escapedName = _.escape(name);
+ return escapedName.charAt(0).toUpperCase() + escapedName.slice(1);
+ },
+ isFirstColumn(index) {
+ return index === 0;
+ },
+ stageConnectorClass(index, stage) {
+ let className;
+
+ // If it's the first stage column and only has one job
+ if (index === 0 && stage.groups.length === 1) {
+ className = 'no-margin';
+ } else if (index > 0) {
+ // If it is not the first column
+ className = 'left-margin';
+ }
+
+ return className;
+ },
+ refreshPipelineGraph() {
+ this.$emit('refreshPipelineGraph');
+ },
+ },
+};