2022-01-26 12:08:38 +05:30
|
|
|
<script>
|
2022-03-02 08:16:31 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
|
|
|
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
|
|
|
|
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
|
|
|
|
import { __, sprintf } from '~/locale';
|
|
|
|
import CiHeader from '~/vue_shared/components/header_ci_component.vue';
|
|
|
|
import getPipelineQuery from './graphql/queries/pipeline.query.graphql';
|
2022-01-26 12:08:38 +05:30
|
|
|
import BridgeEmptyState from './components/empty_state.vue';
|
|
|
|
import BridgeSidebar from './components/sidebar.vue';
|
2022-03-02 08:16:31 +05:30
|
|
|
import { SIDEBAR_COLLAPSE_BREAKPOINTS } from './components/constants';
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BridgePageApp',
|
|
|
|
components: {
|
|
|
|
BridgeEmptyState,
|
|
|
|
BridgeSidebar,
|
2022-03-02 08:16:31 +05:30
|
|
|
CiHeader,
|
|
|
|
GlLoadingIcon,
|
|
|
|
},
|
|
|
|
inject: ['buildId', 'projectFullPath', 'pipelineIid'],
|
|
|
|
apollo: {
|
|
|
|
pipeline: {
|
|
|
|
query: getPipelineQuery,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
fullPath: this.projectFullPath,
|
|
|
|
iid: this.pipelineIid,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update(data) {
|
|
|
|
if (!data?.project?.pipeline) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { pipeline } = data.project;
|
|
|
|
const stages = pipeline?.stages.edges.map((edge) => edge.node) || [];
|
|
|
|
const jobs = stages.map((stage) => stage.jobs.nodes).flat();
|
|
|
|
|
|
|
|
return {
|
|
|
|
...pipeline,
|
|
|
|
commit: {
|
|
|
|
...pipeline.commit,
|
|
|
|
commit_path: pipeline.commit.webPath,
|
|
|
|
short_id: pipeline.commit.shortId,
|
|
|
|
},
|
|
|
|
id: getIdFromGraphQLId(pipeline.id),
|
|
|
|
jobs,
|
|
|
|
stages,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isSidebarExpanded: true,
|
|
|
|
pipeline: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
bridgeJob() {
|
|
|
|
return (
|
|
|
|
this.pipeline.jobs?.filter(
|
|
|
|
(job) => getIdFromGraphQLId(job.id) === Number(this.buildId),
|
|
|
|
)[0] || {}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
bridgeName() {
|
|
|
|
return sprintf(__('Job %{jobName}'), { jobName: this.bridgeJob.name });
|
|
|
|
},
|
|
|
|
isPipelineLoading() {
|
|
|
|
return this.$apollo.queries.pipeline.loading;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
window.addEventListener('resize', this.onResize);
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.onResize();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleSidebar() {
|
|
|
|
this.isSidebarExpanded = !this.isSidebarExpanded;
|
|
|
|
},
|
|
|
|
onResize() {
|
|
|
|
const breakpoint = bp.getBreakpointSize();
|
|
|
|
if (SIDEBAR_COLLAPSE_BREAKPOINTS.includes(breakpoint)) {
|
|
|
|
this.isSidebarExpanded = false;
|
|
|
|
} else if (!this.isSidebarExpanded) {
|
|
|
|
this.isSidebarExpanded = true;
|
|
|
|
}
|
|
|
|
},
|
2022-01-26 12:08:38 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
2022-03-02 08:16:31 +05:30
|
|
|
<gl-loading-icon v-if="isPipelineLoading" size="lg" class="gl-mt-4" />
|
|
|
|
<div v-else>
|
|
|
|
<ci-header
|
|
|
|
class="gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
|
|
|
|
:status="bridgeJob.detailedStatus"
|
|
|
|
:time="bridgeJob.createdAt"
|
|
|
|
:user="pipeline.user"
|
|
|
|
:has-sidebar-button="true"
|
|
|
|
:item-name="bridgeName"
|
|
|
|
@clickedSidebarButton="toggleSidebar"
|
|
|
|
/>
|
|
|
|
<bridge-empty-state :downstream-pipeline-path="bridgeJob.downstreamPipeline.path" />
|
|
|
|
<bridge-sidebar
|
|
|
|
v-if="isSidebarExpanded"
|
|
|
|
:bridge-job="bridgeJob"
|
|
|
|
:commit="pipeline.commit"
|
|
|
|
:is-sidebar-expanded="isSidebarExpanded"
|
|
|
|
@toggleSidebar="toggleSidebar"
|
|
|
|
/>
|
|
|
|
</div>
|
2022-01-26 12:08:38 +05:30
|
|
|
</div>
|
|
|
|
</template>
|