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
9934d0f4
Commit
9934d0f4
authored
Apr 27, 2020
by
Marvin Karegyeya
Committed by
Paul Slaughter
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove update function logic from issue.js
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21414
parent
191b9600
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
44 deletions
+98
-44
app/assets/javascripts/boards/models/issue.js
app/assets/javascripts/boards/models/issue.js
+1
-25
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+27
-1
changelogs/unreleased/Remove-update-function-logic-from-issue-js.yml
...unreleased/Remove-update-function-logic-from-issue-js.yml
+5
-0
spec/frontend/boards/boards_store_spec.js
spec/frontend/boards/boards_store_spec.js
+61
-0
spec/frontend/boards/issue_spec.js
spec/frontend/boards/issue_spec.js
+4
-18
No files found.
app/assets/javascripts/boards/models/issue.js
View file @
9934d0f4
...
@@ -99,31 +99,7 @@ class ListIssue {
...
@@ -99,31 +99,7 @@ class ListIssue {
}
}
update
()
{
update
()
{
const
data
=
{
return
boardsStore
.
updateIssue
(
this
);
issue
:
{
milestone_id
:
this
.
milestone
?
this
.
milestone
.
id
:
null
,
due_date
:
this
.
dueDate
,
assignee_ids
:
this
.
assignees
.
length
>
0
?
this
.
assignees
.
map
(
u
=>
u
.
id
)
:
[
0
],
label_ids
:
this
.
labels
.
map
(
label
=>
label
.
id
),
},
};
if
(
!
data
.
issue
.
label_ids
.
length
)
{
data
.
issue
.
label_ids
=
[
''
];
}
const
projectPath
=
this
.
project
?
this
.
project
.
path
:
''
;
return
axios
.
patch
(
`
${
this
.
path
}
.json`
,
data
).
then
(({
data
:
body
=
{}
}
=
{})
=>
{
/**
* Since post implementation of Scoped labels, server can reject
* same key-ed labels. To keep the UI and server Model consistent,
* we're just assigning labels that server echo's back to us when we
* PATCH the said object.
*/
if
(
body
)
{
this
.
labels
=
convertObjectPropsToCamelCase
(
body
.
labels
,
{
deep
:
true
});
}
});
}
}
}
}
...
...
app/assets/javascripts/boards/stores/boards_store.js
View file @
9934d0f4
...
@@ -6,7 +6,11 @@ import { sortBy } from 'lodash';
...
@@ -6,7 +6,11 @@ import { sortBy } from 'lodash';
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
BoardsStoreEE
from
'
ee_else_ce/boards/stores/boards_store_ee
'
;
import
BoardsStoreEE
from
'
ee_else_ce/boards/stores/boards_store_ee
'
;
import
{
getUrlParamsArray
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
getUrlParamsArray
,
parseBoolean
,
convertObjectPropsToCamelCase
,
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
...
@@ -632,6 +636,28 @@ const boardsStore = {
...
@@ -632,6 +636,28 @@ const boardsStore = {
issue
.
assignees
=
obj
.
assignees
.
map
(
a
=>
new
ListAssignee
(
a
));
issue
.
assignees
=
obj
.
assignees
.
map
(
a
=>
new
ListAssignee
(
a
));
}
}
},
},
updateIssue
(
issue
)
{
const
data
=
{
issue
:
{
milestone_id
:
issue
.
milestone
?
issue
.
milestone
.
id
:
null
,
due_date
:
issue
.
dueDate
,
assignee_ids
:
issue
.
assignees
.
length
>
0
?
issue
.
assignees
.
map
(({
id
})
=>
id
)
:
[
0
],
label_ids
:
issue
.
labels
.
length
>
0
?
issue
.
labels
.
map
(({
id
})
=>
id
)
:
[
''
],
},
};
return
axios
.
patch
(
`
${
issue
.
path
}
.json`
,
data
).
then
(({
data
:
body
=
{}
}
=
{})
=>
{
/**
* Since post implementation of Scoped labels, server can reject
* same key-ed labels. To keep the UI and server Model consistent,
* we're just assigning labels that server echo's back to us when we
* PATCH the said object.
*/
if
(
body
)
{
issue
.
labels
=
convertObjectPropsToCamelCase
(
body
.
labels
,
{
deep
:
true
});
}
});
},
};
};
BoardsStoreEE
.
initEESpecific
(
boardsStore
);
BoardsStoreEE
.
initEESpecific
(
boardsStore
);
...
...
changelogs/unreleased/Remove-update-function-logic-from-issue-js.yml
0 → 100644
View file @
9934d0f4
---
title
:
Moves updateIssue from issue model to board store
merge_request
:
21414
author
:
nuwe1
type
:
other
spec/frontend/boards/boards_store_spec.js
View file @
9934d0f4
...
@@ -1040,5 +1040,66 @@ describe('boardsStore', () => {
...
@@ -1040,5 +1040,66 @@ describe('boardsStore', () => {
});
});
});
});
});
});
describe
(
'
updateIssue
'
,
()
=>
{
let
issue
;
let
patchSpy
;
beforeEach
(()
=>
{
issue
=
new
ListIssue
({
title
:
'
Testing
'
,
id
:
1
,
iid
:
1
,
confidential
:
false
,
labels
:
[
{
id
:
1
,
title
:
'
test
'
,
color
:
'
red
'
,
description
:
'
testing
'
,
},
],
assignees
:
[
{
id
:
1
,
name
:
'
name
'
,
username
:
'
username
'
,
avatar_url
:
'
http://avatar_url
'
,
},
],
real_path
:
'
path/to/issue
'
,
});
patchSpy
=
jest
.
fn
().
mockReturnValue
([
200
,
{
labels
:
[]
}]);
axiosMock
.
onPatch
(
`path/to/issue.json`
).
reply
(({
data
})
=>
patchSpy
(
JSON
.
parse
(
data
)));
});
it
(
'
passes assignee ids when there are assignees
'
,
()
=>
{
boardsStore
.
updateIssue
(
issue
);
return
boardsStore
.
updateIssue
(
issue
).
then
(()
=>
{
expect
(
patchSpy
).
toHaveBeenCalledWith
({
issue
:
{
milestone_id
:
null
,
assignee_ids
:
[
1
],
label_ids
:
[
1
],
},
});
});
});
it
(
'
passes assignee ids of [0] when there are no assignees
'
,
()
=>
{
issue
.
removeAllAssignees
();
return
boardsStore
.
updateIssue
(
issue
).
then
(()
=>
{
expect
(
patchSpy
).
toHaveBeenCalledWith
({
issue
:
{
milestone_id
:
null
,
assignee_ids
:
[
0
],
label_ids
:
[
1
],
},
});
});
});
});
});
});
});
});
spec/frontend/boards/issue_spec.js
View file @
9934d0f4
/* global ListIssue */
/* global ListIssue */
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
'
~/boards/models/label
'
;
import
'
~/boards/models/label
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/assignee
'
;
import
'
~/boards/models/issue
'
;
import
'
~/boards/models/issue
'
;
...
@@ -173,25 +172,12 @@ describe('Issue model', () => {
...
@@ -173,25 +172,12 @@ describe('Issue model', () => {
});
});
describe
(
'
update
'
,
()
=>
{
describe
(
'
update
'
,
()
=>
{
it
(
'
passes assignee ids when there are assignees
'
,
done
=>
{
it
(
'
passes update to boardsStore
'
,
()
=>
{
jest
.
spyOn
(
axios
,
'
patch
'
).
mockImplementation
((
url
,
data
)
=>
{
jest
.
spyOn
(
boardsStore
,
'
updateIssue
'
).
mockImplementation
();
expect
(
data
.
issue
.
assignee_ids
).
toEqual
([
1
]);
done
();
return
Promise
.
resolve
();
});
issue
.
update
(
'
url
'
);
});
it
(
'
passes assignee ids of [0] when there are no assignees
'
,
done
=>
{
issue
.
update
();
jest
.
spyOn
(
axios
,
'
patch
'
).
mockImplementation
((
url
,
data
)
=>
{
expect
(
data
.
issue
.
assignee_ids
).
toEqual
([
0
]);
done
();
return
Promise
.
resolve
();
});
issue
.
removeAllAssignees
();
expect
(
boardsStore
.
updateIssue
).
toHaveBeenCalledWith
(
issue
);
issue
.
update
(
'
url
'
);
});
});
});
});
});
});
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