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
33993356
Commit
33993356
authored
Sep 03, 2019
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'remove-vue-resource-from-sidebar-service' into 'master'"
This reverts merge request !32400
parent
89409a19
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
51 deletions
+61
-51
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue
...cripts/sidebar/components/assignees/sidebar_assignees.vue
+6
-2
app/assets/javascripts/sidebar/services/sidebar_service.js
app/assets/javascripts/sidebar/services/sidebar_service.js
+17
-6
app/assets/javascripts/sidebar/sidebar_mediator.js
app/assets/javascripts/sidebar/sidebar_mediator.js
+18
-14
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
+0
-5
spec/javascripts/sidebar/mock_data.js
spec/javascripts/sidebar/mock_data.js
+10
-0
spec/javascripts/sidebar/sidebar_mediator_spec.js
spec/javascripts/sidebar/sidebar_mediator_spec.js
+4
-15
spec/javascripts/sidebar/sidebar_move_issue_spec.js
spec/javascripts/sidebar/sidebar_move_issue_spec.js
+5
-8
No files found.
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue
View file @
33993356
...
@@ -67,14 +67,18 @@ export default {
...
@@ -67,14 +67,18 @@ export default {
saveAssignees
()
{
saveAssignees
()
{
this
.
loading
=
true
;
this
.
loading
=
true
;
function
setLoadingFalse
()
{
this
.
loading
=
false
;
}
this
.
mediator
this
.
mediator
.
saveAssignees
(
this
.
field
)
.
saveAssignees
(
this
.
field
)
.
then
(
setLoadingFalse
.
bind
(
this
))
.
then
(()
=>
{
.
then
(()
=>
{
this
.
loading
=
false
;
refreshUserMergeRequestCounts
();
refreshUserMergeRequestCounts
();
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
this
.
loading
=
false
;
setLoadingFalse
()
;
return
new
Flash
(
__
(
'
Error occurred when saving assignees
'
));
return
new
Flash
(
__
(
'
Error occurred when saving assignees
'
));
});
});
},
},
...
...
app/assets/javascripts/sidebar/services/sidebar_service.js
View file @
33993356
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
Vue
.
use
(
VueResource
);
export
default
class
SidebarService
{
export
default
class
SidebarService
{
constructor
(
endpointMap
)
{
constructor
(
endpointMap
)
{
...
@@ -15,15 +18,23 @@ export default class SidebarService {
...
@@ -15,15 +18,23 @@ export default class SidebarService {
}
}
get
()
{
get
()
{
return
axios
.
get
(
this
.
endpoint
);
return
Vue
.
http
.
get
(
this
.
endpoint
);
}
}
update
(
key
,
data
)
{
update
(
key
,
data
)
{
return
axios
.
put
(
this
.
endpoint
,
{
[
key
]:
data
});
return
Vue
.
http
.
put
(
this
.
endpoint
,
{
[
key
]:
data
,
},
{
emulateJSON
:
true
,
},
);
}
}
getProjectsAutocomplete
(
searchTerm
)
{
getProjectsAutocomplete
(
searchTerm
)
{
return
axios
.
get
(
this
.
projectsAutocompleteEndpoint
,
{
return
Vue
.
http
.
get
(
this
.
projectsAutocompleteEndpoint
,
{
params
:
{
params
:
{
search
:
searchTerm
,
search
:
searchTerm
,
},
},
...
@@ -31,11 +42,11 @@ export default class SidebarService {
...
@@ -31,11 +42,11 @@ export default class SidebarService {
}
}
toggleSubscription
()
{
toggleSubscription
()
{
return
axios
.
post
(
this
.
toggleSubscriptionEndpoint
);
return
Vue
.
http
.
post
(
this
.
toggleSubscriptionEndpoint
);
}
}
moveIssue
(
moveToProjectId
)
{
moveIssue
(
moveToProjectId
)
{
return
axios
.
post
(
this
.
moveIssueEndpoint
,
{
return
Vue
.
http
.
post
(
this
.
moveIssueEndpoint
,
{
move_to_project_id
:
moveToProjectId
,
move_to_project_id
:
moveToProjectId
,
});
});
}
}
...
...
app/assets/javascripts/sidebar/sidebar_mediator.js
View file @
33993356
...
@@ -32,10 +32,7 @@ export default class SidebarMediator {
...
@@ -32,10 +32,7 @@ export default class SidebarMediator {
// If there are no ids, that means we have to unassign (which is id = 0)
// If there are no ids, that means we have to unassign (which is id = 0)
// And it only accepts an array, hence [0]
// And it only accepts an array, hence [0]
const
assignees
=
selected
.
length
===
0
?
[
0
]
:
selected
;
return
this
.
service
.
update
(
field
,
selected
.
length
===
0
?
[
0
]
:
selected
);
const
data
=
{
assignee_ids
:
assignees
};
return
this
.
service
.
update
(
field
,
data
);
}
}
setMoveToProjectId
(
projectId
)
{
setMoveToProjectId
(
projectId
)
{
...
@@ -45,7 +42,8 @@ export default class SidebarMediator {
...
@@ -45,7 +42,8 @@ export default class SidebarMediator {
fetch
()
{
fetch
()
{
return
this
.
service
return
this
.
service
.
get
()
.
get
()
.
then
(({
data
})
=>
{
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
this
.
processFetchedData
(
data
);
this
.
processFetchedData
(
data
);
})
})
.
catch
(()
=>
new
Flash
(
__
(
'
Error occurred when fetching sidebar data
'
)));
.
catch
(()
=>
new
Flash
(
__
(
'
Error occurred when fetching sidebar data
'
)));
...
@@ -73,17 +71,23 @@ export default class SidebarMediator {
...
@@ -73,17 +71,23 @@ export default class SidebarMediator {
}
}
fetchAutocompleteProjects
(
searchTerm
)
{
fetchAutocompleteProjects
(
searchTerm
)
{
return
this
.
service
.
getProjectsAutocomplete
(
searchTerm
).
then
(({
data
})
=>
{
return
this
.
service
this
.
store
.
setAutocompleteProjects
(
data
);
.
getProjectsAutocomplete
(
searchTerm
)
return
this
.
store
.
autocompleteProjects
;
.
then
(
response
=>
response
.
json
())
});
.
then
(
data
=>
{
this
.
store
.
setAutocompleteProjects
(
data
);
return
this
.
store
.
autocompleteProjects
;
});
}
}
moveIssue
()
{
moveIssue
()
{
return
this
.
service
.
moveIssue
(
this
.
store
.
moveToProjectId
).
then
(({
data
})
=>
{
return
this
.
service
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
.
moveIssue
(
this
.
store
.
moveToProjectId
)
visitUrl
(
data
.
web_url
);
.
then
(
response
=>
response
.
json
())
}
.
then
(
data
=>
{
});
if
(
window
.
location
.
pathname
!==
data
.
web_url
)
{
visitUrl
(
data
.
web_url
);
}
});
}
}
}
}
app/views/shared/issuable/_sidebar_assignees.html.haml
View file @
33993356
-
issuable_type
=
issuable_sidebar
[
:type
]
-
issuable_type
=
issuable_sidebar
[
:type
]
-
signed_in
=
!!
issuable_sidebar
.
dig
(
:current_user
,
:id
)
-
signed_in
=
!!
issuable_sidebar
.
dig
(
:current_user
,
:id
)
#js-vue-sidebar-assignees
{
data:
{
field:
"#{issuable_type}"
,
signed_in:
signed_in
}
}
#js-vue-sidebar-assignees
{
data:
{
field:
"#{issuable_type}
[assignee_ids]
"
,
signed_in:
signed_in
}
}
.title.hide-collapsed
.title.hide-collapsed
=
_
(
'Assignee'
)
=
_
(
'Assignee'
)
=
icon
(
'spinner spin'
)
=
icon
(
'spinner spin'
)
...
...
changelogs/unreleased/remove-vue-resource-from-sidebar-service.yml
deleted
100644 → 0
View file @
89409a19
---
title
:
Remove vue resource from sidebar service
merge_request
:
32400
author
:
Lee Tickett
type
:
other
spec/javascripts/sidebar/mock_data.js
View file @
33993356
...
@@ -210,4 +210,14 @@ const mockData = {
...
@@ -210,4 +210,14 @@ 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
;
export
default
mockData
;
spec/javascripts/sidebar/sidebar_mediator_spec.js
View file @
33993356
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
_
from
'
underscore
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Vue
from
'
vue
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
Mock
from
'
./mock_data
'
;
import
Mock
from
'
./mock_data
'
;
describe
(
'
Sidebar mediator
'
,
function
()
{
describe
(
'
Sidebar mediator
'
,
function
()
{
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
this
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
this
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
});
});
...
@@ -18,7 +15,7 @@ describe('Sidebar mediator', function() {
...
@@ -18,7 +15,7 @@ describe('Sidebar mediator', function() {
SidebarService
.
singleton
=
null
;
SidebarService
.
singleton
=
null
;
SidebarStore
.
singleton
=
null
;
SidebarStore
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
mock
.
restore
(
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
});
});
it
(
'
assigns yourself
'
,
()
=>
{
it
(
'
assigns yourself
'
,
()
=>
{
...
@@ -29,7 +26,6 @@ describe('Sidebar mediator', function() {
...
@@ -29,7 +26,6 @@ describe('Sidebar mediator', function() {
});
});
it
(
'
saves assignees
'
,
done
=>
{
it
(
'
saves assignees
'
,
done
=>
{
mock
.
onPut
(
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
).
reply
(
200
,
{});
this
.
mediator
this
.
mediator
.
saveAssignees
(
'
issue[assignee_ids]
'
)
.
saveAssignees
(
'
issue[assignee_ids]
'
)
.
then
(
resp
=>
{
.
then
(
resp
=>
{
...
@@ -42,9 +38,6 @@ describe('Sidebar mediator', function() {
...
@@ -42,9 +38,6 @@ describe('Sidebar mediator', function() {
it
(
'
fetches the data
'
,
done
=>
{
it
(
'
fetches the data
'
,
done
=>
{
const
mockData
=
const
mockData
=
Mock
.
responseMap
.
GET
[
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
];
Mock
.
responseMap
.
GET
[
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
];
mock
.
onGet
(
'
/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras
'
)
.
reply
(
200
,
mockData
);
spyOn
(
this
.
mediator
,
'
processFetchedData
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
,
'
processFetchedData
'
).
and
.
callThrough
();
this
.
mediator
this
.
mediator
...
@@ -81,7 +74,6 @@ describe('Sidebar mediator', function() {
...
@@ -81,7 +74,6 @@ describe('Sidebar mediator', function() {
it
(
'
fetches autocomplete projects
'
,
done
=>
{
it
(
'
fetches autocomplete projects
'
,
done
=>
{
const
searchTerm
=
'
foo
'
;
const
searchTerm
=
'
foo
'
;
mock
.
onGet
(
'
/autocomplete/projects?project_id=15
'
).
reply
(
200
,
{});
spyOn
(
this
.
mediator
.
service
,
'
getProjectsAutocomplete
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
service
,
'
getProjectsAutocomplete
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
store
,
'
setAutocompleteProjects
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
store
,
'
setAutocompleteProjects
'
).
and
.
callThrough
();
...
@@ -96,9 +88,7 @@ describe('Sidebar mediator', function() {
...
@@ -96,9 +88,7 @@ describe('Sidebar mediator', function() {
});
});
it
(
'
moves issue
'
,
done
=>
{
it
(
'
moves issue
'
,
done
=>
{
const
mockData
=
Mock
.
responseMap
.
POST
[
'
/gitlab-org/gitlab-shell/issues/5/move
'
];
const
moveToProjectId
=
7
;
const
moveToProjectId
=
7
;
mock
.
onPost
(
'
/gitlab-org/gitlab-shell/issues/5/move
'
).
reply
(
200
,
mockData
);
this
.
mediator
.
store
.
setMoveToProjectId
(
moveToProjectId
);
this
.
mediator
.
store
.
setMoveToProjectId
(
moveToProjectId
);
spyOn
(
this
.
mediator
.
service
,
'
moveIssue
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
service
,
'
moveIssue
'
).
and
.
callThrough
();
const
visitUrl
=
spyOnDependency
(
SidebarMediator
,
'
visitUrl
'
);
const
visitUrl
=
spyOnDependency
(
SidebarMediator
,
'
visitUrl
'
);
...
@@ -115,7 +105,6 @@ describe('Sidebar mediator', function() {
...
@@ -115,7 +105,6 @@ describe('Sidebar mediator', function() {
it
(
'
toggle subscription
'
,
done
=>
{
it
(
'
toggle subscription
'
,
done
=>
{
this
.
mediator
.
store
.
setSubscribedState
(
false
);
this
.
mediator
.
store
.
setSubscribedState
(
false
);
mock
.
onPost
(
'
/gitlab-org/gitlab-shell/issues/5/toggle_subscription
'
).
reply
(
200
,
{});
spyOn
(
this
.
mediator
.
service
,
'
toggleSubscription
'
).
and
.
callThrough
();
spyOn
(
this
.
mediator
.
service
,
'
toggleSubscription
'
).
and
.
callThrough
();
this
.
mediator
this
.
mediator
...
...
spec/javascripts/sidebar/sidebar_move_issue_spec.js
View file @
33993356
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
_
from
'
underscore
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Vue
from
'
vue
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarStore
from
'
~/sidebar/stores/sidebar_store
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
import
SidebarService
from
'
~/sidebar/services/sidebar_service
'
;
...
@@ -8,12 +8,8 @@ import SidebarMoveIssue from '~/sidebar/lib/sidebar_move_issue';
...
@@ -8,12 +8,8 @@ import SidebarMoveIssue from '~/sidebar/lib/sidebar_move_issue';
import
Mock
from
'
./mock_data
'
;
import
Mock
from
'
./mock_data
'
;
describe
(
'
SidebarMoveIssue
'
,
function
()
{
describe
(
'
SidebarMoveIssue
'
,
function
()
{
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
Vue
.
http
.
interceptors
.
push
(
Mock
.
sidebarMockInterceptor
);
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
.
mediator
=
new
SidebarMediator
(
Mock
.
mediator
);
this
.
$content
=
$
(
`
this
.
$content
=
$
(
`
<div class="dropdown">
<div class="dropdown">
...
@@ -41,7 +37,8 @@ describe('SidebarMoveIssue', function() {
...
@@ -41,7 +37,8 @@ describe('SidebarMoveIssue', function() {
SidebarMediator
.
singleton
=
null
;
SidebarMediator
.
singleton
=
null
;
this
.
sidebarMoveIssue
.
destroy
();
this
.
sidebarMoveIssue
.
destroy
();
mock
.
restore
();
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
Mock
.
sidebarMockInterceptor
);
});
});
describe
(
'
init
'
,
()
=>
{
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