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
cb7b6dbd
Commit
cb7b6dbd
authored
Jul 02, 2019
by
Lyza Danger Gardner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate `LoggedOutMessage` to preact
- Rename from `loggedout-message` to `logged-out-message` for consistency
parent
aea2d10c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
102 additions
and
40 deletions
+102
-40
logged-out-message.js
src/sidebar/components/logged-out-message.js
+51
-0
loggedout-message.js
src/sidebar/components/loggedout-message.js
+0
-16
svg-icon.js
src/sidebar/components/svg-icon.js
+1
-0
logged-out-message-test.js
src/sidebar/components/test/logged-out-message-test.js
+37
-0
index.js
src/sidebar/index.js
+4
-1
loggedout-message.html
src/sidebar/templates/loggedout-message.html
+0
-16
sidebar-content.html
src/sidebar/templates/sidebar-content.html
+2
-2
logged-out-message.scss
src/styles/sidebar/components/logged-out-message.scss
+6
-4
sidebar.scss
src/styles/sidebar/sidebar.scss
+1
-1
No files found.
src/sidebar/components/logged-out-message.js
0 → 100644
View file @
cb7b6dbd
'use strict'
;
const
propTypes
=
require
(
'prop-types'
);
const
{
createElement
}
=
require
(
'preact'
);
const
{
withServices
}
=
require
(
'../util/service-context'
);
const
SvgIcon
=
require
(
'./svg-icon'
);
/**
* Render a call-to-action to log in or sign up. This message is intended to be
* displayed to non-auth'd users when viewing a single annotation in a
* direct-linked context (i.e. URL with syntax `/#annotations:<annotation_id>`)
*/
function
LoggedOutMessage
({
onLogin
,
serviceUrl
})
{
return
(
<
div
className
=
"logged-out-message"
>
<
span
>
This
is
a
public
annotation
created
with
Hypothesis
.
<
br
/>
To
reply
or
make
your
own
annotations
on
this
document
,{
' '
}
<
a
className
=
"logged-out-message__link"
href
=
{
serviceUrl
(
'signup'
)}
target
=
"_blank"
rel
=
"noopener noreferrer"
>
create
a
free
account
<
/a>{' '
}
or
{
' '
}
<
a
className
=
"logged-out-message__link"
href
=
""
onClick
=
{
onLogin
}
>
log
in
<
/a
>
.
<
/span
>
<
div
className
=
"logged-out-message__logo"
>
<
a
href
=
"https://hypothes.is"
>
<
SvgIcon
name
=
"logo"
className
=
"logged-out-message__logo-icon"
/>
<
/a
>
<
/div
>
<
/div
>
);
}
LoggedOutMessage
.
propTypes
=
{
onLogin
:
propTypes
.
func
.
isRequired
,
serviceUrl
:
propTypes
.
func
.
isRequired
,
};
LoggedOutMessage
.
injectedProps
=
[
'serviceUrl'
];
module
.
exports
=
withServices
(
LoggedOutMessage
);
src/sidebar/components/loggedout-message.js
deleted
100644 → 0
View file @
aea2d10c
'use strict'
;
module
.
exports
=
{
controllerAs
:
'vm'
,
//@ngInject
controller
:
function
(
serviceUrl
)
{
this
.
serviceUrl
=
serviceUrl
;
},
bindings
:
{
/**
* Called when the user clicks on the "Log in" text.
*/
onLogin
:
'&'
,
},
template
:
require
(
'../templates/loggedout-message.html'
),
};
src/sidebar/components/svg-icon.js
View file @
cb7b6dbd
...
...
@@ -16,6 +16,7 @@ const icons = {
help
:
require
(
'../../images/icons/help.svg'
),
leave
:
require
(
'../../images/icons/leave.svg'
),
lock
:
require
(
'../../images/icons/lock.svg'
),
logo
:
require
(
'../../images/icons/logo.svg'
),
public
:
require
(
'../../images/icons/public.svg'
),
refresh
:
require
(
'../../images/icons/refresh.svg'
),
share
:
require
(
'../../images/icons/share.svg'
),
...
...
src/sidebar/components/test/logged-out-message-test.js
0 → 100644
View file @
cb7b6dbd
'use strict'
;
const
{
createElement
}
=
require
(
'preact'
);
const
{
shallow
}
=
require
(
'enzyme'
);
const
LoggedOutMessage
=
require
(
'../logged-out-message'
);
describe
(
'LoggedOutMessage'
,
()
=>
{
const
createLoggedOutMessage
=
props
=>
{
return
shallow
(
<
LoggedOutMessage
onLogin
=
{
sinon
.
stub
()}
serviceUrl
=
{
sinon
.
stub
()}
{...
props
}
/
>
).
dive
();
// Dive needed because this component uses `withServices`
};
it
(
'should link to signup'
,
()
=>
{
const
fakeServiceUrl
=
sinon
.
stub
().
returns
(
'signup_link'
);
const
wrapper
=
createLoggedOutMessage
({
serviceUrl
:
fakeServiceUrl
});
const
signupLink
=
wrapper
.
find
(
'.logged-out-message__link'
).
at
(
0
);
assert
.
calledWith
(
fakeServiceUrl
,
'signup'
);
assert
.
equal
(
signupLink
.
prop
(
'href'
),
'signup_link'
);
});
it
(
'should have a login click handler'
,
()
=>
{
const
fakeOnLogin
=
sinon
.
stub
();
const
wrapper
=
createLoggedOutMessage
({
onLogin
:
fakeOnLogin
});
const
loginLink
=
wrapper
.
find
(
'.logged-out-message__link'
).
at
(
1
);
assert
.
equal
(
loginLink
.
prop
(
'onClick'
),
fakeOnLogin
);
});
});
src/sidebar/index.js
View file @
cb7b6dbd
...
...
@@ -171,7 +171,10 @@ function startAngularApp(config) {
wrapReactComponent
(
require
(
'./components/help-link'
))
)
.
component
(
'helpPanel'
,
require
(
'./components/help-panel'
))
.
component
(
'loggedoutMessage'
,
require
(
'./components/loggedout-message'
))
.
component
(
'loggedOutMessage'
,
wrapReactComponent
(
require
(
'./components/logged-out-message'
))
)
.
component
(
'markdown'
,
require
(
'./components/markdown'
))
.
component
(
'moderationBanner'
,
...
...
src/sidebar/templates/loggedout-message.html
deleted
100644 → 0
View file @
aea2d10c
<!-- message to display to loggedout users when they visit direct linked annotations -->
<li
class=
"loggedout-message"
>
<span>
This is a public annotation created with Hypothesis.
<br>
To reply or make your own annotations on this document,
<a
class=
"loggedout-message__link"
href=
"{{vm.serviceUrl('signup')}}"
target=
"_blank"
>
create a free account
</a>
or
<a
class=
"loggedout-message__link"
href=
""
ng-click=
"vm.onLogin()"
>
log in
</a>
.
</span>
<span
class=
"loggedout-message-logo"
>
<a
href=
"https://hypothes.is"
>
<i
class=
"h-icon-hypothesis-logo loggedout-message-logo__icon"
></i>
</a>
</span>
</li>
src/sidebar/templates/sidebar-content.html
View file @
cb7b6dbd
...
...
@@ -46,5 +46,5 @@
thread=
"vm.rootThread"
>
</thread-list>
<loggedout-message
ng-if=
"vm.shouldShowLoggedOutMessage()"
on-login=
"vm.onLogin()"
>
</loggedout-message>
<logged
-
out-message
ng-if=
"vm.shouldShowLoggedOutMessage()"
on-login=
"vm.onLogin()"
>
</logged
-
out-message>
src/styles/sidebar/components/loggedout-message.scss
→
src/styles/sidebar/components/logged
-
out-message.scss
View file @
cb7b6dbd
.loggedout-message
{
.logged
-
out-message
{
margin
:
25px
auto
;
width
:
70%
;
text-align
:
center
;
...
...
@@ -7,7 +7,7 @@
flex-direction
:
column
;
}
.loggedout-message__link
{
.logged
-
out-message__link
{
text-decoration
:
underline
;
color
:
$grey-5
;
...
...
@@ -16,11 +16,13 @@
}
}
.logged
out-message-
logo
{
.logged
-out-message__
logo
{
margin-top
:
25px
;
display
:
flex
;
justify-content
:
center
;
}
.logged
out-message-logo__
icon
{
.logged
-out-message__logo-
icon
{
font-size
:
30px
;
color
:
$grey-4
;
...
...
src/styles/sidebar/sidebar.scss
View file @
cb7b6dbd
...
...
@@ -30,7 +30,7 @@ $base-line-height: 20px;
@import
'./components/group-list'
;
@import
'./components/group-list-item'
;
@import
'./components/help-panel'
;
@import
'./components/loggedout-message'
;
@import
'./components/logged
-
out-message'
;
@import
'./components/markdown'
;
@import
'./components/menu'
;
@import
'./components/menu-item'
;
...
...
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