Commit 7f13bc9e authored by Florie Guibert's avatar Florie Guibert

Consolidate labels widget architecture

Review feedback
parent 2584c5b5
...@@ -162,20 +162,18 @@ export default { ...@@ -162,20 +162,18 @@ export default {
labelIds = labels.map(({ id }) => id); labelIds = labels.map(({ id }) => id);
const currentIid = this.oldIid || this.iid; const currentIid = this.oldIid || this.iid;
const updateVariables = {
iid: currentIid,
projectPath: this.fullPath,
labelIds,
};
switch (this.issuableType) { switch (this.issuableType) {
case IssuableType.Issue: case IssuableType.Issue:
return { return updateVariables;
iid: currentIid,
projectPath: this.fullPath,
labelIds,
};
case IssuableType.MergeRequest: case IssuableType.MergeRequest:
return { updateVariables.operationMode = MutationOperationMode.Replace;
iid: currentIid, return updateVariables;
labelIds,
operationMode: MutationOperationMode.Replace,
projectPath: this.fullPath,
};
default: default:
return {}; return {};
} }
...@@ -200,25 +198,34 @@ export default { ...@@ -200,25 +198,34 @@ export default {
labels: data[mutationName]?.[this.issuableType].labels?.nodes, labels: data[mutationName]?.[this.issuableType].labels?.nodes,
}); });
}) })
.catch(() => createFlash({ message: __('An error occurred while updating labels.') })) .catch((error) =>
createFlash({
message: __('An error occurred while updating labels.'),
captureError: true,
error,
}),
)
.finally(() => { .finally(() => {
this.labelsSelectInProgress = false; this.labelsSelectInProgress = false;
}); });
}, },
getRemoveVariables(labelId) { getRemoveVariables(labelId) {
const removeVariables = {
iid: this.iid,
projectPath: this.fullPath,
};
switch (this.issuableType) { switch (this.issuableType) {
case IssuableType.Issue: case IssuableType.Issue:
return { return {
iid: this.iid, ...removeVariables,
projectPath: this.fullPath,
removeLabelIds: [labelId], removeLabelIds: [labelId],
}; };
case IssuableType.MergeRequest: case IssuableType.MergeRequest:
return { return {
iid: this.iid, ...removeVariables,
labelIds: [labelId], labelIds: [labelId],
operationMode: MutationOperationMode.Remove, operationMode: MutationOperationMode.Remove,
projectPath: this.fullPath,
}; };
default: default:
return {}; return {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment