Commit b746b126 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '229344-update-confidential-form-buttons' into 'master'

Update confidential form buttons

Closes #229344

See merge request gitlab-org/gitlab!40893
parents ee0d1c43 86a705c4
<script>
import $ from 'jquery';
import { GlLoadingIcon } from '@gitlab/ui';
import { GlButton } from '@gitlab/ui';
import { mapActions } from 'vuex';
import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '~/flash';
......@@ -8,7 +8,7 @@ import eventHub from '../../event_hub';
export default {
components: {
GlLoadingIcon,
GlButton,
},
props: {
fullPath: {
......@@ -64,18 +64,18 @@ export default {
<template>
<div class="sidebar-item-warning-message-actions">
<button type="button" class="btn btn-default gl-mr-3" @click="closeForm">
<gl-button class="gl-mr-3" @click="closeForm">
{{ __('Cancel') }}
</button>
<button
type="button"
class="btn btn-close"
data-testid="confidential-toggle"
</gl-button>
<gl-button
category="secondary"
variant="warning"
:disabled="isLoading"
:loading="isLoading"
data-testid="confidential-toggle"
@click.prevent="submitForm"
>
<gl-loading-icon v-if="isLoading" inline />
{{ toggleButtonText }}
</button>
</gl-button>
</div>
</template>
---
title: Update confidential form buttons to gl-button
merge_request: 40893
author:
type: changed
......@@ -39,7 +39,7 @@ RSpec.describe 'Issues > User sees live update', :js do
expect(page).to have_css('.sidebar-item-warning-message')
within('.sidebar-item-warning-message') do
find('.btn-close').click
find('[data-testid="confidential-toggle"]').click
end
wait_for_requests
......
import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import waitForPromises from 'helpers/wait_for_promises';
import EditFormButtons from '~/sidebar/components/confidential/edit_form_buttons.vue';
import eventHub from '~/sidebar/event_hub';
......@@ -56,11 +55,11 @@ describe('Edit Form Buttons', () => {
});
it('disables the toggle button', () => {
expect(findConfidentialToggle().attributes('disabled')).toBe('disabled');
expect(findConfidentialToggle().props('disabled')).toBe(true);
});
it('finds the GlLoadingIcon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
it('sets loading on the toggle button', () => {
expect(findConfidentialToggle().props('loading')).toBe(true);
});
});
......@@ -99,7 +98,7 @@ describe('Edit Form Buttons', () => {
describe('when succeeds', () => {
beforeEach(() => {
createComponent({ data: { isLoading: false }, props: { confidential: true } });
findConfidentialToggle().trigger('click');
findConfidentialToggle().vm.$emit('click', new Event('click'));
});
it('dispatches the correct action', () => {
......@@ -109,9 +108,9 @@ describe('Edit Form Buttons', () => {
});
});
it('resets loading', () => {
it('resets loading on the toggle button', () => {
return waitForPromises().then(() => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(findConfidentialToggle().props('loading')).toBe(false);
});
});
......@@ -135,7 +134,7 @@ describe('Edit Form Buttons', () => {
props: { confidential: true },
resolved: false,
});
findConfidentialToggle().trigger('click');
findConfidentialToggle().vm.$emit('click', new Event('click'));
});
it('calls flash with the correct message', () => {
......
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