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
35547f13
Commit
35547f13
authored
Jun 23, 2021
by
Scott Stern
Committed by
Ezekiel Kigbo
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix selecting scoped label in boards sidebar
parent
e33e7ac7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
3 deletions
+92
-3
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+12
-1
app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/store/mutations.js
...d/components/sidebar/labels_select_vue/store/mutations.js
+12
-0
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/store/mutations.js
...omponents/sidebar/labels_select_widget/store/mutations.js
+12
-0
spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/mutations_spec.js
...ponents/sidebar/labels_select_vue/store/mutations_spec.js
+28
-1
spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js
...ents/sidebar/labels_select_widget/store/mutations_spec.js
+28
-1
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
35547f13
...
@@ -720,7 +720,18 @@ export const searchBy = (query = '', searchSpace = {}) => {
...
@@ -720,7 +720,18 @@ export const searchBy = (query = '', searchSpace = {}) => {
* @param {Object} label
* @param {Object} label
* @returns Boolean
* @returns Boolean
*/
*/
export
const
isScopedLabel
=
({
title
=
''
})
=>
title
.
indexOf
(
'
::
'
)
!==
-
1
;
export
const
isScopedLabel
=
({
title
=
''
}
=
{})
=>
title
.
indexOf
(
'
::
'
)
!==
-
1
;
/**
* Returns the base value of the scoped label
*
* Expected Label to be an Object with `title` as a key:
* { title: 'LabelTitle', ...otherProperties };
*
* @param {Object} label
* @returns String
*/
export
const
scopedLabelKey
=
({
title
=
''
})
=>
isScopedLabel
({
title
})
&&
title
.
split
(
'
::
'
)[
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 @
35547f13
import
{
isScopedLabel
,
scopedLabelKey
}
from
'
~/lib/utils/common_utils
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
@@ -66,5 +67,16 @@ export default {
...
@@ -66,5 +67,16 @@ export default {
candidateLabel
.
touched
=
true
;
candidateLabel
.
touched
=
true
;
candidateLabel
.
set
=
!
candidateLabel
.
set
;
candidateLabel
.
set
=
!
candidateLabel
.
set
;
}
}
if
(
isScopedLabel
(
candidateLabel
))
{
const
scopedBase
=
scopedLabelKey
(
candidateLabel
);
const
currentActiveScopedLabel
=
state
.
labels
.
find
(({
title
})
=>
{
return
title
.
startsWith
(
scopedBase
)
&&
title
!==
''
&&
title
!==
candidateLabel
.
title
;
});
if
(
currentActiveScopedLabel
)
{
currentActiveScopedLabel
.
set
=
false
;
}
}
},
},
};
};
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/store/mutations.js
View file @
35547f13
import
{
isScopedLabel
,
scopedLabelKey
}
from
'
~/lib/utils/common_utils
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
{
DropdownVariant
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
@@ -55,5 +56,16 @@ export default {
...
@@ -55,5 +56,16 @@ export default {
candidateLabel
.
touched
=
true
;
candidateLabel
.
touched
=
true
;
candidateLabel
.
set
=
!
candidateLabel
.
set
;
candidateLabel
.
set
=
!
candidateLabel
.
set
;
}
}
if
(
isScopedLabel
(
candidateLabel
))
{
const
scopedBase
=
scopedLabelKey
(
candidateLabel
);
const
currentActiveScopedLabel
=
state
.
labels
.
find
(
({
title
})
=>
title
.
indexOf
(
scopedBase
)
===
0
&&
title
!==
candidateLabel
.
title
,
);
if
(
currentActiveScopedLabel
)
{
currentActiveScopedLabel
.
set
=
false
;
}
}
},
},
};
};
spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/mutations_spec.js
View file @
35547f13
...
@@ -153,7 +153,16 @@ describe('LabelsSelect Mutations', () => {
...
@@ -153,7 +153,16 @@ describe('LabelsSelect Mutations', () => {
});
});
describe
(
`
${
types
.
UPDATE_SELECTED_LABELS
}
`
,
()
=>
{
describe
(
`
${
types
.
UPDATE_SELECTED_LABELS
}
`
,
()
=>
{
const
labels
=
[{
id
:
1
},
{
id
:
2
},
{
id
:
3
},
{
id
:
4
}];
let
labels
;
beforeEach
(()
=>
{
labels
=
[
{
id
:
1
,
title
:
'
scoped::test
'
,
set
:
true
},
{
id
:
2
,
set
:
false
,
title
:
'
scoped::one
'
},
{
id
:
3
,
title
:
''
},
{
id
:
4
,
title
:
''
},
];
});
it
(
'
updates `state.labels` to include `touched` and `set` props based on provided `labels` param
'
,
()
=>
{
it
(
'
updates `state.labels` to include `touched` and `set` props based on provided `labels` param
'
,
()
=>
{
const
updatedLabelIds
=
[
2
];
const
updatedLabelIds
=
[
2
];
...
@@ -169,5 +178,23 @@ describe('LabelsSelect Mutations', () => {
...
@@ -169,5 +178,23 @@ describe('LabelsSelect Mutations', () => {
}
}
});
});
});
});
describe
(
'
when label is scoped
'
,
()
=>
{
it
(
'
unsets the currently selected scoped label and sets the current label
'
,
()
=>
{
const
state
=
{
labels
,
};
mutations
[
types
.
UPDATE_SELECTED_LABELS
](
state
,
{
labels
:
[{
id
:
2
,
title
:
'
scoped::one
'
}],
});
expect
(
state
.
labels
).
toEqual
([
{
id
:
1
,
title
:
'
scoped::test
'
,
set
:
false
},
{
id
:
2
,
set
:
true
,
title
:
'
scoped::one
'
,
touched
:
true
},
{
id
:
3
,
title
:
''
},
{
id
:
4
,
title
:
''
},
]);
});
});
});
});
});
});
spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js
View file @
35547f13
...
@@ -120,7 +120,16 @@ describe('LabelsSelect Mutations', () => {
...
@@ -120,7 +120,16 @@ describe('LabelsSelect Mutations', () => {
});
});
describe
(
`
${
types
.
UPDATE_SELECTED_LABELS
}
`
,
()
=>
{
describe
(
`
${
types
.
UPDATE_SELECTED_LABELS
}
`
,
()
=>
{
const
labels
=
[{
id
:
1
},
{
id
:
2
},
{
id
:
3
},
{
id
:
4
}];
let
labels
;
beforeEach
(()
=>
{
labels
=
[
{
id
:
1
,
title
:
'
scoped::test
'
,
set
:
true
},
{
id
:
2
,
set
:
false
,
title
:
'
scoped::one
'
},
{
id
:
3
,
title
:
''
},
{
id
:
4
,
title
:
''
},
];
});
it
(
'
updates `state.labels` to include `touched` and `set` props based on provided `labels` param
'
,
()
=>
{
it
(
'
updates `state.labels` to include `touched` and `set` props based on provided `labels` param
'
,
()
=>
{
const
updatedLabelIds
=
[
2
];
const
updatedLabelIds
=
[
2
];
...
@@ -136,5 +145,23 @@ describe('LabelsSelect Mutations', () => {
...
@@ -136,5 +145,23 @@ describe('LabelsSelect Mutations', () => {
}
}
});
});
});
});
describe
(
'
when label is scoped
'
,
()
=>
{
it
(
'
unsets the currently selected scoped label and sets the current label
'
,
()
=>
{
const
state
=
{
labels
,
};
mutations
[
types
.
UPDATE_SELECTED_LABELS
](
state
,
{
labels
:
[{
id
:
2
,
title
:
'
scoped::one
'
}],
});
expect
(
state
.
labels
).
toEqual
([
{
id
:
1
,
title
:
'
scoped::test
'
,
set
:
false
},
{
id
:
2
,
set
:
true
,
title
:
'
scoped::one
'
,
touched
:
true
},
{
id
:
3
,
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