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
015e15f4
Commit
015e15f4
authored
Feb 02, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted right_sidebar.js to use axios
parent
deaf6aee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
29 deletions
+24
-29
app/assets/javascripts/right_sidebar.js
app/assets/javascripts/right_sidebar.js
+11
-20
spec/javascripts/right_sidebar_spec.js
spec/javascripts/right_sidebar_spec.js
+13
-9
No files found.
app/assets/javascripts/right_sidebar.js
View file @
015e15f4
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
flash
from
'
./flash
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
function
Sidebar
(
currentUser
)
{
function
Sidebar
(
currentUser
)
{
this
.
toggleTodo
=
this
.
toggleTodo
.
bind
(
this
);
this
.
toggleTodo
=
this
.
toggleTodo
.
bind
(
this
);
...
@@ -62,7 +64,7 @@ Sidebar.prototype.sidebarToggleClicked = function (e, triggered) {
...
@@ -62,7 +64,7 @@ Sidebar.prototype.sidebarToggleClicked = function (e, triggered) {
Sidebar
.
prototype
.
toggleTodo
=
function
(
e
)
{
Sidebar
.
prototype
.
toggleTodo
=
function
(
e
)
{
var
$btnText
,
$this
,
$todoLoading
,
ajaxType
,
url
;
var
$btnText
,
$this
,
$todoLoading
,
ajaxType
,
url
;
$this
=
$
(
e
.
currentTarget
);
$this
=
$
(
e
.
currentTarget
);
ajaxType
=
$this
.
attr
(
'
data-delete-path
'
)
?
'
DELETE
'
:
'
POST
'
;
ajaxType
=
$this
.
attr
(
'
data-delete-path
'
)
?
'
delete
'
:
'
post
'
;
if
(
$this
.
attr
(
'
data-delete-path
'
))
{
if
(
$this
.
attr
(
'
data-delete-path
'
))
{
url
=
""
+
(
$this
.
attr
(
'
data-delete-path
'
));
url
=
""
+
(
$this
.
attr
(
'
data-delete-path
'
));
}
else
{
}
else
{
...
@@ -71,25 +73,14 @@ Sidebar.prototype.toggleTodo = function(e) {
...
@@ -71,25 +73,14 @@ Sidebar.prototype.toggleTodo = function(e) {
$this
.
tooltip
(
'
hide
'
);
$this
.
tooltip
(
'
hide
'
);
return
$
.
ajax
({
$
(
'
.js-issuable-todo
'
).
disable
().
addClass
(
'
is-loading
'
);
url
:
url
,
type
:
ajaxType
,
return
axios
[
ajaxType
](
url
,
{
dataType
:
'
json
'
,
issuable_id
:
$this
.
data
(
'
issuable-id
'
),
data
:
{
issuable_type
:
$this
.
data
(
'
issuable-type
'
),
issuable_id
:
$this
.
data
(
'
issuable-id
'
),
}).
then
(({
data
})
=>
{
issuable_type
:
$this
.
data
(
'
issuable-type
'
)
this
.
todoUpdateDone
(
data
);
},
});
beforeSend
:
(
function
(
_this
)
{
return
function
()
{
$
(
'
.js-issuable-todo
'
).
disable
()
.
addClass
(
'
is-loading
'
);
};
})(
this
)
}).
done
((
function
(
_this
)
{
return
function
(
data
)
{
return
_this
.
todoUpdateDone
(
data
);
};
})(
this
));
};
};
Sidebar
.
prototype
.
todoUpdateDone
=
function
(
data
)
{
Sidebar
.
prototype
.
todoUpdateDone
=
function
(
data
)
{
...
...
spec/javascripts/right_sidebar_spec.js
View file @
015e15f4
/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, new-parens, no-return-assign, new-cap, vars-on-top, max-len */
/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, new-parens, no-return-assign, new-cap, vars-on-top, max-len */
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
'
~/commons/bootstrap
'
;
import
'
~/commons/bootstrap
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Sidebar
from
'
~/right_sidebar
'
;
import
Sidebar
from
'
~/right_sidebar
'
;
(
function
()
{
(
function
()
{
...
@@ -35,10 +37,12 @@ import Sidebar from '~/right_sidebar';
...
@@ -35,10 +37,12 @@ import Sidebar from '~/right_sidebar';
var
fixtureName
=
'
issues/open-issue.html.raw
'
;
var
fixtureName
=
'
issues/open-issue.html.raw
'
;
preloadFixtures
(
fixtureName
);
preloadFixtures
(
fixtureName
);
loadJSONFixtures
(
'
todos/todos.json
'
);
loadJSONFixtures
(
'
todos/todos.json
'
);
let
mock
;
beforeEach
(
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
this
.
sidebar
=
new
Sidebar
;
mock
=
new
MockAdapter
(
axios
);
this
.
sidebar
=
new
Sidebar
();
$aside
=
$
(
'
.right-sidebar
'
);
$aside
=
$
(
'
.right-sidebar
'
);
$page
=
$
(
'
.layout-page
'
);
$page
=
$
(
'
.layout-page
'
);
$icon
=
$aside
.
find
(
'
i
'
);
$icon
=
$aside
.
find
(
'
i
'
);
...
@@ -63,20 +67,20 @@ import Sidebar from '~/right_sidebar';
...
@@ -63,20 +67,20 @@ import Sidebar from '~/right_sidebar';
return
assertSidebarState
(
'
collapsed
'
);
return
assertSidebarState
(
'
collapsed
'
);
});
});
it
(
'
should broadcast todo:toggle event when add todo clicked
'
,
function
()
{
it
(
'
should broadcast todo:toggle event when add todo clicked
'
,
function
(
done
)
{
var
todos
=
getJSONFixture
(
'
todos/todos.json
'
);
var
todos
=
getJSONFixture
(
'
todos/todos.json
'
);
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
()
{
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
();
var
d
=
$
.
Deferred
();
mock
.
onAny
(
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/issues-project/todos`
).
reply
(
200
,
todos
);
var
response
=
todos
;
d
.
resolve
(
response
);
return
d
.
promise
();
});
var
todoToggleSpy
=
spyOnEvent
(
document
,
'
todo:toggle
'
);
var
todoToggleSpy
=
spyOnEvent
(
document
,
'
todo:toggle
'
);
$
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
click
();
$
(
'
.issuable-sidebar-header .js-issuable-todo
'
).
click
();
expect
(
todoToggleSpy
.
calls
.
count
()).
toEqual
(
1
);
setTimeout
(()
=>
{
expect
(
todoToggleSpy
.
calls
.
count
()).
toEqual
(
1
);
done
();
});
});
});
it
(
'
should not hide collapsed icons
'
,
()
=>
{
it
(
'
should not hide collapsed icons
'
,
()
=>
{
...
...
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