Commit 818c0aeb authored by Mike Greiling's avatar Mike Greiling

Merge branch 'psi-boards-default-avatar' into 'master'

Remove some unneeded default_avatar complexity

See merge request gitlab-org/gitlab!26748
parents 0edd1b14 4d61a10b
...@@ -84,7 +84,6 @@ export default () => { ...@@ -84,7 +84,6 @@ export default () => {
rootPath: $boardApp.dataset.rootPath, rootPath: $boardApp.dataset.rootPath,
bulkUpdatePath: $boardApp.dataset.bulkUpdatePath, bulkUpdatePath: $boardApp.dataset.bulkUpdatePath,
detailIssue: boardsStore.detail, detailIssue: boardsStore.detail,
defaultAvatar: $boardApp.dataset.defaultAvatar,
}, },
computed: { computed: {
detailIssueVisible() { detailIssueVisible() {
...@@ -130,13 +129,10 @@ export default () => { ...@@ -130,13 +129,10 @@ export default () => {
position = -1; position = -1;
} }
boardsStore.addList( boardsStore.addList({
{ ...listObj,
...listObj, position,
position, });
},
this.defaultAvatar,
);
}); });
boardsStore.addBlankState(); boardsStore.addBlankState();
......
export default class ListAssignee { export default class ListAssignee {
constructor(obj, defaultAvatar) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this.name = obj.name; this.name = obj.name;
this.username = obj.username; this.username = obj.username;
this.avatar = obj.avatar_url || obj.avatar || defaultAvatar; this.avatar = obj.avatar_url || obj.avatar || gon.default_avatar_url;
this.path = obj.path; this.path = obj.path;
this.state = obj.state; this.state = obj.state;
this.webUrl = obj.web_url || obj.webUrl; this.webUrl = obj.web_url || obj.webUrl;
......
...@@ -10,7 +10,7 @@ import IssueProject from './project'; ...@@ -10,7 +10,7 @@ import IssueProject from './project';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
class ListIssue { class ListIssue {
constructor(obj, defaultAvatar) { constructor(obj) {
this.subscribed = obj.subscribed; this.subscribed = obj.subscribed;
this.labels = []; this.labels = [];
this.assignees = []; this.assignees = [];
...@@ -22,11 +22,11 @@ class ListIssue { ...@@ -22,11 +22,11 @@ class ListIssue {
this.closed = obj.closed; this.closed = obj.closed;
this.isLoading = {}; this.isLoading = {};
this.refreshData(obj, defaultAvatar); this.refreshData(obj);
} }
refreshData(obj, defaultAvatar) { refreshData(obj) {
boardsStore.refreshIssueData(this, obj, defaultAvatar); boardsStore.refreshIssueData(this, obj);
} }
addLabel(label) { addLabel(label) {
......
...@@ -36,7 +36,7 @@ const TYPES = { ...@@ -36,7 +36,7 @@ const TYPES = {
}; };
class List { class List {
constructor(obj, defaultAvatar) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this._uid = this.guid(); this._uid = this.guid();
this.position = obj.position; this.position = obj.position;
...@@ -55,7 +55,6 @@ class List { ...@@ -55,7 +55,6 @@ class List {
this.maxIssueCount = Object.hasOwnProperty.call(obj, 'max_issue_count') this.maxIssueCount = Object.hasOwnProperty.call(obj, 'max_issue_count')
? obj.max_issue_count ? obj.max_issue_count
: 0; : 0;
this.defaultAvatar = defaultAvatar;
if (obj.label) { if (obj.label) {
this.label = new ListLabel(obj.label); this.label = new ListLabel(obj.label);
...@@ -156,7 +155,7 @@ class List { ...@@ -156,7 +155,7 @@ class List {
createIssues(data) { createIssues(data) {
data.forEach(issueObj => { data.forEach(issueObj => {
this.addIssue(new ListIssue(issueObj, this.defaultAvatar)); this.addIssue(new ListIssue(issueObj));
}); });
} }
......
...@@ -74,8 +74,8 @@ const boardsStore = { ...@@ -74,8 +74,8 @@ const boardsStore = {
showPage(page) { showPage(page) {
this.state.currentPage = page; this.state.currentPage = page;
}, },
addList(listObj, defaultAvatar) { addList(listObj) {
const list = new List(listObj, defaultAvatar); const list = new List(listObj);
this.state.lists = _.sortBy([...this.state.lists, list], 'position'); this.state.lists = _.sortBy([...this.state.lists, list], 'position');
return list; return list;
...@@ -602,7 +602,7 @@ const boardsStore = { ...@@ -602,7 +602,7 @@ const boardsStore = {
clearMultiSelect() { clearMultiSelect() {
this.multiSelect.list = []; this.multiSelect.list = [];
}, },
refreshIssueData(issue, obj, defaultAvatar) { refreshIssueData(issue, obj) {
issue.id = obj.id; issue.id = obj.id;
issue.iid = obj.iid; issue.iid = obj.iid;
issue.title = obj.title; issue.title = obj.title;
...@@ -631,7 +631,7 @@ const boardsStore = { ...@@ -631,7 +631,7 @@ const boardsStore = {
} }
if (obj.assignees) { if (obj.assignees) {
issue.assignees = obj.assignees.map(a => new ListAssignee(a, defaultAvatar)); issue.assignees = obj.assignees.map(a => new ListAssignee(a));
} }
}, },
}; };
......
...@@ -15,7 +15,6 @@ module BoardsHelper ...@@ -15,7 +15,6 @@ module BoardsHelper
root_path: root_path, root_path: root_path,
full_path: full_path, full_path: full_path,
bulk_update_path: @bulk_issues_path, bulk_update_path: @bulk_issues_path,
default_avatar: image_path(default_avatar),
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s, time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
recent_boards_endpoint: recent_boards_path recent_boards_endpoint: recent_boards_path
} }
......
...@@ -2,8 +2,8 @@ import ListIssue from '~/boards/models/issue'; ...@@ -2,8 +2,8 @@ import ListIssue from '~/boards/models/issue';
import IssueProject from '~/boards/models/project'; import IssueProject from '~/boards/models/project';
class ListIssueEE extends ListIssue { class ListIssueEE extends ListIssue {
constructor(obj, defaultAvatar) { constructor(obj) {
super(obj, defaultAvatar, { super(obj, {
IssueProject, IssueProject,
}); });
......
...@@ -155,18 +155,17 @@ describe('Issue card component', () => { ...@@ -155,18 +155,17 @@ describe('Issue card component', () => {
describe('assignee default avatar', () => { describe('assignee default avatar', () => {
beforeEach(done => { beforeEach(done => {
global.gon.default_avatar_url = 'default_avatar';
wrapper.setProps({ wrapper.setProps({
issue: { issue: {
...wrapper.props('issue'), ...wrapper.props('issue'),
assignees: [ assignees: [
new ListAssignee( new ListAssignee({
{ id: 1,
id: 1, name: 'testing 123',
name: 'testing 123', username: 'test',
username: 'test', }),
},
'default_avatar',
),
], ],
}, },
}); });
...@@ -174,6 +173,10 @@ describe('Issue card component', () => { ...@@ -174,6 +173,10 @@ describe('Issue card component', () => {
wrapper.vm.$nextTick(done); wrapper.vm.$nextTick(done);
}); });
afterEach(() => {
global.gon.default_avatar_url = null;
});
it('displays defaults avatar if users avatar is null', () => { it('displays defaults avatar if users avatar is null', () => {
expect(wrapper.find('.board-card-assignee img').exists()).toBe(true); expect(wrapper.find('.board-card-assignee img').exists()).toBe(true);
expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe( expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe(
......
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