Commit 9d8801cf authored by Mike Greiling's avatar Mike Greiling

Merge branch '229206-batch-publish-button' into 'master'

Migrate batch publish buttons

Closes #229204 and #229206

See merge request gitlab-org/gitlab!38839
parents 0f56fcb5 2623b1b6
<script> <script>
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import NoteableNote from '~/notes/components/noteable_note.vue'; import NoteableNote from '~/notes/components/noteable_note.vue';
import LoadingButton from '~/vue_shared/components/loading_button.vue'; import { GlButton } from '@gitlab/ui';
import PublishButton from './publish_button.vue'; import PublishButton from './publish_button.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
components: { components: {
NoteableNote, NoteableNote,
PublishButton, PublishButton,
LoadingButton, GlButton,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { props: {
...@@ -115,18 +115,15 @@ export default { ...@@ -115,18 +115,15 @@ export default {
></div> ></div>
<p class="draft-note-actions d-flex"> <p class="draft-note-actions d-flex">
<publish-button <publish-button :show-count="true" :should-publish="false" category="secondary" />
:show-count="true" <gl-button
:should-publish="false"
class="btn btn-success btn-inverted gl-mr-3"
/>
<loading-button
ref="publishNowButton" ref="publishNowButton"
:loading="isPublishingDraft(draft.id) || isPublishing" :loading="isPublishingDraft(draft.id) || isPublishing"
:label="__('Add comment now')" class="gl-ml-3"
container-class="btn btn-inverted"
@click="publishNow" @click="publishNow"
/> >
{{ __('Add comment now') }}
</gl-button>
</p> </p>
</template> </template>
</article> </article>
......
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { GlBadge } from '@gitlab/ui';
export default { export default {
components: {
GlBadge,
},
computed: { computed: {
...mapGetters('batchComments', ['draftsCount']), ...mapGetters('batchComments', ['draftsCount']),
}, },
}; };
</script> </script>
<template> <template>
<span class="drafts-count-component"> <gl-badge size="sm" variant="success">
<span class="drafts-count-number">{{ draftsCount }}</span> {{ draftsCount }}
<span class="sr-only"> {{ n__('draft', 'drafts', draftsCount) }} </span> <span class="sr-only"> {{ n__('draft', 'drafts', draftsCount) }} </span>
</span> </gl-badge>
</template> </template>
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import LoadingButton from '~/vue_shared/components/loading_button.vue'; import { GlButton } from '@gitlab/ui';
import DraftsCount from './drafts_count.vue'; import DraftsCount from './drafts_count.vue';
export default { export default {
components: { components: {
LoadingButton, GlButton,
DraftsCount, DraftsCount,
}, },
props: { props: {
...@@ -20,6 +20,16 @@ export default { ...@@ -20,6 +20,16 @@ export default {
required: false, required: false,
default: __('Finish review'), default: __('Finish review'),
}, },
category: {
type: String,
required: false,
default: 'primary',
},
variant: {
type: String,
required: false,
default: 'success',
},
shouldPublish: { shouldPublish: {
type: Boolean, type: Boolean,
required: true, required: true,
...@@ -42,14 +52,14 @@ export default { ...@@ -42,14 +52,14 @@ export default {
</script> </script>
<template> <template>
<loading-button <gl-button
:loading="isPublishing" :loading="isPublishing"
container-class="btn btn-success js-publish-draft-button qa-submit-review" class="js-publish-draft-button qa-submit-review"
:category="category"
:variant="variant"
@click="onClick" @click="onClick"
> >
<span> {{ label }}
{{ label }} <drafts-count v-if="showCount" />
<drafts-count v-if="showCount" /> </gl-button>
</span>
</loading-button>
</template> </template>
...@@ -4,18 +4,6 @@ $draft-actions-left-margin: 40px + $gl-padding; ...@@ -4,18 +4,6 @@ $draft-actions-left-margin: 40px + $gl-padding;
margin: 0; margin: 0;
background: $orange-50; background: $orange-50;
.drafts-count-component {
@include transition(background-color);
background: rgba($green-500, 0.2);
}
button:focus,
button:hover {
.drafts-count-component {
background: $black-transparent;
}
}
.referenced-commands.draft-note-commands { .referenced-commands.draft-note-commands {
background: $orange-100; background: $orange-100;
font-size: $label-font-size; font-size: $label-font-size;
...@@ -39,8 +27,9 @@ button[disabled] { ...@@ -39,8 +27,9 @@ button[disabled] {
&, &,
&:focus, &:focus,
&:hover { &:hover {
.drafts-count-component { .gl-badge {
background: $gl-gray-100; background: $gl-gray-100;
color: $gl-gray-500;
} }
} }
} }
......
$drafts-count-size: 1.6;
.drafts-count-component {
font-size: $label-font-size;
display: inline-block;
min-width: $drafts-count-size * 1em;
height: $drafts-count-size * 1em;
line-height: $drafts-count-size;
background: $black-transparent;
border-radius: 50%;
margin-left: $gl-padding-4;
padding: 0 $gl-padding-4;
}
...@@ -24,7 +24,7 @@ describe('Batch comments drafts count component', () => { ...@@ -24,7 +24,7 @@ describe('Batch comments drafts count component', () => {
}); });
it('renders count', () => { it('renders count', () => {
expect(vm.$el.querySelector('.drafts-count-number').textContent).toBe('1'); expect(vm.$el.textContent).toContain('1');
}); });
it('renders screen reader text', done => { it('renders screen reader text', done => {
......
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