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

Remove inter-dependencies on vue.

parent e5ae6a9f
......@@ -872,8 +872,8 @@ DEPENDENCIES
gollum-rugged_adapter (~> 0.4.2)
gon (~> 6.1.0)
grape (~> 0.15.0)
gssapi
grape-entity (~> 0.6.0)
gssapi
haml_lint (~> 0.18.2)
hamlit (~> 2.6.1)
health_check (~> 2.2.0)
......
/* eslint-disable */
//= require vue
//= require vue-resource
//= require_directory ./models
//= require_directory ./stores
//= require_directory ./services
......
//= require ../stores/approvals_store
//= require subbable_resource
(() => {
class ApprovalsApi {
......@@ -9,25 +8,24 @@
}
init(mergeRequestEndpoint) {
const approvalsEndpoint = `${mergeRequestEndpoint}/approvals`;
const approvalsEndpoint = `${mergeRequestEndpoint}/approvals.json`;
this.resource = gl.ApprovalsResource = new gl.SubbableResource(approvalsEndpoint);
}
fetchApprovals() {
return this.resource.get().fail((err) => {
return this.resource.get({ type: 'GET' }).fail((err) => {
console.error(`Error fetching approvals. ${err}`);
});
}
approveMergeRequest() {
return this.resource.post().fail((err) => {
return this.resource.post({ type: 'POST' }).fail((err) => {
console.error(`Error approving merge request. ${err}`);
});
}
unapproveMergeRequest() {
return this.resource.delete().fail((err) => {
return this.resource.delete({ type: 'DELETE' }).fail((err) => {
console.error(`Error unapproving merge request. ${err}`);
});
}
......
......@@ -22,17 +22,17 @@
}
fetch() {
return this.api.fetchApprovals({ type: 'GET' })
return this.api.fetchApprovals()
.then((data) => this.rootStore.assignToData(data));
}
approve() {
return this.api.approveMergeRequest({ type: 'POST' })
return this.api.approveMergeRequest()
.then((data) => this.rootStore.assignToData(data));
}
unapprove() {
return this.api.unapproveMergeRequest({ type: 'DELETE' })
return this.api.unapproveMergeRequest()
.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.
*
* TODO: Provide support for matchers
*
* */
class SubbableResource {
constructor(resourcePath) {
constructor(resourcePath, test) {
this.endpoint = resourcePath;
// TODO: Switch to axios.create
this.defaultPayload = { url: resourcePath };
// TODO: Switch to axios.create asap
this.resource = $.ajax;
this.subscribers = [];
}
extendDefaultPayload(payload) {
return Object.assign(payload, this.defaultPayload);
}
subscribe(callback) {
this.subscribers.push(callback);
}
......@@ -27,21 +33,25 @@
}
get(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload)
.then(data => this.publish(data));
}
post(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload)
.then(data => this.publish(data));
}
put(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload)
.then(data => this.publish(data));
}
delete(payload) {
this.extendDefaultPayload(payload);
return this.resource(payload)
.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: 1:1 configuration compared to link_to_member_avatar
TODO: Backport to CE
......
......@@ -4,4 +4,5 @@
<i class="fa fa-spinner fa-spin loading-icon"></i>
`,
});
})();
\ No newline at end of file
})();
......@@ -30,6 +30,8 @@
= 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)
= yield :page_specific_javascripts
......
/* eslint-disable */
//= require jquery
//= require vue
//= require vue_common_component/link_to_member_avatar
((gl) => {
......@@ -104,10 +103,10 @@
describe('Interaction', function() {
it('should remove approval', function() {
});
it('should give approval', function() {
});
// 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