Commit b1765f28 authored by Lennard Sprong's avatar Lennard Sprong Committed by Lennard Sprong
Browse files

feat: Display trigger jobs in sidebar

parent c913947d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import { cancelPipeline, retryPipeline } from './pipeline_actions';
jest.mock('../gitlab/get_gitlab_service');

describe('retryOrCancelPipeline', () => {
  const item = new PipelineItemModel(projectInRepository, pipeline, [job], false);
  const item = new PipelineItemModel(projectInRepository, pipeline, [job]);
  const gitLabService: Partial<GitLabService> = {
    cancelOrRetryPipeline: jest.fn(),
  };
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ describe('CurrentBranchRefrehser', () => {
        getMrClosingIssues: () => [{ iid: 123 }],
        getSingleProjectIssue: () => issue,
        getJobsForPipeline: () => [job],
        getTriggerJobsForPipeline: () => [],
        getExternalStatusForCommit: () => [externalStatus],
        fetchFromApi: () => [pipeline],
      });
+6 −10
Original line number Diff line number Diff line
@@ -53,16 +53,12 @@ const getJobs = async (
  if (!pipeline) return [];
  try {
    const projectId = projectInRepository.project.restId;
    const pipelinePromise = getGitLabService(projectInRepository).getJobsForPipeline(
      pipeline.id,
      projectId,
    );
    const statusPromise = getGitLabService(projectInRepository).getExternalStatusForCommit(
      pipeline.sha,
      pipeline.ref,
      projectId,
    );
    return [...(await pipelinePromise), ...(await statusPromise)];
    const service = getGitLabService(projectInRepository);

    const pipelinePromise = service.getJobsForPipeline(pipeline.id, projectId);
    const bridgesPromise = service.getTriggerJobsForPipeline(pipeline.id, projectId);
    const statusPromise = service.getExternalStatusForCommit(pipeline.sha, pipeline.ref, projectId);
    return [...(await pipelinePromise), ...(await bridgesPromise), ...(await statusPromise)];
  } catch (e) {
    log.error(new UserFriendlyError('Failed to fetch jobs for pipeline.', e));
    return [];
+9 −0
Original line number Diff line number Diff line
@@ -936,6 +936,15 @@ export class GitLabService {
    );
  }

  async getTriggerJobsForPipeline(pipelineId: number, projectId: number): Promise<RestJob[]> {
    const pages: RestJob[] = await this.fetchAllPages(
      `/projects/${projectId}/pipelines/${pipelineId}/bridges`,
      {},
      'trigger jobs for pipeline',
    );
    return pages;
  }

  async getExternalStatusForCommit(
    sha: string,
    ref: string | null,
+4 −4
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import { ErrorItem } from './items/error_item';
import { ItemModel } from './items/item_model';
import { MrItemModel } from './items/mr_item_model';
import { IssueItem } from './items/issue_item';
import { PipelineItemModel } from './items/pipeline_item_model';
import { PipelineRootItemModel } from './items/pipeline_root_item_model';
import { isEnabled, FeatureFlag } from '../../common/feature_flags';

import {
@@ -30,7 +30,7 @@ export class CurrentBranchDataProvider

  private state: TreeState = { type: 'invalid' };

  private pipelineItem?: PipelineItemModel;
  private pipelineItem?: PipelineRootItemModel;

  private mrState?: { mr: RestMr; item: MrItemModel };

@@ -43,11 +43,11 @@ export class CurrentBranchDataProvider
    if (!state.pipeline) {
      return new vscode.TreeItem('No pipeline found');
    }
    this.pipelineItem = new PipelineItemModel(
    this.pipelineItem = new PipelineRootItemModel(
      state.projectInRepository,
      state.pipeline,
      state.jobs,
      state.type === 'tag',
      state.type === 'tag' ? 'Tag Pipeline' : 'Pipeline',
    );
    return this.pipelineItem;
  }
Loading