Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
2450954f
Commit
2450954f
authored
Feb 02, 2017
by
chdorner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new profile update endpoint for dismissing tutorial
parent
806925fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
session.js
src/sidebar/session.js
+11
-6
session-test.js
src/sidebar/test/session-test.js
+14
-3
No files found.
src/sidebar/session.js
View file @
2450954f
...
@@ -20,11 +20,6 @@ function sessionActions(options) {
...
@@ -20,11 +20,6 @@ function sessionActions(options) {
},
},
_load
:
{
method
:
'GET'
},
_load
:
{
method
:
'GET'
},
dismiss_sidebar_tutorial
:
{
method
:
'POST'
,
params
:
{
path
:
'dismiss_sidebar_tutorial'
},
},
};
};
Object
.
keys
(
actions
).
forEach
(
function
(
action
)
{
Object
.
keys
(
actions
).
forEach
(
function
(
action
)
{
...
@@ -104,6 +99,16 @@ function session($http, $resource, $rootScope, annotationUI, auth,
...
@@ -104,6 +99,16 @@ function session($http, $resource, $rootScope, annotationUI, auth,
return
lastLoad
;
return
lastLoad
;
};
};
/**
* @name session.dismissSidebarTutorial()
*
* @description Stores the preference server-side that the user dismissed
* the sidebar tutorial, and then updates the session state.
*/
function
dismissSidebarTutorial
()
{
return
store
.
profile
.
update
({},
{
preferences
:
{
show_sidebar_tutorial
:
false
}}).
then
(
update
);
}
/**
/**
* @name session.update()
* @name session.update()
*
*
...
@@ -203,7 +208,7 @@ function session($http, $resource, $rootScope, annotationUI, auth,
...
@@ -203,7 +208,7 @@ function session($http, $resource, $rootScope, annotationUI, auth,
}
}
return
{
return
{
dismissSidebarTutorial
:
resource
.
dismiss_sidebar_t
utorial
,
dismissSidebarTutorial
:
dismissSidebarT
utorial
,
load
:
resource
.
load
,
load
:
resource
.
load
,
login
:
resource
.
login
,
login
:
resource
.
login
,
logout
:
logout
,
logout
:
logout
,
...
...
src/sidebar/test/session-test.js
View file @
2450954f
...
@@ -45,6 +45,7 @@ describe('session', function () {
...
@@ -45,6 +45,7 @@ describe('session', function () {
fakeStore
=
{
fakeStore
=
{
profile
:
{
profile
:
{
read
:
sandbox
.
stub
(),
read
:
sandbox
.
stub
(),
update
:
sandbox
.
stub
().
returns
(
Promise
.
resolve
({})),
},
},
};
};
fakeSettings
=
{
fakeSettings
=
{
...
@@ -292,11 +293,21 @@ describe('session', function () {
...
@@ -292,11 +293,21 @@ describe('session', function () {
});
});
describe
(
'#dismissSidebarTutorial()'
,
function
()
{
describe
(
'#dismissSidebarTutorial()'
,
function
()
{
var
url
=
'https://test.hypothes.is/root/app/dismiss_sidebar_tutorial'
;
beforeEach
(
function
()
{
fakeStore
.
profile
.
update
.
returns
(
Promise
.
resolve
({
preferences
:
{},
}));
});
it
(
'disables the tutorial for the user'
,
function
()
{
it
(
'disables the tutorial for the user'
,
function
()
{
$httpBackend
.
expectPOST
(
url
).
respond
({});
session
.
dismissSidebarTutorial
();
session
.
dismissSidebarTutorial
();
$httpBackend
.
flush
();
assert
.
calledWith
(
fakeStore
.
profile
.
update
,
{},
{
preferences
:
{
show_sidebar_tutorial
:
false
}});
});
it
(
'should update the session with the response from the API'
,
function
()
{
return
session
.
dismissSidebarTutorial
().
then
(
function
()
{
assert
.
isNotOk
(
session
.
state
.
preferences
.
show_sidebar_tutorial
);
});
});
});
});
});
...
...
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