debian-mirror-gitlab/app/assets/javascripts/jobs/components/sidebar.vue

181 lines
5.5 KiB
Vue
Raw Normal View History

2018-12-05 23:21:45 +05:30
<script>
2021-04-17 20:07:23 +05:30
import { GlButton, GlIcon } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import { isEmpty } from 'lodash';
2021-01-29 00:20:46 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
2022-01-26 12:08:38 +05:30
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue';
2021-03-11 19:13:27 +05:30
import { JOB_SIDEBAR } from '../constants';
2018-12-13 13:39:08 +05:30
import ArtifactsBlock from './artifacts_block.vue';
import CommitBlock from './commit_block.vue';
2021-03-11 19:13:27 +05:30
import JobRetryForwardDeploymentModal from './job_retry_forward_deployment_modal.vue';
import JobSidebarRetryButton from './job_sidebar_retry_button.vue';
2018-12-13 13:39:08 +05:30
import JobsContainer from './jobs_container.vue';
2021-01-29 00:20:46 +05:30
import JobSidebarDetailsContainer from './sidebar_job_details_container.vue';
2021-03-11 19:13:27 +05:30
import StagesDropdown from './stages_dropdown.vue';
import TriggerBlock from './trigger_block.vue';
2021-01-29 00:20:46 +05:30
export const forwardDeploymentFailureModalId = 'forward-deployment-failure';
2018-12-05 23:21:45 +05:30
2018-12-13 13:39:08 +05:30
export default {
name: 'JobSidebar',
2021-01-29 00:20:46 +05:30
i18n: {
...JOB_SIDEBAR,
},
2021-04-17 20:07:23 +05:30
borderTopClass: ['gl-border-t-solid', 'gl-border-t-1', 'gl-border-t-gray-100'],
2021-01-29 00:20:46 +05:30
forwardDeploymentFailureModalId,
2018-12-13 13:39:08 +05:30
components: {
ArtifactsBlock,
CommitBlock,
2021-01-29 00:20:46 +05:30
GlButton,
2020-11-24 15:15:51 +05:30
GlIcon,
2018-12-13 13:39:08 +05:30
JobsContainer,
2021-01-29 00:20:46 +05:30
JobSidebarRetryButton,
JobRetryForwardDeploymentModal,
JobSidebarDetailsContainer,
StagesDropdown,
2020-11-24 15:15:51 +05:30
TooltipOnTruncate,
2021-01-29 00:20:46 +05:30
TriggerBlock,
2018-12-13 13:39:08 +05:30
},
props: {
2020-11-24 15:15:51 +05:30
artifactHelpUrl: {
type: String,
required: false,
default: '',
},
2018-12-13 13:39:08 +05:30
},
computed: {
2021-01-29 00:20:46 +05:30
...mapGetters(['hasForwardDeploymentFailure']),
2019-09-04 21:01:54 +05:30
...mapState(['job', 'stages', 'jobs', 'selectedStage']),
2021-04-17 20:07:23 +05:30
retryButtonCategory() {
return this.job.status && this.job.recoverable ? 'primary' : 'secondary';
2018-12-13 13:39:08 +05:30
},
hasArtifact() {
2021-04-29 21:17:54 +05:30
// the artifact object will always have a locked property
return Object.keys(this.job.artifact).length > 1;
2018-12-05 23:21:45 +05:30
},
2018-12-13 13:39:08 +05:30
hasTriggers() {
2020-03-13 15:44:24 +05:30
return !isEmpty(this.job.trigger);
2018-12-05 23:21:45 +05:30
},
2018-12-13 13:39:08 +05:30
hasStages() {
2021-01-29 00:20:46 +05:30
return this.job?.pipeline?.stages?.length > 0;
2018-12-13 13:39:08 +05:30
},
commit() {
2021-01-29 00:20:46 +05:30
return this.job?.pipeline?.commit || {};
},
shouldShowJobRetryForwardDeploymentModal() {
return this.job.retry_path && this.hasForwardDeploymentFailure;
2018-12-13 13:39:08 +05:30
},
},
methods: {
...mapActions(['fetchJobsForStage', 'toggleSidebar']),
},
};
2018-12-05 23:21:45 +05:30
</script>
<template>
2019-02-15 15:39:39 +05:30
<aside class="right-sidebar build-sidebar" data-offset-top="101" data-spy="affix">
2018-12-05 23:21:45 +05:30
<div class="sidebar-container">
<div class="blocks-container">
2021-04-17 20:07:23 +05:30
<div class="gl-py-5 gl-display-flex gl-align-items-center">
2020-11-24 15:15:51 +05:30
<tooltip-on-truncate :title="job.name" truncate-target="child"
><h4 class="my-0 mr-2 gl-text-truncate">
{{ job.name }}
</h4>
</tooltip-on-truncate>
2021-04-17 20:07:23 +05:30
<div class="gl-flex-grow-1 gl-flex-shrink-0 gl-text-right">
2021-01-29 00:20:46 +05:30
<job-sidebar-retry-button
2019-03-02 22:35:43 +05:30
v-if="job.retry_path"
2021-04-17 20:07:23 +05:30
:category="retryButtonCategory"
2019-03-02 22:35:43 +05:30
:href="job.retry_path"
2021-01-29 00:20:46 +05:30
:modal-id="$options.forwardDeploymentFailureModalId"
2021-04-17 20:07:23 +05:30
variant="confirm"
2020-03-13 15:44:24 +05:30
data-qa-selector="retry_button"
2021-01-29 00:20:46 +05:30
data-testid="retry-button"
/>
2021-04-17 20:07:23 +05:30
<gl-button
2019-03-02 22:35:43 +05:30
v-if="job.cancel_path"
:href="job.cancel_path"
data-method="post"
2021-01-29 00:20:46 +05:30
data-testid="cancel-button"
2019-03-02 22:35:43 +05:30
rel="nofollow"
2021-01-29 00:20:46 +05:30
>{{ $options.i18n.cancel }}
2021-04-17 20:07:23 +05:30
</gl-button>
2019-03-02 22:35:43 +05:30
</div>
2021-01-03 14:25:43 +05:30
<gl-button
2021-01-29 00:20:46 +05:30
:aria-label="$options.i18n.toggleSidebar"
2021-01-03 14:25:43 +05:30
category="tertiary"
2021-04-17 20:07:23 +05:30
class="gl-md-display-none gl-ml-2"
2021-01-03 14:25:43 +05:30
icon="chevron-double-lg-right"
2018-12-13 13:39:08 +05:30
@click="toggleSidebar"
2021-01-03 14:25:43 +05:30
/>
2018-12-13 13:39:08 +05:30
</div>
2019-03-02 22:35:43 +05:30
2021-04-17 20:07:23 +05:30
<div
v-if="job.terminal_path || job.new_issue_path"
class="gl-py-5"
:class="$options.borderTopClass"
>
<gl-button
2018-12-13 13:39:08 +05:30
v-if="job.new_issue_path"
:href="job.new_issue_path"
2021-04-17 20:07:23 +05:30
category="secondary"
variant="confirm"
2020-10-24 23:57:45 +05:30
data-testid="job-new-issue"
2021-04-17 20:07:23 +05:30
>
{{ $options.i18n.newIssue }}
</gl-button>
<gl-button
2019-03-02 22:35:43 +05:30
v-if="job.terminal_path"
:href="job.terminal_path"
target="_blank"
2021-01-29 00:20:46 +05:30
data-testid="terminal-link"
2018-12-13 13:39:08 +05:30
>
2021-01-29 00:20:46 +05:30
{{ $options.i18n.debug }}
2021-04-17 20:07:23 +05:30
<gl-icon name="external-link" />
</gl-button>
2018-12-13 13:39:08 +05:30
</div>
2021-04-17 20:07:23 +05:30
<job-sidebar-details-container class="gl-py-5" :class="$options.borderTopClass" />
<artifacts-block
v-if="hasArtifact"
class="gl-py-5"
:class="$options.borderTopClass"
:artifact="job.artifact"
:help-url="artifactHelpUrl"
/>
<trigger-block
v-if="hasTriggers"
class="gl-py-5"
:class="$options.borderTopClass"
:trigger="job.trigger"
/>
2018-12-13 13:39:08 +05:30
<commit-block
:commit="commit"
2021-04-17 20:07:23 +05:30
class="gl-py-5"
:class="$options.borderTopClass"
2018-12-13 13:39:08 +05:30
:merge-request="job.merge_request"
/>
2018-12-05 23:21:45 +05:30
2018-12-13 13:39:08 +05:30
<stages-dropdown
2021-01-29 00:20:46 +05:30
v-if="job.pipeline"
2021-04-17 20:07:23 +05:30
class="gl-py-5"
:class="$options.borderTopClass"
2018-12-13 13:39:08 +05:30
:pipeline="job.pipeline"
:selected-stage="selectedStage"
2021-01-29 00:20:46 +05:30
:stages="stages"
2018-12-13 13:39:08 +05:30
@requestSidebarStageDropdown="fetchJobsForStage"
2018-12-05 23:21:45 +05:30
/>
</div>
2021-01-29 00:20:46 +05:30
<jobs-container v-if="jobs.length" :job-id="job.id" :jobs="jobs" />
2018-12-05 23:21:45 +05:30
</div>
2021-01-29 00:20:46 +05:30
<job-retry-forward-deployment-modal
v-if="shouldShowJobRetryForwardDeploymentModal"
:modal-id="$options.forwardDeploymentFailureModalId"
:href="job.retry_path"
/>
2018-12-05 23:21:45 +05:30
</aside>
</template>