diff --git a/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue b/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue index 6a43fdb541f436cecab483bc5e786df540fab68c..8aa1c862055712b33dce88cfc893d3f83755716f 100644 --- a/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue +++ b/app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue @@ -43,7 +43,6 @@ export default { }; }, update(data) { - this.canUpdate = data.workItem.userPermissions.updateWorkItem; return ( data.workItem.widgets.find((widget) => widget.type === WIDGET_TYPE_HIERARCHY)?.children .nodes ?? [] @@ -54,6 +53,7 @@ export default { }, result({ data }) { this.canUpdate = data.workItem.userPermissions.updateWorkItem; + this.confidential = data.workItem.confidential; }, }, }, @@ -63,6 +63,7 @@ export default { isOpen: true, children: [], canUpdate: false, + confidential: false, }; }, computed: { @@ -164,6 +165,7 @@ export default { data-testid="add-links-form" :issuable-gid="issuableGid" :children-ids="childrenIds" + :parent-confidential="confidential" @cancel="hideAddForm" @addWorkItemChild="addChild" /> diff --git a/app/assets/javascripts/work_items/components/work_item_links/work_item_links_form.vue b/app/assets/javascripts/work_items/components/work_item_links/work_item_links_form.vue index d01d59050e633d066b8009fa25c3adc08ff68bea..707baf81d29342eac0c56805ee64edb5e77b85f8 100644 --- a/app/assets/javascripts/work_items/components/work_item_links/work_item_links_form.vue +++ b/app/assets/javascripts/work_items/components/work_item_links/work_item_links_form.vue @@ -28,6 +28,11 @@ export default { required: false, default: () => [], }, + parentConfidential: { + type: Boolean, + required: false, + default: false, + }, }, apollo: { availableWorkItems: { @@ -123,6 +128,7 @@ export default { hierarchyWidget: { parentId: this.issuableGid, }, + confidential: this.parentConfidential, }, }, }) 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 921f75ccb0a5541becb7f54b5f917ed6e04315bc..827976551e0522b5a5e7e6e489c8a9298cc908d0 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 @@ -8,6 +8,7 @@ query workItemQuery($id: WorkItemID!) { userPermissions { updateWorkItem } + confidential widgets { type ... on WorkItemWidgetHierarchy { diff --git a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js index 56c1d8054fd817a96aaf493d785fa922bc10b21d..ce927a41d7425323e2500acd98e992ef852eff48 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js @@ -5,6 +5,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import WorkItemLinksForm from '~/work_items/components/work_item_links/work_item_links_form.vue'; +import { WORK_ITEM_TYPE_IDS } from '~/work_items/constants'; import projectWorkItemsQuery from '~/work_items/graphql/project_work_items.query.graphql'; import createWorkItemMutation from '~/work_items/graphql/create_work_item.mutation.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; @@ -22,14 +23,17 @@ describe('WorkItemLinksForm', () => { const updateMutationResolver = jest.fn().mockResolvedValue(updateWorkItemMutationResponse); const createMutationResolver = jest.fn().mockResolvedValue(createWorkItemMutationResponse); - const createComponent = async ({ listResponse = availableWorkItemsResponse } = {}) => { + const createComponent = async ({ + listResponse = availableWorkItemsResponse, + parentConfidential = false, + } = {}) => { wrapper = shallowMountExtended(WorkItemLinksForm, { apolloProvider: createMockApollo([ [projectWorkItemsQuery, jest.fn().mockResolvedValue(listResponse)], [updateWorkItemMutation, updateMutationResolver], [createWorkItemMutation, createMutationResolver], ]), - propsData: { issuableGid: 'gid://gitlab/WorkItem/1' }, + propsData: { issuableGid: 'gid://gitlab/WorkItem/1', parentConfidential }, provide: { projectPath: 'project/path', }, @@ -55,14 +59,46 @@ describe('WorkItemLinksForm', () => { expect(findForm().exists()).toBe(true); }); - it('creates child task', async () => { + it('creates child task in non confidential parent', async () => { findInput().vm.$emit('input', 'Create task test'); findForm().vm.$emit('submit', { preventDefault: jest.fn(), }); await waitForPromises(); - expect(createMutationResolver).toHaveBeenCalled(); + expect(createMutationResolver).toHaveBeenCalledWith({ + input: { + title: 'Create task test', + projectPath: 'project/path', + workItemTypeId: WORK_ITEM_TYPE_IDS.TASK, + hierarchyWidget: { + parentId: 'gid://gitlab/WorkItem/1', + }, + confidential: false, + }, + }); + }); + + it('creates child task in confidential parent', async () => { + await createComponent({ parentConfidential: true }); + + findInput().vm.$emit('input', 'Create confidential task'); + + findForm().vm.$emit('submit', { + preventDefault: jest.fn(), + }); + await waitForPromises(); + expect(createMutationResolver).toHaveBeenCalledWith({ + input: { + title: 'Create confidential task', + projectPath: 'project/path', + workItemTypeId: WORK_ITEM_TYPE_IDS.TASK, + hierarchyWidget: { + parentId: 'gid://gitlab/WorkItem/1', + }, + confidential: true, + }, + }); }); // Follow up issue to turn this functionality back on https://gitlab.com/gitlab-org/gitlab/-/issues/368757 diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index 05ca66d25234cf68493031a2d638443b7818e0d4..46aaf480564d23fc2d27cab9b470f528af888905 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -337,6 +337,7 @@ export const workItemHierarchyEmptyResponse = { userPermissions: { updateWorkItem: false, }, + confidential: false, widgets: [ { type: 'DESCRIPTION', @@ -369,6 +370,7 @@ export const workItemHierarchyNoUpdatePermissionResponse = { userPermissions: { updateWorkItem: false, }, + confidential: false, widgets: [ { type: 'DESCRIPTION', @@ -412,6 +414,7 @@ export const workItemHierarchyResponse = { userPermissions: { updateWorkItem: true, }, + confidential: false, widgets: [ { type: 'DESCRIPTION',