forked from Sage-Bionetworks/Synapse-React-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styleguide.setup.js
53 lines (48 loc) · 2.12 KB
/
styleguide.setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {detectSSOCode, getAccessTokenFromCookie, signOut, getUserProfile, isInSynapseExperimentalMode, getAuthenticatedOn} from './src/lib/utils/SynapseClient'
import {AVATAR, SMALL_USER_CARD, MEDIUM_USER_CARD, LARGE_USER_CARD,GENERIC_CARD,COMPUTATIONAL, PUBLICATION} from './src/lib/utils/SynapseConstants'
import brainSvg from './src/demo/containers/playground/icons/brain.svg'
import circleSvg from './src/demo/containers/playground/icons/circle.svg'
import mouseSvg from './src/demo/containers/playground/icons/mouse.svg'
import resilienceadSvg from './src/demo/containers/playground/icons/resiliencead.svg'
import moment from 'moment'
import { SynapseContextConsumer } from './src/lib/utils/SynapseContext'
global.currentUserProfile = false
global.accessToken = false
global.sessionChangeHandler = async () => {
detectSSOCode()
getAccessTokenFromCookie()
.then(accessToken => {
global.accessToken = accessToken
getUserProfile(accessToken).then(profile => {
global.currentUserProfile = profile
if (accessToken) {
getAuthenticatedOn(accessToken).then(authenticatedOn => {
const date = moment(authenticatedOn.authenticatedOn).format('L LT')
alert(`You are currently logged in as ${profile.userName} (last authenticated at ${date})`)
})
}
})
console.log('Session has successfully been changed' + accessToken)
})
.catch((error) => {
console.error(error)
})
}
global.signOut = signOut
global.sessionChangeHandler()
console.log(`Is in Synapse Experimental Mode? ${isInSynapseExperimentalMode()}`)
// example iconOptions (for custom icon mapping)
global.iconOptions = {
'AMP-AD': circleSvg,
'M2OVE-AD': brainSvg,
'MODEL-AD': mouseSvg,
'Resilience-AD': resilienceadSvg,
}
global.SynapseContextConsumer = SynapseContextConsumer
global.AVATAR = AVATAR
global.SMALL_USER_CARD = SMALL_USER_CARD
global.MEDIUM_USER_CARD = MEDIUM_USER_CARD
global.LARGE_USER_CARD = LARGE_USER_CARD
global.GENERIC_CARD = GENERIC_CARD
global.COMPUTATIONAL = COMPUTATIONAL
global.PUBLICATION = PUBLICATION