Commit 329521e1 authored by Marvin Karegyeya's avatar Marvin Karegyeya Committed by Phil Hughes

Replace GlDeprecatedDropdown with GlDropdown in app/assets/javascripts/logs

parent efc7239c
...@@ -3,12 +3,11 @@ import { throttle } from 'lodash'; ...@@ -3,12 +3,11 @@ import { throttle } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { import {
GlSprintf, GlSprintf,
GlIcon,
GlAlert, GlAlert,
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownHeader, GlDropdownSectionHeader,
GlDeprecatedDropdownItem, GlDropdownItem,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlInfiniteScroll, GlInfiniteScroll,
} from '@gitlab/ui'; } from '@gitlab/ui';
...@@ -23,12 +22,11 @@ import { formatDate } from '../utils'; ...@@ -23,12 +22,11 @@ import { formatDate } from '../utils';
export default { export default {
components: { components: {
GlSprintf, GlSprintf,
GlIcon,
GlAlert, GlAlert,
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownHeader, GlDropdownSectionHeader,
GlDeprecatedDropdownItem, GlDropdownItem,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlInfiniteScroll, GlInfiniteScroll,
LogSimpleFilters, LogSimpleFilters,
LogAdvancedFilters, LogAdvancedFilters,
...@@ -174,46 +172,38 @@ export default { ...@@ -174,46 +172,38 @@ export default {
<div class="top-bar d-md-flex border bg-secondary-50 pt-2 pr-1 pb-0 pl-2"> <div class="top-bar d-md-flex border bg-secondary-50 pt-2 pr-1 pb-0 pl-2">
<div class="flex-grow-0"> <div class="flex-grow-0">
<gl-deprecated-dropdown <gl-dropdown
id="environments-dropdown" id="environments-dropdown"
:text="environments.current || managedApps.current" :text="environments.current || managedApps.current"
:disabled="environments.isLoading" :disabled="environments.isLoading"
class="mb-2 gl-h-32 pr-2 d-flex d-md-block js-environments-dropdown" class="gl-mr-3 gl-mb-3 gl-display-flex gl-display-md-block js-environments-dropdown"
> >
<gl-deprecated-dropdown-header class="gl-text-center"> <gl-dropdown-section-header>
{{ s__('Environments|Environments') }} {{ s__('Environments|Environments') }}
</gl-deprecated-dropdown-header> </gl-dropdown-section-header>
<gl-deprecated-dropdown-item <gl-dropdown-item
v-for="env in environments.options" v-for="env in environments.options"
:key="env.id" :key="env.id"
:is-check-item="true"
:is-checked="isCurrentEnvironment(env.name)"
@click="showEnvironment(env.name)" @click="showEnvironment(env.name)"
> >
<div class="d-flex"> {{ env.name }}
<gl-icon </gl-dropdown-item>
:class="{ invisible: !isCurrentEnvironment(env.name) }" <gl-dropdown-divider />
name="status_success_borderless" <gl-dropdown-section-header>
/>
<div class="gl-flex-grow-1">{{ env.name }}</div>
</div>
</gl-deprecated-dropdown-item>
<gl-deprecated-dropdown-divider />
<gl-deprecated-dropdown-header class="gl-text-center">
{{ s__('Environments|Managed apps') }} {{ s__('Environments|Managed apps') }}
</gl-deprecated-dropdown-header> </gl-dropdown-section-header>
<gl-deprecated-dropdown-item <gl-dropdown-item
v-for="app in managedApps.options" v-for="app in managedApps.options"
:key="app.id" :key="app.id"
:is-check-item="true"
:is-checked="isCurrentManagedApp(app.name)"
@click="showManagedApp(app.name)" @click="showManagedApp(app.name)"
> >
<div class="gl-display-flex"> {{ app.name }}
<gl-icon </gl-dropdown-item>
:class="{ invisible: !isCurrentManagedApp(app.name) }" </gl-dropdown>
name="status_success_borderless"
/>
<div class="gl-flex-grow-1">{{ app.name }}</div>
</div>
</gl-deprecated-dropdown-item>
</gl-deprecated-dropdown>
</div> </div>
<log-advanced-filters <log-advanced-filters
......
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { import { GlDropdown, GlDropdownSectionHeader, GlDropdownItem } from '@gitlab/ui';
GlIcon,
GlDeprecatedDropdown,
GlDeprecatedDropdownHeader,
GlDeprecatedDropdownItem,
} from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
export default { export default {
components: { components: {
GlIcon, GlDropdown,
GlDeprecatedDropdown, GlDropdownSectionHeader,
GlDeprecatedDropdownHeader, GlDropdownItem,
GlDeprecatedDropdownItem,
}, },
props: { props: {
disabled: { disabled: {
...@@ -44,35 +38,31 @@ export default { ...@@ -44,35 +38,31 @@ export default {
</script> </script>
<template> <template>
<div> <div>
<gl-deprecated-dropdown <gl-dropdown
ref="podsDropdown" ref="podsDropdown"
:text="podDropdownText" :text="podDropdownText"
:disabled="disabled" :disabled="disabled"
class="mb-2 gl-h-32 pr-2 d-flex d-md-block flex-grow-0 qa-pods-dropdown" class="gl-mr-3 gl-mb-3 gl-display-flex gl-display-md-block qa-pods-dropdown"
> >
<gl-deprecated-dropdown-header class="text-center"> <gl-dropdown-section-header>
{{ s__('Environments|Select pod') }} {{ s__('Environments|Select pod') }}
</gl-deprecated-dropdown-header> </gl-dropdown-section-header>
<gl-deprecated-dropdown-item v-if="!pods.options.length" disabled> <gl-dropdown-item v-if="!pods.options.length" disabled>
<span ref="noPodsMsg" class="text-muted"> <span ref="noPodsMsg" class="text-muted">
{{ s__('Environments|No pods to display') }} {{ s__('Environments|No pods to display') }}
</span> </span>
</gl-deprecated-dropdown-item> </gl-dropdown-item>
<gl-deprecated-dropdown-item <gl-dropdown-item
v-for="podName in pods.options" v-for="podName in pods.options"
:key="podName" :key="podName"
:is-check-item="true"
:is-checked="isCurrentPod(podName)"
class="text-nowrap" class="text-nowrap"
@click="showPodLogs(podName)" @click="showPodLogs(podName)"
> >
<div class="d-flex"> {{ podName }}
<gl-icon </gl-dropdown-item>
:class="{ invisible: !isCurrentPod(podName) }" </gl-dropdown>
name="status_success_borderless"
/>
<div class="flex-grow-1">{{ podName }}</div>
</div>
</gl-deprecated-dropdown-item>
</gl-deprecated-dropdown>
</div> </div>
</template> </template>
---
title: Replace-GlDeprecatedDropdown-with-GlDropdown-in-app/assets/javascripts/logs
merge_request: 41421
author: nuwe1
type: other
import { GlSprintf, GlIcon, GlDeprecatedDropdown, GlDeprecatedDropdownItem } from '@gitlab/ui'; import { GlSprintf, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import EnvironmentLogs from '~/logs/components/environment_logs.vue'; import EnvironmentLogs from '~/logs/components/environment_logs.vue';
...@@ -121,7 +121,7 @@ describe('EnvironmentLogs', () => { ...@@ -121,7 +121,7 @@ describe('EnvironmentLogs', () => {
it('displays UI elements', () => { it('displays UI elements', () => {
initWrapper(); initWrapper();
expect(findEnvironmentsDropdown().is(GlDeprecatedDropdown)).toBe(true); expect(findEnvironmentsDropdown().is(GlDropdown)).toBe(true);
expect(findSimpleFilters().exists()).toBe(true); expect(findSimpleFilters().exists()).toBe(true);
expect(findLogControlButtons().exists()).toBe(true); expect(findLogControlButtons().exists()).toBe(true);
...@@ -164,7 +164,7 @@ describe('EnvironmentLogs', () => { ...@@ -164,7 +164,7 @@ describe('EnvironmentLogs', () => {
it('displays a disabled environments dropdown', () => { it('displays a disabled environments dropdown', () => {
expect(findEnvironmentsDropdown().attributes('disabled')).toBe('true'); expect(findEnvironmentsDropdown().attributes('disabled')).toBe('true');
expect(findEnvironmentsDropdown().findAll(GlDeprecatedDropdownItem).length).toBe(0); expect(findEnvironmentsDropdown().findAll(GlDropdownItem).length).toBe(0);
}); });
it('does not update buttons state', () => { it('does not update buttons state', () => {
...@@ -241,7 +241,7 @@ describe('EnvironmentLogs', () => { ...@@ -241,7 +241,7 @@ describe('EnvironmentLogs', () => {
}); });
it('populates environments dropdown', () => { it('populates environments dropdown', () => {
const items = findEnvironmentsDropdown().findAll(GlDeprecatedDropdownItem); const items = findEnvironmentsDropdown().findAll(GlDropdownItem);
expect(findEnvironmentsDropdown().props('text')).toBe(mockEnvName); expect(findEnvironmentsDropdown().props('text')).toBe(mockEnvName);
expect(items.length).toBe(mockEnvironments.length); expect(items.length).toBe(mockEnvironments.length);
mockEnvironments.forEach((env, i) => { mockEnvironments.forEach((env, i) => {
...@@ -251,14 +251,14 @@ describe('EnvironmentLogs', () => { ...@@ -251,14 +251,14 @@ describe('EnvironmentLogs', () => {
}); });
it('dropdown has one environment selected', () => { it('dropdown has one environment selected', () => {
const items = findEnvironmentsDropdown().findAll(GlDeprecatedDropdownItem); const items = findEnvironmentsDropdown().findAll(GlDropdownItem);
mockEnvironments.forEach((env, i) => { mockEnvironments.forEach((env, i) => {
const item = items.at(i); const item = items.at(i);
if (item.text() !== mockEnvName) { if (item.text() !== mockEnvName) {
expect(item.find(GlIcon).classes('invisible')).toBe(true); expect(item.find(GlDropdownItem).attributes('ischecked')).toBeFalsy();
} else { } else {
expect(item.find(GlIcon).classes('invisible')).toBe(false); expect(item.find(GlDropdownItem).attributes('ischecked')).toBeTruthy();
} }
}); });
}); });
...@@ -286,7 +286,7 @@ describe('EnvironmentLogs', () => { ...@@ -286,7 +286,7 @@ describe('EnvironmentLogs', () => {
describe('when user clicks', () => { describe('when user clicks', () => {
it('environment name, trace is refreshed', () => { it('environment name, trace is refreshed', () => {
const items = findEnvironmentsDropdown().findAll(GlDeprecatedDropdownItem); const items = findEnvironmentsDropdown().findAll(GlDropdownItem);
const index = 1; // any env const index = 1; // any env
expect(dispatch).not.toHaveBeenCalledWith(`${module}/showEnvironment`, expect.anything()); expect(dispatch).not.toHaveBeenCalledWith(`${module}/showEnvironment`, expect.anything());
......
import { GlIcon, GlDeprecatedDropdownItem } from '@gitlab/ui'; import { GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createStore } from '~/logs/stores'; import { createStore } from '~/logs/stores';
import { mockPods, mockPodName } from '../mock_data'; import { mockPods, mockPodName } from '../mock_data';
...@@ -17,7 +17,7 @@ describe('LogSimpleFilters', () => { ...@@ -17,7 +17,7 @@ describe('LogSimpleFilters', () => {
const findPodsNoPodsText = () => wrapper.find({ ref: 'noPodsMsg' }); const findPodsNoPodsText = () => wrapper.find({ ref: 'noPodsMsg' });
const findPodsDropdownItems = () => const findPodsDropdownItems = () =>
findPodsDropdown() findPodsDropdown()
.findAll(GlDeprecatedDropdownItem) .findAll(GlDropdownItem)
.filter(item => !('disabled' in item.attributes())); .filter(item => !('disabled' in item.attributes()));
const mockPodsLoading = () => { const mockPodsLoading = () => {
...@@ -114,9 +114,9 @@ describe('LogSimpleFilters', () => { ...@@ -114,9 +114,9 @@ describe('LogSimpleFilters', () => {
mockPods.forEach((pod, i) => { mockPods.forEach((pod, i) => {
const item = items.at(i); const item = items.at(i);
if (item.text() !== mockPodName) { if (item.text() !== mockPodName) {
expect(item.find(GlIcon).classes('invisible')).toBe(true); expect(item.find(GlDropdownItem).attributes('ischecked')).toBeFalsy();
} else { } else {
expect(item.find(GlIcon).classes('invisible')).toBe(false); expect(item.find(GlDropdownItem).attributes('ischecked')).toBeTruthy();
} }
}); });
}); });
......
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