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
ba15a2b1
Commit
ba15a2b1
authored
Mar 12, 2021
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `authDomain` to `defaultAuthority` on store.session
Rename `authDomain` and extend comments to clarify
parent
b1ce8485
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
20 deletions
+23
-20
AnnotationHeader.js
src/sidebar/components/Annotation/AnnotationHeader.js
+2
-2
AnnotationHeader-test.js
...debar/components/Annotation/test/AnnotationHeader-test.js
+1
-1
use-filter-options-test.js
src/sidebar/components/hooks/test/use-filter-options-test.js
+1
-1
use-filter-options.js
src/sidebar/components/hooks/use-filter-options.js
+3
-3
account-id.js
src/sidebar/helpers/account-id.js
+6
-4
session.js
src/sidebar/store/modules/session.js
+7
-6
session-test.js
src/sidebar/store/modules/test/session-test.js
+3
-3
No files found.
src/sidebar/components/Annotation/AnnotationHeader.js
View file @
ba15a2b1
...
@@ -53,10 +53,10 @@ function AnnotationHeader({
...
@@ -53,10 +53,10 @@ function AnnotationHeader({
settings
,
settings
,
})
{
})
{
const
store
=
useStoreProxy
();
const
store
=
useStoreProxy
();
const
authDomain
=
store
.
authDomain
();
const
defaultAuthority
=
store
.
defaultAuthority
();
const
displayNamesEnabled
=
store
.
isFeatureEnabled
(
'client_display_names'
);
const
displayNamesEnabled
=
store
.
isFeatureEnabled
(
'client_display_names'
);
const
isThirdParty
=
isThirdPartyUser
(
annotation
.
user
,
authDomain
);
const
isThirdParty
=
isThirdPartyUser
(
annotation
.
user
,
defaultAuthority
);
const
authorDisplayName
=
annotationDisplayName
(
const
authorDisplayName
=
annotationDisplayName
(
annotation
,
annotation
,
isThirdParty
,
isThirdParty
,
...
...
src/sidebar/components/Annotation/test/AnnotationHeader-test.js
View file @
ba15a2b1
...
@@ -51,7 +51,7 @@ describe('AnnotationHeader', () => {
...
@@ -51,7 +51,7 @@ describe('AnnotationHeader', () => {
fakeSettings
=
{
usernameUrl
:
'http://foo.bar/'
};
fakeSettings
=
{
usernameUrl
:
'http://foo.bar/'
};
fakeStore
=
{
fakeStore
=
{
authDomain
:
sinon
.
stub
().
returns
(
'foo.com'
),
defaultAuthority
:
sinon
.
stub
().
returns
(
'foo.com'
),
isFeatureEnabled
:
sinon
.
stub
().
returns
(
false
),
isFeatureEnabled
:
sinon
.
stub
().
returns
(
false
),
route
:
sinon
.
stub
().
returns
(
'sidebar'
),
route
:
sinon
.
stub
().
returns
(
'sidebar'
),
setExpanded
:
sinon
.
stub
(),
setExpanded
:
sinon
.
stub
(),
...
...
src/sidebar/components/hooks/test/use-filter-options-test.js
View file @
ba15a2b1
...
@@ -52,7 +52,7 @@ describe('sidebar/components/hooks/use-user-filter-options', () => {
...
@@ -52,7 +52,7 @@ describe('sidebar/components/hooks/use-user-filter-options', () => {
fakeStore
=
{
fakeStore
=
{
allAnnotations
:
sinon
.
stub
().
returns
([]),
allAnnotations
:
sinon
.
stub
().
returns
([]),
authDomain
:
sinon
.
stub
().
returns
(
'foo.com'
),
defaultAuthority
:
sinon
.
stub
().
returns
(
'foo.com'
),
getFocusFilters
:
sinon
.
stub
().
returns
({}),
getFocusFilters
:
sinon
.
stub
().
returns
({}),
isFeatureEnabled
:
sinon
.
stub
().
returns
(
false
),
isFeatureEnabled
:
sinon
.
stub
().
returns
(
false
),
profile
:
sinon
.
stub
().
returns
({}),
profile
:
sinon
.
stub
().
returns
({}),
...
...
src/sidebar/components/hooks/use-filter-options.js
View file @
ba15a2b1
...
@@ -15,7 +15,7 @@ import { annotationDisplayName } from '../../helpers/annotation-user';
...
@@ -15,7 +15,7 @@ import { annotationDisplayName } from '../../helpers/annotation-user';
export
function
useUserFilterOptions
()
{
export
function
useUserFilterOptions
()
{
const
store
=
useStoreProxy
();
const
store
=
useStoreProxy
();
const
annotations
=
store
.
allAnnotations
();
const
annotations
=
store
.
allAnnotations
();
const
authDomain
=
store
.
authDomain
();
const
defaultAuthority
=
store
.
defaultAuthority
();
const
displayNamesEnabled
=
store
.
isFeatureEnabled
(
'client_display_names'
);
const
displayNamesEnabled
=
store
.
isFeatureEnabled
(
'client_display_names'
);
const
focusFilters
=
store
.
getFocusFilters
();
const
focusFilters
=
store
.
getFocusFilters
();
const
currentUsername
=
username
(
store
.
profile
().
userid
);
const
currentUsername
=
username
(
store
.
profile
().
userid
);
...
@@ -27,7 +27,7 @@ export function useUserFilterOptions() {
...
@@ -27,7 +27,7 @@ export function useUserFilterOptions() {
const
username_
=
username
(
annotation
.
user
);
const
username_
=
username
(
annotation
.
user
);
users
[
username_
]
=
annotationDisplayName
(
users
[
username_
]
=
annotationDisplayName
(
annotation
,
annotation
,
isThirdPartyUser
(
annotation
.
user
,
authDomain
),
isThirdPartyUser
(
annotation
.
user
,
defaultAuthority
),
displayNamesEnabled
displayNamesEnabled
);
);
});
});
...
@@ -64,8 +64,8 @@ export function useUserFilterOptions() {
...
@@ -64,8 +64,8 @@ export function useUserFilterOptions() {
return
userOptions
;
return
userOptions
;
},
[
},
[
annotations
,
annotations
,
authDomain
,
currentUsername
,
currentUsername
,
defaultAuthority
,
displayNamesEnabled
,
displayNamesEnabled
,
focusFilters
.
user
,
focusFilters
.
user
,
]);
]);
...
...
src/sidebar/helpers/account-id.js
View file @
ba15a2b1
...
@@ -31,17 +31,19 @@ export function username(user) {
...
@@ -31,17 +31,19 @@ export function username(user) {
}
}
/**
/**
* Returns true if the authority is of a 3rd party user.
* Returns true if the user's provider (authority) differs from the default
* authority for the application.
*
*
* @param {string} user
* @param {string} user
* @param {string} authDomain
* @param {string} defaultAuthority - The application's default authority
* (user identity provider)
*/
*/
export
function
isThirdPartyUser
(
user
,
authDomain
)
{
export
function
isThirdPartyUser
(
user
,
defaultAuthority
)
{
const
account
=
parseAccountID
(
user
);
const
account
=
parseAccountID
(
user
);
if
(
!
account
)
{
if
(
!
account
)
{
return
false
;
return
false
;
}
}
return
account
.
provider
!==
authDomain
;
return
account
.
provider
!==
defaultAuthority
;
}
}
src/sidebar/store/modules/session.js
View file @
ba15a2b1
...
@@ -26,13 +26,14 @@ const initialProfile = {
...
@@ -26,13 +26,14 @@ const initialProfile = {
function
init
(
settings
)
{
function
init
(
settings
)
{
return
{
return
{
/**
/**
* The app's authentication domain, from settings
* The app's default authority (user identity provider), from settings,
* e.g. `hypothes.is` or `localhost`
* FIXME: This returns an empty string when `authDomain` is missing
* FIXME: This returns an empty string when `authDomain` is missing
* because other app logic has long assumed its string-y presence:
* because other app logic has long assumed its string-y presence:
* behavior when it's missing is undefined. This setting should be
* behavior when it's missing is undefined. This setting should be
* enforced similarly to how `apiUrl` is enforced.
* enforced similarly to how `apiUrl` is enforced.
*/
*/
authDomain
:
settings
?.
authDomain
??
''
,
defaultAuthority
:
settings
?.
authDomain
??
''
,
/**
/**
* Profile object fetched from the `/api/profile` endpoint.
* Profile object fetched from the `/api/profile` endpoint.
*/
*/
...
@@ -62,10 +63,10 @@ function updateProfile(profile) {
...
@@ -62,10 +63,10 @@ function updateProfile(profile) {
/**
/**
*
*
* @return
s
{string}
* @return {string}
*/
*/
function
authDomain
(
state
)
{
function
defaultAuthority
(
state
)
{
return
state
.
authDomain
;
return
state
.
defaultAuthority
;
}
}
/**
/**
...
@@ -119,7 +120,7 @@ export default storeModule({
...
@@ -119,7 +120,7 @@ export default storeModule({
},
},
selectors
:
{
selectors
:
{
authDomain
,
defaultAuthority
,
hasFetchedProfile
,
hasFetchedProfile
,
isFeatureEnabled
,
isFeatureEnabled
,
isLoggedIn
,
isLoggedIn
,
...
...
src/sidebar/store/modules/test/session-test.js
View file @
ba15a2b1
...
@@ -18,12 +18,12 @@ describe('sidebar/store/modules/session', () => {
...
@@ -18,12 +18,12 @@ describe('sidebar/store/modules/session', () => {
});
});
});
});
describe
(
'#
authDomain
'
,
()
=>
{
describe
(
'#
defaultAuthority
'
,
()
=>
{
it
(
'returns the
authDomain
from the settings'
,
()
=>
{
it
(
'returns the
default authority
from the settings'
,
()
=>
{
fakeSettings
.
authDomain
=
'foo.com'
;
fakeSettings
.
authDomain
=
'foo.com'
;
store
=
createStore
([
session
],
[
fakeSettings
]);
store
=
createStore
([
session
],
[
fakeSettings
]);
assert
.
equal
(
store
.
authDomain
(),
'foo.com'
);
assert
.
equal
(
store
.
defaultAuthority
(),
'foo.com'
);
});
});
});
});
...
...
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