Commit 4a78ec9f authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'migrate-environment_actions-button' into 'master'

Migrate Bootstrap button for environment_actions

See merge request gitlab-org/gitlab!41844
parents 367a4e9d 891476a0
<script> <script>
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlButton, GlIcon, GlLoadingIcon } from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import { formatTime } from '~/lib/utils/datetime_utility'; import { formatTime } from '~/lib/utils/datetime_utility';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -10,6 +10,7 @@ export default { ...@@ -10,6 +10,7 @@ export default {
tooltip, tooltip,
}, },
components: { components: {
GlButton,
GlIcon, GlIcon,
GlLoadingIcon, GlLoadingIcon,
}, },
...@@ -68,13 +69,12 @@ export default { ...@@ -68,13 +69,12 @@ export default {
</script> </script>
<template> <template>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button <gl-button
v-tooltip v-tooltip
:title="title" :title="title"
:aria-label="title" :aria-label="title"
:disabled="isLoading" :disabled="isLoading"
type="button" class="dropdown dropdown-new js-environment-actions-dropdown"
class="dropdown btn btn-default dropdown-new js-environment-actions-dropdown"
data-container="body" data-container="body"
data-toggle="dropdown" data-toggle="dropdown"
> >
...@@ -83,23 +83,23 @@ export default { ...@@ -83,23 +83,23 @@ export default {
<gl-icon name="chevron-down" /> <gl-icon name="chevron-down" />
<gl-loading-icon v-if="isLoading" /> <gl-loading-icon v-if="isLoading" />
</span> </span>
</button> </gl-button>
<ul class="dropdown-menu dropdown-menu-right"> <ul class="dropdown-menu dropdown-menu-right">
<li v-for="(action, i) in actions" :key="i"> <li v-for="(action, i) in actions" :key="i" class="gl-display-flex">
<button <gl-button
:class="{ disabled: isActionDisabled(action) }" :class="{ disabled: isActionDisabled(action) }"
:disabled="isActionDisabled(action)" :disabled="isActionDisabled(action)"
type="button" variant="link"
class="js-manual-action-link no-btn btn d-flex align-items-center" class="js-manual-action-link gl-flex-fill-1"
@click="onClickAction(action)" @click="onClickAction(action)"
> >
<span class="flex-fill">{{ action.name }}</span> <span class="gl-flex-fill-1">{{ action.name }}</span>
<span v-if="action.scheduledAt" class="text-secondary"> <span v-if="action.scheduledAt" class="text-secondary float-right">
<gl-icon name="clock" /> <gl-icon name="clock" />
{{ remainingTime(action) }} {{ remainingTime(action) }}
</span> </span>
</button> </gl-button>
</li> </li>
</ul> </ul>
</div> </div>
......
---
title: Migrate Bootstrap button for environment_actions
merge_request: 41844
author:
type: other
...@@ -46,7 +46,7 @@ RSpec.describe 'Environments page', :js do ...@@ -46,7 +46,7 @@ RSpec.describe 'Environments page', :js do
it 'shows an enabled play button' do it 'shows an enabled play button' do
find('.js-environment-actions-dropdown').click find('.js-environment-actions-dropdown').click
play_button = %q{button.js-manual-action-link.no-btn.btn} play_button = %q{button.js-manual-action-link}
expect(page).to have_selector(play_button) expect(page).to have_selector(play_button)
end end
...@@ -130,7 +130,7 @@ RSpec.describe 'Environments page', :js do ...@@ -130,7 +130,7 @@ RSpec.describe 'Environments page', :js do
it 'show a disabled play button' do it 'show a disabled play button' do
find('.js-environment-actions-dropdown').click find('.js-environment-actions-dropdown').click
disabled_play_button = %q{button.js-manual-action-link.no-btn.btn.disabled} disabled_play_button = %q{button.js-manual-action-link.disabled}
expect(page).to have_selector(disabled_play_button) expect(page).to have_selector(disabled_play_button)
end end
......
...@@ -59,11 +59,7 @@ describe('EnvironmentActions Component', () => { ...@@ -59,11 +59,7 @@ describe('EnvironmentActions Component', () => {
}); });
it("should render a disabled action when it's not playable", () => { it("should render a disabled action when it's not playable", () => {
expect(vm.find('.dropdown-menu li:last-child button').attributes('disabled')).toEqual( expect(vm.find('.dropdown-menu li:last-child gl-button-stub').props('disabled')).toBe(true);
'disabled',
);
expect(vm.find('.dropdown-menu li:last-child button').classes('disabled')).toBe(true);
}); });
}); });
...@@ -81,7 +77,7 @@ describe('EnvironmentActions Component', () => { ...@@ -81,7 +77,7 @@ describe('EnvironmentActions Component', () => {
scheduledAt: '2018-10-05T08:23:00Z', scheduledAt: '2018-10-05T08:23:00Z',
}; };
const findDropdownItem = action => { const findDropdownItem = action => {
const buttons = vm.findAll('.dropdown-menu li button'); const buttons = vm.findAll('.dropdown-menu li gl-button-stub');
return buttons.filter(button => button.text().startsWith(action.name)).at(0); return buttons.filter(button => button.text().startsWith(action.name)).at(0);
}; };
...@@ -95,7 +91,7 @@ describe('EnvironmentActions Component', () => { ...@@ -95,7 +91,7 @@ describe('EnvironmentActions Component', () => {
eventHub.$on('postAction', emitSpy); eventHub.$on('postAction', emitSpy);
jest.spyOn(window, 'confirm').mockImplementation(() => true); jest.spyOn(window, 'confirm').mockImplementation(() => true);
findDropdownItem(scheduledJobAction).trigger('click'); findDropdownItem(scheduledJobAction).vm.$emit('click');
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
expect(emitSpy).toHaveBeenCalledWith({ endpoint: scheduledJobAction.playPath }); expect(emitSpy).toHaveBeenCalledWith({ endpoint: scheduledJobAction.playPath });
...@@ -106,7 +102,7 @@ describe('EnvironmentActions Component', () => { ...@@ -106,7 +102,7 @@ describe('EnvironmentActions Component', () => {
eventHub.$on('postAction', emitSpy); eventHub.$on('postAction', emitSpy);
jest.spyOn(window, 'confirm').mockImplementation(() => false); jest.spyOn(window, 'confirm').mockImplementation(() => false);
findDropdownItem(scheduledJobAction).trigger('click'); findDropdownItem(scheduledJobAction).vm.$emit('click');
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
expect(emitSpy).not.toHaveBeenCalled(); expect(emitSpy).not.toHaveBeenCalled();
......
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