Commit a818a654 authored by Evan Read's avatar Evan Read

Migrate environment dashboard dropdown

parent dcf0987a
<script> <script>
import { GlTooltipDirective, GlLink, GlButton, GlIcon } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlTooltipDirective, GlLink, GlIcon } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
export default { export default {
components: { components: {
GlDropdown,
GlDropdownItem,
GlIcon, GlIcon,
ProjectAvatar, ProjectAvatar,
GlLink, GlLink,
GlButton,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -32,9 +33,9 @@ export default { ...@@ -32,9 +33,9 @@ export default {
<template> <template>
<div <div
class="d-flex align-items-center page-title-holder text-secondary justify-content-between pb-2 mb-3" class="gl-display-flex gl-align-items-center page-title-holder text-secondary gl-justify-content-space-between pb-2 mb-3"
> >
<div class="d-flex align-items-center"> <div class="gl-display-flex gl-align-items-center">
<project-avatar :project="project.namespace" :size="20" class="flex-shrink-0" /> <project-avatar :project="project.namespace" :size="20" class="flex-shrink-0" />
<gl-link class="js-namespace-link text-secondary" :href="`/${project.namespace.full_path}`"> <gl-link class="js-namespace-link text-secondary" :href="`/${project.namespace.full_path}`">
<span class="js-namespace gl-mr-3"> {{ project.namespace.name }} </span> <span class="js-namespace gl-mr-3"> {{ project.namespace.name }} </span>
...@@ -45,23 +46,23 @@ export default { ...@@ -45,23 +46,23 @@ export default {
<span class="js-name gl-mr-3"> {{ project.name }} </span> <span class="js-name gl-mr-3"> {{ project.name }} </span>
</gl-link> </gl-link>
</div> </div>
<div class="dropdown js-more-actions"> <div class="gl-display-flex js-more-actions">
<button <gl-dropdown
v-gl-tooltip toggle-class="js-more-actions-toggle gl-display-flex gl-align-items-center gl-px-3! gl-bg-transparent gl-shadow-none!"
class="js-more-actions-toggle d-flex align-items-center ml-2 btn btn-transparent" right
type="button"
data-toggle="dropdown"
:title="$options.moreActionsText"
> >
<gl-icon name="ellipsis_v" class="text-secondary" /> <template #button-content>
</button> <gl-icon
<ul class="dropdown-menu dropdown-menu-right"> v-gl-tooltip
<li> :title="$options.moreActionsText"
<gl-button class="js-remove-button" variant="link" @click="onRemove()"> name="ellipsis_v"
<span class="text-danger"> {{ $options.removeProjectText }} </span> class="text-secondary"
</gl-button> />
</li> </template>
</ul> <gl-dropdown-item class="js-remove-button" variant="link" @click="onRemove()">
<span class="text-danger"> {{ $options.removeProjectText }} </span>
</gl-dropdown-item>
</gl-dropdown>
</div> </div>
</div> </div>
</template> </template>
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
exports[`Project Header matches the snapshot 1`] = ` exports[`Project Header matches the snapshot 1`] = `
<div <div
class="d-flex align-items-center page-title-holder text-secondary justify-content-between pb-2 mb-3" class="gl-display-flex gl-align-items-center page-title-holder text-secondary gl-justify-content-space-between pb-2 mb-3"
> >
<div <div
class="d-flex align-items-center" class="gl-display-flex gl-align-items-center"
> >
<project-avatar-stub <project-avatar-stub
class="flex-shrink-0" class="flex-shrink-0"
...@@ -48,41 +48,35 @@ exports[`Project Header matches the snapshot 1`] = ` ...@@ -48,41 +48,35 @@ exports[`Project Header matches the snapshot 1`] = `
</div> </div>
<div <div
class="dropdown js-more-actions" class="gl-display-flex js-more-actions"
> >
<button <gl-dropdown-stub
class="js-more-actions-toggle d-flex align-items-center ml-2 btn btn-transparent" category="primary"
data-toggle="dropdown" headertext=""
title="More actions" right=""
type="button" size="medium"
text=""
toggleclass="js-more-actions-toggle gl-display-flex gl-align-items-center gl-px-3! gl-bg-transparent gl-shadow-none!"
variant="default"
> >
<gl-icon-stub
class="text-secondary" <gl-dropdown-item-stub
name="ellipsis_v" avatarurl=""
size="16" class="js-remove-button"
/> iconcolor=""
</button> iconname=""
iconrightarialabel=""
<ul iconrightname=""
class="dropdown-menu dropdown-menu-right" secondarytext=""
> variant="link"
<li> >
<gl-button-stub <span
buttontextclasses="" class="text-danger"
category="primary"
class="js-remove-button"
icon=""
size="medium"
variant="link"
> >
<span Remove
class="text-danger" </span>
> </gl-dropdown-item-stub>
Remove </gl-dropdown-stub>
</span>
</gl-button-stub>
</li>
</ul>
</div> </div>
</div> </div>
`; `;
import { GlButton } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import component from 'ee/environments_dashboard/components/dashboard/project_header.vue'; import component from 'ee/environments_dashboard/components/dashboard/project_header.vue';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
...@@ -66,21 +66,18 @@ describe('Project Header', () => { ...@@ -66,21 +66,18 @@ describe('Project Header', () => {
describe('more actions', () => { describe('more actions', () => {
it('should list "remove" as an action', () => { it('should list "remove" as an action', () => {
const removeLink = wrapper const removeLink = wrapper
.find('.dropdown-menu') .find(GlDropdown)
.findAll('li') .findAll(GlDropdownItem)
.filter(w => w.text() === 'Remove'); .filter(w => w.text() === 'Remove');
expect(removeLink.exists()).toBe(true); expect(removeLink.exists()).toBe(true);
}); });
it('should emit a "remove" event when "remove" is clicked', () => { it('should emit a "remove" event when "remove" is clicked', () => {
const removeLink = wrapper const removeLink = wrapper
.find('.dropdown-menu') .find(GlDropdown)
.findAll('li') .findAll(GlDropdownItem)
.filter(w => w.text() === 'Remove'); .filter(w => w.text() === 'Remove');
removeLink removeLink.at(0).vm.$emit('click');
.at(0)
.find(GlButton)
.vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('remove')).toContainEqual([propsData.project.remove_path]); expect(wrapper.emitted('remove')).toContainEqual([propsData.project.remove_path]);
......
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