Skip to content

Commit b70303a

Browse files
committed
small improvements and comments
1 parent b8d2e96 commit b70303a

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

src/mainPage/header.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ACCOUNT_MENU_LABEL = '▼'
2323
const SIGN_UP__MENU_LINK = 'https://solidproject.org/get_a_pod'
2424

2525
// data structure extracted for solid-ui-header binding
26-
export const DEFAULT_HELP_MENU_LIST = [
26+
export const HELP_MENU_LIST = [
2727
{ label: 'User guide', url: 'https://solidos.github.io/userguide/', target: '_blank' },
2828
{ label: 'Report a problem', url: 'https://github.com/solidos/solidos/issues', target: '_blank' }
2929
]
@@ -69,20 +69,29 @@ export async function createHeader (store: LiveStore, outliner: OutlineManager)
6969
authSession.events.on('logout', refreshCurrentHeader)
7070
authSession.events.on('sessionRestore', refreshCurrentHeader)
7171

72-
header.addEventListener('login-success', async () => {
73-
await refreshCurrentHeader()
72+
header.addEventListener('auth-action-select', async (e: Event) => {
73+
const detail = (e as CustomEvent).detail
74+
if (detail?.role === 'login') {
75+
await refreshCurrentHeader()
76+
await openDashboardPane(outliner, 'profile') // upon successfull login, we open the dashboard pane
77+
}
7478
})
7579

7680
header.addEventListener('signup-success', async () => {
77-
await refreshCurrentHeader()
81+
// do nothing
7882
})
7983

80-
header.addEventListener('account-menu-select', (e: Event) => {
84+
header.addEventListener('account-menu-select', async (e: Event) => {
8185
const detail = (e as CustomEvent).detail
8286
if (detail?.action === 'logout') {
8387
authSession.logout()
8488
} else if (detail?.action === 'show-profile') {
85-
openUserProfile(outliner)
89+
// TODO see if this can be consolidated
90+
if (!authn.currentUser()) {
91+
openUserProfile(outliner)
92+
} else {
93+
await openDashboardPane(outliner, 'profile')
94+
}
8695
}
8796
})
8897
}
@@ -123,7 +132,7 @@ function setHeaderOptions (outliner: OutlineManager) {
123132
const headerOptions = {
124133
logo: SOLID_ICON_URL,
125134
helpIcon: HELP_MENU_ICON,
126-
helpMenuList: DEFAULT_HELP_MENU_LIST,
135+
helpMenuList: HELP_MENU_LIST,
127136
layout,
128137
theme,
129138
brandLink: '/',
@@ -160,17 +169,24 @@ async function setUserMenu () {
160169
label: utils.label(me),
161170
avatar: widgets.findImage(me),
162171
webid: me.value,
163-
action: 'show-profile',
164-
pane: 'profile-pane'
172+
action: 'show-profile'
165173
},
166174
// TODO add all my available accounts
167175
]
168176

169177
return accountMenu
170178
}
171179

172-
// Does not work to jump to user profile,
180+
// TODO see if these 2 calls can be consolidated
173181
function openUserProfile (outliner: OutlineManager) {
182+
console.log('-----Opening user profile')
174183
outliner.GotoSubject(authn.currentUser(), true, undefined, true, undefined)
175184
location.reload()
176185
}
186+
187+
async function openDashboardPane (outliner: any, pane: string): Promise<void> {
188+
console.log('-----Opening profile pane')
189+
outliner.showDashboard({
190+
pane
191+
})
192+
}

0 commit comments

Comments
 (0)