Merge branch 'ide-project-avatar-identicon' into 'master'

Changes empty project avatar to identicon in the IDE

Closes #44298

See merge request gitlab-org/gitlab-ce!17899
This commit is contained in:
Filipa Lacerda 2018-03-21 12:35:57 +00:00
commit 22fc4863d3
3 changed files with 62 additions and 7 deletions

View file

@ -1,13 +1,15 @@
<script> <script>
import projectAvatarImage from '~/vue_shared/components/project_avatar/image.vue'; import ProjectAvatarImage from '~/vue_shared/components/project_avatar/image.vue';
import branchesTree from './ide_project_branches_tree.vue'; import Identicon from '../../vue_shared/components/identicon.vue';
import externalLinks from './ide_external_links.vue'; import BranchesTree from './ide_project_branches_tree.vue';
import ExternalLinks from './ide_external_links.vue';
export default { export default {
components: { components: {
branchesTree, BranchesTree,
externalLinks, ExternalLinks,
projectAvatarImage, ProjectAvatarImage,
Identicon,
}, },
props: { props: {
project: { project: {
@ -25,7 +27,10 @@ export default {
:title="project.name" :title="project.name"
:href="project.web_url" :href="project.web_url"
> >
<div class="avatar-container s40 project-avatar"> <div
v-if="project.avatar_url"
class="avatar-container s40 project-avatar"
>
<project-avatar-image <project-avatar-image
class="avatar-container project-avatar" class="avatar-container project-avatar"
:link-href="project.path" :link-href="project.path"
@ -34,6 +39,12 @@ export default {
:img-size="40" :img-size="40"
/> />
</div> </div>
<identicon
v-else
size-class="s40"
:entity-id="project.id"
:entity-name="project.name"
/>
<div class="sidebar-context-title"> <div class="sidebar-context-title">
{{ project.name }} {{ project.name }}
</div> </div>

View file

@ -0,0 +1,5 @@
---
title: Make project avatar in IDE consistent with the rest of GitLab
merge_request:
author:
type: changed

View file

@ -0,0 +1,39 @@
import Vue from 'vue';
import ProjectTree from '~/ide/components/ide_project_tree.vue';
import createComponent from 'spec/helpers/vue_mount_component_helper';
describe('IDE project tree', () => {
const Component = Vue.extend(ProjectTree);
let vm;
beforeEach(() => {
vm = createComponent(Component, {
project: {
id: 1,
name: 'test',
web_url: gl.TEST_HOST,
avatar_url: '',
branches: [],
},
});
});
afterEach(() => {
vm.$destroy();
});
it('renders identicon when projct has no avatar', () => {
expect(vm.$el.querySelector('.identicon')).not.toBeNull();
});
it('renders avatar image if project has avatar', done => {
vm.project.avatar_url = gl.TEST_HOST;
vm.$nextTick(() => {
expect(vm.$el.querySelector('.identicon')).toBeNull();
expect(vm.$el.querySelector('img.avatar')).not.toBeNull();
done();
});
});
});