Commit c78087d1 authored by Frédéric Caplette's avatar Frédéric Caplette

Merge branch '346370-tooltips-paused-runner' into 'master'

Update runner Pause/Resume button labels

See merge request gitlab-org/gitlab!82702
parents c329d4ea 6963d4a3
...@@ -3,7 +3,7 @@ import { GlButton, GlTooltipDirective } from '@gitlab/ui'; ...@@ -3,7 +3,7 @@ import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import runnerToggleActiveMutation from '~/runner/graphql/shared/runner_toggle_active.mutation.graphql'; import runnerToggleActiveMutation from '~/runner/graphql/shared/runner_toggle_active.mutation.graphql';
import { createAlert } from '~/flash'; import { createAlert } from '~/flash';
import { captureException } from '~/runner/sentry_utils'; import { captureException } from '~/runner/sentry_utils';
import { I18N_PAUSE, I18N_RESUME } from '../constants'; import { I18N_PAUSE, I18N_PAUSE_TOOLTIP, I18N_RESUME, I18N_RESUME_TOOLTIP } from '../constants';
export default { export default {
name: 'RunnerPauseButton', name: 'RunnerPauseButton',
...@@ -52,11 +52,10 @@ export default { ...@@ -52,11 +52,10 @@ export default {
return null; return null;
}, },
tooltip() { tooltip() {
// Only show tooltip when compact. // Prevent a "sticky" tooltip: If this button is disabled,
// Also prevent a "sticky" tooltip: If this button is // mouseout listeners don't run leaving the tooltip stuck
// disabled, mouseout listeners don't run leaving the tooltip stuck if (!this.updating) {
if (this.compact && !this.updating) { return this.isActive ? I18N_PAUSE_TOOLTIP : I18N_RESUME_TOOLTIP;
return this.label;
} }
return ''; return '';
}, },
...@@ -102,7 +101,7 @@ export default { ...@@ -102,7 +101,7 @@ export default {
<template> <template>
<gl-button <gl-button
v-gl-tooltip.hover.viewport="tooltip" v-gl-tooltip="tooltip"
v-bind="$attrs" v-bind="$attrs"
:aria-label="ariaLabel" :aria-label="ariaLabel"
:icon="icon" :icon="icon"
......
<script> <script>
import { GlBadge, GlTooltipDirective } from '@gitlab/ui'; import { GlBadge, GlTooltipDirective } from '@gitlab/ui';
import { I18N_PAUSED_RUNNER_DESCRIPTION } from '../constants'; import { I18N_PAUSED_DESCRIPTION } from '../constants';
export default { export default {
components: { components: {
...@@ -9,17 +9,11 @@ export default { ...@@ -9,17 +9,11 @@ export default {
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
i18n: { I18N_PAUSED_DESCRIPTION,
I18N_PAUSED_RUNNER_DESCRIPTION,
},
}; };
</script> </script>
<template> <template>
<gl-badge <gl-badge v-gl-tooltip="$options.I18N_PAUSED_DESCRIPTION" variant="danger" v-bind="$attrs">
v-gl-tooltip="$options.i18n.I18N_PAUSED_RUNNER_DESCRIPTION"
variant="danger"
v-bind="$attrs"
>
{{ s__('Runners|paused') }} {{ s__('Runners|paused') }}
</gl-badge> </gl-badge>
</template> </template>
...@@ -37,13 +37,18 @@ export const I18N_STALE_RUNNER_DESCRIPTION = s__( ...@@ -37,13 +37,18 @@ export const I18N_STALE_RUNNER_DESCRIPTION = s__(
// Actions // Actions
export const I18N_EDIT = __('Edit'); export const I18N_EDIT = __('Edit');
export const I18N_PAUSE = __('Pause'); export const I18N_PAUSE = __('Pause');
export const I18N_PAUSE_TOOLTIP = s__('Runners|Pause from accepting jobs');
export const I18N_PAUSED_DESCRIPTION = s__('Runners|Not accepting jobs');
export const I18N_RESUME = __('Resume'); export const I18N_RESUME = __('Resume');
export const I18N_RESUME_TOOLTIP = s__('Runners|Resume accepting jobs');
export const I18N_DELETE_RUNNER = s__('Runners|Delete runner'); export const I18N_DELETE_RUNNER = s__('Runners|Delete runner');
export const I18N_DELETED_TOAST = s__('Runners|Runner %{name} was deleted'); export const I18N_DELETED_TOAST = s__('Runners|Runner %{name} was deleted');
export const I18N_LOCKED_RUNNER_DESCRIPTION = s__('Runners|You cannot assign to other projects'); export const I18N_LOCKED_RUNNER_DESCRIPTION = s__('Runners|You cannot assign to other projects');
export const I18N_PAUSED_RUNNER_DESCRIPTION = s__('Runners|Not available to run jobs');
// Runner details // Runner details
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
- if runner.locked? - if runner.locked?
= gl_badge_tag s_('Runners|locked'), variant: :warning, size: :sm = gl_badge_tag s_('Runners|locked'), variant: :warning, size: :sm
- unless runner.active? - unless runner.active?
= gl_badge_tag s_('Runners|paused'), variant: :danger, size: :sm = gl_badge_tag s_('Runners|paused'), { variant: :danger, size: :sm }, { title: s_('Runners|Not accepting jobs'), data: { toggle: 'tooltip', container: 'body' } }
.table-section.section-30 .table-section.section-30
.table-mobile-header{ role: 'rowheader' }= s_('Runners|Runner') .table-mobile-header{ role: 'rowheader' }= s_('Runners|Runner')
...@@ -64,10 +64,10 @@ ...@@ -64,10 +64,10 @@
= sprite_icon('pencil', css_class: 'gl-icon') = sprite_icon('pencil', css_class: 'gl-icon')
.btn-group .btn-group
- if runner.active? - if runner.active?
= link_to pause_group_runner_path(@group, runner), method: :post, class: 'gl-button btn btn-default btn-icon has-tooltip', title: _('Pause'), ref: 'tooltip', aria: { label: _('Pause') }, data: { placement: 'top', container: 'body', confirm: _('Are you sure?') } do = link_to pause_group_runner_path(@group, runner), method: :post, class: 'gl-button btn btn-default btn-icon', title: s_('Runners|Pause from accepting jobs'), ref: 'tooltip', aria: { label: _('Pause') }, data: { toggle: 'tooltip', container: 'body', confirm: _('Are you sure?') } do
= sprite_icon('pause', css_class: 'gl-icon') = sprite_icon('pause', css_class: 'gl-icon')
- else - else
= link_to resume_group_runner_path(@group, runner), method: :post, class: 'gl-button btn btn-default btn-icon has-tooltip', title: _('Resume'), ref: 'tooltip', aria: { label: _('Resume') }, data: { placement: 'top', container: 'body'} do = link_to resume_group_runner_path(@group, runner), method: :post, class: 'gl-button btn btn-default btn-icon', title: s_('Runners|Resume accepting jobs'), ref: 'tooltip', aria: { label: _('Resume') }, data: { toggle: 'tooltip', container: 'body'} do
= sprite_icon('play', css_class: 'gl-icon') = sprite_icon('play', css_class: 'gl-icon')
- if runner.belongs_to_more_than_one_project? - if runner.belongs_to_more_than_one_project?
- delete_runner_tooltip = _('Multi-project Runners cannot be removed') - delete_runner_tooltip = _('Multi-project Runners cannot be removed')
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
= link_to edit_project_runner_path(@project, runner), class: 'btn gl-button btn-icon', title: _('Edit'), aria: { label: _('Edit') }, data: { testid: 'edit-runner-link', toggle: 'tooltip', placement: 'top', container: 'body' } do = link_to edit_project_runner_path(@project, runner), class: 'btn gl-button btn-icon', title: _('Edit'), aria: { label: _('Edit') }, data: { testid: 'edit-runner-link', toggle: 'tooltip', placement: 'top', container: 'body' } do
= sprite_icon('pencil') = sprite_icon('pencil')
- if runner.active? - if runner.active?
= link_to pause_project_runner_path(@project, runner), method: :post, class: 'btn gl-button btn-icon', title: _('Pause'), aria: { label: _('Pause') }, data: { toggle: 'tooltip', placement: 'top', container: 'body', confirm: _("Are you sure?") } do = link_to pause_project_runner_path(@project, runner), method: :post, class: 'btn gl-button btn-icon', title: s_('Runners|Pause from accepting jobs'), aria: { label: _('Pause') }, data: { toggle: 'tooltip', container: 'body', confirm: _("Are you sure?") } do
= sprite_icon('pause') = sprite_icon('pause')
- else - else
= link_to resume_project_runner_path(@project, runner), method: :post, class: 'btn gl-button btn-icon', title: _('Resume'), aria: { label: _('Resume') }, data: { toggle: 'tooltip', placement: 'top', container: 'body' } do = link_to resume_project_runner_path(@project, runner), method: :post, class: 'btn gl-button btn-icon', title: s_('Runners|Resume accepting jobs'), aria: { label: _('Resume') }, data: { toggle: 'tooltip', container: 'body' } do
= sprite_icon('play') = sprite_icon('play')
- if runner.belongs_to_one_project? - if runner.belongs_to_one_project?
= link_to _('Remove runner'), project_runner_path(@project, runner), data: { confirm: _("Are you sure?") }, method: :delete, class: 'btn gl-button btn-danger' = link_to _('Remove runner'), project_runner_path(@project, runner), data: { confirm: _("Are you sure?") }, method: :delete, class: 'btn gl-button btn-danger'
......
...@@ -31912,7 +31912,7 @@ msgstr "" ...@@ -31912,7 +31912,7 @@ msgstr ""
msgid "Runners|No recent contact from this runner; last contact was %{timeAgo}" msgid "Runners|No recent contact from this runner; last contact was %{timeAgo}"
msgstr "" msgstr ""
msgid "Runners|Not available to run jobs" msgid "Runners|Not accepting jobs"
msgstr "" msgstr ""
msgid "Runners|Offline" msgid "Runners|Offline"
...@@ -31927,6 +31927,9 @@ msgstr "" ...@@ -31927,6 +31927,9 @@ msgstr ""
msgid "Runners|Online runners" msgid "Runners|Online runners"
msgstr "" msgstr ""
msgid "Runners|Pause from accepting jobs"
msgstr ""
msgid "Runners|Paused" msgid "Runners|Paused"
msgstr "" msgstr ""
...@@ -31963,6 +31966,9 @@ msgstr "" ...@@ -31963,6 +31966,9 @@ msgstr ""
msgid "Runners|Reset token" msgid "Runners|Reset token"
msgstr "" msgstr ""
msgid "Runners|Resume accepting jobs"
msgstr ""
msgid "Runners|Revision" msgid "Runners|Revision"
msgstr "" msgstr ""
......
...@@ -8,6 +8,12 @@ import runnerToggleActiveMutation from '~/runner/graphql/shared/runner_toggle_ac ...@@ -8,6 +8,12 @@ import runnerToggleActiveMutation from '~/runner/graphql/shared/runner_toggle_ac
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { captureException } from '~/runner/sentry_utils'; import { captureException } from '~/runner/sentry_utils';
import { createAlert } from '~/flash'; import { createAlert } from '~/flash';
import {
I18N_PAUSE,
I18N_PAUSE_TOOLTIP,
I18N_RESUME,
I18N_RESUME_TOOLTIP,
} from '~/runner/constants';
import RunnerPauseButton from '~/runner/components/runner_pause_button.vue'; import RunnerPauseButton from '~/runner/components/runner_pause_button.vue';
import { runnersData } from '../mock_data'; import { runnersData } from '../mock_data';
...@@ -74,10 +80,10 @@ describe('RunnerPauseButton', () => { ...@@ -74,10 +80,10 @@ describe('RunnerPauseButton', () => {
describe('Pause/Resume action', () => { describe('Pause/Resume action', () => {
describe.each` describe.each`
runnerState | icon | content | isActive | newActiveValue runnerState | icon | content | tooltip | isActive | newActiveValue
${'paused'} | ${'play'} | ${'Resume'} | ${false} | ${true} ${'paused'} | ${'play'} | ${I18N_RESUME} | ${I18N_RESUME_TOOLTIP} | ${false} | ${true}
${'active'} | ${'pause'} | ${'Pause'} | ${true} | ${false} ${'active'} | ${'pause'} | ${I18N_PAUSE} | ${I18N_PAUSE_TOOLTIP} | ${true} | ${false}
`('When the runner is $runnerState', ({ icon, content, isActive, newActiveValue }) => { `('When the runner is $runnerState', ({ icon, content, tooltip, isActive, newActiveValue }) => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
props: { props: {
...@@ -91,7 +97,11 @@ describe('RunnerPauseButton', () => { ...@@ -91,7 +97,11 @@ describe('RunnerPauseButton', () => {
it(`Displays a ${icon} button`, () => { it(`Displays a ${icon} button`, () => {
expect(findBtn().props('loading')).toBe(false); expect(findBtn().props('loading')).toBe(false);
expect(findBtn().props('icon')).toBe(icon); expect(findBtn().props('icon')).toBe(icon);
});
it('Displays button content', () => {
expect(findBtn().text()).toBe(content); expect(findBtn().text()).toBe(content);
expect(getTooltip()).toBe(tooltip);
}); });
it('Does not display redundant text for screen readers', () => { it('Does not display redundant text for screen readers', () => {
...@@ -218,8 +228,8 @@ describe('RunnerPauseButton', () => { ...@@ -218,8 +228,8 @@ describe('RunnerPauseButton', () => {
}); });
it('Display correctly for screen readers', () => { it('Display correctly for screen readers', () => {
expect(findBtn().attributes('aria-label')).toBe('Pause'); expect(findBtn().attributes('aria-label')).toBe(I18N_PAUSE);
expect(getTooltip()).toBe('Pause'); expect(getTooltip()).toBe(I18N_PAUSE_TOOLTIP);
}); });
describe('Immediately after the button is clicked', () => { describe('Immediately after the button is clicked', () => {
......
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