Commit d5bd70a7 authored by Bryce Johnson's avatar Bryce Johnson

Remove unneeded code upon UX spec change.

parent c74c79e5
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
}, },
approverNamesStringified() { approverNamesStringified() {
const approvers = this.suggestedApprovers; const approvers = this.suggestedApprovers;
if (approvers.length === 1) { return approvers.length === 1 ? approvers[0].name :
return approvers[0].name; approvers.reduce((memo, curr, index) => {
} else {
return approvers.reduce((memo, curr, index) => {
const nextMemo = `${memo}${curr.name}`; const nextMemo = `${memo}${curr.name}`;
if (index === approvers.length - 2) { // second to last index if (index === approvers.length - 2) { // second to last index
...@@ -27,25 +25,18 @@ ...@@ -27,25 +25,18 @@
return `${nextMemo}, `; return `${nextMemo}, `;
}, ''); }, '');
} }
return null;
}, },
showApproveButton() { showApproveButton() {
return this.userCanApprove && !this.userHasApproved; return this.userCanApprove && !this.userHasApproved;
}, },
showApprovalsBody() {
return !this.widgetLoading;
}
}, },
methods: { methods: {
approveMergeRequest() { approveMergeRequest() {
return gl.ApprovalsStore.approve(); return gl.ApprovalsStore.approve();
}, },
}, },
beforeCreate() {
gl.ApprovalsStore.initStoreOnce();
},
template: ` template: `
<div class='approvals-body mr-widget-body' v-if='showApprovalsBody'> <div class='approvals-body mr-widget-body'>
<h4> Requires {{ approvalsRequiredStringified }} <h4> Requires {{ approvalsRequiredStringified }}
<span v-if='!!suggestedApprovers.length'> (from {{ approverNamesStringified }}) </span> <span v-if='!!suggestedApprovers.length'> (from {{ approverNamesStringified }}) </span>
</h4> </h4>
......
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
Vue.component('approvals-footer', { Vue.component('approvals-footer', {
name: 'approvals-footer', name: 'approvals-footer',
props: ['userCanApprove', 'userHasApproved', 'approvedBy', 'approvalsLeft', 'pendingAvatarSvg', 'checkmarkSvg'], props: ['userCanApprove', 'userHasApproved', 'approvedBy', 'approvalsLeft', 'pendingAvatarSvg', 'checkmarkSvg'],
data() {
return {
loaded: false,
};
},
computed: { computed: {
hasApprovers() { hasApprovers() {
return this.approvedBy && this.approvedBy.length; return this.approvedBy && this.approvedBy.length;
...@@ -23,20 +18,14 @@ ...@@ -23,20 +18,14 @@
gl.ApprovalsStore.unapprove(); gl.ApprovalsStore.unapprove();
}, },
}, },
beforeCreate() {
gl.ApprovalsStore.initStoreOnce().then(() => {
this.loaded = true;
});
},
template: ` template: `
<div v-if='loaded' class='mr-widget-footer approved-by-users approvals-footer clearfix'> <div class='mr-widget-footer approved-by-users approvals-footer clearfix'>
<span class='approvers-prefix'> Approved by </span> <span class='approvers-prefix'> Approved by </span>
<span v-for='approver in approvedBy'> <span v-for='approver in approvedBy'>
<link-to-member-avatar <link-to-member-avatar
extra-link-class='approver-avatar' extra-link-class='approver-avatar'
:avatar-url='approver.user.avatar_url' :avatar-url='approver.user.avatar_url'
:display-name='approver.user.name' :display-name='approver.user.name'
:username='approver.user.username'
:profile-url='approver.user.web_url' :profile-url='approver.user.web_url'
:avatar-html='checkmarkSvg' :avatar-html='checkmarkSvg'
:show-tooltip='true'> :show-tooltip='true'>
......
...@@ -15,56 +15,29 @@ ...@@ -15,56 +15,29 @@
init(rootStore) { init(rootStore) {
this.rootStore = rootStore; this.rootStore = rootStore;
this.api = new gl.ApprovalsApi(rootStore.dataset.endpoint); this.api = new gl.ApprovalsApi(rootStore.dataset.endpoint);
this.state = {
loading: false,
};
}
initStoreOnce() {
const state = this.state;
if (!state.loading) {
state.loading = true;
return this.fetch()
.then(() => {
state.loading = false;
this.assignToRootStore(false, 'loading');
})
.catch((err) => {
console.error(`Failed to initialize approvals store: ${err}`);
});
}
return Promise.resolve();
} }
fetch() { fetch() {
return this.api.fetchApprovals() return this.api.fetchApprovals()
.then(res => this.assignToRootStore(res.data)); .then(res => this.assignToRootStore('approvals', res.data));
} }
approve() { approve() {
return this.api.approveMergeRequest() return this.api.approveMergeRequest()
.then(res => this.assignToRootStore(res.data)) .then(res => this.assignToRootStore('approvals', res.data))
.then(data => this.maybeHideWidgetBody(data.approvals_left)); .then(data => this.maybeHideWidgetBody(data.approvals_left));
} }
unapprove() { unapprove() {
return this.api.unapproveMergeRequest() return this.api.unapproveMergeRequest()
.then(res => this.assignToRootStore(res.data)) .then(res => this.assignToRootStore('approvals', res.data))
.then(data => this.maybeHideWidgetBody(data.approvals_left)); .then(data => this.maybeHideWidgetBody(data.approvals_left));
} }
assignToRootStore(data, key = 'approvals') { assignToRootStore(key, data) {
return this.rootStore.assignToData(key, data); return this.rootStore.assignToData(key, data);
} }
maybeHideWidgetBody(approvalsLeft) {
if (!approvalsLeft) {
this.assignToRootStore(false, 'showWidgetBody');
}
}
} }
gl.ApprovalsStore = ApprovalsStore; gl.ApprovalsStore = ApprovalsStore;
})(); })();
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
assignToData(key, val) { assignToData(key, val) {
this.data[key] = val; this.data[key] = val;
return this.data[key]; return val;
} }
} }
gl.MergeRequestWidgetStore = MergeRequestWidgetStore; gl.MergeRequestWidgetStore = MergeRequestWidgetStore;
......
/* 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
*/
(() => { (() => {
Vue.component('link-to-member-avatar', { Vue.component('link-to-member-avatar', {
props: { props: {
avatarUrl: { avatarUrl: {
type: String, type: String,
required: false required: true,
}, },
username: { profileUrl: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
displayName: { displayName: {
type: String, type: String,
...@@ -33,11 +31,6 @@ ...@@ -33,11 +31,6 @@
required: false, required: false,
default: false, default: false,
}, },
size: {
type: Number,
default: 32,
required: false
},
nonUser: { nonUser: {
type: Boolean, type: Boolean,
default: false, default: false,
...@@ -50,6 +43,11 @@ ...@@ -50,6 +43,11 @@
avatarHtml: { avatarHtml: {
type: String, type: String,
required: false, required: false,
},
size: {
type: Number,
required: false,
default: 32,
} }
}, },
data() { data() {
...@@ -60,7 +58,7 @@ ...@@ -60,7 +58,7 @@
}, },
computed: { computed: {
avatarSizeClass() { avatarSizeClass() {
return `s${this.size}`; return `s{this.avatarSizeClass}`;
}, },
avatarHtmlClass() { avatarHtmlClass() {
return `${this.avatarSizeClass} ${this.defaultAvatarClass}`; return `${this.avatarSizeClass} ${this.defaultAvatarClass}`;
...@@ -68,9 +66,6 @@ ...@@ -68,9 +66,6 @@
avatarElemId() { avatarElemId() {
return this.username ? `${this.username}-avatar-link` : 'non-user-avatar-link'; return this.username ? `${this.username}-avatar-link` : 'non-user-avatar-link';
}, },
userProfileUrl() {
return this.nonUser || !this.username ? '' : `/${this.username}`;
},
preppedAvatarUrl() { preppedAvatarUrl() {
return this.avatarUrl || this.noAvatarUrl; return this.avatarUrl || this.noAvatarUrl;
}, },
...@@ -90,14 +85,9 @@ ...@@ -90,14 +85,9 @@
return this.tooltipContainer || `#${this.avatarElemId}`; return this.tooltipContainer || `#${this.avatarElemId}`;
}, },
}, },
methods: {
pixelizeValue(size) {
return size + 'px';
},
},
template: ` template: `
<div class='link-to-member-avatar' :id='avatarElemId'> <div class='link-to-member-avatar' :id='avatarElemId'>
<a :href='userProfileUrl' :class='linkClass' :data-original-title='displayName' :data-container='tooltipContainerAttr'> <a :href='profileUrl' :class='linkClass' :data-original-title='displayName' :data-container='tooltipContainerAttr'>
<svg v-if='avatarHtml' v-html='avatarHtml' :class='avatarHtmlClass' :width='size' :height='size' :alt='displayName'></svg> <svg v-if='avatarHtml' v-html='avatarHtml' :class='avatarHtmlClass' :width='size' :height='size' :alt='displayName'></svg>
<img :class='avatarClass' :src='preppedAvatarUrl' :width='size' :height='size' :alt='displayName'/> <img :class='avatarClass' :src='preppedAvatarUrl' :width='size' :height='size' :alt='displayName'/>
</a> </a>
......
...@@ -468,7 +468,7 @@ ...@@ -468,7 +468,7 @@
padding-left: 15px; padding-left: 15px;
margin-left: 10px; margin-left: 10px;
&:hover { &:hover {
color: lighten($gl-gray, 10%); color: $btn-gray-light;
} }
} }
......
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
#merge-request-widget-app.mr-state-widget{ 'data-endpoint'=> merge_request_path(@merge_request) } #merge-request-widget-app.mr-state-widget{ 'data-endpoint'=> merge_request_path(@merge_request) }
= render 'projects/merge_requests/widget/heading' = render 'projects/merge_requests/widget/heading'
.mr-widget-body .mr-widget-body
- if @merge_request.requires_approve?
.loading{ 'v-show' => 'loading' }
= icon('spinner spin')
= render 'projects/merge_requests/widget/open/approvals_body'
= render 'projects/merge_requests/widget/open/approvals_footer'
-# After conflicts are resolved, the user is redirected back to the MR page. -# After conflicts are resolved, the user is redirected back to the MR page.
-# There is a short window before background workers run and GitLab processes -# There is a short window before background workers run and GitLab processes
-# the new push and commits, during which it will think the conflicts still exist. -# the new push and commits, during which it will think the conflicts still exist.
...@@ -48,8 +55,3 @@ ...@@ -48,8 +55,3 @@
!= markdown issues_sentence(mr_closes_issues), pipeline: :gfm, author: @merge_request.author != markdown issues_sentence(mr_closes_issues), pipeline: :gfm, author: @merge_request.author
= mr_assign_issues_link = mr_assign_issues_link
- if @merge_request.requires_approve?
= render 'projects/merge_requests/widget/open/approvals_body'
= render 'projects/merge_requests/widget/open/approvals_footer'
.loading{ 'v-show' => 'loading' }
= icon('spinner spin')
%approvals-body{':user-can-approve' => 'approvals.user_can_approve', ':user-has-approved' => 'approvals.user_has_approved', ':approved-by' => 'approvals.approved_by', ':approvals-left':'approvals.approvals_left', ':suggested-approvers' => 'approvals.suggested_approvers', ':widget-loading' => 'loading'} %approvals-body{':user-can-approve' => 'approvals.user_can_approve', ':user-has-approved' => 'approvals.user_has_approved', ':approved-by' => 'approvals.approved_by', ':approvals-left':'approvals.approvals_left', ':suggested-approvers' => 'approvals.suggested_approvers', ':widget-loading' => 'loading'}
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
//= require jquery //= require jquery
//= require merge_request_widget/approvals/components/approvals_body //= require merge_request_widget/approvals/components/approvals_body
// - showapprovebutton
//
(() => { (() => {
gl.ApprovalsStore = { gl.ApprovalsStore = {
data: {}, data: {},
...@@ -38,7 +35,6 @@ ...@@ -38,7 +35,6 @@
this.approvalsBody = new ApprovalsBodyComponent({ this.approvalsBody = new ApprovalsBodyComponent({
el: '#mock-container', el: '#mock-container',
propsData: this.initialData, propsData: this.initialData,
beforeCreate() {},
}); });
} }
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
}); });
it('should correctly compute computed values', function() { it('should correctly compute computed values', function() {
// disabledclass, avatarClass, tooltipClass, userProfileUrl, preppedAvatarUrl, linkClass, tooltipClass
const correctVals = { const correctVals = {
'disabledClass': 'disabled', 'disabledClass': 'disabled',
'avatarClass': 'avatar avatar-inline s48 ', 'avatarClass': 'avatar avatar-inline s48 ',
...@@ -81,7 +80,6 @@ ...@@ -81,7 +80,6 @@
}); });
it('should correctly compute computed values', function(done) { it('should correctly compute computed values', function(done) {
// disabledclass, avatarClass, tooltipClass, userProfileUrl, preppedAvatarUrl, linkClass, tooltipClass
const correctVals = { const correctVals = {
'disabledClass': '', 'disabledClass': '',
'avatarClass': 'avatar avatar-inline s48 ', 'avatarClass': 'avatar avatar-inline s48 ',
...@@ -100,16 +98,5 @@ ...@@ -100,16 +98,5 @@
}); });
}); });
}); });
describe('Interaction', function() {
it('should remove approval', function() {
});
it('should give approval', function() {
});
// click link and handler fires
});
}); });
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
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