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

Replace GlDeprecatedDropdown in app/assets/javascripts/alertmanagement

parent 73756dad
<script> <script>
import { GlDeprecatedDropdown, GlDeprecatedDropdownItem, GlButton } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { trackAlertStatusUpdateOptions } from '../constants'; import { trackAlertStatusUpdateOptions } from '../constants';
...@@ -18,9 +18,8 @@ export default { ...@@ -18,9 +18,8 @@ export default {
RESOLVED: s__('AlertManagement|Resolved'), RESOLVED: s__('AlertManagement|Resolved'),
}, },
components: { components: {
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownItem, GlDropdownItem,
GlButton,
}, },
props: { props: {
projectPath: { projectPath: {
...@@ -91,39 +90,30 @@ export default { ...@@ -91,39 +90,30 @@ export default {
<template> <template>
<div class="dropdown dropdown-menu-selectable" :class="dropdownClass"> <div class="dropdown dropdown-menu-selectable" :class="dropdownClass">
<gl-deprecated-dropdown <gl-dropdown
ref="dropdown" ref="dropdown"
right right
:text="$options.statuses[alert.status]" :text="$options.statuses[alert.status]"
class="w-100" class="w-100"
toggle-class="dropdown-menu-toggle" toggle-class="dropdown-menu-toggle"
variant="outline-default"
@keydown.esc.native="$emit('hide-dropdown')" @keydown.esc.native="$emit('hide-dropdown')"
@hide="$emit('hide-dropdown')" @hide="$emit('hide-dropdown')"
> >
<div v-if="isSidebar" class="dropdown-title gl-display-flex"> <p v-if="isSidebar" class="gl-new-dropdown-header-top" data-testid="dropdown-header">
<span class="alert-title gl-ml-auto">{{ s__('AlertManagement|Assign status') }}</span> {{ s__('AlertManagement|Assign status') }}
<gl-button </p>
:aria-label="__('Close')"
variant="link"
class="dropdown-title-button dropdown-menu-close gl-ml-auto gl-text-black-normal!"
icon="close"
@click="$emit('hide-dropdown')"
/>
</div>
<div class="dropdown-content dropdown-body"> <div class="dropdown-content dropdown-body">
<gl-deprecated-dropdown-item <gl-dropdown-item
v-for="(label, field) in $options.statuses" v-for="(label, field) in $options.statuses"
:key="field" :key="field"
data-testid="statusDropdownItem" data-testid="statusDropdownItem"
class="gl-vertical-align-middle"
:active="label.toUpperCase() === alert.status" :active="label.toUpperCase() === alert.status"
:active-class="'is-active'" :active-class="'is-active'"
@click="updateAlertStatus(label)" @click="updateAlertStatus(label)"
> >
{{ label }} {{ label }}
</gl-deprecated-dropdown-item> </gl-dropdown-item>
</div> </div>
</gl-deprecated-dropdown> </gl-dropdown>
</div> </div>
</template> </template>
<script> <script>
import { GlDeprecatedDropdownItem } from '@gitlab/ui'; import { GlDropdownItem } from '@gitlab/ui';
export default { export default {
components: { components: {
GlDeprecatedDropdownItem, GlDropdownItem,
}, },
props: { props: {
user: { user: {
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
</script> </script>
<template> <template>
<gl-deprecated-dropdown-item <gl-dropdown-item
:key="user.username" :key="user.username"
data-testid="assigneeDropdownItem" data-testid="assigneeDropdownItem"
class="assignee-dropdown-item gl-vertical-align-middle" class="assignee-dropdown-item gl-vertical-align-middle"
...@@ -47,5 +47,5 @@ export default { ...@@ -47,5 +47,5 @@ export default {
</strong> </strong>
<span class="dropdown-menu-user-username"> {{ user.username }}</span> <span class="dropdown-menu-user-username"> {{ user.username }}</span>
</span> </span>
</gl-deprecated-dropdown-item> </gl-dropdown-item>
</template> </template>
<script> <script>
import { import {
GlIcon, GlIcon,
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlDeprecatedDropdownHeader, GlDropdownSectionHeader,
GlDeprecatedDropdownItem, GlDropdownItem,
GlSearchBoxByType,
GlLoadingIcon, GlLoadingIcon,
GlTooltip, GlTooltip,
GlButton, GlButton,
...@@ -33,10 +34,11 @@ export default { ...@@ -33,10 +34,11 @@ export default {
}, },
components: { components: {
GlIcon, GlIcon,
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownItem, GlDropdownItem,
GlDeprecatedDropdownDivider, GlDropdownDivider,
GlDeprecatedDropdownHeader, GlDropdownSectionHeader,
GlSearchBoxByType,
GlLoadingIcon, GlLoadingIcon,
GlTooltip, GlTooltip,
GlButton, GlButton,
...@@ -216,48 +218,36 @@ export default { ...@@ -216,48 +218,36 @@ export default {
</p> </p>
<div class="dropdown dropdown-menu-selectable" :class="dropdownClass"> <div class="dropdown dropdown-menu-selectable" :class="dropdownClass">
<gl-deprecated-dropdown <gl-dropdown
ref="dropdown" ref="dropdown"
:text="userName" :text="userName"
class="w-100" class="w-100"
toggle-class="dropdown-menu-toggle" toggle-class="dropdown-menu-toggle"
variant="outline-default"
@keydown.esc.native="hideDropdown" @keydown.esc.native="hideDropdown"
@hide="hideDropdown" @hide="hideDropdown"
> >
<div class="dropdown-title gl-display-flex"> <p class="gl-new-dropdown-header-top">
<span class="alert-title gl-ml-auto">{{ __('Assign To') }}</span> {{ __('Assign To') }}
<gl-button </p>
:aria-label="__('Close')" <gl-search-box-by-type
variant="link"
class="dropdown-title-button dropdown-menu-close gl-ml-auto gl-text-black-normal!"
icon="close"
@click="hideDropdown"
/>
</div>
<div class="dropdown-input">
<input
v-model.trim="search" v-model.trim="search"
class="dropdown-input-field" class="m-2"
type="search"
:placeholder="__('Search users')" :placeholder="__('Search users')"
/> />
<gl-icon name="search" class="dropdown-input-search ic-search" data-hidden="true" />
</div>
<div class="dropdown-content dropdown-body"> <div class="dropdown-content dropdown-body">
<template v-if="userListValid"> <template v-if="userListValid">
<gl-deprecated-dropdown-item <gl-dropdown-item
:active="!userName" :active="!userName"
active-class="is-active" active-class="is-active"
@click="updateAlertAssignees('')" @click="updateAlertAssignees('')"
> >
{{ __('Unassigned') }} {{ __('Unassigned') }}
</gl-deprecated-dropdown-item> </gl-dropdown-item>
<gl-deprecated-dropdown-divider /> <gl-dropdown-divider />
<gl-deprecated-dropdown-header class="mt-0"> <gl-dropdown-section-header>
{{ __('Assignee') }} {{ __('Assignee') }}
</gl-deprecated-dropdown-header> </gl-dropdown-section-header>
<sidebar-assignee <sidebar-assignee
v-for="user in sortedUsers" v-for="user in sortedUsers"
:key="user.username" :key="user.username"
...@@ -266,12 +256,12 @@ export default { ...@@ -266,12 +256,12 @@ export default {
@update-alert-assignees="updateAlertAssignees" @update-alert-assignees="updateAlertAssignees"
/> />
</template> </template>
<gl-deprecated-dropdown-item v-else-if="userListEmpty"> <p v-else-if="userListEmpty" class="mx-3 my-2">
{{ __('No Matching Results') }} {{ __('No Matching Results') }}
</gl-deprecated-dropdown-item> </p>
<gl-loading-icon v-else /> <gl-loading-icon v-else />
</div> </div>
</gl-deprecated-dropdown> </gl-dropdown>
</div> </div>
<gl-loading-icon v-if="isUpdating" :inline="true" /> <gl-loading-icon v-if="isUpdating" :inline="true" />
......
---
title: Replace-GIDeprecatedDropdown-in-app/assets/javascripts/alert_management
merge_request: 41409
author: nuwe1
type: other
...@@ -3,8 +3,8 @@ import { ...@@ -3,8 +3,8 @@ import {
GlTable, GlTable,
GlAlert, GlAlert,
GlLoadingIcon, GlLoadingIcon,
GlDeprecatedDropdown, GlDropdown,
GlDeprecatedDropdownItem, GlDropdownItem,
GlIcon, GlIcon,
GlTabs, GlTabs,
GlTab, GlTab,
...@@ -34,12 +34,12 @@ describe('AlertManagementTable', () => { ...@@ -34,12 +34,12 @@ describe('AlertManagementTable', () => {
const findAlerts = () => wrapper.findAll('table tbody tr'); const findAlerts = () => wrapper.findAll('table tbody tr');
const findAlert = () => wrapper.find(GlAlert); const findAlert = () => wrapper.find(GlAlert);
const findLoader = () => wrapper.find(GlLoadingIcon); const findLoader = () => wrapper.find(GlLoadingIcon);
const findStatusDropdown = () => wrapper.find(GlDeprecatedDropdown); const findStatusDropdown = () => wrapper.find(GlDropdown);
const findStatusFilterTabs = () => wrapper.findAll(GlTab); const findStatusFilterTabs = () => wrapper.findAll(GlTab);
const findStatusTabs = () => wrapper.find(GlTabs); const findStatusTabs = () => wrapper.find(GlTabs);
const findStatusFilterBadge = () => wrapper.findAll(GlBadge); const findStatusFilterBadge = () => wrapper.findAll(GlBadge);
const findDateFields = () => wrapper.findAll(TimeAgo); const findDateFields = () => wrapper.findAll(TimeAgo);
const findFirstStatusOption = () => findStatusDropdown().find(GlDeprecatedDropdownItem); const findFirstStatusOption = () => findStatusDropdown().find(GlDropdownItem);
const findPagination = () => wrapper.find(GlPagination); const findPagination = () => wrapper.find(GlPagination);
const findSearch = () => wrapper.find(GlSearchBoxByType); const findSearch = () => wrapper.find(GlSearchBoxByType);
const findSeverityColumnHeader = () => const findSeverityColumnHeader = () =>
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { GlDeprecatedDropdownItem } from '@gitlab/ui'; import { GlDropdownItem } from '@gitlab/ui';
import SidebarAssignee from '~/alert_management/components/sidebar/sidebar_assignee.vue'; import SidebarAssignee from '~/alert_management/components/sidebar/sidebar_assignee.vue';
import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue'; import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue';
import AlertSetAssignees from '~/alert_management/graphql/mutations/alert_set_assignees.mutation.graphql'; import AlertSetAssignees from '~/alert_management/graphql/mutations/alert_set_assignees.mutation.graphql';
...@@ -106,7 +106,7 @@ describe('Alert Details Sidebar Assignees', () => { ...@@ -106,7 +106,7 @@ describe('Alert Details Sidebar Assignees', () => {
it('renders a unassigned option', async () => { it('renders a unassigned option', async () => {
wrapper.setData({ isDropdownSearching: false }); wrapper.setData({ isDropdownSearching: false });
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.find(GlDeprecatedDropdownItem).text()).toBe('Unassigned'); expect(wrapper.find(GlDropdownItem).text()).toBe('Unassigned');
}); });
it('calls `$apollo.mutate` with `AlertSetAssignees` mutation and variables containing `iid`, `assigneeUsernames`, & `projectPath`', async () => { it('calls `$apollo.mutate` with `AlertSetAssignees` mutation and variables containing `iid`, `assigneeUsernames`, & `projectPath`', async () => {
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlDeprecatedDropdown, GlDeprecatedDropdownItem, GlLoadingIcon } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlLoadingIcon } from '@gitlab/ui';
import { trackAlertStatusUpdateOptions } from '~/alert_management/constants'; import { trackAlertStatusUpdateOptions } from '~/alert_management/constants';
import AlertSidebarStatus from '~/alert_management/components/sidebar/sidebar_status.vue'; import AlertSidebarStatus from '~/alert_management/components/sidebar/sidebar_status.vue';
import updateAlertStatus from '~/alert_management/graphql/mutations/update_alert_status.mutation.graphql'; import updateAlertStatus from '~/alert_management/graphql/mutations/update_alert_status.mutation.graphql';
...@@ -10,9 +10,10 @@ const mockAlert = mockAlerts[0]; ...@@ -10,9 +10,10 @@ const mockAlert = mockAlerts[0];
describe('Alert Details Sidebar Status', () => { describe('Alert Details Sidebar Status', () => {
let wrapper; let wrapper;
const findStatusDropdown = () => wrapper.find(GlDeprecatedDropdown); const findStatusDropdown = () => wrapper.find(GlDropdown);
const findStatusDropdownItem = () => wrapper.find(GlDeprecatedDropdownItem); const findStatusDropdownItem = () => wrapper.find(GlDropdownItem);
const findStatusLoadingIcon = () => wrapper.find(GlLoadingIcon); const findStatusLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findStatusDropdownHeader = () => wrapper.find('[data-testid="dropdown-header"]');
function mountComponent({ data, sidebarCollapsed = true, loading = false, stubs = {} } = {}) { function mountComponent({ data, sidebarCollapsed = true, loading = false, stubs = {} } = {}) {
wrapper = mount(AlertSidebarStatus, { wrapper = mount(AlertSidebarStatus, {
...@@ -56,11 +57,7 @@ describe('Alert Details Sidebar Status', () => { ...@@ -56,11 +57,7 @@ describe('Alert Details Sidebar Status', () => {
}); });
it('displays the dropdown status header', () => { it('displays the dropdown status header', () => {
expect( expect(findStatusDropdownHeader().exists()).toBe(true);
findStatusDropdown()
.find('.dropdown-title')
.exists(),
).toBe(true);
}); });
describe('updating the alert status', () => { describe('updating the alert status', () => {
......
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