Commit 6d0b1229 authored by Miguel Rincon's avatar Miguel Rincon

Cleanup suggested issuables icon classes

Currently we are serving one main CSS file which is importing all the
CSS files that are page specific.

This change removes two classes from the main CSS file in favor
of utility classes.
parent 8d57501f
<script> <script>
/* eslint-disable @gitlab/vue-require-i18n-strings */
import { GlLink, GlTooltip, GlTooltipDirective, GlIcon } from '@gitlab/ui'; import { GlLink, GlTooltip, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { uniqueId } from 'lodash'; import { uniqueId } from 'lodash';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -26,12 +25,6 @@ export default { ...@@ -26,12 +25,6 @@ export default {
}, },
}, },
computed: { computed: {
isOpen() {
return this.suggestion.state === 'opened';
},
isClosed() {
return this.suggestion.state === 'closed';
},
counts() { counts() {
return [ return [
{ {
...@@ -48,7 +41,13 @@ export default { ...@@ -48,7 +41,13 @@ export default {
}, },
].filter(({ count }) => count); ].filter(({ count }) => count);
}, },
stateIcon() { isClosed() {
return this.suggestion.state === 'closed';
},
stateIconClass() {
return this.isClosed ? 'gl-text-blue-500' : 'gl-text-green-500';
},
stateIconName() {
return this.isClosed ? 'issue-close' : 'issue-open-m'; return this.isClosed ? 'issue-close' : 'issue-open-m';
}, },
stateTitle() { stateTitle() {
...@@ -72,7 +71,7 @@ export default { ...@@ -72,7 +71,7 @@ export default {
v-gl-tooltip.bottom v-gl-tooltip.bottom
:title="__('Confidential')" :title="__('Confidential')"
name="eye-slash" name="eye-slash"
class="suggestion-help-hover mr-1 suggestion-confidential" class="gl-cursor-help gl-mr-2 gl-text-orange-500"
/> />
<gl-link <gl-link
:href="suggestion.webUrl" :href="suggestion.webUrl"
...@@ -83,15 +82,7 @@ export default { ...@@ -83,15 +82,7 @@ export default {
</gl-link> </gl-link>
</div> </div>
<div class="text-secondary suggestion-footer"> <div class="text-secondary suggestion-footer">
<gl-icon <gl-icon ref="state" :name="stateIconName" :class="stateIconClass" class="gl-cursor-help" />
ref="state"
:name="stateIcon"
:class="{
'suggestion-state-open': isOpen,
'suggestion-state-closed': isClosed,
}"
class="suggestion-help-hover"
/>
<gl-tooltip :target="() => $refs.state" placement="bottom"> <gl-tooltip :target="() => $refs.state" placement="bottom">
<span class="d-block"> <span class="d-block">
<span class="bold"> {{ stateTitle }} </span> {{ timeFormatted(closedOrCreatedDate) }} <span class="bold"> {{ stateTitle }} </span> {{ timeFormatted(closedOrCreatedDate) }}
...@@ -102,9 +93,9 @@ export default { ...@@ -102,9 +93,9 @@ export default {
<timeago-tooltip <timeago-tooltip
:time="suggestion.createdAt" :time="suggestion.createdAt"
tooltip-placement="bottom" tooltip-placement="bottom"
class="suggestion-help-hover" class="gl-cursor-help"
/> />
by {{ __('by') }}
<gl-link :href="suggestion.author.webUrl"> <gl-link :href="suggestion.author.webUrl">
<user-avatar-image <user-avatar-image
:img-src="suggestion.author.avatarUrl" :img-src="suggestion.author.avatarUrl"
...@@ -122,7 +113,7 @@ export default { ...@@ -122,7 +113,7 @@ export default {
<timeago-tooltip <timeago-tooltip
:time="suggestion.updatedAt" :time="suggestion.updatedAt"
tooltip-placement="bottom" tooltip-placement="bottom"
class="suggestion-help-hover" class="gl-cursor-help"
/> />
</template> </template>
<span class="suggestion-counts"> <span class="suggestion-counts">
...@@ -131,7 +122,7 @@ export default { ...@@ -131,7 +122,7 @@ export default {
:key="id" :key="id"
v-gl-tooltip.bottom v-gl-tooltip.bottom
:title="tooltipTitle" :title="tooltipTitle"
class="suggestion-help-hover gl-ml-3 text-tertiary" class="gl-cursor-help gl-ml-3 text-tertiary"
> >
<gl-icon :name="icon" /> {{ count }} <gl-icon :name="icon" /> {{ count }}
</span> </span>
......
...@@ -877,18 +877,6 @@ ...@@ -877,18 +877,6 @@
vertical-align: sub; vertical-align: sub;
} }
.suggestion-confidential {
color: $orange-500;
}
.suggestion-state-open {
color: $green-500;
}
.suggestion-state-closed {
color: $blue-500;
}
.suggestion-help-hover { .suggestion-help-hover {
cursor: help; cursor: help;
} }
......
...@@ -6,10 +6,10 @@ import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_ima ...@@ -6,10 +6,10 @@ import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_ima
import mockData from '../mock_data'; import mockData from '../mock_data';
describe('Issuable suggestions suggestion component', () => { describe('Issuable suggestions suggestion component', () => {
let vm; let wrapper;
function createComponent(suggestion = {}) { function createComponent(suggestion = {}) {
vm = shallowMount(Suggestion, { wrapper = shallowMount(Suggestion, {
propsData: { propsData: {
suggestion: { suggestion: {
...mockData(), ...mockData(),
...@@ -19,37 +19,40 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -19,37 +19,40 @@ describe('Issuable suggestions suggestion component', () => {
}); });
} }
const findLink = () => wrapper.findComponent(GlLink);
const findAuthorLink = () => wrapper.findAll(GlLink).at(1);
const findIcon = () => wrapper.findComponent(GlIcon);
const findTooltip = () => wrapper.findComponent(GlTooltip);
const findUserAvatar = () => wrapper.findComponent(UserAvatarImage);
afterEach(() => { afterEach(() => {
vm.destroy(); wrapper.destroy();
}); });
it('renders title', () => { it('renders title', () => {
createComponent(); createComponent();
expect(vm.text()).toContain('Test issue'); expect(wrapper.text()).toContain('Test issue');
}); });
it('renders issue link', () => { it('renders issue link', () => {
createComponent(); createComponent();
const link = vm.find(GlLink); expect(findLink().attributes('href')).toBe(`${TEST_HOST}/test/issue/1`);
expect(link.attributes('href')).toBe(`${TEST_HOST}/test/issue/1`);
}); });
it('renders IID', () => { it('renders IID', () => {
createComponent(); createComponent();
expect(vm.text()).toContain('#1'); expect(wrapper.text()).toContain('#1');
}); });
describe('opened state', () => { describe('opened state', () => {
it('renders icon', () => { it('renders icon', () => {
createComponent(); createComponent();
const icon = vm.find(GlIcon); expect(findIcon().props('name')).toBe('issue-open-m');
expect(findIcon().attributes('class')).toMatch('gl-text-green-500');
expect(icon.props('name')).toBe('issue-open-m');
}); });
it('renders created timeago', () => { it('renders created timeago', () => {
...@@ -57,10 +60,8 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -57,10 +60,8 @@ describe('Issuable suggestions suggestion component', () => {
closedAt: '', closedAt: '',
}); });
const tooltip = vm.find(GlTooltip); expect(findTooltip().text()).toContain('Opened');
expect(findTooltip().text()).toContain('3 days ago');
expect(tooltip.find('.d-block').text()).toContain('Opened');
expect(tooltip.text()).toContain('3 days ago');
}); });
}); });
...@@ -70,18 +71,15 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -70,18 +71,15 @@ describe('Issuable suggestions suggestion component', () => {
state: 'closed', state: 'closed',
}); });
const icon = vm.find(GlIcon); expect(findIcon().props('name')).toBe('issue-close');
expect(findIcon().attributes('class')).toMatch('gl-text-blue-500');
expect(icon.props('name')).toBe('issue-close');
}); });
it('renders closed timeago', () => { it('renders closed timeago', () => {
createComponent(); createComponent();
const tooltip = vm.find(GlTooltip); expect(findTooltip().text()).toContain('Opened');
expect(findTooltip().text()).toContain('1 day ago');
expect(tooltip.find('.d-block').text()).toContain('Opened');
expect(tooltip.text()).toContain('1 day ago');
}); });
}); });
...@@ -89,18 +87,14 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -89,18 +87,14 @@ describe('Issuable suggestions suggestion component', () => {
it('renders author info', () => { it('renders author info', () => {
createComponent(); createComponent();
const link = vm.findAll(GlLink).at(1); expect(findAuthorLink().text()).toContain('Author Name');
expect(findAuthorLink().text()).toContain('@author.username');
expect(link.text()).toContain('Author Name');
expect(link.text()).toContain('@author.username');
}); });
it('renders author image', () => { it('renders author image', () => {
createComponent(); createComponent();
const image = vm.find(UserAvatarImage); expect(findUserAvatar().props('imgSrc')).toBe(`${TEST_HOST}/avatar`);
expect(image.props('imgSrc')).toBe(`${TEST_HOST}/avatar`);
}); });
}); });
...@@ -108,7 +102,7 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -108,7 +102,7 @@ describe('Issuable suggestions suggestion component', () => {
it('renders upvotes count', () => { it('renders upvotes count', () => {
createComponent(); createComponent();
const count = vm.findAll('.suggestion-counts span').at(0); const count = wrapper.findAll('.suggestion-counts span').at(0);
expect(count.text()).toContain('1'); expect(count.text()).toContain('1');
expect(count.find(GlIcon).props('name')).toBe('thumb-up'); expect(count.find(GlIcon).props('name')).toBe('thumb-up');
...@@ -117,7 +111,7 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -117,7 +111,7 @@ describe('Issuable suggestions suggestion component', () => {
it('renders notes count', () => { it('renders notes count', () => {
createComponent(); createComponent();
const count = vm.findAll('.suggestion-counts span').at(1); const count = wrapper.findAll('.suggestion-counts span').at(1);
expect(count.text()).toContain('2'); expect(count.text()).toContain('2');
expect(count.find(GlIcon).props('name')).toBe('comment'); expect(count.find(GlIcon).props('name')).toBe('comment');
...@@ -130,10 +124,9 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -130,10 +124,9 @@ describe('Issuable suggestions suggestion component', () => {
confidential: true, confidential: true,
}); });
const icon = vm.find(GlIcon); expect(findIcon().props('name')).toBe('eye-slash');
expect(findIcon().attributes('class')).toMatch('gl-text-orange-500');
expect(icon.props('name')).toBe('eye-slash'); expect(findIcon().attributes('title')).toBe('Confidential');
expect(icon.attributes('title')).toBe('Confidential');
}); });
}); });
}); });
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