Commit 141ae0d3 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '335364-use-glavatar-in-group_item-vue' into 'master'

Use GlAvatar in `group_item.vue`

See merge request gitlab-org/gitlab!65852
parents 0e5c3de6 08286581
<script> <script>
import { import {
GlAvatar,
GlLoadingIcon, GlLoadingIcon,
GlBadge, GlBadge,
GlIcon, GlIcon,
...@@ -7,7 +8,6 @@ import { ...@@ -7,7 +8,6 @@ import {
GlSafeHtmlDirective, GlSafeHtmlDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import identicon from '~/vue_shared/components/identicon.vue';
import UserAccessRoleBadge from '~/vue_shared/components/user_access_role_badge.vue'; import UserAccessRoleBadge from '~/vue_shared/components/user_access_role_badge.vue';
import { VISIBILITY_TYPE_ICON, GROUP_VISIBILITY_TYPE } from '../constants'; import { VISIBILITY_TYPE_ICON, GROUP_VISIBILITY_TYPE } from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -23,11 +23,11 @@ export default { ...@@ -23,11 +23,11 @@ export default {
SafeHtml: GlSafeHtmlDirective, SafeHtml: GlSafeHtmlDirective,
}, },
components: { components: {
GlAvatar,
GlBadge, GlBadge,
GlLoadingIcon, GlLoadingIcon,
GlIcon, GlIcon,
UserAccessRoleBadge, UserAccessRoleBadge,
identicon,
itemCaret, itemCaret,
itemTypeIcon, itemTypeIcon,
itemStats, itemStats,
...@@ -125,21 +125,21 @@ export default { ...@@ -125,21 +125,21 @@ export default {
size="lg" size="lg"
class="d-none d-sm-inline-flex flex-shrink-0 gl-mr-3" class="d-none d-sm-inline-flex flex-shrink-0 gl-mr-3"
/> />
<div <a
:class="{ 'd-sm-flex': !group.isChildrenLoading }" :class="{ 'gl-sm-display-flex': !group.isChildrenLoading }"
class="avatar-container rect-avatar s32 d-none flex-grow-0 flex-shrink-0" class="gl-display-none gl-text-decoration-none! gl-mr-3"
:href="group.relativePath"
:aria-label="group.name"
> >
<a :href="group.relativePath" class="no-expand"> <gl-avatar
<img shape="rect"
v-if="hasAvatar" :entity-name="group.name"
:src="group.avatarUrl" :src="group.avatarUrl"
data-testid="group-avatar" :alt="group.name"
class="avatar s40" :size="32"
:itemprop="microdata.imageItemprop" :itemprop="microdata.imageItemprop"
/> />
<identicon v-else :entity-id="group.id" :entity-name="group.name" size-class="s40" />
</a> </a>
</div>
<div class="group-text-container d-flex flex-fill align-items-center"> <div class="group-text-container d-flex flex-fill align-items-center">
<div class="group-text flex-grow-1 flex-shrink-1"> <div class="group-text flex-grow-1 flex-shrink-1">
<div class="d-flex align-items-center flex-wrap title namespace-title gl-mr-3"> <div class="d-flex align-items-center flex-wrap title namespace-title gl-mr-3">
......
...@@ -208,13 +208,13 @@ RSpec.describe 'Group show page' do ...@@ -208,13 +208,13 @@ RSpec.describe 'Group show page' do
expect(page).to have_selector('.content[itemscope][itemtype="https://schema.org/Organization"]') expect(page).to have_selector('.content[itemscope][itemtype="https://schema.org/Organization"]')
page.within('.group-home-panel') do page.within('.group-home-panel') do
expect(page).to have_selector('img.avatar[itemprop="logo"]') expect(page).to have_selector('[itemprop="logo"]')
expect(page).to have_selector('[itemprop="name"]', text: group.name) expect(page).to have_selector('[itemprop="name"]', text: group.name)
expect(page).to have_selector('[itemprop="description"]', text: group.description) expect(page).to have_selector('[itemprop="description"]', text: group.description)
end end
page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do
expect(page).to have_selector('img.avatar[itemprop="image"]') expect(page).to have_selector('[itemprop="image"]')
expect(page).to have_selector('[itemprop="name"]', text: project.name) expect(page).to have_selector('[itemprop="name"]', text: project.name)
expect(page).to have_selector('[itemprop="description"]', text: project.description) expect(page).to have_selector('[itemprop="description"]', text: project.description)
end end
...@@ -224,12 +224,12 @@ RSpec.describe 'Group show page' do ...@@ -224,12 +224,12 @@ RSpec.describe 'Group show page' do
el.click el.click
wait_for_all_requests wait_for_all_requests
page.within(el) do page.within(el) do
expect(page).to have_selector('img.avatar[itemprop="logo"]') expect(page).to have_selector('[itemprop="logo"]')
expect(page).to have_selector('[itemprop="name"]', text: subgroup.name) expect(page).to have_selector('[itemprop="name"]', text: subgroup.name)
expect(page).to have_selector('[itemprop="description"]', text: subgroup.description) expect(page).to have_selector('[itemprop="description"]', text: subgroup.description)
page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do page.within('[itemprop="owns"][itemtype="https://schema.org/SoftwareSourceCode"]') do
expect(page).to have_selector('img.avatar[itemprop="image"]') expect(page).to have_selector('[itemprop="image"]')
expect(page).to have_selector('[itemprop="name"]', text: subproject.name) expect(page).to have_selector('[itemprop="name"]', text: subproject.name)
expect(page).to have_selector('[itemprop="description"]', text: subproject.description) expect(page).to have_selector('[itemprop="description"]', text: subproject.description)
end end
......
...@@ -236,13 +236,13 @@ describe('GroupItemComponent', () => { ...@@ -236,13 +236,13 @@ describe('GroupItemComponent', () => {
describe('schema.org props', () => { describe('schema.org props', () => {
describe('when showSchemaMarkup is disabled on the group', () => { describe('when showSchemaMarkup is disabled on the group', () => {
it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', (attr) => { it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', (attr) => {
expect(wrapper.vm.$el.getAttribute(attr)).toBeNull(); expect(wrapper.attributes(attr)).toBeUndefined();
}); });
it.each( it.each(
['.js-group-avatar', '.js-group-name', '.js-group-description'], ['.js-group-avatar', '.js-group-name', '.js-group-description'],
'it does not set `itemprop` on sub-nodes', 'it does not set `itemprop` on sub-nodes',
(selector) => { (selector) => {
expect(wrapper.vm.$el.querySelector(selector).getAttribute('itemprop')).toBeNull(); expect(wrapper.find(selector).attributes('itemprop')).toBeUndefined();
}, },
); );
}); });
...@@ -263,16 +263,16 @@ describe('GroupItemComponent', () => { ...@@ -263,16 +263,16 @@ describe('GroupItemComponent', () => {
${'itemtype'} | ${'https://schema.org/Organization'} ${'itemtype'} | ${'https://schema.org/Organization'}
${'itemprop'} | ${'subOrganization'} ${'itemprop'} | ${'subOrganization'}
`('it does set correct $attr', ({ attr, value } = {}) => { `('it does set correct $attr', ({ attr, value } = {}) => {
expect(wrapper.vm.$el.getAttribute(attr)).toBe(value); expect(wrapper.attributes(attr)).toBe(value);
}); });
it.each` it.each`
selector | propValue selector | propValue
${'[data-testid="group-avatar"]'} | ${'logo'} ${'img'} | ${'logo'}
${'[data-testid="group-name"]'} | ${'name'} ${'[data-testid="group-name"]'} | ${'name'}
${'[data-testid="group-description"]'} | ${'description'} ${'[data-testid="group-description"]'} | ${'description'}
`('it does set correct $selector', ({ selector, propValue } = {}) => { `('it does set correct $selector', ({ selector, propValue } = {}) => {
expect(wrapper.vm.$el.querySelector(selector).getAttribute('itemprop')).toBe(propValue); expect(wrapper.find(selector).attributes('itemprop')).toBe(propValue);
}); });
}); });
}); });
......
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