Commit dec81a3f authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'sunjungp-master-patch-22797' into 'master'

Update GlDeprecatedButton with GlButton in deployment_action_button

Closes #219821

See merge request gitlab-org/gitlab!39700
parents 6d51ea5d b84d8891
...@@ -11,3 +11,9 @@ export const CANCELED = 'canceled'; ...@@ -11,3 +11,9 @@ export const CANCELED = 'canceled';
export const STOPPING = 'stopping'; export const STOPPING = 'stopping';
export const DEPLOYING = 'deploying'; export const DEPLOYING = 'deploying';
export const REDEPLOYING = 'redeploying'; export const REDEPLOYING = 'redeploying';
export const ACT_BUTTON_ICONS = {
play: 'play',
repeat: 'repeat',
stop: 'stop',
};
<script> <script>
import { GlTooltipDirective, GlDeprecatedButton } from '@gitlab/ui'; import { GlTooltipDirective, GlButton } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { RUNNING } from './constants'; import { RUNNING } from './constants';
export default { export default {
name: 'DeploymentActionButton', name: 'DeploymentActionButton',
components: { components: {
GlDeprecatedButton, GlButton,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -35,6 +35,10 @@ export default { ...@@ -35,6 +35,10 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
icon: {
type: String,
required: true,
},
}, },
computed: { computed: {
isActionInProgress() { isActionInProgress() {
...@@ -58,18 +62,19 @@ export default { ...@@ -58,18 +62,19 @@ export default {
</script> </script>
<template> <template>
<span v-gl-tooltip :title="actionInProgressTooltip" class="d-inline-block" tabindex="0"> <span v-gl-tooltip :title="actionInProgressTooltip" class="gl-display-inline-block" tabindex="0">
<gl-deprecated-button <gl-button
v-gl-tooltip v-gl-tooltip
category="primary"
size="small"
:title="buttonTitle" :title="buttonTitle"
:loading="isLoading" :loading="isLoading"
:disabled="isActionInProgress" :disabled="isActionInProgress"
:class="`btn btn-default btn-sm inline gl-ml-2 ${containerClasses}`" :class="`inline gl-ml-2 ${containerClasses}`"
:icon="icon"
@click="$emit('click')" @click="$emit('click')"
> >
<span class="d-inline-flex align-items-baseline">
<slot> </slot> <slot> </slot>
</span> </gl-button>
</gl-deprecated-button>
</span> </span>
</template> </template>
<script> <script>
import { GlIcon } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -7,14 +6,22 @@ import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; ...@@ -7,14 +6,22 @@ import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import MRWidgetService from '../../services/mr_widget_service'; import MRWidgetService from '../../services/mr_widget_service';
import DeploymentActionButton from './deployment_action_button.vue'; import DeploymentActionButton from './deployment_action_button.vue';
import DeploymentViewButton from './deployment_view_button.vue'; import DeploymentViewButton from './deployment_view_button.vue';
import { MANUAL_DEPLOY, FAILED, SUCCESS, STOPPING, DEPLOYING, REDEPLOYING } from './constants'; import {
MANUAL_DEPLOY,
FAILED,
SUCCESS,
STOPPING,
DEPLOYING,
REDEPLOYING,
ACT_BUTTON_ICONS,
} from './constants';
export default { export default {
name: 'DeploymentActions', name: 'DeploymentActions',
btnIcons: ACT_BUTTON_ICONS,
components: { components: {
DeploymentActionButton, DeploymentActionButton,
DeploymentViewButton, DeploymentViewButton,
GlIcon,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { props: {
...@@ -151,10 +158,10 @@ export default { ...@@ -151,10 +158,10 @@ export default {
:action-in-progress="actionInProgress" :action-in-progress="actionInProgress"
:actions-configuration="$options.actionsConfiguration[constants.DEPLOYING]" :actions-configuration="$options.actionsConfiguration[constants.DEPLOYING]"
:computed-deployment-status="computedDeploymentStatus" :computed-deployment-status="computedDeploymentStatus"
:icon="$options.btnIcons.play"
container-classes="js-manual-deploy-action" container-classes="js-manual-deploy-action"
@click="deployManually" @click="deployManually"
> >
<gl-icon name="play" />
<span>{{ $options.actionsConfiguration[constants.DEPLOYING].buttonText }}</span> <span>{{ $options.actionsConfiguration[constants.DEPLOYING].buttonText }}</span>
</deployment-action-button> </deployment-action-button>
<deployment-action-button <deployment-action-button
...@@ -162,10 +169,10 @@ export default { ...@@ -162,10 +169,10 @@ export default {
:action-in-progress="actionInProgress" :action-in-progress="actionInProgress"
:actions-configuration="$options.actionsConfiguration[constants.REDEPLOYING]" :actions-configuration="$options.actionsConfiguration[constants.REDEPLOYING]"
:computed-deployment-status="computedDeploymentStatus" :computed-deployment-status="computedDeploymentStatus"
:icon="$options.btnIcons.repeat"
container-classes="js-manual-redeploy-action" container-classes="js-manual-redeploy-action"
@click="redeploy" @click="redeploy"
> >
<gl-icon name="repeat" />
<span>{{ $options.actionsConfiguration[constants.REDEPLOYING].buttonText }}</span> <span>{{ $options.actionsConfiguration[constants.REDEPLOYING].buttonText }}</span>
</deployment-action-button> </deployment-action-button>
<deployment-view-button <deployment-view-button
...@@ -181,10 +188,9 @@ export default { ...@@ -181,10 +188,9 @@ export default {
:computed-deployment-status="computedDeploymentStatus" :computed-deployment-status="computedDeploymentStatus"
:actions-configuration="$options.actionsConfiguration[constants.STOPPING]" :actions-configuration="$options.actionsConfiguration[constants.STOPPING]"
:button-title="$options.actionsConfiguration[constants.STOPPING].buttonText" :button-title="$options.actionsConfiguration[constants.STOPPING].buttonText"
:icon="$options.btnIcons.stop"
container-classes="js-stop-env" container-classes="js-stop-env"
@click="stopEnvironment" @click="stopEnvironment"
> />
<gl-icon name="stop" />
</deployment-action-button>
</div> </div>
</template> </template>
---
title: Update GlDeprecatedButton with GlButton in deployment_action_button
merge_request: 39700
author:
type: changed
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlIcon, GlLoadingIcon, GlDeprecatedButton } from '@gitlab/ui'; import { GlIcon, GlLoadingIcon, GlButton } from '@gitlab/ui';
import DeploymentActionButton from '~/vue_merge_request_widget/components/deployment/deployment_action_button.vue'; import DeploymentActionButton from '~/vue_merge_request_widget/components/deployment/deployment_action_button.vue';
import { import {
CREATED, CREATED,
...@@ -13,6 +13,7 @@ const baseProps = { ...@@ -13,6 +13,7 @@ const baseProps = {
actionsConfiguration: actionButtonMocks[DEPLOYING], actionsConfiguration: actionButtonMocks[DEPLOYING],
actionInProgress: null, actionInProgress: null,
computedDeploymentStatus: CREATED, computedDeploymentStatus: CREATED,
icon: 'play',
}; };
describe('Deployment action button', () => { describe('Deployment action button', () => {
...@@ -28,18 +29,18 @@ describe('Deployment action button', () => { ...@@ -28,18 +29,18 @@ describe('Deployment action button', () => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('when passed only icon', () => { describe('when passed only icon via props', () => {
beforeEach(() => { beforeEach(() => {
factory({ factory({
propsData: baseProps, propsData: baseProps,
slots: { default: ['<gl-icon name="stop" />'] }, slots: {},
stubs: { stubs: {
'gl-icon': GlIcon, 'gl-icon': GlIcon,
}, },
}); });
}); });
it('renders slot correctly', () => { it('renders prop icon correctly', () => {
expect(wrapper.find(GlIcon).exists()).toBe(true); expect(wrapper.find(GlIcon).exists()).toBe(true);
}); });
}); });
...@@ -49,7 +50,7 @@ describe('Deployment action button', () => { ...@@ -49,7 +50,7 @@ describe('Deployment action button', () => {
factory({ factory({
propsData: baseProps, propsData: baseProps,
slots: { slots: {
default: ['<gl-icon name="play" />', `<span>${actionButtonMocks[DEPLOYING]}</span>`], default: [`<span>${actionButtonMocks[DEPLOYING]}</span>`],
}, },
stubs: { stubs: {
'gl-icon': GlIcon, 'gl-icon': GlIcon,
...@@ -57,7 +58,7 @@ describe('Deployment action button', () => { ...@@ -57,7 +58,7 @@ describe('Deployment action button', () => {
}); });
}); });
it('renders slot correctly', () => { it('renders slot and icon prop correctly', () => {
expect(wrapper.find(GlIcon).exists()).toBe(true); expect(wrapper.find(GlIcon).exists()).toBe(true);
expect(wrapper.text()).toContain(actionButtonMocks[DEPLOYING]); expect(wrapper.text()).toContain(actionButtonMocks[DEPLOYING]);
}); });
...@@ -75,7 +76,7 @@ describe('Deployment action button', () => { ...@@ -75,7 +76,7 @@ describe('Deployment action button', () => {
it('is disabled and shows the loading icon', () => { it('is disabled and shows the loading icon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
expect(wrapper.find(GlDeprecatedButton).props('disabled')).toBe(true); expect(wrapper.find(GlButton).props('disabled')).toBe(true);
}); });
}); });
...@@ -90,7 +91,7 @@ describe('Deployment action button', () => { ...@@ -90,7 +91,7 @@ describe('Deployment action button', () => {
}); });
it('is disabled and does not show the loading icon', () => { it('is disabled and does not show the loading icon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.find(GlDeprecatedButton).props('disabled')).toBe(true); expect(wrapper.find(GlButton).props('disabled')).toBe(true);
}); });
}); });
...@@ -106,7 +107,7 @@ describe('Deployment action button', () => { ...@@ -106,7 +107,7 @@ describe('Deployment action button', () => {
}); });
it('is disabled and does not show the loading icon', () => { it('is disabled and does not show the loading icon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.find(GlDeprecatedButton).props('disabled')).toBe(true); expect(wrapper.find(GlButton).props('disabled')).toBe(true);
}); });
}); });
...@@ -118,7 +119,7 @@ describe('Deployment action button', () => { ...@@ -118,7 +119,7 @@ describe('Deployment action button', () => {
}); });
it('is not disabled nor does it show the loading icon', () => { it('is not disabled nor does it show the loading icon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.find(GlDeprecatedButton).props('disabled')).toBe(false); expect(wrapper.find(GlButton).props('disabled')).toBe(false);
}); });
}); });
}); });
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