From 818e6eaf7b7686873ee412306145e30de60bb41f Mon Sep 17 00:00:00 2001
From: Natalia Tepluhina <ntepluhina@gitlab.com>
Date: Tue, 23 Aug 2022 13:19:01 +0000
Subject: [PATCH] Fixed fullPath for assignees and labels

- added fullPath to work item payload
- removed injection

Changelog: fixed
---
 .../components/work_item_assignees.vue        |  5 +-
 .../components/work_item_description.vue      |  5 +-
 .../components/work_item_detail.vue           |  6 +++
 .../components/work_item_labels.vue           |  5 +-
 .../graphql/create_work_item.mutation.graphql |  2 +-
 ...reate_work_item_from_task.mutation.graphql |  2 +-
 .../local_update_work_item.mutation.graphql   |  2 +-
 .../graphql/update_work_item.mutation.graphql |  2 +-
 .../update_work_item_task.mutation.graphql    |  2 +-
 .../update_work_item_widgets.mutation.graphql |  2 +-
 .../graphql/work_item.fragment.graphql        | 35 +++---------
 .../graphql/work_item.query.graphql           |  2 +-
 .../graphql/work_item_links.query.graphql     |  2 +-
 .../work_item_widgets.fragment.graphql        | 31 +++++++++++
 .../graphql/work_item.fragment.graphql        | 53 -------------------
 .../work_item_widgets.fragment.graphql        | 37 +++++++++++++
 .../components/work_item_assignees_spec.js    |  4 +-
 .../components/work_item_description_spec.js  |  4 +-
 .../components/work_item_labels_spec.js       |  4 +-
 spec/frontend/work_items/mock_data.js         | 50 +++++++++++++++++
 20 files changed, 153 insertions(+), 102 deletions(-)
 create mode 100644 app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
 delete mode 100644 ee/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
 create mode 100644 ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql

diff --git a/app/assets/javascripts/work_items/components/work_item_assignees.vue b/app/assets/javascripts/work_items/components/work_item_assignees.vue
index 7342f215b5e69..9e5403bb41681 100644
--- a/app/assets/javascripts/work_items/components/work_item_assignees.vue
+++ b/app/assets/javascripts/work_items/components/work_item_assignees.vue
@@ -52,7 +52,6 @@ export default {
     GlDropdownDivider,
   },
   mixins: [Tracking.mixin()],
-  inject: ['fullPath'],
   props: {
     workItemId: {
       type: String,
@@ -80,6 +79,10 @@ export default {
       required: false,
       default: false,
     },
+    fullPath: {
+      type: String,
+      required: true,
+    },
   },
   data() {
     return {
diff --git a/app/assets/javascripts/work_items/components/work_item_description.vue b/app/assets/javascripts/work_items/components/work_item_description.vue
index cf59789ce2df7..c18ea3ddb00c1 100644
--- a/app/assets/javascripts/work_items/components/work_item_description.vue
+++ b/app/assets/javascripts/work_items/components/work_item_description.vue
@@ -21,12 +21,15 @@ export default {
     MarkdownField,
   },
   mixins: [Tracking.mixin()],
-  inject: ['fullPath'],
   props: {
     workItemId: {
       type: String,
       required: true,
     },
+    fullPath: {
+      type: String,
+      required: true,
+    },
   },
   markdownDocsPath: helpPagePath('user/markdown'),
   data() {
diff --git a/app/assets/javascripts/work_items/components/work_item_detail.vue b/app/assets/javascripts/work_items/components/work_item_detail.vue
index a5580c14a7ac3..5cc93f0a76776 100644
--- a/app/assets/javascripts/work_items/components/work_item_detail.vue
+++ b/app/assets/javascripts/work_items/components/work_item_detail.vue
@@ -121,6 +121,9 @@ export default {
     canDelete() {
       return this.workItem?.userPermissions?.deleteWorkItem;
     },
+    fullPath() {
+      return this.workItem?.project.fullPath;
+    },
     workItemsMvc2Enabled() {
       return this.glFeatures.workItemsMvc2;
     },
@@ -326,12 +329,14 @@ export default {
           :allows-multiple-assignees="workItemAssignees.allowsMultipleAssignees"
           :work-item-type="workItemType"
           :can-invite-members="workItemAssignees.canInviteMembers"
+          :full-path="fullPath"
           @error="error = $event"
         />
         <work-item-labels
           v-if="workItemLabels"
           :work-item-id="workItem.id"
           :can-update="canUpdate"
+          :full-path="fullPath"
           @error="error = $event"
         />
       </template>
@@ -347,6 +352,7 @@ export default {
       <work-item-description
         v-if="hasDescriptionWidget"
         :work-item-id="workItem.id"
+        :full-path="fullPath"
         class="gl-pt-5"
         @error="error = $event"
       />
diff --git a/app/assets/javascripts/work_items/components/work_item_labels.vue b/app/assets/javascripts/work_items/components/work_item_labels.vue
index e73488bbd701e..e608e4ad57e09 100644
--- a/app/assets/javascripts/work_items/components/work_item_labels.vue
+++ b/app/assets/javascripts/work_items/components/work_item_labels.vue
@@ -31,7 +31,6 @@ export default {
     LabelItem,
   },
   mixins: [Tracking.mixin()],
-  inject: ['fullPath'],
   props: {
     workItemId: {
       type: String,
@@ -41,6 +40,10 @@ export default {
       type: Boolean,
       required: true,
     },
+    fullPath: {
+      type: String,
+      required: true,
+    },
   },
   data() {
     return {
diff --git a/app/assets/javascripts/work_items/graphql/create_work_item.mutation.graphql b/app/assets/javascripts/work_items/graphql/create_work_item.mutation.graphql
index 4cc23fa00718c..1228c876a556c 100644
--- a/app/assets/javascripts/work_items/graphql/create_work_item.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/create_work_item.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation createWorkItem($input: WorkItemCreateInput!) {
   workItemCreate(input: $input) {
diff --git a/app/assets/javascripts/work_items/graphql/create_work_item_from_task.mutation.graphql b/app/assets/javascripts/work_items/graphql/create_work_item_from_task.mutation.graphql
index 1f98cd4fa2b8d..ccfe62cc58562 100644
--- a/app/assets/javascripts/work_items/graphql/create_work_item_from_task.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/create_work_item_from_task.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation workItemCreateFromTask($input: WorkItemCreateFromTaskInput!) {
   workItemCreateFromTask(input: $input) {
diff --git a/app/assets/javascripts/work_items/graphql/local_update_work_item.mutation.graphql b/app/assets/javascripts/work_items/graphql/local_update_work_item.mutation.graphql
index 790b8e60b6a7d..43c92cf89eccd 100644
--- a/app/assets/javascripts/work_items/graphql/local_update_work_item.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/local_update_work_item.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation localUpdateWorkItem($input: LocalUpdateWorkItemInput) {
   localUpdateWorkItem(input: $input) @client {
diff --git a/app/assets/javascripts/work_items/graphql/update_work_item.mutation.graphql b/app/assets/javascripts/work_items/graphql/update_work_item.mutation.graphql
index 0a887fcfc00a0..25eb8099251e8 100644
--- a/app/assets/javascripts/work_items/graphql/update_work_item.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/update_work_item.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation workItemUpdate($input: WorkItemUpdateInput!) {
   workItemUpdate(input: $input) {
diff --git a/app/assets/javascripts/work_items/graphql/update_work_item_task.mutation.graphql b/app/assets/javascripts/work_items/graphql/update_work_item_task.mutation.graphql
index fad5a9fa5bc9f..ad861a60d1509 100644
--- a/app/assets/javascripts/work_items/graphql/update_work_item_task.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/update_work_item_task.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation workItemUpdateTask($input: WorkItemUpdateTaskInput!) {
   workItemUpdate: workItemUpdateTask(input: $input) {
diff --git a/app/assets/javascripts/work_items/graphql/update_work_item_widgets.mutation.graphql b/app/assets/javascripts/work_items/graphql/update_work_item_widgets.mutation.graphql
index 6a94c96b34740..148b340b439d8 100644
--- a/app/assets/javascripts/work_items/graphql/update_work_item_widgets.mutation.graphql
+++ b/app/assets/javascripts/work_items/graphql/update_work_item_widgets.mutation.graphql
@@ -1,4 +1,4 @@
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 mutation workItemUpdateWidgets($input: WorkItemUpdateWidgetsInput!) {
   workItemUpdateWidgets(input: $input) {
diff --git a/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql b/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
index e8ef27ec77896..e77f577c897bb 100644
--- a/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
+++ b/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
@@ -1,4 +1,5 @@
 #import "~/graphql_shared/fragments/user.fragment.graphql"
+#import "ee_else_ce/work_items/graphql/work_item_widgets.fragment.graphql"
 
 fragment WorkItem on WorkItem {
   id
@@ -6,6 +7,10 @@ fragment WorkItem on WorkItem {
   state
   description
   confidential
+  project {
+    id
+    fullPath
+  }
   workItemType {
     id
     name
@@ -16,34 +21,6 @@ fragment WorkItem on WorkItem {
     updateWorkItem
   }
   widgets {
-    ... on WorkItemWidgetDescription {
-      type
-      description
-      descriptionHtml
-    }
-    ... on WorkItemWidgetAssignees {
-      type
-      allowsMultipleAssignees
-      canInviteMembers
-      assignees {
-        nodes {
-          ...User
-        }
-      }
-    }
-    ... on WorkItemWidgetHierarchy {
-      type
-      parent {
-        id
-        iid
-        title
-        confidential
-      }
-      children {
-        nodes {
-          id
-        }
-      }
-    }
+    ...WorkItemWidgets
   }
 }
diff --git a/app/assets/javascripts/work_items/graphql/work_item.query.graphql b/app/assets/javascripts/work_items/graphql/work_item.query.graphql
index a9f7b7145516a..276061af1932e 100644
--- a/app/assets/javascripts/work_items/graphql/work_item.query.graphql
+++ b/app/assets/javascripts/work_items/graphql/work_item.query.graphql
@@ -1,5 +1,5 @@
 #import "~/graphql_shared/fragments/label.fragment.graphql"
-#import "ee_else_ce/work_items/graphql/work_item.fragment.graphql"
+#import "./work_item.fragment.graphql"
 
 query workItem($id: WorkItemID!) {
   workItem(id: $id) {
diff --git a/app/assets/javascripts/work_items/graphql/work_item_links.query.graphql b/app/assets/javascripts/work_items/graphql/work_item_links.query.graphql
index df62ca1c14315..2ca4450f89258 100644
--- a/app/assets/javascripts/work_items/graphql/work_item_links.query.graphql
+++ b/app/assets/javascripts/work_items/graphql/work_item_links.query.graphql
@@ -1,4 +1,4 @@
-query workItemQuery($id: WorkItemID!) {
+query workItemLinksQuery($id: WorkItemID!) {
   workItem(id: $id) {
     id
     workItemType {
diff --git a/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql b/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
new file mode 100644
index 0000000000000..510788217ca91
--- /dev/null
+++ b/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
@@ -0,0 +1,31 @@
+fragment WorkItemWidgets on WorkItemWidget {
+  ... on WorkItemWidgetDescription {
+    type
+    description
+    descriptionHtml
+  }
+  ... on WorkItemWidgetAssignees {
+    type
+    allowsMultipleAssignees
+    canInviteMembers
+    assignees {
+      nodes {
+        ...User
+      }
+    }
+  }
+  ... on WorkItemWidgetHierarchy {
+    type
+    parent {
+      id
+      iid
+      title
+      confidential
+    }
+    children {
+      nodes {
+        id
+      }
+    }
+  }
+}
diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
deleted file mode 100644
index 86bd7c8cdf982..0000000000000
--- a/ee/app/assets/javascripts/work_items/graphql/work_item.fragment.graphql
+++ /dev/null
@@ -1,53 +0,0 @@
-#import "~/graphql_shared/fragments/user.fragment.graphql"
-
-fragment WorkItem on WorkItem {
-  id
-  title
-  state
-  description
-  confidential
-  workItemType {
-    id
-    name
-    iconName
-  }
-  userPermissions {
-    deleteWorkItem
-    updateWorkItem
-  }
-  widgets {
-    ... on WorkItemWidgetDescription {
-      type
-      description
-      descriptionHtml
-    }
-    ... on WorkItemWidgetAssignees {
-      type
-      allowsMultipleAssignees
-      canInviteMembers
-      assignees {
-        nodes {
-          ...User
-        }
-      }
-    }
-    ... on WorkItemWidgetWeight {
-      type
-      weight
-    }
-    ... on WorkItemWidgetHierarchy {
-      type
-      parent {
-        id
-        iid
-        title
-        confidential
-      }
-      children {
-        nodes {
-          id
-        }
-      }
-    }
-  }
-}
diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
new file mode 100644
index 0000000000000..28b2d14c01066
--- /dev/null
+++ b/ee/app/assets/javascripts/work_items/graphql/work_item_widgets.fragment.graphql
@@ -0,0 +1,37 @@
+#import "~/graphql_shared/fragments/user.fragment.graphql"
+
+fragment WorkItemWidgets on WorkItemWidget {
+  ... on WorkItemWidgetDescription {
+    type
+    description
+    descriptionHtml
+  }
+  ... on WorkItemWidgetAssignees {
+    type
+    allowsMultipleAssignees
+    canInviteMembers
+    assignees {
+      nodes {
+        ...User
+      }
+    }
+  }
+  ... on WorkItemWidgetWeight {
+    type
+    weight
+  }
+  ... on WorkItemWidgetHierarchy {
+    type
+    parent {
+      id
+      iid
+      title
+      confidential
+    }
+    children {
+      nodes {
+        id
+      }
+    }
+  }
+}
diff --git a/spec/frontend/work_items/components/work_item_assignees_spec.js b/spec/frontend/work_items/components/work_item_assignees_spec.js
index b00a9efa9329d..897992df1e10e 100644
--- a/spec/frontend/work_items/components/work_item_assignees_spec.js
+++ b/spec/frontend/work_items/components/work_item_assignees_spec.js
@@ -82,9 +82,6 @@ describe('WorkItemAssignees component', () => {
     });
 
     wrapper = mountExtended(WorkItemAssignees, {
-      provide: {
-        fullPath: 'test-project-path',
-      },
       propsData: {
         assignees,
         workItemId,
@@ -92,6 +89,7 @@ describe('WorkItemAssignees component', () => {
         workItemType: TASK_TYPE_NAME,
         canUpdate,
         canInviteMembers,
+        fullPath: 'test-project-path',
       },
       attachTo: document.body,
       apolloProvider,
diff --git a/spec/frontend/work_items/components/work_item_description_spec.js b/spec/frontend/work_items/components/work_item_description_spec.js
index 8017c46dea88f..6ec786507c033 100644
--- a/spec/frontend/work_items/components/work_item_description_spec.js
+++ b/spec/frontend/work_items/components/work_item_description_spec.js
@@ -57,9 +57,7 @@ describe('WorkItemDescription', () => {
       ]),
       propsData: {
         workItemId: id,
-      },
-      provide: {
-        fullPath: '/group/project',
+        fullPath: 'test-project-path',
       },
       stubs: {
         MarkdownField,
diff --git a/spec/frontend/work_items/components/work_item_labels_spec.js b/spec/frontend/work_items/components/work_item_labels_spec.js
index c206afc905ad6..1d976897c1598 100644
--- a/spec/frontend/work_items/components/work_item_labels_spec.js
+++ b/spec/frontend/work_items/components/work_item_labels_spec.js
@@ -45,13 +45,11 @@ describe('WorkItemLabels component', () => {
     });
 
     wrapper = mountExtended(WorkItemLabels, {
-      provide: {
-        fullPath: 'test-project-path',
-      },
       propsData: {
         labels,
         workItemId,
         canUpdate,
+        fullPath: 'test-project-path',
       },
       attachTo: document.body,
       apolloProvider,
diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js
index d24ac2a9f93ed..8deca5c50b7d8 100644
--- a/spec/frontend/work_items/mock_data.js
+++ b/spec/frontend/work_items/mock_data.js
@@ -28,6 +28,11 @@ export const workItemQueryResponse = {
       confidential: false,
       createdAt: '2022-08-03T12:41:54Z',
       closedAt: null,
+      project: {
+        __typename: 'Project',
+        id: '1',
+        fullPath: 'test-project-path',
+      },
       workItemType: {
         __typename: 'WorkItemType',
         id: 'gid://gitlab/WorkItems::Type/5',
@@ -93,6 +98,11 @@ export const updateWorkItemMutationResponse = {
         confidential: false,
         createdAt: '2022-08-03T12:41:54Z',
         closedAt: null,
+        project: {
+          __typename: 'Project',
+          id: '1',
+          fullPath: 'test-project-path',
+        },
         workItemType: {
           __typename: 'WorkItemType',
           id: 'gid://gitlab/WorkItems::Type/5',
@@ -157,6 +167,11 @@ export const workItemResponseFactory = ({
       confidential,
       createdAt: '2022-08-03T12:41:54Z',
       closedAt: null,
+      project: {
+        __typename: 'Project',
+        id: '1',
+        fullPath: 'test-project-path',
+      },
       workItemType: {
         __typename: 'WorkItemType',
         id: 'gid://gitlab/WorkItems::Type/5',
@@ -251,6 +266,11 @@ export const createWorkItemMutationResponse = {
         confidential: false,
         createdAt: '2022-08-03T12:41:54Z',
         closedAt: null,
+        project: {
+          __typename: 'Project',
+          id: '1',
+          fullPath: 'test-project-path',
+        },
         workItemType: {
           __typename: 'WorkItemType',
           id: 'gid://gitlab/WorkItems::Type/5',
@@ -282,6 +302,11 @@ export const createWorkItemFromTaskMutationResponse = {
         confidential: false,
         createdAt: '2022-08-03T12:41:54Z',
         closedAt: null,
+        project: {
+          __typename: 'Project',
+          id: '1',
+          fullPath: 'test-project-path',
+        },
         workItemType: {
           __typename: 'WorkItemType',
           id: 'gid://gitlab/WorkItems::Type/5',
@@ -310,6 +335,11 @@ export const createWorkItemFromTaskMutationResponse = {
         closedAt: null,
         description: '',
         confidential: false,
+        project: {
+          __typename: 'Project',
+          id: '1',
+          fullPath: 'test-project-path',
+        },
         workItemType: {
           __typename: 'WorkItemType',
           id: 'gid://gitlab/WorkItems::Type/5',
@@ -388,6 +418,11 @@ export const workItemHierarchyEmptyResponse = {
       title: 'New title',
       createdAt: '2022-08-03T12:41:54Z',
       closedAt: null,
+      project: {
+        __typename: 'Project',
+        id: '1',
+        fullPath: 'test-project-path',
+      },
       userPermissions: {
         deleteWorkItem: false,
         updateWorkItem: false,
@@ -426,6 +461,11 @@ export const workItemHierarchyNoUpdatePermissionResponse = {
         deleteWorkItem: false,
         updateWorkItem: false,
       },
+      project: {
+        __typename: 'Project',
+        id: '1',
+        fullPath: 'test-project-path',
+      },
       confidential: false,
       widgets: [
         {
@@ -475,6 +515,11 @@ export const workItemHierarchyResponse = {
         updateWorkItem: true,
       },
       confidential: false,
+      project: {
+        __typename: 'Project',
+        id: '1',
+        fullPath: 'test-project-path',
+      },
       widgets: [
         {
           type: 'DESCRIPTION',
@@ -570,6 +615,11 @@ export const changeWorkItemParentMutationResponse = {
         confidential: false,
         createdAt: '2022-08-03T12:41:54Z',
         closedAt: null,
+        project: {
+          __typename: 'Project',
+          id: '1',
+          fullPath: 'test-project-path',
+        },
         widgets: [
           {
             __typename: 'WorkItemWidgetHierarchy',
-- 
GitLab