Skip to content

Commit 5ac3124

Browse files
SharonStratsClaudeOpus 5.5
andcommitted
Fix the navigation issues with storage as well add to friends button did not appear on compact profile header
Prompt: when the user is on their "storage" container the full view of folder pane should appear, the storage in navbar should show the sidebar and the content no folder pane header. Co-authored-by: ClaudeOpus 5.5 <ClaudeOpus5.5@openai.com>
1 parent 7bc3b0d commit 5ac3124

15 files changed

Lines changed: 346 additions & 42 deletions

File tree

‎src/components/profile-heading/ProfileHeading.styles.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@
241241
align-self: center;
242242
}
243243

244+
:host([compact]) .profile__heading-edit-action {
245+
align-self: center;
246+
}
247+
244248
:host([compact]) .name {
245249
white-space: normal;
246250
overflow-wrap: anywhere;

‎src/components/profile-heading/ProfileHeading.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export default class ProfileHeading extends WebComponent {
221221
</header>
222222
</div>
223223
224-
${(this.editContext || showFriend) && !this.compact
224+
${(this.editContext && !this.compact) || showFriend
225225
? html`
226226
<div class="profile__actions profile__heading-edit-action">
227227
${showFriend
@@ -246,7 +246,7 @@ export default class ProfileHeading extends WebComponent {
246246
</div>
247247
`
248248
: nothing}
249-
${this.editContext
249+
${this.editContext && !this.compact
250250
? html`
251251
<solid-ui-button
252252
variant="tertiary"

‎src/mainPage/index.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { LiveStore, NamedNode } from 'rdflib'
7+
import { authSession } from 'solid-logic'
78
import type { RenderEnvironment } from 'pane-registry'
89
import { getOutliner, OutlineManager } from '../index'
910
import { createHeader } from './header'
@@ -12,6 +13,7 @@ import { navigationFor } from './navigation'
1213
import { initializeProfileHeading, placeProfileHeading } from './profileHeading'
1314
import { registerBrowserNavigation } from '../navigation/browserEvents'
1415
import { clearPaneState } from '../navigation/state'
16+
import { resetPodContexts } from '../navigation/podContext'
1517
import { HUMAN_READABLE_PREVIEW_FRAME_NAME } from '../humanReadablePane'
1618

1719
// Symbol used to stash the last render-relevant env snapshot on the outliner
@@ -55,11 +57,22 @@ export async function initMainPage (
5557
// This is also what Enter on the current URL ends in where the Navigation API is missing (see
5658
// NAVIGATION API FALLBACK in navigation/browserEvents.ts): the browser reloads the page.
5759
clearPaneState()
58-
initializeProfileHeading()
60+
await initializeProfileHeading()
5961
const outliner = getOutliner(document, environment)
6062
;(outliner as any)[LAST_RENDER_ENV_KEY] = renderEnvSignature(environment)
6163
const navigation = navigationFor(outliner, store)
6264
registerBrowserNavigation(navigation)
65+
const refreshNavigationAfterAuth = () => {
66+
resetPodContexts()
67+
navigation.show({ kind: 'restore', forceHeading: true }).catch((error: unknown) => {
68+
console.error('Failed to refresh navigation after an authentication change.', error)
69+
})
70+
}
71+
authSession.events.on('login', refreshNavigationAfterAuth)
72+
authSession.events.on('sessionRestore', refreshNavigationAfterAuth)
73+
authSession.events.on('logout', refreshNavigationAfterAuth)
74+
authSession.events.on('sessionChange', refreshNavigationAfterAuth)
75+
authSession.events.on('identityReplaced', refreshNavigationAfterAuth)
6376
await navigation.show({ kind: 'restore', subject: subject.uri })
6477

6578
const header = await createHeader(navigation)

‎src/mainPage/profileHeading.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ViewerMode } from '../types'
77
import { loadProfileFromURI } from '../utils/webIdUtils'
88
import '../components/profile-heading'
99
import './profileHeading.css'
10-
import { deriveHeading } from '../navigation/chrome'
10+
import { deriveHeading, offersFriendAction } from '../navigation/chrome'
1111
import { getPodContext } from '../navigation/podContext'
1212
import { onNavigated } from '../navigation/events'
1313
import { readNavigationState } from '../navigation/state'
@@ -212,7 +212,7 @@ export async function refreshProfileHeading (force = false): Promise<void> {
212212
}
213213
heading.profileData = profileData
214214
const viewer = authn.currentUser()
215-
heading.friendSubject = isProfilePane && viewer && !viewer.sameTerm(subject)
215+
heading.friendSubject = offersFriendAction(decision.paneName) && viewer && !viewer.sameTerm(subject)
216216
? subject
217217
: undefined
218218
heading.editContext = canEdit
@@ -243,7 +243,7 @@ export function placeProfileHeading (): void {
243243
ensureMountPoint()
244244
}
245245

246-
export function initializeProfileHeading (): void {
246+
export function initializeProfileHeading (): Promise<void> {
247247
ensureMountPoint()
248248

249249
if (!profileSavedListenerRegistered) {
@@ -296,4 +296,5 @@ export function initializeProfileHeading (): void {
296296
readiness.then(() => refreshProfileHeading(true)).catch((error: unknown) => {
297297
console.error('Failed to refresh profile heading.', error)
298298
})
299+
return readiness
299300
}

‎src/navigation/chrome.ts‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import { type NavigationView } from './state'
12+
import type { FolderView } from './options'
1213

1314
/** Registry names of the panes that present a person rather than a resource. */
1415
export const PERSON_PANES = ['profile', 'social']
@@ -17,6 +18,11 @@ export function isPersonPane (paneName?: string): boolean {
1718
return paneName !== undefined && PERSON_PANES.includes(paneName)
1819
}
1920

21+
/** Whether the heading over this pane offers to add its person as a friend: on the Profile and Friends tabs. */
22+
export function offersFriendAction (paneName?: string): boolean {
23+
return isPersonPane(paneName)
24+
}
25+
2026
/** The parts of a navbar item that the rules look at. */
2127
export interface NavbarItemRef {
2228
paneName?: string
@@ -121,6 +127,24 @@ export function isNavbarHidden (input: { viaAccountMenu: boolean, ownProfile: bo
121127
return input.viaAccountMenu || input.ownProfile || input.inViewerPod
122128
}
123129

130+
// Storage
131+
132+
export interface StorageViewInput {
133+
viaAccountMenu: boolean
134+
/** The storage is one of the viewer's own. */
135+
inViewerPod: boolean
136+
/** The storage belongs to a person whose profile was found; the server root has none. */
137+
hasOwner: boolean
138+
}
139+
140+
/**
141+
* The viewer's own storage, and the server root, come with the folder pane's storage header.
142+
* Someone else's storage sits under the navbar of their pod, which already says whose it is.
143+
*/
144+
export function deriveStorageView (input: StorageViewInput): Extract<FolderView, 'explorer' | 'storage'> {
145+
return input.viaAccountMenu || input.inViewerPod || !input.hasOwner ? 'explorer' : 'storage'
146+
}
147+
124148
// File explorer header
125149

126150
export interface ExplorerHeaderInput {
@@ -140,7 +164,11 @@ export function deriveExplorerHeader (input: ExplorerHeaderInput): boolean {
140164
return !input.viewerPodOnly || input.inViewerPod
141165
}
142166

143-
/** The header is never shown over a person's profile or friends, whatever the resource. */
144-
export function explorerHeaderForPane (resourceHeader: boolean, paneName?: string): boolean {
167+
/**
168+
* The header is never shown over a person's profile or friends, whatever the resource,
169+
* nor over a storage view, which has its own header or the navbar.
170+
*/
171+
export function explorerHeaderForPane (resourceHeader: boolean, paneName?: string, folderView?: FolderView): boolean {
172+
if (paneName === 'folder' && (folderView === 'explorer' || folderView === 'storage')) return false
145173
return resourceHeader && !isPersonPane(paneName)
146174
}

‎src/navigation/controller.ts‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import type { OutlineManager } from '../outline/manager'
1313
import { getFolderPaneForStorage, getProfilePaneFromURI, getSocialPaneFromURI, type PaneItem } from '../utils/paneUtils'
1414
import { setNavbarHidden } from './navbarVisibility'
1515
import { readNavigationState, type NavigationState, type NavigationView } from './state'
16-
import type { NavigationSource } from './options'
16+
import type { FolderView, NavigationSource } from './options'
1717
import { isWebIdUri } from '../utils/webIdUtils'
18+
import { deriveStorageView } from './chrome'
19+
import { getPodContext, isInViewerPod, type PodContext } from './podContext'
1820

1921
export type NavigationIntent =
2022
/** Display what the current history entry says was displayed, for the page's own URL. */
@@ -42,6 +44,8 @@ export interface NavigationDeps {
4244
outliner: OutlineManager
4345
byName: (name: string) => PaneDefinition | null | undefined
4446
effects: NavigationEffects
47+
/** Whose pod a URL is in; `getPodContext` unless a test supplies its own. */
48+
podContextOf?: (url: string) => Promise<PodContext>
4549
}
4650

4751
export interface NavigationController {
@@ -55,9 +59,28 @@ export interface NavigationController {
5559
type DisplayedPane = PaneItem | PaneDefinition | null | undefined
5660

5761
export function createNavigationController (deps: NavigationDeps): NavigationController {
58-
const { store, outliner, byName, effects } = deps
62+
const { store, outliner, byName, effects, podContextOf = getPodContext } = deps
5963
let latest = 0
6064

65+
/** The storage pane for a page that is a storage of its pod, or the server root. */
66+
async function storageAt (subject: NamedNode): Promise<PaneItem | null | undefined> {
67+
if (!subject.uri.endsWith('/')) return undefined
68+
const isServerRoot = subject.site().uri === subject.uri
69+
const { storagePanes, viewerStorages } = await podContextOf(subject.uri)
70+
const isStorage = storagePanes.some(pane => pane.subject.uri === subject.uri) ||
71+
viewerStorages.includes(subject.uri)
72+
return isServerRoot || isStorage ? getFolderPaneForStorage(subject) : undefined
73+
}
74+
75+
async function folderViewFor (storage: string, viaAccountMenu: boolean): Promise<FolderView> {
76+
const context = viaAccountMenu ? undefined : await podContextOf(storage)
77+
return deriveStorageView({
78+
viaAccountMenu,
79+
inViewerPod: !!context && isInViewerPod(context, storage),
80+
hasOwner: !!context?.owner
81+
})
82+
}
83+
6184
async function paneForView (subject: NamedNode, view: NavigationView): Promise<DisplayedPane> {
6285
// These panes render a subject other than the page URL.
6386
if (view.subject) {
@@ -67,7 +90,8 @@ export function createNavigationController (deps: NavigationDeps): NavigationCon
6790
if (view.kind === 'storage') return getFolderPaneForStorage(paneSubject)
6891
}
6992
if (view.pane) return byName(view.pane) ?? undefined
70-
return isWebIdUri(subject) ? getProfilePaneFromURI(subject, byName) : undefined
93+
// With nothing recorded, the URL decides: a WebID shows its profile, a storage its storage view
94+
return isWebIdUri(subject) ? getProfilePaneFromURI(subject, byName) : storageAt(subject)
7195
}
7296

7397
async function paneFor (intent: NavigationIntent, subject: NamedNode, state: NavigationState): Promise<DisplayedPane> {
@@ -101,7 +125,11 @@ export function createNavigationController (deps: NavigationDeps): NavigationCon
101125
return
102126
}
103127

104-
outliner.GotoSubject(subject, true, pane ?? undefined, true, undefined, undefined, { source })
128+
const storage = pane && pane.name === 'folder' ? (pane as PaneItem).subject?.uri : undefined
129+
const folderView = storage ? await folderViewFor(storage, source === 'accountMenu') : undefined
130+
if (request !== latest) return
131+
132+
outliner.GotoSubject(subject, true, pane ?? undefined, true, undefined, undefined, folderView ? { source, folderView } : { source })
105133

106134
if (source !== 'accountMenu') {
107135
const { view } = readNavigationState()

‎src/navigation/options.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@
66
*/
77
export type NavigationSource = 'default' | 'accountMenu'
88

9+
/**
10+
* How the folder pane presents a container, when the caller decides it:
11+
* - `explorer`: storage header, sidebar and content
12+
* - `storage`: sidebar and content, under the navbar of someone else's pod
13+
* - `container`: the container alone
14+
*/
15+
export type FolderView = 'explorer' | 'storage' | 'container'
16+
917
export interface GotoSubjectOptions {
1018
source?: NavigationSource
19+
folderView?: FolderView
20+
}
21+
22+
/** The folder view a `GotoSubject` caller asked for, if any. */
23+
export function resolveFolderView (argument?: boolean | GotoSubjectOptions | null): FolderView | undefined {
24+
return typeof argument === 'object' && argument !== null ? argument.folderView : undefined
1125
}
1226

1327
/**

‎src/navigation/podContext.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ function ownerOf (pageUrl: string): Promise<string | undefined> {
8181
}, undefined)
8282
}
8383

84-
function storagesOf (pageUrl: string): Promise<PaneItem[]> {
85-
return remember(storages, podKey(pageUrl), 'storages of the pod', () => getFolderPanesFromURI(sym(pageUrl)), [])
84+
function storagesOf (pageUrl: string, owner?: string): Promise<PaneItem[]> {
85+
const storageSubject = owner ? sym(owner) : sym(pageUrl)
86+
return remember(storages, podKey(pageUrl), 'storages of the pod', () => getFolderPanesFromURI(storageSubject), [])
8687
}
8788

8889
function storagesOfViewer (viewer: string | undefined): Promise<string[]> {
@@ -95,9 +96,10 @@ function storagesOfViewer (viewer: string | undefined): Promise<string[]> {
9596
/** The context for the pod a URL is in; the page's own URL by default. */
9697
export async function getPodContext (pageUrl: string = window.location.href): Promise<PodContext> {
9798
const viewer = authn.currentUser()?.value
98-
const [owner, storagePanes, ownStorages] = await Promise.all([
99-
ownerOf(pageUrl), storagesOf(pageUrl), storagesOfViewer(viewer)
99+
const [owner, ownStorages] = await Promise.all([
100+
ownerOf(pageUrl), storagesOfViewer(viewer)
100101
])
102+
const storagePanes = await storagesOf(pageUrl, owner)
101103
return { viewer, owner, storagePanes, viewerStorages: ownStorages }
102104
}
103105

0 commit comments

Comments
 (0)