Commit 002742ec authored by Florie Guibert's avatar Florie Guibert

Add Labels widget support for epic

Review feedback
parent 6b91dfd0
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import $ from 'jquery'; import $ from 'jquery';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { hide, fixTitle } from '~/tooltips'; import { hide, fixTitle } from '~/tooltips';
import { DEBOUNCE_DROPDOWN_DELAY } from '~/vue_shared/components/sidebar/labels_select_widget/constants';
import createFlash from './flash'; import createFlash from './flash';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { sprintf, s__, __ } from './locale'; import { sprintf, s__, __ } from './locale';
...@@ -130,12 +131,10 @@ Sidebar.prototype.openDropdown = function (blockOrName) { ...@@ -130,12 +131,10 @@ Sidebar.prototype.openDropdown = function (blockOrName) {
// Wait for the sidebar to trigger('click') open // Wait for the sidebar to trigger('click') open
// so it doesn't cause our dropdown to close preemptively // so it doesn't cause our dropdown to close preemptively
setTimeout(() => { setTimeout(() => {
if (gon.features?.labelsWidget) { if (!gon.features?.labelsWidget && !$block.hasClass('labels-select-wrapper')) {
$block.find('.shortcut-sidebar-dropdown-toggle').trigger('click');
} else {
$block.find('.js-sidebar-dropdown-toggle').trigger('click'); $block.find('.js-sidebar-dropdown-toggle').trigger('click');
} }
}, 200); }, DEBOUNCE_DROPDOWN_DELAY);
}; };
Sidebar.prototype.setCollapseAfterUpdate = function ($block) { Sidebar.prototype.setCollapseAfterUpdate = function ($block) {
......
export const SCOPED_LABEL_DELIMITER = '::'; export const SCOPED_LABEL_DELIMITER = '::';
export const DEBOUNCE_DROPDOWN_DELAY = 200;
export const DropdownVariant = { export const DropdownVariant = {
Sidebar: 'sidebar', Sidebar: 'sidebar',
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
mutation createLabel($title: String!, $color: String, $projectPath: ID, $groupPath: ID) { mutation createLabel($title: String!, $color: String, $projectPath: ID, $groupPath: ID) {
labelCreate( labelCreate(
input: { title: $title, color: $color, projectPath: $projectPath, groupPath: $groupPath } input: { title: $title, color: $color, projectPath: $projectPath, groupPath: $groupPath }
) { ) {
label { label {
id ...Label
color
description
title
} }
errors errors
} }
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
query epicLabels($fullPath: ID!, $iid: ID) { query epicLabels($fullPath: ID!, $iid: ID) {
workspace: group(fullPath: $fullPath) { workspace: group(fullPath: $fullPath) {
issuable: epic(iid: $iid) { issuable: epic(iid: $iid) {
id id
labels { labels {
nodes { nodes {
id ...Label
title
color
description
} }
} }
} }
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
mutation updateEpic($input: UpdateEpicInput!) { mutation updateEpic($input: UpdateEpicInput!) {
updateEpic(input: $input) { updateEpic(input: $input) {
epic { epic {
id id
labels { labels {
nodes { nodes {
id ...Label
title
color
description
} }
} }
} }
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
query groupLabels($fullPath: ID!, $searchTerm: String) { query groupLabels($fullPath: ID!, $searchTerm: String) {
workspace: group(fullPath: $fullPath) { workspace: group(fullPath: $fullPath) {
labels(searchTerm: $searchTerm, onlyGroupLabels: true) { labels(searchTerm: $searchTerm, onlyGroupLabels: true) {
nodes { nodes {
id ...Label
title
color
description
} }
} }
} }
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
query issueLabels($fullPath: ID!, $iid: String) { query issueLabels($fullPath: ID!, $iid: String) {
workspace: project(fullPath: $fullPath) { workspace: project(fullPath: $fullPath) {
issuable: issue(iid: $iid) { issuable: issue(iid: $iid) {
id id
labels { labels {
nodes { nodes {
id ...Label
title
color
description
} }
} }
} }
......
#import "~/graphql_shared/fragments/label.fragment.graphql"
query projectLabels($fullPath: ID!, $searchTerm: String) { query projectLabels($fullPath: ID!, $searchTerm: String) {
workspace: project(fullPath: $fullPath) { workspace: project(fullPath: $fullPath) {
labels(searchTerm: $searchTerm, includeAncestorGroups: true) { labels(searchTerm: $searchTerm, includeAncestorGroups: true) {
nodes { nodes {
id ...Label
title
color
description
} }
} }
} }
......
...@@ -6,7 +6,7 @@ import { IssuableType } from '~/issue_show/constants'; ...@@ -6,7 +6,7 @@ import { IssuableType } from '~/issue_show/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue'; import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue';
import { issuableLabelsQueries } from '~/sidebar/constants'; import { issuableLabelsQueries } from '~/sidebar/constants';
import { DropdownVariant } from './constants'; import { DEBOUNCE_DROPDOWN_DELAY, DropdownVariant } from './constants';
import DropdownContents from './dropdown_contents.vue'; import DropdownContents from './dropdown_contents.vue';
import DropdownValue from './dropdown_value.vue'; import DropdownValue from './dropdown_value.vue';
import DropdownValueCollapsed from './dropdown_value_collapsed.vue'; import DropdownValueCollapsed from './dropdown_value_collapsed.vue';
...@@ -181,7 +181,7 @@ export default { ...@@ -181,7 +181,7 @@ export default {
debounce(() => { debounce(() => {
this.$refs.editable.toggle(); this.$refs.editable.toggle();
this.$refs.dropdownContents.showDropdown(); this.$refs.dropdownContents.showDropdown();
}, 200)(); }, DEBOUNCE_DROPDOWN_DELAY)();
}, },
getUpdateVariables(labels) { getUpdateVariables(labels) {
let labelIds = []; let labelIds = [];
......
...@@ -80,6 +80,7 @@ export const createLabelSuccessfulResponse = { ...@@ -80,6 +80,7 @@ export const createLabelSuccessfulResponse = {
color: '#dc143c', color: '#dc143c',
description: null, description: null,
title: 'ewrwrwer', title: 'ewrwrwer',
textColor: '#000000',
__typename: 'Label', __typename: 'Label',
}, },
errors: [], errors: [],
...@@ -98,12 +99,14 @@ export const workspaceLabelsQueryResponse = { ...@@ -98,12 +99,14 @@ export const workspaceLabelsQueryResponse = {
description: null, description: null,
id: 'gid://gitlab/ProjectLabel/1', id: 'gid://gitlab/ProjectLabel/1',
title: 'Label1', title: 'Label1',
textColor: '#000000',
}, },
{ {
color: '#2f7b2e', color: '#2f7b2e',
description: null, description: null,
id: 'gid://gitlab/ProjectLabel/2', id: 'gid://gitlab/ProjectLabel/2',
title: 'Label2', title: 'Label2',
textColor: '#000000',
}, },
], ],
}, },
...@@ -123,6 +126,7 @@ export const issuableLabelsQueryResponse = { ...@@ -123,6 +126,7 @@ export const issuableLabelsQueryResponse = {
description: null, description: null,
id: 'gid://gitlab/ProjectLabel/1', id: 'gid://gitlab/ProjectLabel/1',
title: 'Label1', title: 'Label1',
textColor: '#000000',
}, },
], ],
}, },
......
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