Commit 2422dc50 authored by Bryce Johnson's avatar Bryce Johnson

Remove inter-dependencies on vue.

parent e5ae6a9f
...@@ -872,8 +872,8 @@ DEPENDENCIES ...@@ -872,8 +872,8 @@ DEPENDENCIES
gollum-rugged_adapter (~> 0.4.2) gollum-rugged_adapter (~> 0.4.2)
gon (~> 6.1.0) gon (~> 6.1.0)
grape (~> 0.15.0) grape (~> 0.15.0)
gssapi
grape-entity (~> 0.6.0) grape-entity (~> 0.6.0)
gssapi
haml_lint (~> 0.18.2) haml_lint (~> 0.18.2)
hamlit (~> 2.6.1) hamlit (~> 2.6.1)
health_check (~> 2.2.0) health_check (~> 2.2.0)
......
/* eslint-disable */ /* eslint-disable */
//= require vue
//= require vue-resource
//= require_directory ./models //= require_directory ./models
//= require_directory ./stores //= require_directory ./stores
//= require_directory ./services //= require_directory ./services
......
//= require ../stores/approvals_store //= require ../stores/approvals_store
//= require subbable_resource
(() => { (() => {
class ApprovalsApi { class ApprovalsApi {
...@@ -9,25 +8,24 @@ ...@@ -9,25 +8,24 @@
} }
init(mergeRequestEndpoint) { init(mergeRequestEndpoint) {
const approvalsEndpoint = `${mergeRequestEndpoint}/approvals`; const approvalsEndpoint = `${mergeRequestEndpoint}/approvals.json`;
this.resource = gl.ApprovalsResource = new gl.SubbableResource(approvalsEndpoint); this.resource = gl.ApprovalsResource = new gl.SubbableResource(approvalsEndpoint);
} }
fetchApprovals() { fetchApprovals() {
return this.resource.get().fail((err) => { return this.resource.get({ type: 'GET' }).fail((err) => {
console.error(`Error fetching approvals. ${err}`); console.error(`Error fetching approvals. ${err}`);
}); });
} }
approveMergeRequest() { approveMergeRequest() {
return this.resource.post().fail((err) => { return this.resource.post({ type: 'POST' }).fail((err) => {
console.error(`Error approving merge request. ${err}`); console.error(`Error approving merge request. ${err}`);
}); });
} }
unapproveMergeRequest() { unapproveMergeRequest() {
return this.resource.delete().fail((err) => { return this.resource.delete({ type: 'DELETE' }).fail((err) => {
console.error(`Error unapproving merge request. ${err}`); console.error(`Error unapproving merge request. ${err}`);
}); });
} }
......
...@@ -22,17 +22,17 @@ ...@@ -22,17 +22,17 @@
} }
fetch() { fetch() {
return this.api.fetchApprovals({ type: 'GET' }) return this.api.fetchApprovals()
.then((data) => this.rootStore.assignToData(data)); .then((data) => this.rootStore.assignToData(data));
} }
approve() { approve() {
return this.api.approveMergeRequest({ type: 'POST' }) return this.api.approveMergeRequest()
.then((data) => this.rootStore.assignToData(data)); .then((data) => this.rootStore.assignToData(data));
} }
unapprove() { unapprove() {
return this.api.unapproveMergeRequest({ type: 'DELETE' }) return this.api.unapproveMergeRequest()
.then((data) => this.rootStore.assignToData(data)); .then((data) => this.rootStore.assignToData(data));
} }
} }
......
(() => { (() => {
/* /*
* SubbableResource can be extended to provide a pubsub-style service for one-off REST * SubbableResource can be extended to provide a pubsub-style service for one-off REST
* calls. Subscribe by passing a callback or render method you will use to handle responses. * calls. Subscribe by passing a callback or render method you will use to handle responses.
*
* TODO: Provide support for matchers
* *
* */ * */
class SubbableResource { class SubbableResource {
constructor(resourcePath) { constructor(resourcePath, test) {
this.endpoint = resourcePath; this.endpoint = resourcePath;
this.defaultPayload = { url: resourcePath };
// TODO: Switch to axios.create // TODO: Switch to axios.create asap
this.resource = $.ajax; this.resource = $.ajax;
this.subscribers = []; this.subscribers = [];
} }
extendDefaultPayload(payload) {
return Object.assign(payload, this.defaultPayload);
}
subscribe(callback) { subscribe(callback) {
this.subscribers.push(callback); this.subscribers.push(callback);
} }
...@@ -27,21 +33,25 @@ ...@@ -27,21 +33,25 @@
} }
get(payload) { get(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload) return this.resource(payload)
.then(data => this.publish(data)); .then(data => this.publish(data));
} }
post(payload) { post(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload) return this.resource(payload)
.then(data => this.publish(data)); .then(data => this.publish(data));
} }
put(payload) { put(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload) return this.resource(payload)
.then(data => this.publish(data)); .then(data => this.publish(data));
} }
delete(payload) { delete(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload) return this.resource(payload)
.then(data => this.publish(data)); .then(data => this.publish(data));
} }
......
/* Analogue of link_to_member_avatar in app/helpers/projects_helper.rb /* Analogue of link_to_member_avatar in app/helpers/projects_helper.rb
TODO: Support gravatar link generation, adding name text, username text TODO: Support gravatar link generation, adding name text, username text
TODO: 1:1 configuration compared to link_to_member_avatar TODO: 1:1 configuration compared to link_to_member_avatar
TODO: Backport to CE TODO: Backport to CE
......
...@@ -4,4 +4,5 @@ ...@@ -4,4 +4,5 @@
<i class="fa fa-spinner fa-spin loading-icon"></i> <i class="fa fa-spinner fa-spin loading-icon"></i>
`, `,
}); });
})(); })();
\ No newline at end of file
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
= javascript_include_tag "application" = javascript_include_tag "application"
%script(src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js")
- if content_for?(:page_specific_javascripts) - if content_for?(:page_specific_javascripts)
= yield :page_specific_javascripts = yield :page_specific_javascripts
......
/* eslint-disable */ /* eslint-disable */
//= require jquery //= require jquery
//= require vue
//= require vue_common_component/link_to_member_avatar //= require vue_common_component/link_to_member_avatar
((gl) => { ((gl) => {
...@@ -104,10 +103,10 @@ ...@@ -104,10 +103,10 @@
describe('Interaction', function() { describe('Interaction', function() {
it('should remove approval', function() { it('should remove approval', function() {
}); });
it('should give approval', function() { it('should give approval', function() {
}); });
// click link and handler fires // click link and handler fires
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment