Commit 96c5f74b authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '230734-change-stuck_block-component-to-use-glbadge' into 'master'

Change the job stuck page to use UI library components

Closes #230734

See merge request gitlab-org/gitlab!38618
parents 8deb7069 73577c4c
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlAlert, GlBadge, GlLink } from '@gitlab/ui';
import { s__ } from '../../locale';
/** /**
* Renders Stuck Runners block for job's view. * Renders Stuck Runners block for job's view.
*/ */
export default { export default {
components: { components: {
GlAlert,
GlBadge,
GlLink, GlLink,
}, },
props: { props: {
...@@ -22,40 +25,50 @@ export default { ...@@ -22,40 +25,50 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
hasNoRunnersWithCorrespondingTags() {
return this.tags.length > 0;
},
stuckData() {
if (this.hasNoRunnersWithCorrespondingTags) {
return {
text: s__(`Job|This job is stuck because you don't have
any active runners online or available with any of these tags assigned to them:`),
dataTestId: 'job-stuck-with-tags',
showTags: true,
};
} else if (this.hasNoRunnersForProject) {
return {
text: s__(`Job|This job is stuck because the project
doesn't have any runners online assigned to it.`),
dataTestId: 'job-stuck-no-runners',
showTags: false,
};
}
return {
text: s__(`Job|This job is stuck because you don't
have any active runners that can run this job.`),
dataTestId: 'job-stuck-no-active-runners',
showTags: false,
};
},
},
}; };
</script> </script>
<template> <template>
<div class="bs-callout bs-callout-warning"> <gl-alert variant="warning" :dismissible="false">
<p v-if="tags.length" class="gl-mb-0" data-testid="job-stuck-with-tags"> <p class="gl-mb-0" :data-testid="stuckData.dataTestId">
{{ {{ stuckData.text }}
s__(`This job is stuck because you don't have <template v-if="stuckData.showTags">
any active runners online or available with any of these tags assigned to them:`) <gl-badge v-for="tag in tags" :key="tag" variant="info">
}} {{ tag }}
<span </gl-badge>
v-for="(tag, index) in tags" </template>
:key="index"
class="badge badge-primary gl-mr-2"
data-testid="badge"
>
{{ tag }}
</span>
</p> </p>
<p v-else-if="hasNoRunnersForProject" class="gl-mb-0" data-testid="job-stuck-no-runners">
{{
s__(`Job|This job is stuck because the project
doesn't have any runners online assigned to it.`)
}}
</p>
<p v-else class="gl-mb-0" data-testid="job-stuck-no-active-runners">
{{
s__(`This job is stuck because you don't
have any active runners that can run this job.`)
}}
</p>
{{ __('Go to project') }} {{ __('Go to project') }}
<gl-link v-if="runnersPath" :href="runnersPath"> <gl-link v-if="runnersPath" :href="runnersPath">
{{ __('CI settings') }} {{ __('CI settings') }}
</gl-link> </gl-link>
</div> </gl-alert>
</template> </template>
---
title: Change the job stuck page to use UI library components
merge_request: 38618
author:
type: changed
...@@ -13635,6 +13635,12 @@ msgstr "" ...@@ -13635,6 +13635,12 @@ msgstr ""
msgid "Job|This job is stuck because the project doesn't have any runners online assigned to it." msgid "Job|This job is stuck because the project doesn't have any runners online assigned to it."
msgstr "" msgstr ""
msgid "Job|This job is stuck because you don't have any active runners online or available with any of these tags assigned to them:"
msgstr ""
msgid "Job|This job is stuck because you don't have any active runners that can run this job."
msgstr ""
msgid "Job|for" msgid "Job|for"
msgstr "" msgstr ""
...@@ -24796,12 +24802,6 @@ msgstr "" ...@@ -24796,12 +24802,6 @@ msgstr ""
msgid "This job is preparing to start" msgid "This job is preparing to start"
msgstr "" msgstr ""
msgid "This job is stuck because you don't have any active runners online or available with any of these tags assigned to them:"
msgstr ""
msgid "This job is stuck because you don't have any active runners that can run this job."
msgstr ""
msgid "This job is waiting for resource: " msgid "This job is waiting for resource: "
msgstr "" msgstr ""
......
import { GlLink } from '@gitlab/ui'; import { GlBadge, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import StuckBlock from '~/jobs/components/stuck_block.vue'; import StuckBlock from '~/jobs/components/stuck_block.vue';
...@@ -27,7 +27,7 @@ describe('Stuck Block Job component', () => { ...@@ -27,7 +27,7 @@ describe('Stuck Block Job component', () => {
const findStuckNoRunners = () => wrapper.find('[data-testid="job-stuck-no-runners"]'); const findStuckNoRunners = () => wrapper.find('[data-testid="job-stuck-no-runners"]');
const findStuckWithTags = () => wrapper.find('[data-testid="job-stuck-with-tags"]'); const findStuckWithTags = () => wrapper.find('[data-testid="job-stuck-with-tags"]');
const findRunnerPathLink = () => wrapper.find(GlLink); const findRunnerPathLink = () => wrapper.find(GlLink);
const findAllBadges = () => wrapper.findAll('[data-testid="badge"]'); const findAllBadges = () => wrapper.findAll(GlBadge);
describe('with no runners for project', () => { describe('with no runners for project', () => {
beforeEach(() => { beforeEach(() => {
......
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