summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/commit/pipelines/pipelines_service.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/commit/pipelines/pipelines_service.js')
-rw-r--r--app/assets/javascripts/commit/pipelines/pipelines_service.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/assets/javascripts/commit/pipelines/pipelines_service.js b/app/assets/javascripts/commit/pipelines/pipelines_service.js
new file mode 100644
index 00000000000..8ae98f9bf97
--- /dev/null
+++ b/app/assets/javascripts/commit/pipelines/pipelines_service.js
@@ -0,0 +1,44 @@
+/* globals Vue */
+/* eslint-disable no-unused-vars, no-param-reassign */
+
+/**
+ * Pipelines service.
+ *
+ * Used to fetch the data used to render the pipelines table.
+ * Uses Vue.Resource
+ */
+class PipelinesService {
+
+ /**
+ * FIXME: The url provided to request the pipelines in the new merge request
+ * page already has `.json`.
+ * This should be fixed when the endpoint is improved.
+ *
+ * @param {String} root
+ */
+ constructor(root) {
+ let endpoint;
+
+ if (root.indexOf('.json') === -1) {
+ endpoint = `${root}.json`;
+ } else {
+ endpoint = root;
+ }
+ this.pipelines = Vue.resource(endpoint);
+ }
+
+ /**
+ * Given the root param provided when the class is initialized, will
+ * make a GET request.
+ *
+ * @return {Promise}
+ */
+ all() {
+ return this.pipelines.get();
+ }
+}
+
+window.gl = window.gl || {};
+gl.commits = gl.commits || {};
+gl.commits.pipelines = gl.commits.pipelines || {};
+gl.commits.pipelines.PipelinesService = PipelinesService;