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

165 lines
5.2 KiB
Vue
Raw Normal View History

2018-12-05 23:21:45 +05:30
<script>
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';
import { GlButton, GlIcon, GlLink } from '@gitlab/ui';
2020-11-24 15:15:51 +05:30
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
2018-12-13 13:39:08 +05:30
import ArtifactsBlock from './artifacts_block.vue';
2021-01-29 00:20:46 +05:30
import JobSidebarRetryButton from './job_sidebar_retry_button.vue';
import JobRetryForwardDeploymentModal from './job_retry_forward_deployment_modal.vue';
2018-12-13 13:39:08 +05:30
import TriggerBlock from './trigger_block.vue';
import CommitBlock from './commit_block.vue';
import StagesDropdown from './stages_dropdown.vue';
import JobsContainer from './jobs_container.vue';
2021-01-29 00:20:46 +05:30
import JobSidebarDetailsContainer from './sidebar_job_details_container.vue';
import { JOB_SIDEBAR } from '../constants';
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,
},
forwardDeploymentFailureModalId,
2018-12-13 13:39:08 +05:30
components: {
ArtifactsBlock,
CommitBlock,
2021-01-29 00:20:46 +05:30
GlButton,
GlLink,
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
runnerHelpUrl: {
type: String,
required: false,
default: '',
2018-12-05 23:21:45 +05:30
},
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']),
2018-12-13 13:39:08 +05:30
retryButtonClass() {
2021-01-29 00:20:46 +05:30
let className = 'btn btn-retry';
2018-12-13 13:39:08 +05:30
className +=
this.job.status && this.job.recoverable ? ' btn-primary' : ' btn-inverted-secondary';
return className;
},
hasArtifact() {
2020-03-13 15:44:24 +05:30
return !isEmpty(this.job.artifact);
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">
2019-03-02 22:35:43 +05:30
<div class="block d-flex flex-nowrap 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>
2019-03-02 22:35:43 +05:30
<div class="flex-grow-1 flex-shrink-0 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"
:class="retryButtonClass"
:href="job.retry_path"
2021-01-29 00:20:46 +05:30
:modal-id="$options.forwardDeploymentFailureModalId"
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"
/>
2019-03-02 22:35:43 +05:30
<gl-link
v-if="job.cancel_path"
:href="job.cancel_path"
2021-01-29 00:20:46 +05:30
class="btn btn-default"
2019-03-02 22:35:43 +05:30
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 }}
</gl-link>
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-01-29 00:20:46 +05:30
class="gl-display-md-none gl-ml-2 js-sidebar-build-toggle"
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
<div v-if="job.terminal_path || job.new_issue_path" class="block retry-link">
2019-02-15 15:39:39 +05:30
<gl-link
2018-12-13 13:39:08 +05:30
v-if="job.new_issue_path"
:href="job.new_issue_path"
2020-10-24 23:57:45 +05:30
class="btn btn-success btn-inverted float-left mr-2"
data-testid="job-new-issue"
2021-01-29 00:20:46 +05:30
>{{ $options.i18n.newIssue }}
</gl-link>
2019-02-15 15:39:39 +05:30
<gl-link
2019-03-02 22:35:43 +05:30
v-if="job.terminal_path"
:href="job.terminal_path"
2021-01-29 00:20:46 +05:30
class="btn btn-primary btn-inverted visible-md-block visible-lg-block float-left"
2019-03-02 22:35:43 +05:30
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 }}
<gl-icon :size="14" name="external-link" />
2019-03-02 22:35:43 +05:30
</gl-link>
2018-12-13 13:39:08 +05:30
</div>
2021-01-29 00:20:46 +05:30
<job-sidebar-details-container :runner-help-url="runnerHelpUrl" />
2020-11-24 15:15:51 +05:30
<artifacts-block v-if="hasArtifact" :artifact="job.artifact" :help-url="artifactHelpUrl" />
2019-02-15 15:39:39 +05:30
<trigger-block v-if="hasTriggers" :trigger="job.trigger" />
2018-12-13 13:39:08 +05:30
<commit-block
:commit="commit"
2021-01-29 00:20:46 +05:30
:is-last-block="hasStages"
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"
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>