Commit 476d8352 authored by Jannik Lehmann's avatar Jannik Lehmann Committed by Scott Hampton

Restyle license compliance Button

This commit solves https://gitlab.com/gitlab-org/gitlab/-/issues/229910
The licence compliance Button on the Merge-Request Widget
has been restyled.
parent 918509b3
...@@ -184,7 +184,7 @@ export default { ...@@ -184,7 +184,7 @@ export default {
<slot name="sub-heading"></slot> <slot name="sub-heading"></slot>
</div> </div>
<slot name="action-buttons"></slot> <slot name="action-buttons" :is-collapsible="isCollapsible"></slot>
<button <button
v-if="isCollapsible" v-if="isCollapsible"
......
<script> <script>
import { GlLink, GlIcon } from '@gitlab/ui'; import { GlLink, GlIcon, GlButton } from '@gitlab/ui';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { componentNames } from 'ee/reports/components/issue_body'; import { componentNames } from 'ee/reports/components/issue_body';
import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_compliance/store/constants'; import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_compliance/store/constants';
...@@ -16,6 +16,7 @@ export default { ...@@ -16,6 +16,7 @@ export default {
componentNames, componentNames,
store, store,
components: { components: {
GlButton,
GlLink, GlLink,
ReportItem, ReportItem,
ReportSection, ReportSection,
...@@ -176,26 +177,27 @@ export default { ...@@ -176,26 +177,27 @@ export default {
</gl-link> </gl-link>
</div> </div>
</template> </template>
<template v-if="showActionButtons" #action-buttons> <template v-if="showActionButtons" #action-buttons="{ isCollapsible }">
<div class="gl-display-flex gl-mr-3"> <gl-button
<a v-if="fullReportPath"
v-if="licenseManagementSettingsPath" :href="fullReportPath"
:class="{ 'gl-mr-3': fullReportPath }" target="_blank"
:href="licenseManagementSettingsPath" data-testid="full-report-button"
class="btn btn-default btn-sm js-manage-licenses" class="gl-mr-3"
data-qa-selector="manage_licenses_button" icon="external-link"
> >
{{ s__('ciReport|Manage licenses') }} {{ s__('ciReport|View full report') }}
</a> </gl-button>
<a <gl-button
v-if="fullReportPath" v-if="licenseManagementSettingsPath"
:href="fullReportPath" data-testid="manage-licenses-button"
target="_blank" size="small"
class="btn btn-default btn-sm js-full-report" :class="{ 'gl-mr-3': isCollapsible }"
> :href="licenseManagementSettingsPath"
{{ s__('ciReport|View full report') }} <gl-icon :size="16" name="external-link" /> data-qa-selector="manage_licenses_button"
</a> >
</div> {{ s__('ciReport|Manage licenses') }}
</gl-button>
</template> </template>
</report-section> </report-section>
</div> </div>
......
---
title: Restyle license compliance button on merge request widget
merge_request: 55667
author:
type: changed
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import LicenseManagement from 'ee/vue_shared/license_compliance/mr_widget_license_report.vue'; import LicenseManagement from 'ee/vue_shared/license_compliance/mr_widget_license_report.vue';
import { stubComponent } from 'helpers/stub_component';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import ReportItem from '~/reports/components/report_item.vue'; import ReportItem from '~/reports/components/report_item.vue';
import ReportSection from '~/reports/components/report_section.vue'; import ReportSection from '~/reports/components/report_section.vue';
...@@ -273,7 +274,7 @@ describe('License Report MR Widget', () => { ...@@ -273,7 +274,7 @@ describe('License Report MR Widget', () => {
}); });
describe('`View full report` button', () => { describe('`View full report` button', () => {
const selector = '.js-full-report'; const selector = '[data-testid="full-report-button"]';
it('should be rendered when fullReportPath prop is provided', () => { it('should be rendered when fullReportPath prop is provided', () => {
mountComponent(); mountComponent();
...@@ -294,7 +295,7 @@ describe('License Report MR Widget', () => { ...@@ -294,7 +295,7 @@ describe('License Report MR Widget', () => {
}); });
describe('`Manage licenses` button', () => { describe('`Manage licenses` button', () => {
const selector = '.js-manage-licenses'; const selector = '[data-testid="manage-licenses-button"]';
it('should be rendered when licenseManagementSettingsPath prop is provided', () => { it('should be rendered when licenseManagementSettingsPath prop is provided', () => {
mountComponent(); mountComponent();
...@@ -312,6 +313,36 @@ describe('License Report MR Widget', () => { ...@@ -312,6 +313,36 @@ describe('License Report MR Widget', () => {
expect(wrapper.find(selector).exists()).toBe(false); expect(wrapper.find(selector).exists()).toBe(false);
}); });
it('has gl-mr-3 class when isCollapsbile is true', () => {
mountComponent({
stubs: {
ReportSection: stubComponent(ReportSection, {
template: `
<div>
<slot name="action-buttons" :is-collapsible="true" />
</div>
`,
}),
},
});
expect(wrapper.find(selector).classes()).toContain('gl-mr-3');
});
it('does not have gl-mr-3 class when isCollapsbile is false', () => {
mountComponent({
stubs: {
ReportSection: stubComponent(ReportSection, {
template: `
<div>
<slot name="action-buttons" :is-collapsible="false" />
</div>
`,
}),
},
});
expect(wrapper.find(selector).classes()).not.toContain('gl-mr-3');
});
}); });
it('should init store after mount', () => { it('should init store after mount', () => {
......
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