Commit 5fdaffa0 authored by Tomas Vik (OOO back on 2026-08-31)'s avatar Tomas Vik (OOO back on 2026-08-31) 🌴
Browse files

fix: can't access issue detail from closing issue

parent 596c1bc5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ describe('CurrentBranchRefrehser', () => {
        getProject: async () => project,
        getTrackingBranchName: async () => 'branch',
        getGitLabService: () => ({
          getMrClosingIssues: () => [issue],
          getMrClosingIssues: () => [{ iid: 123 }],
          getSingleProjectIssue: () => issue,
          getPipelineAndMrForCurrentBranch: () => ({ pipeline, mr }),
          getJobsForPipeline: () => [job],
        }),
+12 −6
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import { WrappedRepository } from './git/wrapped_repository';
import { StatusBar } from './status_bar';
import { CurrentBranchDataProvider } from './tree_view/current_branch_data_provider';
import { UserFriendlyError } from './errors/user_friendly_error';
import { notNullOrUndefined } from './utils/not_null_or_undefined';

export interface ValidBranchState {
  valid: true;
@@ -107,14 +108,19 @@ export class CurrentBranchRefresher {
    if (!repository) return INVALID_STATE;
    const gitlabProject = await repository.getProject();
    if (!gitlabProject) return INVALID_STATE;
    const gitLabService = repository.getGitLabService();
    try {
      const { pipeline, mr } = await repository
        .getGitLabService()
        .getPipelineAndMrForCurrentBranch(gitlabProject, await repository.getTrackingBranchName());
      const { pipeline, mr } = await gitLabService.getPipelineAndMrForCurrentBranch(
        gitlabProject,
        await repository.getTrackingBranchName(),
      );
      const jobs = await getJobs(repository, pipeline);
      const issues = mr
        ? await repository.getGitLabService().getMrClosingIssues(gitlabProject, mr.iid)
        : [];
      const minimalIssues = mr ? await gitLabService.getMrClosingIssues(gitlabProject, mr.iid) : [];
      const issues = (
        await Promise.all(
          minimalIssues.map(mi => gitLabService.getSingleProjectIssue(gitlabProject, mi.iid)),
        )
      ).filter(notNullOrUndefined);
      return { valid: true, repository, pipeline, mr, jobs, issues, userInitiated };
    } catch (e) {
      logError(e);
+13 −1
Original line number Diff line number Diff line
@@ -827,7 +827,7 @@ export class GitLabService {
    return issuables.map(normalizeAvatarUrl(this.instanceUrl));
  }

  async getMrClosingIssues(project: GitLabProject, mrId: number): Promise<RestIssuable[]> {
  async getMrClosingIssues(project: GitLabProject, mrId: number): Promise<MinimalRestIssuable[]> {
    try {
      return await this.fetch(
        `/projects/${project.restId}/merge_requests/${mrId}/closes_issues`,
@@ -840,6 +840,18 @@ export class GitLabService {
    }
  }

  async getSingleProjectIssue(
    project: GitLabProject,
    issueIid: number,
  ): Promise<RestIssuable | undefined> {
    try {
      return await this.fetch(`/projects/${project.restId}/issues/${issueIid}`, {}, 'Single Issue');
    } catch (e) {
      logError(e);
      return undefined;
    }
  }

  async getJobsForPipeline(pipeline: RestPipeline): Promise<RestJob[]> {
    return this.fetch(
      `/projects/${pipeline.project_id}/pipelines/${pipeline.id}/jobs`,
+12 −6
Original line number Diff line number Diff line
/**
 * Slimmed-down version of the Issuable, returned for example by
 * https://docs.gitlab.com/ee/api/merge_requests.html#list-issues-that-close-on-merge
 */
interface MinimalRestIssuable {
  id: number;
  iid: number;
  title: string;
  project_id: number;
  author: { name: string; avatar_url: string | null };
}
/**
 * An issuable instance repesents one of these entities:
 *  - Merge Request
@@ -5,13 +16,8 @@
 *  - Epic
 *  - Snippet
 */
interface RestIssuable {
  id: number;
  iid: number;
  title: string;
  project_id: number;
interface RestIssuable extends MinimalRestIssuable {
  web_url: string;
  author: { name: string; avatar_url: string | null };
  references: {
    full: string; // e.g. "gitlab-org/gitlab#219925"
  };
+54 −0
Original line number Diff line number Diff line
{
  "assignee": {
    "avatar_url": "https://secure.gravatar.com/avatar/6042a9152ada74d9fb6a0cdce895337e?s=80&d=identicon",
    "id": 3457201,
    "name": "Tomas Vik",
    "state": "active",
    "username": "viktomas",
    "web_url": "https://gitlab.com/viktomas"
  },
  "author": {
    "avatar_url": "https://secure.gravatar.com/avatar/2c5d6a63b41cbeb3ea4cccda82e758e1?s=80&d=identicon",
    "id": 2935693,
    "name": "Kai Armstrong",
    "state": "active",
    "username": "phikai",
    "web_url": "https://gitlab.com/phikai"
  },
  "created_at": "2020-06-01T17:50:22.893Z",
  "description": "## Problem to Solve\n\nThe Web IDE is a more complete editing experience that helps to facilitate workflows across multiple files and merge requests. However, users favor the single file editing experience.\n\n## Additional Details\n\nThis is a test that should be setup behind a feature flag to see what kind/if any feedback is generated by making this change.\n\n## Proposal\n\nThe primary and inverted buttons of `Edit` and `Web IDE` should be switched so that Web IDE more clearly looks like a primary action that users should perform.\n\n![Screenshot_2020-06-01_12.42.05](/uploads/31537a7d4f9bca62e7e9ff2c7bafc4ef/Screenshot_2020-06-01_12.42.05.png)\n\n### Feature Flag\n\nThis feature needs to be done with a feature flag and it would be good to have the ability to either assign groups to the feature or assign individual users depending on what we want to do for testing.\n\nWe **SHOULD NOT** enable this by default in the %13.2 release, but rather at a minimum toggle the feature flag on for `gitlab-org` and `gitlab-com`.\n\n[Feature flag implementation documentation](https://docs.gitlab.com/ee/development/feature_flags/)\n\n#### Feature Flag implemenation\n\n!35957 Introduces `web_ide_primary_edit` feature flag that can be anabled for a group.\n\n### Instrumentation\n\nIt would be good as part of this to add telemetry to these buttons to see how many clicks each button receives: https://docs.gitlab.com/ee/development/telemetry/snowplow.html#implementing-snowplow-js-frontend-tracking\n\nThere is also a basic A/B test process documented here: https://docs.gitlab.com/ee/development/experiment_guide/#how-to-create-an-ab-test\n\n#### Tracking implementation\n\nClicking the edit buttons will trigger the following events.\n\n|  | event | label  | property |\n| ------ | ------ | --- | --- |\n| ![Screenshot_2020-07-08_at_3.09.59_PM](/uploads/84d8a0d045617281eeaaa60dd8cbd676/Screenshot_2020-07-08_at_3.09.59_PM.png) | `click_edit` | `Edit` | |\n| ![Screenshot_2020-07-08_at_3.11.14_PM](/uploads/bbac329ceca6da11c39f7707bb975921/Screenshot_2020-07-08_at_3.11.14_PM.png) | `click_edit` | `Edit` | `secondary` |\n| ![Screenshot_2020-07-08_at_3.11.19_PM](/uploads/ff23cbccbb002e6f9127cb3ddcbd4f36/Screenshot_2020-07-08_at_3.11.19_PM.png) | `click_edit_ide` | `Web IDE` | |\n| ![Screenshot_2020-07-08_at_3.10.13_PM](/uploads/ed647b6f0720bce60b1494908cbc735a/Screenshot_2020-07-08_at_3.10.13_PM.png) | `click_edit_ide` | `Web IDE` | `secondary` |",
  "id": 35284557,
  "iid": 219925,
  "labels": [
    "Category:Web IDE",
    "Deliverable",
    "backstage [DEPRECATED]",
    "devops::create",
    "feature flag",
    "feature::maintenance",
    "frontend",
    "group::editor",
    "missed-deliverable",
    "missed:13.2",
    "telemetry",
    "workflow::verification"
  ],
  "milestone": {
    "created_at": "2020-04-09T17:39:21.090Z",
    "description": "https://about.gitlab.com/releases/",
    "due_date": "2020-08-17",
    "group_id": 9970,
    "id": 1233752,
    "iid": 50,
    "start_date": "2020-07-18",
    "state": "active",
    "title": "13.3",
    "updated_at": "2020-07-17T11:45:59.705Z",
    "web_url": "https://gitlab.com/groups/gitlab-org/-/milestones/50"
  },
  "project_id": 278964,
  "state": "opened",
  "title": "Change primary button for editing on files",
  "updated_at": "2020-07-21T14:26:09.029Z",
  "user_notes_count": 8
}
Loading