Commit ed142f83 authored by Marvin Karegyeya's avatar Marvin Karegyeya Committed by Brandon Labuschagne

Replace gl deprecated dropdown with gl dropdown in app/assets/javascripts/vue...

Replace gl deprecated dropdown with gl dropdown in app/assets/javascripts/vue shared/components/split button.vue
parent e042b023
<script> <script>
import { isString } from 'lodash'; import { isString } from 'lodash';
import { import { GlDropdown, GlDropdownDivider, GlDropdownItem } from '@gitlab/ui';
GlDeprecatedDropdown,
GlDeprecatedDropdownDivider,
GlDeprecatedDropdownItem,
} from '@gitlab/ui';
const isValidItem = item => const isValidItem = item =>
isString(item.eventName) && isString(item.title) && isString(item.description); isString(item.eventName) && isString(item.title) && isString(item.description);
export default { export default {
components: { components: {
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlDeprecatedDropdownItem, GlDropdownItem,
}, },
props: { props: {
...@@ -32,7 +28,7 @@ export default { ...@@ -32,7 +28,7 @@ export default {
variant: { variant: {
type: String, type: String,
required: false, required: false,
default: 'secondary', default: 'default',
}, },
}, },
...@@ -61,8 +57,8 @@ export default { ...@@ -61,8 +57,8 @@ export default {
</script> </script>
<template> <template>
<gl-deprecated-dropdown <gl-dropdown
:menu-class="`dropdown-menu-selectable ${menuClass}`" :menu-class="menuClass"
split split
:text="dropdownToggleText" :text="dropdownToggleText"
:variant="variant" :variant="variant"
...@@ -70,20 +66,20 @@ export default { ...@@ -70,20 +66,20 @@ export default {
@click="triggerEvent" @click="triggerEvent"
> >
<template v-for="(item, itemIndex) in actionItems"> <template v-for="(item, itemIndex) in actionItems">
<gl-deprecated-dropdown-item <gl-dropdown-item
:key="item.eventName" :key="item.eventName"
:active="selectedItem === item" :is-check-item="true"
active-class="is-active" :is-checked="selectedItem === item"
@click="changeSelectedItem(item)" @click="changeSelectedItem(item)"
> >
<strong>{{ item.title }}</strong> <strong>{{ item.title }}</strong>
<div>{{ item.description }}</div> <div>{{ item.description }}</div>
</gl-deprecated-dropdown-item> </gl-dropdown-item>
<gl-deprecated-dropdown-divider <gl-dropdown-divider
v-if="itemIndex < actionItems.length - 1" v-if="itemIndex < actionItems.length - 1"
:key="`${item.eventName}-divider`" :key="`${item.eventName}-divider`"
/> />
</template> </template>
</gl-deprecated-dropdown> </gl-dropdown>
</template> </template>
---
title: Replace `GlDeprecatedDropdown` with `GlDropdown` in app/assets/javascripts/vue_shared/components/split_button.vue
merge_request: 41433
author: nuwe1
type: other
...@@ -5,14 +5,17 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ ...@@ -5,14 +5,17 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
class="gl-display-flex gl-justify-content-end" class="gl-display-flex gl-justify-content-end"
> >
<div <div
class="dropdown b-dropdown gl-dropdown btn-group" class="dropdown b-dropdown gl-new-dropdown btn-group"
menu-class="dropdown-menu-large"
> >
<button <button
class="btn btn-danger" class="btn btn-danger btn-md gl-button split-content-button"
type="button" type="button"
> >
<!---->
<span <span
class="gl-dropdown-toggle-text" class="gl-new-dropdown-button-text"
> >
Remove integration and resources Remove integration and resources
</span> </span>
...@@ -22,7 +25,7 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ ...@@ -22,7 +25,7 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
<button <button
aria-expanded="false" aria-expanded="false"
aria-haspopup="true" aria-haspopup="true"
class="btn dropdown-toggle btn-danger dropdown-toggle-split" class="btn dropdown-toggle btn-danger btn-md gl-button gl-dropdown-toggle dropdown-toggle-split"
type="button" type="button"
> >
<span <span
...@@ -32,29 +35,58 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ ...@@ -32,29 +35,58 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
</span> </span>
</button> </button>
<ul <ul
class="dropdown-menu dropdown-menu-selectable dropdown-menu-large" class="dropdown-menu dropdown-menu-large"
role="menu" role="menu"
tabindex="-1" tabindex="-1"
> >
<!---->
<li <li
class="gl-new-dropdown-item"
role="presentation" role="presentation"
> >
<button <button
class="dropdown-item is-active" class="dropdown-item"
role="menuitem" role="menuitem"
type="button" type="button"
> >
<strong> <svg
Remove integration and resources class="gl-icon s16 gl-new-dropdown-item-check-icon"
</strong> data-testid="mobile-issue-close-icon"
>
<use
href="#mobile-issue-close"
/>
</svg>
<!---->
<div> <!---->
Deletes all GitLab resources attached to this cluster during removal
<div
class="gl-new-dropdown-item-text-wrapper"
>
<p
class="gl-new-dropdown-item-text-primary"
>
<strong>
Remove integration and resources
</strong>
<div>
Deletes all GitLab resources attached to this cluster during removal
</div>
</p>
<!---->
</div> </div>
<!---->
</button> </button>
</li> </li>
<li <li
class="gl-new-dropdown-divider"
role="presentation" role="presentation"
> >
<hr <hr
...@@ -64,6 +96,7 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ ...@@ -64,6 +96,7 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
/> />
</li> </li>
<li <li
class="gl-new-dropdown-item"
role="presentation" role="presentation"
> >
<button <button
...@@ -71,13 +104,38 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ ...@@ -71,13 +104,38 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
role="menuitem" role="menuitem"
type="button" type="button"
> >
<strong> <svg
Remove integration class="gl-icon s16 gl-new-dropdown-item-check-icon gl-visibility-hidden"
</strong> data-testid="mobile-issue-close-icon"
>
<use
href="#mobile-issue-close"
/>
</svg>
<!---->
<div> <!---->
Removes cluster from project but keeps associated resources
<div
class="gl-new-dropdown-item-text-wrapper"
>
<p
class="gl-new-dropdown-item-text-primary"
>
<strong>
Remove integration
</strong>
<div>
Removes cluster from project but keeps associated resources
</div>
</p>
<!---->
</div> </div>
<!---->
</button> </button>
</li> </li>
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SplitButton renders actionItems 1`] = ` exports[`SplitButton renders actionItems 1`] = `
<gl-deprecated-dropdown-stub <gl-dropdown-stub
menu-class="dropdown-menu-selectable " category="tertiary"
headertext=""
menu-class=""
size="medium"
split="true" split="true"
text="professor" text="professor"
variant="secondary" variant="default"
> >
<gl-deprecated-dropdown-item-stub <gl-dropdown-item-stub
active="true" avatarurl=""
active-class="is-active" iconcolor=""
iconname=""
iconrightname=""
ischecked="true"
ischeckitem="true"
secondarytext=""
> >
<strong> <strong>
professor professor
...@@ -18,11 +26,16 @@ exports[`SplitButton renders actionItems 1`] = ` ...@@ -18,11 +26,16 @@ exports[`SplitButton renders actionItems 1`] = `
<div> <div>
very symphonic very symphonic
</div> </div>
</gl-deprecated-dropdown-item-stub> </gl-dropdown-item-stub>
<gl-deprecated-dropdown-divider-stub /> <gl-dropdown-divider-stub />
<gl-deprecated-dropdown-item-stub <gl-dropdown-item-stub
active-class="is-active" avatarurl=""
iconcolor=""
iconname=""
iconrightname=""
ischeckitem="true"
secondarytext=""
> >
<strong> <strong>
captain captain
...@@ -31,8 +44,8 @@ exports[`SplitButton renders actionItems 1`] = ` ...@@ -31,8 +44,8 @@ exports[`SplitButton renders actionItems 1`] = `
<div> <div>
warp drive warp drive
</div> </div>
</gl-deprecated-dropdown-item-stub> </gl-dropdown-item-stub>
<!----> <!---->
</gl-deprecated-dropdown-stub> </gl-dropdown-stub>
`; `;
import { GlDeprecatedDropdown, GlDeprecatedDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import SplitButton from '~/vue_shared/components/split_button.vue'; import SplitButton from '~/vue_shared/components/split_button.vue';
...@@ -25,10 +25,10 @@ describe('SplitButton', () => { ...@@ -25,10 +25,10 @@ describe('SplitButton', () => {
}); });
}; };
const findDropdown = () => wrapper.find(GlDeprecatedDropdown); const findDropdown = () => wrapper.find(GlDropdown);
const findDropdownItem = (index = 0) => const findDropdownItem = (index = 0) =>
findDropdown() findDropdown()
.findAll(GlDeprecatedDropdownItem) .findAll(GlDropdownItem)
.at(index); .at(index);
const selectItem = index => { const selectItem = index => {
findDropdownItem(index).vm.$emit('click'); findDropdownItem(index).vm.$emit('click');
......
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