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
ad5809ec
Commit
ad5809ec
authored
Sep 10, 2019
by
Winnie Hellmann
Committed by
Paul Slaughter
Sep 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove vue resource from sidebar service
Fixes
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/32400
parent
7ed69a1d
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
65 additions
and
84 deletions
+65
-84
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue
...cripts/sidebar/components/assignees/sidebar_assignees.vue
+2
-6
app/assets/javascripts/sidebar/services/sidebar_service.js
app/assets/javascripts/sidebar/services/sidebar_service.js
+6
-17
app/assets/javascripts/sidebar/sidebar_mediator.js
app/assets/javascripts/sidebar/sidebar_mediator.js
+14
-18
app/views/shared/issuable/_sidebar_assignees.html.haml
app/views/shared/issuable/_sidebar_assignees.html.haml
+1
-1
changelogs/unreleased/remove-vue-resource-from-sidebar-service.yml
...s/unreleased/remove-vue-resource-from-sidebar-service.yml
+5
-0
ee/app/assets/javascripts/sidebar/sidebar_mediator.js
ee/app/assets/javascripts/sidebar/sidebar_mediator.js
+2
-3
ee/spec/javascripts/sidebar/ee_sidebar_mediator_spec.js
ee/spec/javascripts/sidebar/ee_sidebar_mediator_spec.js
+6
-8
spec/javascripts/sidebar/mock_data.js
spec/javascripts/sidebar/mock_data.js
+0
-10
spec/javascripts/sidebar/sidebar_assignees_spec.js
spec/javascripts/sidebar/sidebar_assignees_spec.js
+0
-4
spec/javascripts/sidebar/sidebar_mediator_spec.js
spec/javascripts/sidebar/sidebar_mediator_spec.js
+21
-12
spec/javascripts/sidebar/sidebar_move_issue_spec.js
spec/javascripts/sidebar/sidebar_move_issue_spec.js
+8
-5
No files found.
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue
View file @
ad5809ec
...
...
@@ -67,18 +67,14 @@ export default {
saveAssignees
()
{
this
.
loading
=
true
;
function
setLoadingFalse
()
{
this
.
loading
=
false
;
}
this
.
mediator
.
saveAssignees
(
this
.
field
)
.
then
(
setLoadingFalse
.
bind
(
this
))
.
then
(()
=>
{
this
.
loading
=
false
;
refreshUserMergeRequestCounts
();
})
.
catch
(()
=>
{
setLoadingFalse
()
;
this
.
loading
=
false
;
return
new
Flash
(
__
(
'
Error occurred when saving assignees
'
));
});
},
...
...
app/assets/javascripts/sidebar/services/sidebar_service.js
View file @
ad5809ec
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
Vue
.
use
(
VueResource
);
import
axios
from
'
~/lib/utils/axios_utils
'
;
export
default
class
SidebarService
{
constructor
(
endpointMap
)
{
...
...
@@ -18,23 +15,15 @@ export default class SidebarService {
}
get
()
{
return
Vue
.
http
.
get
(
this
.
endpoint
);
return
axios
.
get
(
this
.
endpoint
);
}
update
(
key
,
data
)
{
return
Vue
.
http
.
put
(
this
.
endpoint
,
{
[
key
]:
data
,
},
{
emulateJSON
:
true
,
},
);
return
axios
.
put
(
this
.
endpoint
,
{
[
key
]:
data
});
}
getProjectsAutocomplete
(
searchTerm
)
{
return
Vue
.
http
.
get
(
this
.
projectsAutocompleteEndpoint
,
{
return
axios
.
get
(
this
.
projectsAutocompleteEndpoint
,
{
params
:
{
search
:
searchTerm
,
},
...
...
@@ -42,11 +31,11 @@ export default class SidebarService {
}
toggleSubscription
()
{
return
Vue
.
http
.
post
(
this
.
toggleSubscriptionEndpoint
);
return
axios
.
post
(
this
.
toggleSubscriptionEndpoint
);
}
moveIssue
(
moveToProjectId
)
{
return
Vue
.
http
.
post
(
this
.
moveIssueEndpoint
,
{
return
axios
.
post
(
this
.
moveIssueEndpoint
,
{
move_to_project_id
:
moveToProjectId
,
});
}
...
...
app/assets/javascripts/sidebar/sidebar_mediator.js
View file @
ad5809ec
...
...
@@ -32,7 +32,10 @@ export default class SidebarMediator {
// If there are no ids, that means we have to unassign (which is id = 0)
// And it only accepts an array, hence [0]
return
this
.
service
.
update
(
field
,
selected
.
length
===
0
?
[
0
]
:
selected
);
const
assignees
=
selected
.
length
===
0
?
[
0
]
:
selected
;
const
data
=
{
assignee_ids
:
assignees
};
return
this
.
service
.
update
(
field
,
data
);
}
setMoveToProjectId
(
projectId
)
{
...
...
@@ -42,8 +45,7 @@ export default class SidebarMediator {
fetch
()
{
return
this
.
service
.
get
()
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
.
then
(({
data
})
=>
{
this
.
processFetchedData
(
data
);
})
.
catch
(()
=>
new
Flash
(
__
(
'
Error occurred when fetching sidebar data
'
)));
...
...
@@ -71,23 +73,17 @@ export default class SidebarMediator {
}
fetchAutocompleteProjects
(
searchTerm
)
{
return
this
.
service
.
getProjectsAutocomplete
(
searchTerm
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
this
.
store
.
setAutocompleteProjects
(
data
);
return
this
.
store
.
autocompleteProjects
;
});
return
this
.
service
.
getProjectsAutocomplete
(
searchTerm
).
then
(({
data
})
=>
{
this
.
store
.
setAutocompleteProjects
(
data
);
return
this
.
store
.
autocompleteProjects
;
});
}
moveIssue
()
{
return
this
.
service
.
moveIssue
(
this
.
store
.
moveToProjectId
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
visitUrl
(
data
.
web_url
);
}
});
return
this
.
service
.
moveIssue
(
this
.
store
.
moveToProjectId
).
then
(({
data
})
=>
{
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
visitUrl
(
data
.
web_url
);
}
});
}
}
app/views/shared/issuable/_sidebar_assignees.html.haml
View file @
ad5809ec
-
issuable_type
=
issuable_sidebar
[
:type
]
-
signed_in
=
!!
issuable_sidebar
.
dig
(
:current_user
,
:id
)
#js-vue-sidebar-assignees
{
data:
{
field:
"#{issuable_type}
[assignee_ids]
"
,
signed_in:
signed_in
}
}
#js-vue-sidebar-assignees
{
data:
{
field:
"#{issuable_type}"
,
signed_in:
signed_in
}
}
.title.hide-collapsed
=
_
(
'Assignee'
)
=
icon
(
'spinner spin'
)
...
...
changelogs/unreleased/remove-vue-resource-from-sidebar-service.yml
0 → 100644
View file @
ad5809ec
---
title
:
Remove vue resource from sidebar service
merge_request
:
32400
author
:
Lee Tickett
type
:
other
ee/app/assets/javascripts/sidebar/sidebar_mediator.js
View file @
ad5809ec
...
...
@@ -16,9 +16,8 @@ export default class SidebarMediator extends CESidebarMediator {
updateWeight
(
newWeight
)
{
this
.
store
.
setLoadingState
(
'
weight
'
,
true
);
return
this
.
service
.
update
(
'
issue[weight]
'
,
newWeight
)
.
then
(
res
=>
res
.
json
())
.
then
(
data
=>
{
.
update
(
'
issue
'
,
{
weight
:
newWeight
})
.
then
(({
data
})
=>
{
this
.
store
.
setWeight
(
data
.
weight
);
this
.
store
.
setLoadingState
(
'
weight
'
,
false
);
})
...
...
ee/spec/javascripts/sidebar/ee_sidebar_mediator_spec.js
View file @
ad5809ec
import
Vue
from
'
vue
'
;
import
_
from
'
underscore
'
;
import
SidebarMediator
from
'
ee/sidebar/sidebar_mediator
'
;
import
CESidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
CESidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
Mock
from
'
./ee_mock_data
'
;
describe
(
'
EE Sidebar mediator
'
,
function
()
{
describe
(
'
EE Sidebar mediator
'
,
()
=>
{
let
mediator
;
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
this
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
});
afterEach
(()
=>
{
SidebarService
.
singleton
=
null
;
CESidebarStore
.
singleton
=
null
;
CESidebarMediator
.
singleton
=
null
;
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
});
it
(
'
processes fetched data
'
,
()
=>
{
const
mockData
=
Mock
.
responseMap
.
GET
[
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar
'
];
this
.
mediator
.
processFetchedData
(
mockData
);
mediator
.
processFetchedData
(
mockData
);
expect
(
this
.
mediator
.
store
.
weight
).
toEqual
(
mockData
.
weight
);
expect
(
mediator
.
store
.
weight
).
toEqual
(
mockData
.
weight
);
});
});
spec/javascripts/sidebar/mock_data.js
View file @
ad5809ec
...
...
@@ -210,14 +210,4 @@ const mockData = {
},
};
mockData
.
sidebarMockInterceptor
=
function
(
request
,
next
)
{
const
body
=
this
.
responseMap
[
request
.
method
.
toUpperCase
()][
request
.
url
];
next
(
request
.
respondWith
(
JSON
.
stringify
(
body
),
{
status
:
200
,
}),
);
}.
bind
(
mockData
);
export
default
mockData
;
spec/javascripts/sidebar/sidebar_assignees_spec.js
View file @
ad5809ec
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
SidebarAssignees
from
'
~/sidebar/components/assignees/sidebar_assignees.vue
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
...
...
@@ -14,8 +13,6 @@ describe('sidebar assignees', () => {
preloadFixtures
(
'
issues/open-issue.html
'
);
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
loadFixtures
(
'
issues/open-issue.html
'
);
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
...
...
@@ -38,7 +35,6 @@ describe('sidebar assignees', () => {
SidebarService
.
singleton
=
null
;
SidebarStore
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
});
it
(
'
calls the mediator when saves the assignees
'
,
()
=>
{
...
...
spec/javascripts/sidebar/sidebar_mediator_spec.js
View file @
ad5809ec
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
Mock
from
'
./mock_data
'
;
const
{
mediator
:
mediatorMockData
}
=
Mock
;
describe
(
'
Sidebar mediator
'
,
function
()
{
let
mock
;
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
this
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
mock
=
new
MockAdapter
(
axios
);
this
.
mediator
=
new
SidebarMediator
(
mediatorMockData
);
});
afterEach
(()
=>
{
SidebarService
.
singleton
=
null
;
SidebarStore
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
mock
.
restore
(
);
});
it
(
'
assigns yourself
'
,
()
=>
{
this
.
mediator
.
assignYourself
();
expect
(
this
.
mediator
.
store
.
currentUser
).
toEqual
(
Mock
.
mediator
.
currentUser
);
expect
(
this
.
mediator
.
store
.
assignees
[
0
]).
toEqual
(
Mock
.
mediator
.
currentUser
);
expect
(
this
.
mediator
.
store
.
currentUser
).
toEqual
(
mediatorMockData
.
currentUser
);
expect
(
this
.
mediator
.
store
.
assignees
[
0
]).
toEqual
(
mediatorMockData
.
currentUser
);
});
it
(
'
saves assignees
'
,
done
=>
{
mock
.
onPut
(
mediatorMockData
.
endpoint
).
reply
(
200
,
{});
this
.
mediator
.
saveAssignees
(
'
issue[assignee_ids]
'
)
.
then
(
resp
=>
{
...
...
@@ -36,8 +42,8 @@ describe('Sidebar mediator', function() {
});
it
(
'
fetches the data
'
,
done
=>
{
const
mockData
=
Mock
.
responseMap
.
GET
[
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
]
;
const
mockData
=
Mock
.
responseMap
.
GET
[
mediatorMockData
.
endpoint
];
mock
.
onGet
(
mediatorMockData
.
endpoint
).
reply
(
200
,
mockData
)
;
spyOn
(
this
.
mediator
,
'
processFetchedData
'
).
and
.
callThrough
();
this
.
mediator
...
...
@@ -50,8 +56,7 @@ describe('Sidebar mediator', function() {
});
it
(
'
processes fetched data
'
,
()
=>
{
const
mockData
=
Mock
.
responseMap
.
GET
[
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
];
const
mockData
=
Mock
.
responseMap
.
GET
[
mediatorMockData
.
endpoint
];
this
.
mediator
.
processFetchedData
(
mockData
);
expect
(
this
.
mediator
.
store
.
assignees
).
toEqual
(
mockData
.
assignees
);
...
...
@@ -74,6 +79,7 @@ describe('Sidebar mediator', function() {
it
(
'
fetches autocomplete projects
'
,
done
=>
{
const
searchTerm
=
'
foo
'
;
mock
.
onGet
(
mediatorMockData
.
projectsAutocompleteEndpoint
).
reply
(
200
,
{});
spyOn
(
this
.
mediator
.
service
,
'
getProjectsAutocomplete
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
store
,
'
setAutocompleteProjects
'
).
and
.
callThrough
();
...
...
@@ -88,7 +94,9 @@ describe('Sidebar mediator', function() {
});
it
(
'
moves issue
'
,
done
=>
{
const
mockData
=
Mock
.
responseMap
.
POST
[
mediatorMockData
.
moveIssueEndpoint
];
const
moveToProjectId
=
7
;
mock
.
onPost
(
mediatorMockData
.
moveIssueEndpoint
).
reply
(
200
,
mockData
);
this
.
mediator
.
store
.
setMoveToProjectId
(
moveToProjectId
);
spyOn
(
this
.
mediator
.
service
,
'
moveIssue
'
).
and
.
callThrough
();
const
visitUrl
=
spyOnDependency
(
SidebarMediator
,
'
visitUrl
'
);
...
...
@@ -97,7 +105,7 @@ describe('Sidebar mediator', function() {
.
moveIssue
()
.
then
(()
=>
{
expect
(
this
.
mediator
.
service
.
moveIssue
).
toHaveBeenCalledWith
(
moveToProjectId
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
'
/root/some-project/issues/5
'
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
mockData
.
web_url
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -105,6 +113,7 @@ describe('Sidebar mediator', function() {
it
(
'
toggle subscription
'
,
done
=>
{
this
.
mediator
.
store
.
setSubscribedState
(
false
);
mock
.
onPost
(
mediatorMockData
.
toggleSubscriptionEndpoint
).
reply
(
200
,
{});
spyOn
(
this
.
mediator
.
service
,
'
toggleSubscription
'
).
and
.
callThrough
();
this
.
mediator
...
...
spec/javascripts/sidebar/sidebar_move_issue_spec.js
View file @
ad5809ec
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
...
...
@@ -8,8 +8,12 @@ import SidebarMoveIssue from '~/sidebar/lib/sidebar_move_issue';
import
Mock
from
'
./mock_data
'
;
describe
(
'
SidebarMoveIssue
'
,
function
()
{
let
mock
;
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
mock
=
new
MockAdapter
(
axios
);
const
mockData
=
Mock
.
responseMap
.
GET
[
'
/autocomplete/projects?project_id=15
'
];
mock
.
onGet
(
'
/autocomplete/projects?project_id=15
'
).
reply
(
200
,
mockData
);
this
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
this
.
$content
=
$
(
`
<div class="dropdown">
...
...
@@ -37,8 +41,7 @@ describe('SidebarMoveIssue', function() {
SidebarMediator
.
singleton
=
null
;
this
.
sidebarMoveIssue
.
destroy
();
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
mock
.
restore
();
});
describe
(
'
init
'
,
()
=>
{
...
...
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