Commit c8557573 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'dmishunov-new-buttons' into 'master'

Converted GlButton to GlNewButton

See merge request gitlab-org/gitlab!28614
parents c57d6e3b e5ac255c
...@@ -4,12 +4,12 @@ import { ...@@ -4,12 +4,12 @@ import {
GlAvatar, GlAvatar,
GlIcon, GlIcon,
GlSprintf, GlSprintf,
GlDeprecatedButton,
GlModal, GlModal,
GlAlert, GlAlert,
GlLoadingIcon, GlLoadingIcon,
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
GlNewButton,
} from '@gitlab/ui'; } from '@gitlab/ui';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
...@@ -22,13 +22,13 @@ export default { ...@@ -22,13 +22,13 @@ export default {
GlAvatar, GlAvatar,
GlIcon, GlIcon,
GlSprintf, GlSprintf,
GlDeprecatedButton,
GlModal, GlModal,
GlAlert, GlAlert,
GlLoadingIcon, GlLoadingIcon,
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
TimeAgoTooltip, TimeAgoTooltip,
GlNewButton,
}, },
apollo: { apollo: {
canCreateSnippet: { canCreateSnippet: {
...@@ -67,17 +67,14 @@ export default { ...@@ -67,17 +67,14 @@ export default {
condition: this.snippet.userPermissions.updateSnippet, condition: this.snippet.userPermissions.updateSnippet,
text: __('Edit'), text: __('Edit'),
href: this.editLink, href: this.editLink,
click: undefined,
variant: 'outline-info',
cssClass: undefined,
}, },
{ {
condition: this.snippet.userPermissions.adminSnippet, condition: this.snippet.userPermissions.adminSnippet,
text: __('Delete'), text: __('Delete'),
href: undefined,
click: this.showDeleteModal, click: this.showDeleteModal,
variant: 'outline-danger', variant: 'danger',
cssClass: 'btn-inverted btn-danger ml-2', category: 'secondary',
cssClass: 'ml-2',
}, },
{ {
condition: this.canCreateSnippet, condition: this.canCreateSnippet,
...@@ -85,9 +82,9 @@ export default { ...@@ -85,9 +82,9 @@ export default {
href: this.snippet.project href: this.snippet.project
? `${this.snippet.project.webUrl}/snippets/new` ? `${this.snippet.project.webUrl}/snippets/new`
: '/snippets/new', : '/snippets/new',
click: undefined, variant: 'success',
variant: 'outline-success', category: 'secondary',
cssClass: 'btn-inverted btn-success ml-2', cssClass: 'ml-2',
}, },
]; ];
}, },
...@@ -187,18 +184,20 @@ export default { ...@@ -187,18 +184,20 @@ export default {
</div> </div>
<div class="detail-page-header-actions"> <div class="detail-page-header-actions">
<div class="d-none d-sm-block"> <div class="d-none d-sm-flex">
<template v-for="(action, index) in personalSnippetActions"> <template v-for="(action, index) in personalSnippetActions">
<gl-deprecated-button <gl-new-button
v-if="action.condition" v-if="action.condition"
:key="index" :key="index"
:disabled="action.disabled"
:variant="action.variant" :variant="action.variant"
:category="action.category"
:class="action.cssClass" :class="action.cssClass"
:href="action.href || undefined" :href="action.href"
@click="action.click ? action.click() : undefined" @click="action.click ? action.click() : undefined"
> >
{{ action.text }} {{ action.text }}
</gl-deprecated-button> </gl-new-button>
</template> </template>
</div> </div>
<div class="d-block d-sm-none dropdown"> <div class="d-block d-sm-none dropdown">
...@@ -206,7 +205,7 @@ export default { ...@@ -206,7 +205,7 @@ export default {
<gl-dropdown-item <gl-dropdown-item
v-for="(action, index) in personalSnippetActions" v-for="(action, index) in personalSnippetActions"
:key="index" :key="index"
:href="action.href || undefined" :href="action.href"
@click="action.click ? action.click() : undefined" @click="action.click ? action.click() : undefined"
>{{ action.text }}</gl-dropdown-item >{{ action.text }}</gl-dropdown-item
> >
...@@ -228,16 +227,17 @@ export default { ...@@ -228,16 +227,17 @@ export default {
</gl-sprintf> </gl-sprintf>
<template #modal-footer> <template #modal-footer>
<gl-deprecated-button @click="closeDeleteModal">{{ __('Cancel') }}</gl-deprecated-button> <gl-new-button @click="closeDeleteModal">{{ __('Cancel') }}</gl-new-button>
<gl-deprecated-button <gl-new-button
variant="danger" variant="danger"
category="primary"
:disabled="isDeleting" :disabled="isDeleting"
data-qa-selector="delete_snippet_button" data-qa-selector="delete_snippet_button"
@click="deleteSnippet" @click="deleteSnippet"
> >
<gl-loading-icon v-if="isDeleting" inline /> <gl-loading-icon v-if="isDeleting" inline />
{{ __('Delete snippet') }} {{ __('Delete snippet') }}
</gl-deprecated-button> </gl-new-button>
</template> </template>
</gl-modal> </gl-modal>
</div> </div>
......
---
title: Replaced old-style buttons with the new ones on Snippet view
merge_request: 28614
author:
type: other
import SnippetHeader from '~/snippets/components/snippet_header.vue'; import SnippetHeader from '~/snippets/components/snippet_header.vue';
import DeleteSnippetMutation from '~/snippets/mutations/deleteSnippet.mutation.graphql'; import DeleteSnippetMutation from '~/snippets/mutations/deleteSnippet.mutation.graphql';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import { GlDeprecatedButton, GlModal } from '@gitlab/ui'; import { GlNewButton, GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
describe('Snippet header component', () => { describe('Snippet header component', () => {
...@@ -89,7 +89,7 @@ describe('Snippet header component', () => { ...@@ -89,7 +89,7 @@ describe('Snippet header component', () => {
updateSnippet: false, updateSnippet: false,
}, },
}); });
expect(wrapper.findAll(GlDeprecatedButton).length).toEqual(0); expect(wrapper.findAll(GlNewButton).length).toEqual(0);
createComponent({ createComponent({
permissions: { permissions: {
...@@ -97,7 +97,7 @@ describe('Snippet header component', () => { ...@@ -97,7 +97,7 @@ describe('Snippet header component', () => {
updateSnippet: false, updateSnippet: false,
}, },
}); });
expect(wrapper.findAll(GlDeprecatedButton).length).toEqual(1); expect(wrapper.findAll(GlNewButton).length).toEqual(1);
createComponent({ createComponent({
permissions: { permissions: {
...@@ -105,7 +105,7 @@ describe('Snippet header component', () => { ...@@ -105,7 +105,7 @@ describe('Snippet header component', () => {
updateSnippet: true, updateSnippet: true,
}, },
}); });
expect(wrapper.findAll(GlDeprecatedButton).length).toEqual(2); expect(wrapper.findAll(GlNewButton).length).toEqual(2);
createComponent({ createComponent({
permissions: { permissions: {
...@@ -117,7 +117,7 @@ describe('Snippet header component', () => { ...@@ -117,7 +117,7 @@ describe('Snippet header component', () => {
canCreateSnippet: true, canCreateSnippet: true,
}); });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(GlDeprecatedButton).length).toEqual(3); expect(wrapper.findAll(GlNewButton).length).toEqual(3);
}); });
}); });
......
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