Skip to content

Commit 5e0b1a9

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent e7d07db commit 5e0b1a9

File tree

55 files changed

+613
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+613
-365
lines changed

app/assets/javascripts/graphql_shared/issuable_client.js

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ export const config = {
8080
},
8181
},
8282
},
83+
WorkItemWidgetHierarchy: {
84+
fields: {
85+
// If we add any key args, the children field becomes children({"first":10}) and
86+
// kills any possibility to handle it on the widget level without hardcoding a string.
87+
children: {
88+
keyArgs: false,
89+
},
90+
},
91+
},
8392
WorkItem: {
8493
fields: {
8594
// widgets policy because otherwise the subscriptions invalidate the cache

app/assets/javascripts/issues/show/components/description.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ export default {
336336
update: (cache, { data: { workItemCreate } }) =>
337337
addHierarchyChild({
338338
cache,
339-
fullPath: this.fullPath,
340-
iid: this.issueIid,
339+
id: convertToGraphQLId(TYPENAME_WORK_ITEM, this.issueId),
341340
workItem: workItemCreate.workItem,
342341
}),
343342
});
@@ -371,8 +370,7 @@ export default {
371370
update: (cache) =>
372371
removeHierarchyChild({
373372
cache,
374-
fullPath: this.fullPath,
375-
iid: this.issueIid,
373+
id: convertToGraphQLId(TYPENAME_WORK_ITEM, this.issueId),
376374
workItem: { id },
377375
}),
378376
});

app/assets/javascripts/projects/components/project_delete_button.vue

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script>
2-
import { __ } from '~/locale';
32
import SharedDeleteButton from './shared/delete_button.vue';
43
54
export default {
@@ -11,11 +10,6 @@ export default {
1110
type: String,
1211
required: true,
1312
},
14-
buttonText: {
15-
type: String,
16-
required: false,
17-
default: __('Delete project'),
18-
},
1913
formPath: {
2014
type: String,
2115
required: true,
@@ -47,7 +41,6 @@ export default {
4741
<template>
4842
<shared-delete-button
4943
:confirm-phrase="confirmPhrase"
50-
:button-text="buttonText"
5144
:form-path="formPath"
5245
:is-fork="isFork"
5346
:issues-count="issuesCount"

app/assets/javascripts/projects/components/shared/delete_button.vue

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ export default {
1515
type: String,
1616
required: true,
1717
},
18-
buttonText: {
19-
type: String,
20-
required: false,
21-
default: __('Delete project'),
22-
},
2318
formPath: {
2419
type: String,
2520
required: true,
@@ -63,6 +58,9 @@ export default {
6358
this.isModalVisible = true;
6459
},
6560
},
61+
i18n: {
62+
deleteProject: __('Delete project'),
63+
},
6664
};
6765
</script>
6866

@@ -91,7 +89,7 @@ export default {
9189
variant="danger"
9290
data-testid="delete-button"
9391
@click="onButtonClick"
94-
>{{ buttonText }}</gl-button
92+
>{{ $options.i18n.deleteProject }}</gl-button
9593
>
9694
</gl-form>
9795
</template>

app/assets/javascripts/projects/project_delete_button.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export default (selector = '#js-project-delete-button') => {
99

1010
const {
1111
confirmPhrase,
12-
buttonText,
1312
formPath,
1413
isFork,
1514
issuesCount,
@@ -25,7 +24,6 @@ export default (selector = '#js-project-delete-button') => {
2524
return createElement(ProjectDeleteButton, {
2625
props: {
2726
confirmPhrase,
28-
buttonText,
2927
formPath,
3028
isFork: parseBoolean(isFork),
3129
issuesCount: parseInt(issuesCount, 10),

app/assets/javascripts/work_items/components/work_item_detail.vue

+3-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import updateWorkItemMutation from '../graphql/update_work_item.mutation.graphql
3333
import groupWorkItemByIidQuery from '../graphql/group_work_item_by_iid.query.graphql';
3434
import workItemByIidQuery from '../graphql/work_item_by_iid.query.graphql';
3535
import getAllowedWorkItemChildTypes from '../graphql/work_item_allowed_children.query.graphql';
36-
import { findHierarchyWidgetChildren, findHierarchyWidgetDefinition } from '../utils';
36+
import { findHierarchyWidgetDefinition } from '../utils';
3737
3838
import WorkItemTree from './work_item_links/work_item_tree.vue';
3939
import WorkItemActions from './work_item_actions.vue';
@@ -119,6 +119,7 @@ export default {
119119
isStickyHeaderShowing: false,
120120
editMode: false,
121121
draftData: {},
122+
hasChildren: false,
122123
};
123124
},
124125
apollo: {
@@ -282,12 +283,6 @@ export default {
282283
workItemNotes() {
283284
return this.isWidgetPresent(WIDGET_TYPE_NOTES);
284285
},
285-
children() {
286-
return this.workItem ? findHierarchyWidgetChildren(this.workItem) : [];
287-
},
288-
hasChildren() {
289-
return !isEmpty(this.children);
290-
},
291286
workItemBodyClass() {
292287
return {
293288
'gl-pt-5': !this.updateError && !this.isModal,
@@ -672,13 +667,13 @@ export default {
672667
:parent-work-item-type="workItem.workItemType.name"
673668
:work-item-id="workItem.id"
674669
:work-item-iid="workItemIid"
675-
:children="children"
676670
:can-update="canUpdate"
677671
:can-update-children="canUpdateChildren"
678672
:confidential="workItem.confidential"
679673
:allowed-child-types="allowedChildTypes"
680674
@show-modal="openInModal"
681675
@addChild="$emit('addChild')"
676+
@childrenLoaded="hasChildren = $event"
682677
/>
683678
<work-item-relationships
684679
v-if="workItemLinkedItems"

app/assets/javascripts/work_items/components/work_item_links/work_item_children_wrapper.vue

+7-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
88
import { s__ } from '~/locale';
99
import { defaultSortableOptions, DRAG_DELAY } from '~/sortable/constants';
1010
11-
import { WORK_ITEM_TYPE_VALUE_OBJECTIVE } from '../../constants';
11+
import { WORK_ITEM_TYPE_VALUE_OBJECTIVE, DEFAULT_PAGE_SIZE_CHILD_ITEMS } from '../../constants';
1212
import { findHierarchyWidgets } from '../../utils';
1313
import { addHierarchyChild, removeHierarchyChild } from '../../graphql/cache_utils';
1414
import reorderWorkItem from '../../graphql/reorder_work_item.mutation.graphql';
1515
import updateWorkItemMutation from '../../graphql/update_work_item.mutation.graphql';
1616
import groupWorkItemByIidQuery from '../../graphql/group_work_item_by_iid.query.graphql';
1717
import workItemByIidQuery from '../../graphql/work_item_by_iid.query.graphql';
18+
import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql';
1819
import WorkItemLinkChild from './work_item_link_child.vue';
1920
2021
export default {
@@ -97,9 +98,7 @@ export default {
9798
update: (cache) =>
9899
removeHierarchyChild({
99100
cache,
100-
fullPath: this.fullPath,
101-
iid: this.workItemIid,
102-
isGroup: this.isGroup,
101+
id: this.workItemId,
103102
workItem: child,
104103
}),
105104
});
@@ -130,9 +129,7 @@ export default {
130129
update: (cache) =>
131130
addHierarchyChild({
132131
cache,
133-
fullPath: this.fullPath,
134-
iid: this.workItemIid,
135-
isGroup: this.isGroup,
132+
id: this.workItemId,
136133
workItem: child,
137134
}),
138135
});
@@ -228,12 +225,12 @@ export default {
228225
update: (store) => {
229226
store.updateQuery(
230227
{
231-
query: this.isGroup ? groupWorkItemByIidQuery : workItemByIidQuery,
232-
variables: { fullPath: this.fullPath, iid: this.workItemIid },
228+
query: getWorkItemTreeQuery,
229+
variables: { id: this.workItemId, pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS },
233230
},
234231
(sourceData) =>
235232
produce(sourceData, (draftData) => {
236-
const { widgets } = draftData.workspace.workItem;
233+
const { widgets } = draftData.workItem;
237234
const hierarchyWidget = findHierarchyWidgets(widgets);
238235
hierarchyWidget.children.nodes = updatedChildren;
239236
}),

app/assets/javascripts/work_items/components/work_item_links/work_item_link_child.vue

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
WIDGET_TYPE_HIERARCHY,
1212
WORK_ITEM_TYPE_VALUE_OBJECTIVE,
1313
WORK_ITEM_TYPE_VALUE_TASK,
14+
DEFAULT_PAGE_SIZE_CHILD_ITEMS,
1415
} from '../../constants';
1516
import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql';
1617
import WorkItemLinkChildContents from '../shared/work_item_link_child_contents.vue';
@@ -138,6 +139,7 @@ export default {
138139
query: getWorkItemTreeQuery,
139140
variables: {
140141
id: this.childItem.id,
142+
pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS,
141143
},
142144
});
143145
this.children = this.getWidgetByType(data?.workItem, WIDGET_TYPE_HIERARCHY).children.nodes;

app/assets/javascripts/work_items/components/work_item_links/work_item_links.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import {
2222
WORK_ITEM_STATUS_TEXT,
2323
I18N_WORK_ITEM_SHOW_LABELS,
2424
TASKS_ANCHOR,
25+
DEFAULT_PAGE_SIZE_CHILD_ITEMS,
2526
} from '../../constants';
2627
import { findHierarchyWidgetChildren } from '../../utils';
2728
import { removeHierarchyChild } from '../../graphql/cache_utils';
28-
import groupWorkItemByIidQuery from '../../graphql/group_work_item_by_iid.query.graphql';
29-
import workItemByIidQuery from '../../graphql/work_item_by_iid.query.graphql';
29+
import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql';
3030
import WidgetWrapper from '../widget_wrapper.vue';
3131
import WorkItemDetailModal from '../work_item_detail_modal.vue';
3232
import WorkItemLinksForm from './work_item_links_form.vue';
@@ -62,19 +62,19 @@ export default {
6262
apollo: {
6363
workItem: {
6464
query() {
65-
return this.isGroup ? groupWorkItemByIidQuery : workItemByIidQuery;
65+
return getWorkItemTreeQuery;
6666
},
6767
variables() {
6868
return {
69-
fullPath: this.fullPath,
70-
iid: this.iid,
69+
id: this.issuableGid,
70+
pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS,
7171
};
7272
},
7373
update(data) {
74-
return data.workspace.workItem ?? {};
74+
return data.workItem ?? {};
7575
},
7676
skip() {
77-
return !this.iid;
77+
return !this.issuableId;
7878
},
7979
error(e) {
8080
this.error = e.message || this.$options.i18n.fetchError;

app/assets/javascripts/work_items/components/work_item_links/work_item_links_form.vue

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import WorkItemTokenInput from '../shared/work_item_token_input.vue';
66
import { addHierarchyChild } from '../../graphql/cache_utils';
77
import groupWorkItemTypesQuery from '../../graphql/group_work_item_types.query.graphql';
88
import projectWorkItemTypesQuery from '../../graphql/project_work_item_types.query.graphql';
9-
import updateWorkItemMutation from '../../graphql/update_work_item.mutation.graphql';
9+
import updateWorkItemHierarchyMutation from '../../graphql/update_work_item_hierarchy.mutation.graphql';
1010
import createWorkItemMutation from '../../graphql/create_work_item.mutation.graphql';
1111
import {
1212
FORM_TYPES,
@@ -271,7 +271,7 @@ export default {
271271
this.submitInProgress = true;
272272
this.$apollo
273273
.mutate({
274-
mutation: updateWorkItemMutation,
274+
mutation: updateWorkItemHierarchyMutation,
275275
variables: {
276276
input: {
277277
id: this.issuableGid,
@@ -311,9 +311,7 @@ export default {
311311
update: (cache, { data }) =>
312312
addHierarchyChild({
313313
cache,
314-
fullPath: this.fullPath,
315-
iid: this.workItemIid,
316-
isGroup: this.isGroup,
314+
id: this.issuableGid,
317315
workItem: data.workItemCreate.workItem,
318316
}),
319317
})

app/assets/javascripts/work_items/components/work_item_links/work_item_tree.vue

+39-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { GlToggle } from '@gitlab/ui';
2+
import { GlToggle, GlLoadingIcon } from '@gitlab/ui';
33
import { sprintf, s__ } from '~/locale';
44
import {
55
FORM_TYPES,
@@ -12,7 +12,10 @@ import {
1212
WORK_ITEM_TYPE_ENUM_EPIC,
1313
I18N_WORK_ITEM_SHOW_LABELS,
1414
CHILD_ITEMS_ANCHOR,
15+
DEFAULT_PAGE_SIZE_CHILD_ITEMS,
1516
} from '../../constants';
17+
import { findHierarchyWidgets } from '../../utils';
18+
import getWorkItemTreeQuery from '../../graphql/work_item_tree.query.graphql';
1619
import WidgetWrapper from '../widget_wrapper.vue';
1720
import WorkItemActionsSplitButton from './work_item_actions_split_button.vue';
1821
import WorkItemLinksForm from './work_item_links_form.vue';
@@ -31,6 +34,7 @@ export default {
3134
WorkItemChildrenWrapper,
3235
WorkItemTreeActions,
3336
GlToggle,
37+
GlLoadingIcon,
3438
},
3539
inject: ['hasSubepicsFeature'],
3640
props: {
@@ -61,11 +65,6 @@ export default {
6165
required: false,
6266
default: false,
6367
},
64-
children: {
65-
type: Array,
66-
required: false,
67-
default: () => [],
68-
},
6968
canUpdate: {
7069
type: Boolean,
7170
required: false,
@@ -92,6 +91,28 @@ export default {
9291
showLabels: true,
9392
};
9493
},
94+
apollo: {
95+
hierarchyWidget: {
96+
query: getWorkItemTreeQuery,
97+
variables() {
98+
return {
99+
id: this.workItemId,
100+
pageSize: DEFAULT_PAGE_SIZE_CHILD_ITEMS,
101+
};
102+
},
103+
skip() {
104+
return !this.workItemId;
105+
},
106+
update({ workItem = {} }) {
107+
const { children } = findHierarchyWidgets(workItem.widgets);
108+
this.$emit('childrenLoaded', Boolean(children?.count));
109+
return children || {};
110+
},
111+
error() {
112+
this.error = s__('WorkItems|An error occurred while fetching children');
113+
},
114+
},
115+
},
95116
computed: {
96117
childrenIds() {
97118
return this.children.map((c) => c.id);
@@ -135,6 +156,15 @@ export default {
135156
canShowActionsMenu() {
136157
return this.workItemType.toUpperCase() === WORK_ITEM_TYPE_ENUM_EPIC && this.workItemIid;
137158
},
159+
children() {
160+
return this.hierarchyWidget?.nodes || [];
161+
},
162+
isLoadingChildren() {
163+
return this.$apollo.queries.hierarchyWidget.loading;
164+
},
165+
showEmptyMessage() {
166+
return !this.isShownAddForm && this.children.length === 0 && !this.isLoadingChildren;
167+
},
138168
},
139169
methods: {
140170
genericActionItems(workItem) {
@@ -206,7 +236,7 @@ export default {
206236
</template>
207237
<template #body>
208238
<div class="gl-new-card-content gl-px-0">
209-
<div v-if="!isShownAddForm && children.length === 0" data-testid="tree-empty">
239+
<div v-if="showEmptyMessage" data-testid="tree-empty">
210240
<p class="gl-new-card-empty">
211241
{{ $options.WORK_ITEMS_TREE_TEXT_MAP[workItemType].empty }}
212242
</p>
@@ -227,6 +257,7 @@ export default {
227257
@addChild="$emit('addChild')"
228258
/>
229259
<work-item-children-wrapper
260+
v-if="!isLoadingChildren"
230261
:children="children"
231262
:can-update="canUpdateChildren"
232263
:full-path="fullPath"
@@ -237,6 +268,7 @@ export default {
237268
@error="error = $event"
238269
@show-modal="showModal"
239270
/>
271+
<gl-loading-icon v-else size="md" />
240272
</div>
241273
</template>
242274
</widget-wrapper>

0 commit comments

Comments
 (0)