diff --git a/app/assets/javascripts/graphql_shared/issuable_client.js b/app/assets/javascripts/graphql_shared/issuable_client.js index 903cd27232a..35e0363f473 100644 --- a/app/assets/javascripts/graphql_shared/issuable_client.js +++ b/app/assets/javascripts/graphql_shared/issuable_client.js @@ -80,6 +80,15 @@ export const config = { }, }, }, + WorkItemWidgetHierarchy: { + fields: { + // If we add any key args, the children field becomes children({"first":10}) and + // kills any possibility to handle it on the widget level without hardcoding a string. + children: { + keyArgs: false, + }, + }, + }, WorkItem: { fields: { // widgets policy because otherwise the subscriptions invalidate the cache diff --git a/app/assets/javascripts/issues/show/components/description.vue b/app/assets/javascripts/issues/show/components/description.vue index fdf9c00b352..7a9ae81bd16 100644 --- a/app/assets/javascripts/issues/show/components/description.vue +++ b/app/assets/javascripts/issues/show/components/description.vue @@ -336,8 +336,7 @@ export default { update: (cache, { data: { workItemCreate } }) => addHierarchyChild({ cache, - fullPath: this.fullPath, - iid: this.issueIid, + id: convertToGraphQLId(TYPENAME_WORK_ITEM, this.issueId), workItem: workItemCreate.workItem, }), }); @@ -371,8 +370,7 @@ export default { update: (cache) => removeHierarchyChild({ cache, - fullPath: this.fullPath, - iid: this.issueIid, + id: convertToGraphQLId(TYPENAME_WORK_ITEM, this.issueId), workItem: { id }, }), }); diff --git a/app/assets/javascripts/projects/components/project_delete_button.vue b/app/assets/javascripts/projects/components/project_delete_button.vue index dc8f9b45c8e..924b6f55db4 100644 --- a/app/assets/javascripts/projects/components/project_delete_button.vue +++ b/app/assets/javascripts/projects/components/project_delete_button.vue @@ -1,5 +1,4 @@ @@ -91,7 +89,7 @@ export default { variant="danger" data-testid="delete-button" @click="onButtonClick" - >{{ buttonText }}{{ $options.i18n.deleteProject }} diff --git a/app/assets/javascripts/projects/project_delete_button.js b/app/assets/javascripts/projects/project_delete_button.js index c9eea2d2194..b4d388eda3a 100644 --- a/app/assets/javascripts/projects/project_delete_button.js +++ b/app/assets/javascripts/projects/project_delete_button.js @@ -9,7 +9,6 @@ export default (selector = '#js-project-delete-button') => { const { confirmPhrase, - buttonText, formPath, isFork, issuesCount, @@ -25,7 +24,6 @@ export default (selector = '#js-project-delete-button') => { return createElement(ProjectDeleteButton, { props: { confirmPhrase, - buttonText, formPath, isFork: parseBoolean(isFork), issuesCount: parseInt(issuesCount, 10), 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 caea1d10a08..87c862d7e52 100644 --- a/app/assets/javascripts/work_items/components/work_item_detail.vue +++ b/app/assets/javascripts/work_items/components/work_item_detail.vue @@ -33,7 +33,7 @@ import updateWorkItemMutation from '../graphql/update_work_item.mutation.graphql import groupWorkItemByIidQuery from '../graphql/group_work_item_by_iid.query.graphql'; import workItemByIidQuery from '../graphql/work_item_by_iid.query.graphql'; import getAllowedWorkItemChildTypes from '../graphql/work_item_allowed_children.query.graphql'; -import { findHierarchyWidgetChildren, findHierarchyWidgetDefinition } from '../utils'; +import { findHierarchyWidgetDefinition } from '../utils'; import WorkItemTree from './work_item_links/work_item_tree.vue'; import WorkItemActions from './work_item_actions.vue'; @@ -119,6 +119,7 @@ export default { isStickyHeaderShowing: false, editMode: false, draftData: {}, + hasChildren: false, }; }, apollo: { @@ -282,12 +283,6 @@ export default { workItemNotes() { return this.isWidgetPresent(WIDGET_TYPE_NOTES); }, - children() { - return this.workItem ? findHierarchyWidgetChildren(this.workItem) : []; - }, - hasChildren() { - return !isEmpty(this.children); - }, workItemBodyClass() { return { 'gl-pt-5': !this.updateError && !this.isModal, @@ -672,13 +667,13 @@ export default { :parent-work-item-type="workItem.workItemType.name" :work-item-id="workItem.id" :work-item-iid="workItemIid" - :children="children" :can-update="canUpdate" :can-update-children="canUpdateChildren" :confidential="workItem.confidential" :allowed-child-types="allowedChildTypes" @show-modal="openInModal" @addChild="$emit('addChild')" + @childrenLoaded="hasChildren = $event" /> removeHierarchyChild({ cache, - fullPath: this.fullPath, - iid: this.workItemIid, - isGroup: this.isGroup, + id: this.workItemId, workItem: child, }), }); @@ -130,9 +129,7 @@ export default { update: (cache) => addHierarchyChild({ cache, - fullPath: this.fullPath, - iid: this.workItemIid, - isGroup: this.isGroup, + id: this.workItemId, workItem: child, }), }); @@ -228,12 +225,12 @@ export default { update: (store) => { store.updateQuery( { - query: this.isGroup ? groupWorkItemByIidQuery : workItemByIidQuery, - variables: { fullPath: this.fullPath, iid: this.workItemIid }, + query: getWorkItemTreeQuery, + variables: { id: this.workItemId, pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS }, }, (sourceData) => produce(sourceData, (draftData) => { - const { widgets } = draftData.workspace.workItem; + const { widgets } = draftData.workItem; const hierarchyWidget = findHierarchyWidgets(widgets); hierarchyWidget.children.nodes = updatedChildren; }), diff --git a/app/assets/javascripts/work_items/components/work_item_links/work_item_link_child.vue b/app/assets/javascripts/work_items/components/work_item_links/work_item_link_child.vue index 59d574afad5..f9f23ebeed5 100644 --- a/app/assets/javascripts/work_items/components/work_item_links/work_item_link_child.vue +++ b/app/assets/javascripts/work_items/components/work_item_links/work_item_link_child.vue @@ -11,6 +11,7 @@ import { WIDGET_TYPE_HIERARCHY, WORK_ITEM_TYPE_VALUE_OBJECTIVE, WORK_ITEM_TYPE_VALUE_TASK, + DEFAULT_PAGE_SIZE_CHILD_ITEMS, } from '../../constants'; import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql'; import WorkItemLinkChildContents from '../shared/work_item_link_child_contents.vue'; @@ -138,6 +139,7 @@ export default { query: getWorkItemTreeQuery, variables: { id: this.childItem.id, + pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS, }, }); this.children = this.getWidgetByType(data?.workItem, WIDGET_TYPE_HIERARCHY).children.nodes; 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 5ccddeb38cc..e100778aafd 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 @@ -22,11 +22,11 @@ import { WORK_ITEM_STATUS_TEXT, I18N_WORK_ITEM_SHOW_LABELS, TASKS_ANCHOR, + DEFAULT_PAGE_SIZE_CHILD_ITEMS, } from '../../constants'; import { findHierarchyWidgetChildren } from '../../utils'; import { removeHierarchyChild } from '../../graphql/cache_utils'; -import groupWorkItemByIidQuery from '../../graphql/group_work_item_by_iid.query.graphql'; -import workItemByIidQuery from '../../graphql/work_item_by_iid.query.graphql'; +import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql'; import WidgetWrapper from '../widget_wrapper.vue'; import WorkItemDetailModal from '../work_item_detail_modal.vue'; import WorkItemLinksForm from './work_item_links_form.vue'; @@ -62,19 +62,19 @@ export default { apollo: { workItem: { query() { - return this.isGroup ? groupWorkItemByIidQuery : workItemByIidQuery; + return getWorkItemTreeQuery; }, variables() { return { - fullPath: this.fullPath, - iid: this.iid, + id: this.issuableGid, + pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS, }; }, update(data) { - return data.workspace.workItem ?? {}; + return data.workItem ?? {}; }, skip() { - return !this.iid; + return !this.issuableId; }, error(e) { this.error = e.message || this.$options.i18n.fetchError; 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 ceae8938628..b329c8541ab 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 @@ -6,7 +6,7 @@ import WorkItemTokenInput from '../shared/work_item_token_input.vue'; import { addHierarchyChild } from '../../graphql/cache_utils'; import groupWorkItemTypesQuery from '../../graphql/group_work_item_types.query.graphql'; import projectWorkItemTypesQuery from '../../graphql/project_work_item_types.query.graphql'; -import updateWorkItemMutation from '../../graphql/update_work_item.mutation.graphql'; +import updateWorkItemHierarchyMutation from '../../graphql/update_work_item_hierarchy.mutation.graphql'; import createWorkItemMutation from '../../graphql/create_work_item.mutation.graphql'; import { FORM_TYPES, @@ -271,7 +271,7 @@ export default { this.submitInProgress = true; this.$apollo .mutate({ - mutation: updateWorkItemMutation, + mutation: updateWorkItemHierarchyMutation, variables: { input: { id: this.issuableGid, @@ -311,9 +311,7 @@ export default { update: (cache, { data }) => addHierarchyChild({ cache, - fullPath: this.fullPath, - iid: this.workItemIid, - isGroup: this.isGroup, + id: this.issuableGid, workItem: data.workItemCreate.workItem, }), }) diff --git a/app/assets/javascripts/work_items/components/work_item_links/work_item_tree.vue b/app/assets/javascripts/work_items/components/work_item_links/work_item_tree.vue index bf32efdb8dd..e35a186f297 100644 --- a/app/assets/javascripts/work_items/components/work_item_links/work_item_tree.vue +++ b/app/assets/javascripts/work_items/components/work_item_links/work_item_tree.vue @@ -1,5 +1,5 @@