Commit 164c76d2 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '219911-req-button' into 'master'

Update requirements buttons to gl-button

Closes #219911

See merge request gitlab-org/gitlab!39372
parents eb25db6a 3222456d
<script> <script>
import { escape } from 'lodash'; import { escape } from 'lodash';
import { import { GlPopover, GlLink, GlAvatar, GlButton, GlTooltipDirective } from '@gitlab/ui';
GlPopover,
GlLink,
GlAvatar,
GlDeprecatedButton,
GlIcon,
GlLoadingIcon,
GlTooltipDirective,
} from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { getTimeago } from '~/lib/utils/datetime_utility'; import { getTimeago } from '~/lib/utils/datetime_utility';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -22,9 +14,7 @@ export default { ...@@ -22,9 +14,7 @@ export default {
GlPopover, GlPopover,
GlLink, GlLink,
GlAvatar, GlAvatar,
GlDeprecatedButton, GlButton,
GlIcon,
GlLoadingIcon,
RequirementStatusBadge, RequirementStatusBadge,
}, },
directives: { directives: {
...@@ -149,7 +139,7 @@ export default { ...@@ -149,7 +139,7 @@ export default {
class="d-block d-sm-none" class="d-block d-sm-none"
/> />
</div> </div>
<div class="issuable-meta"> <div class="d-flex">
<ul v-if="showIssuableMetaActions" class="controls flex-column flex-sm-row"> <ul v-if="showIssuableMetaActions" class="controls flex-column flex-sm-row">
<requirement-status-badge <requirement-status-badge
v-if="testReport" v-if="testReport"
...@@ -158,36 +148,27 @@ export default { ...@@ -158,36 +148,27 @@ export default {
class="d-none d-sm-block" class="d-none d-sm-block"
/> />
<li v-if="canUpdate && !isArchived" class="requirement-edit d-sm-block"> <li v-if="canUpdate && !isArchived" class="requirement-edit d-sm-block">
<gl-deprecated-button <gl-button
v-gl-tooltip v-gl-tooltip
size="sm" icon="pencil"
class="border-0"
:title="__('Edit')" :title="__('Edit')"
@click="$emit('editClick', requirement)" @click="$emit('editClick', requirement)"
> />
<gl-icon name="pencil" />
</gl-deprecated-button>
</li> </li>
<li v-if="canArchive && !isArchived" class="requirement-archive d-sm-block"> <li v-if="canArchive && !isArchived" class="requirement-archive d-sm-block">
<gl-deprecated-button <gl-button
v-if="!stateChangeRequestActive"
v-gl-tooltip v-gl-tooltip
size="sm" icon="archive"
class="border-0" :loading="stateChangeRequestActive"
:title="__('Archive')" :title="__('Archive')"
@click="handleArchiveClick" @click="handleArchiveClick"
> />
<gl-icon v-if="!stateChangeRequestActive" name="archive" />
<gl-loading-icon v-else />
</gl-deprecated-button>
</li> </li>
<li v-if="canArchive && isArchived" class="requirement-reopen d-sm-block"> <li v-if="canArchive && isArchived" class="requirement-reopen d-sm-block">
<gl-deprecated-button <gl-button :loading="stateChangeRequestActive" @click="handleReopenClick">{{
size="xs" __('Reopen')
class="p-2" }}</gl-button>
:loading="stateChangeRequestActive"
@click="handleReopenClick"
>{{ __('Reopen') }}</gl-deprecated-button
>
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -42,9 +42,16 @@ ...@@ -42,9 +42,16 @@
} }
.controls { .controls {
.requirement-edit .btn, align-items: flex-start;
.requirement-archive .btn {
padding: $gl-padding-4 $gl-vert-padding; @include media-breakpoint-down(xs) {
.requirement-archive {
margin-top: $gl-padding-4;
}
.requirement-edit {
margin-right: 0;
}
} }
} }
......
---
title: Update requirements list buttons to gl-button
merge_request: 39372
author:
type: changed
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink, GlDeprecatedButton, GlIcon, GlLoadingIcon } from '@gitlab/ui'; import { GlLink, GlButton } from '@gitlab/ui';
import RequirementItem from 'ee/requirements/components/requirement_item.vue'; import RequirementItem from 'ee/requirements/components/requirement_item.vue';
import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue'; import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue';
...@@ -172,7 +172,7 @@ describe('RequirementItem', () => { ...@@ -172,7 +172,7 @@ describe('RequirementItem', () => {
it('renders requirement-status-badge component', () => { it('renders requirement-status-badge component', () => {
const statusBadgeElSm = wrapper.find('.issuable-main-info').find(RequirementStatusBadge); const statusBadgeElSm = wrapper.find('.issuable-main-info').find(RequirementStatusBadge);
const statusBadgeElMd = wrapper.find('.issuable-meta').find(RequirementStatusBadge); const statusBadgeElMd = wrapper.find('.controls').find(RequirementStatusBadge);
expect(statusBadgeElSm.exists()).toBe(true); expect(statusBadgeElSm.exists()).toBe(true);
expect(statusBadgeElMd.exists()).toBe(true); expect(statusBadgeElMd.exists()).toBe(true);
...@@ -182,12 +182,10 @@ describe('RequirementItem', () => { ...@@ -182,12 +182,10 @@ describe('RequirementItem', () => {
}); });
it('renders element containing requirement `Edit` button when `requirement.userPermissions.updateRequirement` is true', () => { it('renders element containing requirement `Edit` button when `requirement.userPermissions.updateRequirement` is true', () => {
const editButtonEl = wrapper.find('.controls .requirement-edit').find(GlDeprecatedButton); const editButtonEl = wrapper.find('.controls .requirement-edit').find(GlButton);
expect(editButtonEl.exists()).toBe(true); expect(editButtonEl.exists()).toBe(true);
expect(editButtonEl.attributes('title')).toBe('Edit'); expect(editButtonEl.attributes('title')).toBe('Edit');
expect(editButtonEl.find(GlIcon).exists()).toBe(true);
expect(editButtonEl.find(GlIcon).props('name')).toBe('pencil');
}); });
it('does not render element containing requirement `Edit` button when `requirement.userPermissions.updateRequirement` is false', () => { it('does not render element containing requirement `Edit` button when `requirement.userPermissions.updateRequirement` is false', () => {
...@@ -205,14 +203,10 @@ describe('RequirementItem', () => { ...@@ -205,14 +203,10 @@ describe('RequirementItem', () => {
}); });
it('renders element containing requirement `Archive` button when `requirement.userPermissions.adminRequirement` is true', () => { it('renders element containing requirement `Archive` button when `requirement.userPermissions.adminRequirement` is true', () => {
const archiveButtonEl = wrapper const archiveButtonEl = wrapper.find('.controls .requirement-archive').find(GlButton);
.find('.controls .requirement-archive')
.find(GlDeprecatedButton);
expect(archiveButtonEl.exists()).toBe(true); expect(archiveButtonEl.exists()).toBe(true);
expect(archiveButtonEl.attributes('title')).toBe('Archive'); expect(archiveButtonEl.attributes('title')).toBe('Archive');
expect(archiveButtonEl.find(GlIcon).exists()).toBe(true);
expect(archiveButtonEl.find(GlIcon).props('name')).toBe('archive');
}); });
it('does not render element containing requirement `Archive` button when `requirement.userPermissions.adminRequirement` is false', () => { it('does not render element containing requirement `Archive` button when `requirement.userPermissions.adminRequirement` is false', () => {
...@@ -229,23 +223,8 @@ describe('RequirementItem', () => { ...@@ -229,23 +223,8 @@ describe('RequirementItem', () => {
wrapperNoArchive.destroy(); wrapperNoArchive.destroy();
}); });
it('renders loading icon within archive button when `stateChangeRequestActive` prop is true', () => {
wrapper.setProps({
stateChangeRequestActive: true,
});
return wrapper.vm.$nextTick(() => {
expect(
wrapper
.find('.requirement-archive')
.find(GlLoadingIcon)
.exists(),
).toBe(true);
});
});
it('renders `Reopen` button when current requirement is archived and `requirement.userPermissions.adminRequirement` is true', () => { it('renders `Reopen` button when current requirement is archived and `requirement.userPermissions.adminRequirement` is true', () => {
const reopenButton = wrapperArchived.find('.requirement-reopen').find(GlDeprecatedButton); const reopenButton = wrapperArchived.find('.requirement-reopen').find(GlButton);
expect(reopenButton.exists()).toBe(true); expect(reopenButton.exists()).toBe(true);
expect(reopenButton.props('loading')).toBe(false); expect(reopenButton.props('loading')).toBe(false);
......
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