Commit 308a0562 authored by Marvin Karegyeya's avatar Marvin Karegyeya Committed by Jose Ivan Vargas

Replace GlDeprecatedDropdown in app/assets/javascripts/ci variable list

parent 4c1368a9
<script> <script>
import { import { GlDropdown, GlDropdownItem, GlDropdownDivider, GlSearchBoxByType } from '@gitlab/ui';
GlDeprecatedDropdown,
GlDeprecatedDropdownItem,
GlDeprecatedDropdownDivider,
GlSearchBoxByType,
GlIcon,
} from '@gitlab/ui';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
export default { export default {
name: 'CiEnvironmentsDropdown', name: 'CiEnvironmentsDropdown',
components: { components: {
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownItem, GlDropdownItem,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlSearchBoxByType, GlSearchBoxByType,
GlIcon,
}, },
props: { props: {
value: { value: {
...@@ -66,28 +59,25 @@ export default { ...@@ -66,28 +59,25 @@ export default {
}; };
</script> </script>
<template> <template>
<gl-deprecated-dropdown :text="value"> <gl-dropdown :text="value">
<gl-search-box-by-type v-model.trim="searchTerm" class="gl-m-3" /> <gl-search-box-by-type v-model.trim="searchTerm" class="gl-m-3" />
<gl-deprecated-dropdown-item <gl-dropdown-item
v-for="environment in filteredResults" v-for="environment in filteredResults"
:key="environment" :key="environment"
:is-checked="isSelected(environment)"
is-check-item
@click="selectEnvironment(environment)" @click="selectEnvironment(environment)"
> >
<gl-icon
:class="{ invisible: !isSelected(environment) }"
name="mobile-issue-close"
class="vertical-align-middle"
/>
{{ environment }} {{ environment }}
</gl-deprecated-dropdown-item> </gl-dropdown-item>
<gl-deprecated-dropdown-item v-if="!filteredResults.length" ref="noMatchingResults">{{ <gl-dropdown-item v-if="!filteredResults.length" ref="noMatchingResults">{{
__('No matching results') __('No matching results')
}}</gl-deprecated-dropdown-item> }}</gl-dropdown-item>
<template v-if="shouldRenderCreateButton"> <template v-if="shouldRenderCreateButton">
<gl-deprecated-dropdown-divider /> <gl-dropdown-divider />
<gl-deprecated-dropdown-item @click="createClicked"> <gl-dropdown-item @click="createClicked">
{{ composedCreateButtonLabel }} {{ composedCreateButtonLabel }}
</gl-deprecated-dropdown-item> </gl-dropdown-item>
</template> </template>
</gl-deprecated-dropdown> </gl-dropdown>
</template> </template>
---
title: Replace-GlDeprecatedDropdown-with-GlDropdown-in-app/assets/javascripts/ci_variable_list
merge_request: 41413
author: nuwe1
type: other
import Vuex from 'vuex'; import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { GlDeprecatedDropdownItem, GlIcon } from '@gitlab/ui'; import { GlDropdownItem, GlIcon } from '@gitlab/ui';
import CiEnvironmentsDropdown from '~/ci_variable_list/components/ci_environments_dropdown.vue'; import CiEnvironmentsDropdown from '~/ci_variable_list/components/ci_environments_dropdown.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -17,7 +17,7 @@ describe('Ci environments dropdown', () => { ...@@ -17,7 +17,7 @@ describe('Ci environments dropdown', () => {
}, },
}); });
wrapper = shallowMount(CiEnvironmentsDropdown, { wrapper = mount(CiEnvironmentsDropdown, {
store, store,
localVue, localVue,
propsData: { propsData: {
...@@ -26,9 +26,9 @@ describe('Ci environments dropdown', () => { ...@@ -26,9 +26,9 @@ describe('Ci environments dropdown', () => {
}); });
}; };
const findAllDropdownItems = () => wrapper.findAll(GlDeprecatedDropdownItem); const findAllDropdownItems = () => wrapper.findAll(GlDropdownItem);
const findDropdownItemByIndex = index => wrapper.findAll(GlDeprecatedDropdownItem).at(index); const findDropdownItemByIndex = index => wrapper.findAll(GlDropdownItem).at(index);
const findActiveIconByIndex = index => wrapper.findAll(GlIcon).at(index); const findActiveIconByIndex = index => findDropdownItemByIndex(index).find(GlIcon);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -61,6 +61,10 @@ describe('Ci environments dropdown', () => { ...@@ -61,6 +61,10 @@ describe('Ci environments dropdown', () => {
expect(findDropdownItemByIndex(1).text()).toBe('prod'); expect(findDropdownItemByIndex(1).text()).toBe('prod');
expect(findDropdownItemByIndex(2).text()).toBe('staging'); expect(findDropdownItemByIndex(2).text()).toBe('staging');
}); });
it('should not display active checkmark on the inactive stage', () => {
expect(findActiveIconByIndex(0).classes('gl-visibility-hidden')).toBe(true);
});
}); });
describe('Enviroments found', () => { describe('Enviroments found', () => {
...@@ -84,7 +88,7 @@ describe('Ci environments dropdown', () => { ...@@ -84,7 +88,7 @@ describe('Ci environments dropdown', () => {
}); });
it('should display active checkmark if active', () => { it('should display active checkmark if active', () => {
expect(findActiveIconByIndex(0).classes('invisible')).toBe(false); expect(findActiveIconByIndex(0).classes('gl-visibility-hidden')).toBe(false);
}); });
describe('Custom events', () => { describe('Custom events', () => {
......
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