Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3d2445d4
Commit
3d2445d4
authored
Sep 22, 2021
by
Coung Ngo
Committed by
Kushal Pandya
Sep 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sidebar labels scoped label selection bug
parent
f98d4700
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
13 deletions
+19
-13
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+4
-2
app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/store/mutations.js
...d/components/sidebar/labels_select_vue/store/mutations.js
+5
-4
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/constants.js
...ared/components/sidebar/labels_select_widget/constants.js
+2
-0
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/list_item.vue
...s/settings/compliance_frameworks/components/list_item.vue
+2
-1
spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/mutations_spec.js
...ponents/sidebar/labels_select_vue/store/mutations_spec.js
+6
-6
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
3d2445d4
...
@@ -6,6 +6,7 @@ import { GlBreakpointInstance as breakpointInstance } from '@gitlab/ui/dist/util
...
@@ -6,6 +6,7 @@ import { GlBreakpointInstance as breakpointInstance } from '@gitlab/ui/dist/util
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
{
isFunction
,
defer
}
from
'
lodash
'
;
import
{
isFunction
,
defer
}
from
'
lodash
'
;
import
{
SCOPED_LABEL_DELIMITER
}
from
'
~/vue_shared/components/sidebar/labels_select_widget/constants
'
;
import
{
convertToCamelCase
,
convertToSnakeCase
}
from
'
./text_utility
'
;
import
{
convertToCamelCase
,
convertToSnakeCase
}
from
'
./text_utility
'
;
import
{
isObject
}
from
'
./type_utility
'
;
import
{
isObject
}
from
'
./type_utility
'
;
import
{
getLocationHash
}
from
'
./url_utility
'
;
import
{
getLocationHash
}
from
'
./url_utility
'
;
...
@@ -685,7 +686,7 @@ export const searchBy = (query = '', searchSpace = {}) => {
...
@@ -685,7 +686,7 @@ export const searchBy = (query = '', searchSpace = {}) => {
* @param {Object} label
* @param {Object} label
* @returns Boolean
* @returns Boolean
*/
*/
export
const
isScopedLabel
=
({
title
=
''
}
=
{})
=>
title
.
in
dexOf
(
'
::
'
)
!==
-
1
;
export
const
isScopedLabel
=
({
title
=
''
}
=
{})
=>
title
.
in
cludes
(
SCOPED_LABEL_DELIMITER
)
;
/**
/**
* Returns the base value of the scoped label
* Returns the base value of the scoped label
...
@@ -696,7 +697,8 @@ export const isScopedLabel = ({ title = '' } = {}) => title.indexOf('::') !== -1
...
@@ -696,7 +697,8 @@ export const isScopedLabel = ({ title = '' } = {}) => title.indexOf('::') !== -1
* @param {Object} label
* @param {Object} label
* @returns String
* @returns String
*/
*/
export
const
scopedLabelKey
=
({
title
=
''
})
=>
isScopedLabel
({
title
})
&&
title
.
split
(
'
::
'
)[
0
];
export
const
scopedLabelKey
=
({
title
=
''
})
=>
isScopedLabel
({
title
})
&&
title
.
split
(
SCOPED_LABEL_DELIMITER
)[
0
];
// Methods to set and get Cookie
// Methods to set and get Cookie
export
const
setCookie
=
(
name
,
value
)
=>
Cookies
.
set
(
name
,
value
,
{
expires
:
365
});
export
const
setCookie
=
(
name
,
value
)
=>
Cookies
.
set
(
name
,
value
,
{
expires
:
365
});
...
...
app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/store/mutations.js
View file @
3d2445d4
import
{
isScopedLabel
,
scopedLabelKey
}
from
'
~/lib/utils/common_utils
'
;
import
{
isScopedLabel
,
scopedLabelKey
}
from
'
~/lib/utils/common_utils
'
;
import
{
SCOPED_LABEL_DELIMITER
}
from
'
~/vue_shared/components/sidebar/labels_select_widget/constants
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
@@ -66,10 +67,10 @@ export default {
...
@@ -66,10 +67,10 @@ export default {
}
}
if
(
isScopedLabel
(
candidateLabel
))
{
if
(
isScopedLabel
(
candidateLabel
))
{
const
scoped
Base
=
scopedLabelKey
(
candidateLabel
)
;
const
scoped
KeyWithDelimiter
=
`
${
scopedLabelKey
(
candidateLabel
)}${
SCOPED_LABEL_DELIMITER
}
`
;
const
currentActiveScopedLabel
=
state
.
labels
.
find
(
({
title
})
=>
{
const
currentActiveScopedLabel
=
state
.
labels
.
find
(
return
title
.
startsWith
(
scopedBase
)
&&
title
!==
''
&&
title
!==
candidateLabel
.
title
;
({
title
})
=>
title
.
startsWith
(
scopedKeyWithDelimiter
)
&&
title
!==
candidateLabel
.
title
,
}
);
);
if
(
currentActiveScopedLabel
)
{
if
(
currentActiveScopedLabel
)
{
currentActiveScopedLabel
.
set
=
false
;
currentActiveScopedLabel
.
set
=
false
;
...
...
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/constants.js
View file @
3d2445d4
export
const
SCOPED_LABEL_DELIMITER
=
'
::
'
;
export
const
DropdownVariant
=
{
export
const
DropdownVariant
=
{
Sidebar
:
'
sidebar
'
,
Sidebar
:
'
sidebar
'
,
Standalone
:
'
standalone
'
,
Standalone
:
'
standalone
'
,
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/components/list_item.vue
View file @
3d2445d4
<
script
>
<
script
>
import
{
GlLabel
,
GlButton
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
GlLabel
,
GlButton
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
SCOPED_LABEL_DELIMITER
}
from
'
~/vue_shared/components/sidebar/labels_select_widget/constants
'
;
import
{
DELETE_BUTTON_LABEL
,
EDIT_BUTTON_LABEL
}
from
'
../constants
'
;
import
{
DELETE_BUTTON_LABEL
,
EDIT_BUTTON_LABEL
}
from
'
../constants
'
;
export
default
{
export
default
{
...
@@ -22,7 +23,7 @@ export default {
...
@@ -22,7 +23,7 @@ export default {
},
},
computed
:
{
computed
:
{
isScoped
()
{
isScoped
()
{
return
this
.
framework
.
name
.
includes
(
'
::
'
);
return
this
.
framework
.
name
.
includes
(
SCOPED_LABEL_DELIMITER
);
},
},
},
},
i18n
:
{
i18n
:
{
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/mutations_spec.js
View file @
3d2445d4
...
@@ -157,9 +157,9 @@ describe('LabelsSelect Mutations', () => {
...
@@ -157,9 +157,9 @@ describe('LabelsSelect Mutations', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
labels
=
[
labels
=
[
{
id
:
1
,
title
:
'
scoped
::test
'
,
set
:
true
},
{
id
:
1
,
title
:
'
scoped
'
},
{
id
:
2
,
set
:
false
,
title
:
'
scoped::one
'
},
{
id
:
2
,
title
:
'
scoped::one
'
,
set
:
false
},
{
id
:
3
,
title
:
'
'
},
{
id
:
3
,
title
:
'
scoped::test
'
,
set
:
true
},
{
id
:
4
,
title
:
''
},
{
id
:
4
,
title
:
''
},
];
];
});
});
...
@@ -189,9 +189,9 @@ describe('LabelsSelect Mutations', () => {
...
@@ -189,9 +189,9 @@ describe('LabelsSelect Mutations', () => {
});
});
expect
(
state
.
labels
).
toEqual
([
expect
(
state
.
labels
).
toEqual
([
{
id
:
1
,
title
:
'
scoped
::test
'
,
set
:
false
},
{
id
:
1
,
title
:
'
scoped
'
},
{
id
:
2
,
set
:
true
,
title
:
'
scoped::one
'
,
touched
:
true
},
{
id
:
2
,
title
:
'
scoped::one
'
,
set
:
true
,
touched
:
true
},
{
id
:
3
,
title
:
'
'
},
{
id
:
3
,
title
:
'
scoped::test
'
,
set
:
false
},
{
id
:
4
,
title
:
''
},
{
id
:
4
,
title
:
''
},
]);
]);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment