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
e44034fb
Commit
e44034fb
authored
Jul 15, 2021
by
Coung Ngo
Committed by
Phil Hughes
Jul 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue sidebar weight not setting value of 0
parent
370f2a34
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
92 deletions
+41
-92
ee/app/assets/javascripts/sidebar/components/weight/sidebar_weight_widget.vue
...ripts/sidebar/components/weight/sidebar_weight_widget.vue
+17
-11
ee/spec/features/issues/issue_sidebar_spec.rb
ee/spec/features/issues/issue_sidebar_spec.rb
+21
-13
ee/spec/features/issues/issue_weight_spec.rb
ee/spec/features/issues/issue_weight_spec.rb
+0
-65
ee/spec/frontend/sidebar/components/weight/sidebar_weight_widget_spec.js
...d/sidebar/components/weight/sidebar_weight_widget_spec.js
+2
-2
ee/spec/frontend/sidebar/mock_data.js
ee/spec/frontend/sidebar/mock_data.js
+1
-1
No files found.
ee/app/assets/javascripts/sidebar/components/weight/sidebar_weight_widget.vue
View file @
e44034fb
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
{
import
{
GlButton
,
GlButton
,
GlForm
,
GlForm
,
GlFormGroup
,
GlFormInput
,
GlFormInput
,
GlLoadingIcon
,
GlLoadingIcon
,
GlIcon
,
GlIcon
,
...
@@ -23,6 +24,7 @@ export default {
...
@@ -23,6 +24,7 @@ export default {
components
:
{
components
:
{
GlButton
,
GlButton
,
GlForm
,
GlForm
,
GlFormGroup
,
GlFormInput
,
GlFormInput
,
GlIcon
,
GlIcon
,
GlLoadingIcon
,
GlLoadingIcon
,
...
@@ -65,10 +67,10 @@ export default {
...
@@ -65,10 +67,10 @@ export default {
};
};
},
},
update
(
data
)
{
update
(
data
)
{
return
data
.
workspace
?.
issuable
?.
weight
||
null
;
return
data
.
workspace
?.
issuable
?.
weight
;
},
},
result
({
data
})
{
result
({
data
})
{
this
.
$emit
(
'
weightUpdated
'
,
data
.
workspace
?.
issuable
?.
weight
||
null
);
this
.
$emit
(
'
weightUpdated
'
,
data
.
workspace
?.
issuable
?.
weight
);
},
},
error
()
{
error
()
{
createFlash
({
createFlash
({
...
@@ -84,7 +86,7 @@ export default {
...
@@ -84,7 +86,7 @@ export default {
return
this
.
$apollo
.
queries
?.
weight
?.
loading
||
this
.
loading
;
return
this
.
$apollo
.
queries
?.
weight
?.
loading
||
this
.
loading
;
},
},
hasWeight
()
{
hasWeight
()
{
return
this
.
weight
!=
=
null
;
return
this
.
weight
!=
null
;
},
},
weightLabel
()
{
weightLabel
()
{
return
this
.
hasWeight
?
this
.
weight
:
this
.
$options
.
i18n
.
noWeightLabel
;
return
this
.
hasWeight
?
this
.
weight
:
this
.
$options
.
i18n
.
noWeightLabel
;
...
@@ -106,7 +108,8 @@ export default {
...
@@ -106,7 +108,8 @@ export default {
},
},
methods
:
{
methods
:
{
setWeight
(
remove
)
{
setWeight
(
remove
)
{
const
weight
=
remove
?
null
:
this
.
weight
;
const
shouldRemoveWeight
=
remove
||
this
.
weight
===
''
;
const
weight
=
shouldRemoveWeight
?
null
:
this
.
weight
;
this
.
loading
=
true
;
this
.
loading
=
true
;
this
.
$apollo
this
.
$apollo
.
mutate
({
.
mutate
({
...
@@ -209,13 +212,16 @@ export default {
...
@@ -209,13 +212,16 @@ export default {
</template>
</template>
<
template
#default
>
<
template
#default
>
<gl-form
@
submit.prevent=
"handleFormSubmit()"
>
<gl-form
@
submit.prevent=
"handleFormSubmit()"
>
<gl-form-input
<gl-form-group
:label=
"__('Weight')"
label-for=
"weight-input"
label-sr-only
>
v-model.number=
"weight"
<gl-form-input
v-autofocusonshow
id=
"weight-input"
type=
"number"
v-model.number=
"weight"
min=
"0"
v-autofocusonshow
:placeholder=
"$options.i18n.inputPlaceholder"
type=
"number"
/>
min=
"0"
:placeholder=
"$options.i18n.inputPlaceholder"
/>
</gl-form-group>
</gl-form>
</gl-form>
</
template
>
</
template
>
</sidebar-editable-item>
</sidebar-editable-item>
...
...
ee/spec/features/issues/issue_sidebar_spec.rb
View file @
e44034fb
...
@@ -39,31 +39,39 @@ RSpec.describe 'Issue Sidebar' do
...
@@ -39,31 +39,39 @@ RSpec.describe 'Issue Sidebar' do
wait_for_all_requests
wait_for_all_requests
end
end
it
'updates weight in sidebar to
1
'
do
it
'updates weight in sidebar to
0
'
do
page
.
within
'.weight'
do
page
.
within
'.weight'
do
click_button
'Edit'
click_button
'Edit'
find
(
'input'
).
send_keys
1
,
:enter
send_keys
0
,
:enter
page
.
within
'[data-testid="sidebar-weight-value"]'
do
expect
(
page
).
to
have_text
'0 - remove weight'
expect
(
page
).
to
have_content
'1'
end
end
end
end
end
it
'updates weight in sidebar to no weight'
do
it
'updates weight in sidebar to no weight
by clicking `remove weight`
'
do
page
.
within
'.weight'
do
page
.
within
'.weight'
do
click_button
'Edit'
click_button
'Edit'
find
(
'input'
).
send_keys
1
,
:enter
send_keys
1
,
:enter
page
.
within
'[data-testid="sidebar-weight-value"]'
do
expect
(
page
).
to
have_text
'1 - remove weight'
expect
(
page
).
to
have_content
'1'
end
click_button
'remove weight'
click_button
'remove weight'
page
.
within
'[data-testid="sidebar-weight-value"]'
do
expect
(
page
).
to
have_text
'None'
expect
(
page
).
to
have_content
'None'
end
end
end
it
'updates weight in sidebar to no weight by setting an empty value'
do
page
.
within
'.weight'
do
click_button
'Edit'
send_keys
1
,
:enter
expect
(
page
).
to
have_text
'1 - remove weight'
click_button
'Edit'
send_keys
:backspace
,
:enter
expect
(
page
).
to
have_text
'None'
end
end
end
end
end
end
...
...
ee/spec/features/issues/issue_weight_spec.rb
deleted
100644 → 0
View file @
370f2a34
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Issue weight'
,
:js
do
let_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
end
it
'allows user to update weight from none to something'
do
issue
=
create
(
:issue
,
author:
user
,
project:
project
)
visit
project_issue_path
(
project
,
issue
)
page
.
within
(
'.weight'
)
do
expect
(
page
).
to
have_content
"None"
click_button
'Edit'
find
(
'.block.weight input'
).
send_keys
1
,
:enter
page
.
within
(
'[data-testid="sidebar-weight-value"]'
)
do
expect
(
page
).
to
have_content
"1"
end
end
end
it
'allows user to update weight from one value to another'
do
issue
=
create
(
:issue
,
author:
user
,
project:
project
,
weight:
2
)
visit
project_issue_path
(
project
,
issue
)
page
.
within
(
'.weight'
)
do
expect
(
page
).
to
have_content
"2"
click_button
'Edit'
find
(
'.block.weight input'
).
send_keys
3
,
:enter
page
.
within
(
'[data-testid="sidebar-weight-value"]'
)
do
expect
(
page
).
to
have_content
"3"
end
end
end
it
'allows user to remove weight'
do
issue
=
create
(
:issue
,
author:
user
,
project:
project
,
weight:
5
)
visit
project_issue_path
(
project
,
issue
)
page
.
within
(
'.weight'
)
do
expect
(
page
).
to
have_content
"5"
click_button
'remove weight'
page
.
within
(
'[data-testid="sidebar-weight-value"]'
)
do
expect
(
page
).
to
have_content
"None"
end
end
end
end
ee/spec/frontend/sidebar/components/weight/sidebar_weight_widget_spec.js
View file @
e44034fb
...
@@ -87,11 +87,11 @@ describe('Sidebar Weight Widget', () => {
...
@@ -87,11 +87,11 @@ describe('Sidebar Weight Widget', () => {
});
});
it
(
'
toggle is checked
'
,
()
=>
{
it
(
'
toggle is checked
'
,
()
=>
{
expect
(
findWeightValue
().
text
()).
toBe
(
'
1
'
);
expect
(
findWeightValue
().
text
()).
toBe
(
'
0
'
);
});
});
it
(
'
emits `weightUpdated` event with a `true` payload
'
,
()
=>
{
it
(
'
emits `weightUpdated` event with a `true` payload
'
,
()
=>
{
expect
(
wrapper
.
emitted
(
'
weightUpdated
'
)).
toEqual
([[
1
]]);
expect
(
wrapper
.
emitted
(
'
weightUpdated
'
)).
toEqual
([[
0
]]);
});
});
});
});
...
...
ee/spec/frontend/sidebar/mock_data.js
View file @
e44034fb
...
@@ -179,7 +179,7 @@ export const issueNoWeightResponse = () => ({
...
@@ -179,7 +179,7 @@ export const issueNoWeightResponse = () => ({
export
const
issueWeightResponse
=
()
=>
({
export
const
issueWeightResponse
=
()
=>
({
data
:
{
data
:
{
workspace
:
{
workspace
:
{
issuable
:
{
id
:
mockIssueId
,
weight
:
1
,
__typename
:
'
Issue
'
},
issuable
:
{
id
:
mockIssueId
,
weight
:
0
,
__typename
:
'
Issue
'
},
__typename
:
'
Project
'
,
__typename
:
'
Project
'
,
},
},
},
},
...
...
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