From b54cbd83ab6ba041991e159ff7e7f43f348458e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 10:35:47 -0500 Subject: [PATCH 1/6] Preferences view: implement new design (#710) Rebuild the basicPreferences pane to match the new Preferences design: - Card layout with a Help & Support sidebar (stacks below on narrow screens) - User types: a Role dropdown (Regular user / Power user / Developer) that saves solid:PowerUser / solid:Developer to the private preferences file, replacing the old ui:Classifier form - Manage your trusted applications: a table of origins with Read / Write / Append / Control checkboxes that save as soon as they change, a trash button per app, and a last row to add a new URL (Enter to add). URLs are validated and normalised to their origin; errors show inline instead of alert() - Delete your Solid account: warning box and a "Delete your account" button linking to the provider's deletion page, with a fallback message when none is found - Customize Theme is left out, as agreed in the issue Data logic lives in preferencesData.ts so it can be unit tested; adds tests for it and for the rendered view. The standalone trustedApplications pane is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPTQkfDiRe2xrMJTcygUUo --- src/dashboard/basicPreferences.css | 354 ++++++++++++ src/dashboard/basicPreferences.ts | 570 ++++++++++++++----- src/dashboard/preferencesData.ts | 166 ++++++ src/dashboard/preferencesFormText.ttl | 18 - test/unit/dashboard/basicPreferences.test.ts | 121 ++++ test/unit/dashboard/preferencesData.test.ts | 162 ++++++ 6 files changed, 1216 insertions(+), 175 deletions(-) create mode 100644 src/dashboard/basicPreferences.css create mode 100644 src/dashboard/preferencesData.ts delete mode 100644 src/dashboard/preferencesFormText.ttl create mode 100644 test/unit/dashboard/basicPreferences.test.ts create mode 100644 test/unit/dashboard/preferencesData.test.ts diff --git a/src/dashboard/basicPreferences.css b/src/dashboard/basicPreferences.css new file mode 100644 index 00000000..d36afcee --- /dev/null +++ b/src/dashboard/basicPreferences.css @@ -0,0 +1,354 @@ +/* Preferences view (basicPreferences pane). Design: SolidOS/solid-panes#710 */ + +.preferences-pane { + --preferences-border: var(--solid-ui-color-slate-200, #e2e8f0); + --preferences-primary: var(--solid-ui-color-primary, #7c4dff); + --preferences-text: var(--color-text, #101828); + --preferences-muted: var(--color-text-secondary, #4a5565); + --preferences-danger: var(--solid-ui-color-red-600, #dc2626); + --preferences-danger-bg: var(--solid-ui-color-red-50, #fef2f2); + --preferences-header-bg: color-mix(in srgb, var(--preferences-primary) 10%, #ffffff); + + box-sizing: border-box; + width: 100%; + padding: 16px; + background: var(--solid-ui-color-slate-50, #f8fafc); + color: var(--preferences-text); + font-size: var(--solid-ui-font-size-md, 1rem); +} + +.preferences-pane *, +.preferences-pane *::before, +.preferences-pane *::after { + box-sizing: border-box; +} + +.preferences-layout { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); + align-items: start; + gap: 16px; + max-width: 1200px; + margin: 0 auto; +} + +.preferences-main { + display: flex; + flex-direction: column; + gap: 16px; + min-width: 0; +} + +.preferences-card { + background: var(--solid-ui-color-white, #ffffff); + border: 1px solid var(--preferences-border); + border-radius: 5px; + padding: 24px; +} + +.preferences-card--compact { + padding: 16px; +} + +.preferences-card__title { + display: flex; + align-items: center; + gap: 6px; + margin: 0 0 8px; + font-size: 1.25rem; + font-weight: 600; + line-height: 1.3; +} + +.preferences-card__subtitle { + margin: 0 0 8px; + font-size: 1rem; + font-weight: 600; +} + +.preferences-card__description, +.preferences-muted { + margin: 0 0 16px; + color: var(--preferences-muted); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + line-height: 1.5; +} + +.preferences-muted:last-child { + margin-bottom: 0; +} + +.preferences-pane a { + color: var(--preferences-primary); +} + +.preferences-pane a icon-lucide-external-link { + width: 12px; + height: 12px; + vertical-align: -1px; +} + +/* Info icon with tooltip */ +.preferences-info { + display: inline-flex; + width: 16px; + height: 16px; + color: var(--preferences-muted); + cursor: help; + border-radius: 50%; +} + +.preferences-info icon-lucide-info { + width: 16px; + height: 16px; +} + +.preferences-info:focus-visible { + outline: 2px solid var(--preferences-primary); + outline-offset: 2px; +} + +/* User types */ +.preferences-field { + display: flex; + flex-direction: column; + gap: 8px; + max-width: 480px; +} + +.preferences-label { + display: flex; + align-items: center; + gap: 6px; + font-weight: 600; +} + +.preferences-select, +.preferences-input { + width: 100%; + min-height: 40px; + padding: 8px 12px; + border: 1px solid var(--solid-ui-color-gray-400, #9ca3af); + border-radius: 5px; + background: var(--solid-ui-color-white, #ffffff); + color: inherit; + font: inherit; + font-size: var(--solid-ui-font-size-sm, 0.875rem); +} + +.preferences-input { + min-height: 32px; + padding: 4px 8px; + border-color: transparent; +} + +.preferences-input:hover { + border-color: var(--preferences-border); +} + +.preferences-select:focus-visible, +.preferences-input:focus-visible { + outline: 2px solid var(--preferences-primary); + outline-offset: 1px; +} + +/* Trusted applications table */ +.preferences-table-wrapper { + overflow-x: auto; + margin-bottom: 12px; + border: 1px solid var(--preferences-border); + border-radius: 5px; +} + +.preferences-table { + width: 100%; + border-collapse: collapse; + font-size: var(--solid-ui-font-size-sm, 0.875rem); +} + +.preferences-table thead th { + background: var(--preferences-header-bg); + font-weight: 600; + text-align: left; +} + +.preferences-table th, +.preferences-table td { + padding: 12px 16px; + border-bottom: 1px solid var(--preferences-border); + vertical-align: middle; +} + +.preferences-table tbody tr:last-child th, +.preferences-table tbody tr:last-child td { + border-bottom: none; +} + +.preferences-table th:first-child, +.preferences-table td:first-child { + border-right: 1px solid var(--preferences-border); + min-width: 240px; +} + +.preferences-table__url { + font-weight: 500; + text-align: left; + overflow-wrap: anywhere; +} + +.preferences-table__new .preferences-table__url { + padding: 6px 8px; +} + +.preferences-table__mode input { + width: 16px; + height: 16px; + margin: 0; + accent-color: var(--preferences-primary); + cursor: pointer; +} + +.preferences-table__action { + width: 48px; + text-align: right; +} + +.preferences-table tr[aria-busy='true'] { + opacity: 0.6; +} + +.preferences-icon-button { + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + padding: 0; + border: none; + border-radius: 5px; + background: transparent; + color: var(--solid-ui-color-gray-400, #9ca3af); + cursor: pointer; +} + +.preferences-icon-button icon-lucide-trash-2 { + width: 16px; + height: 16px; +} + +.preferences-icon-button:hover:not(:disabled), +.preferences-icon-button:focus-visible { + color: var(--preferences-danger); + background: var(--preferences-danger-bg); +} + +.preferences-icon-button:focus-visible { + outline: 2px solid var(--preferences-primary); +} + +/* Delete account */ +.preferences-warning { + display: flex; + gap: 8px; + margin-bottom: 16px; + padding: 12px 16px; + border-radius: 5px; + background: var(--preferences-danger-bg); + color: var(--preferences-danger); + font-size: var(--solid-ui-font-size-sm, 0.875rem); +} + +.preferences-warning icon-lucide-triangle-alert { + flex: 0 0 16px; + width: 16px; + height: 16px; + margin-top: 2px; +} + +.preferences-warning p { + margin: 4px 0 0; + color: var(--preferences-text); +} + +.preferences-delete-actions { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.preferences-pane .preferences-danger-button { + display: inline-flex; + align-items: center; + gap: 6px; + min-height: 36px; + padding: 6px 12px; + border: 1px solid var(--preferences-danger); + border-radius: 5px; + background: var(--solid-ui-color-white, #ffffff); + color: var(--preferences-danger); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + text-decoration: none; +} + +.preferences-danger-button icon-lucide-trash-2 { + width: 14px; + height: 14px; +} + +.preferences-pane .preferences-danger-button:hover, +.preferences-pane .preferences-danger-button:focus-visible { + background: var(--preferences-danger-bg); +} + +.preferences-danger-button:focus-visible { + outline: 2px solid var(--preferences-danger); + outline-offset: 2px; +} + +/* Status messages */ +.preferences-status { + margin: 12px 0 0; + font-size: var(--solid-ui-font-size-sm, 0.875rem); +} + +.preferences-status--error { + color: var(--solid-ui-color-red-700, #b91c1c); +} + +.preferences-status--success { + color: var(--solid-ui-color-green-700, #15803d); +} + +.preferences-status--info { + color: var(--preferences-muted); +} + +.preferences-visually-hidden { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; +} + +@media (max-width: 900px) { + .preferences-layout { + grid-template-columns: minmax(0, 1fr); + } +} + +@media (max-width: 600px) { + .preferences-pane { + padding: 8px; + } + + .preferences-card { + padding: 16px; + } + + .preferences-table th:first-child, + .preferences-table td:first-child { + min-width: 180px; + } +} diff --git a/src/dashboard/basicPreferences.ts b/src/dashboard/basicPreferences.ts index 2b40e1b1..b847e199 100644 --- a/src/dashboard/basicPreferences.ts +++ b/src/dashboard/basicPreferences.ts @@ -1,202 +1,458 @@ +/* + * Preferences view: the "Preferences" item in the logged-in user's menu. + * + * Design: https://github.com/SolidOS/solid-panes/issues/710 + * Sections: User types, Manage your trusted applications, Delete your Solid account, + * and a Help & Support sidebar. "Customize Theme" is not implemented yet (see the issue). + */ +import { html, nothing, render, type TemplateResult } from 'lit-html' import { PaneDefinition } from 'pane-registry' -import { IndexedFormula, NamedNode, parse, Store } from 'rdflib' -import { icons, login, ns, widgets } from 'solid-ui' +import { NamedNode, parse, Statement, Store } from 'rdflib' +import { icons, login, ns } from 'solid-ui' +import '~icons/lucide/info' +import '~icons/lucide/trash-2' +import '~icons/lucide/triangle-alert' +import '~icons/lucide/external-link' +import './basicPreferences.css' import ontologyData from './ontologyData.ttl' -import preferencesFormText from './preferencesFormText.ttl' +import { + accessModes, + type AccessMode, + getDeletionUrlForServer, + getUserRole, + listTrustedApps, + normalizeOrigin, + roleChange, + roleOptions, + trustedAppChange, + type TrustedApp, + type UserRole +} from './preferencesData' + +const USER_GUIDE_URL = 'https://solidos.github.io/userguide/' +const USER_TYPES_GUIDE_URL = 'https://github.com/solidos/userguide/#role' + +type Status = { kind: 'info' | 'error' | 'success', text: string } | null + +interface PreferencesState { + me: NamedNode | null + loading: boolean + loadError: string | null + + preferencesFile: NamedNode | null + role: UserRole + roleStatus: Status + + profileEditable: boolean + trustedApps: TrustedApp[] + newAppUrl: string + newAppModes: AccessMode[] + appsStatus: Status + busyOrigins: Set + + deletion: { checking: boolean, links: Array<{ server: string, url: string }>, servers: string[] } +} export const basicPreferencesPane: PaneDefinition = { icon: icons.iconBase + 'noun_Sliders_341315_000000.svg', name: 'basicPreferences', - label: _subject => { - return null - }, + label: _subject => null, - // Render the pane // The subject should be the logged in user. - render: (subject, context) => { + render: (_subject, context) => { const dom = context.dom // @ts-ignore const store = context.session.store as Store + const container = dom.createElement('div') + container.classList.add('preferences-pane') - function complainIfBad (ok: Boolean, mess: any) { - if (ok) return - container.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) + // Labels for the user type classes, used elsewhere in the data browser + const ontologyDoc = store.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT') + if (!store.holds(undefined, undefined, undefined, ontologyDoc)) { + ;(parse as any)(ontologyData, store, ontologyDoc.uri, 'text/turtle', null) } - const container = dom.createElement('div') + const state: PreferencesState = { + me: null, + loading: true, + loadError: null, + preferencesFile: null, + role: 'user', + roleStatus: null, + profileEditable: false, + trustedApps: [], + newAppUrl: '', + newAppModes: ['Read'], + appsStatus: null, + busyOrigins: new Set(), + deletion: { checking: true, links: [], servers: [] } + } - const formArea = setupUserTypesSection(container, dom) + const update = () => render(view(state, actions), container) - function loadData (doc: NamedNode, turtle: String) { - doc = doc.doc() // remove # from URI if nec - if (!store.holds(undefined, undefined, undefined, doc)) { - // If not loaded already - ;(parse as any)(turtle, store, doc.uri, 'text/turtle', null) // Load form directly - } + async function save (deletions: Statement[], insertions: Statement[]) { + if (!store.updater) throw new Error('Store has no updater') + if (!deletions.length && !insertions.length) return + await store.updater.update(deletions, insertions) } - const preferencesForm = store.sym( - 'urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597#this' - ) - loadData(preferencesForm, preferencesFormText) - - const ontologyExtra = store.sym( - 'urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT' - ) - loadData(ontologyExtra, ontologyData) - - async function doRender () { - const renderContext = await login.ensureLoadedPreferences({ - dom, - div: container - }) - if (!renderContext.preferencesFile) { - // Could be CORS - console.log( - 'Not doing private class preferences as no access to preferences file. ' + - renderContext.preferencesFileError - ) - return + const actions: Actions = { + async setRole (role) { + if (!state.me || !state.preferencesFile || role === state.role) return + const previous = state.role + state.role = role + state.roleStatus = { kind: 'info', text: 'Saving…' } + update() + try { + const { deletions, insertions } = roleChange(store, state.me, state.preferencesFile, role) + await save(deletions, insertions) + state.roleStatus = { kind: 'success', text: 'Saved.' } + } catch (err) { + state.role = previous + state.roleStatus = { kind: 'error', text: `Could not save your user type: ${messageOf(err)}` } + } + update() + }, + + async setAppModes (origin, modes) { + if (!state.me) return + state.busyOrigins.add(origin) + state.appsStatus = null + update() + try { + const { deletions, insertions } = trustedAppChange(store, state.me, origin, modes) + await save(deletions, insertions) + state.appsStatus = { + kind: 'success', + text: modes.length ? `Updated ${origin}.` : `Removed ${origin}.` + } + } catch (err) { + state.appsStatus = { kind: 'error', text: `Could not update ${origin}: ${messageOf(err)}` } + } + state.busyOrigins.delete(origin) + state.trustedApps = listTrustedApps(store, state.me) + update() + }, + + setNewAppUrl (value) { + state.newAppUrl = value + }, + + toggleNewAppMode (mode, checked) { + state.newAppModes = accessModes.filter(m => + m === mode ? checked : state.newAppModes.includes(m)) + update() + }, + + async addApp () { + if (!state.me) return + if (!state.newAppUrl.trim()) return + const origin = normalizeOrigin(state.newAppUrl) + if (!origin) { + state.appsStatus = { + kind: 'error', + text: 'Please enter a valid application URL, for example https://trusted.app or http://localhost:3000.' + } + update() + return + } + if (state.trustedApps.some(app => app.origin === origin)) { + state.appsStatus = { kind: 'error', text: `${origin} is already in the list.` } + update() + return + } + const modes = state.newAppModes.length ? state.newAppModes : ['Read' as AccessMode] + state.newAppUrl = '' + state.newAppModes = ['Read'] + await actions.setAppModes(origin, modes) } - const appendedForm = widgets.appendForm( - dom, - formArea, - {}, - renderContext.me, - preferencesForm, - renderContext.preferencesFile, - complainIfBad - ) - appendedForm.style.borderStyle = 'none' - - const trustedApplicationsView = context.session.paneRegistry.byName('trustedApplications') - if (trustedApplicationsView) { - container.appendChild(trustedApplicationsView.render(null, context)) + } + + async function load () { + update() + try { + const authContext = await login.ensureLoadedPreferences({ dom, div: container }) + const me = authContext.me as NamedNode | undefined + if (!me) throw new Error('You need to be logged in to see your preferences.') + state.me = me + + if (authContext.preferencesFile) { + state.preferencesFile = authContext.preferencesFile as NamedNode + state.role = getUserRole(store, me, state.preferencesFile) + } else { + // Could be CORS + console.log('No access to preferences file. ' + (authContext as any).preferencesFileError) + state.roleStatus = { + kind: 'error', + text: 'Your preferences file could not be loaded, so your user type cannot be changed right now.' + } + } + + state.profileEditable = !!store.updater?.editable(me.doc().uri, store) + state.trustedApps = listTrustedApps(store, me) + } catch (err) { + state.loadError = messageOf(err) } + state.loading = false + update() - // @@ TODO Remove need for casting as any and bang (!) syntax - addDeleteSection(container, store, renderContext.me!, dom) + if (state.me) { + await findDeletionLinks(store, state.me, state.deletion) + update() + } } - doRender() - + load() return container } } -function setupUserTypesSection ( - container: Element, - dom: HTMLDocument -): Element { - const formContainer = createSection(container, dom, 'User types') - - const description = formContainer.appendChild(dom.createElement('p')) - description.innerText = 'Here you can self-assign user types to help the data browser know which views you would like to access.' - - const userTypesLink = formContainer.appendChild(dom.createElement('a')) - userTypesLink.href = 'https://github.com/solidos/userguide/#role' - userTypesLink.innerText = 'Read more' +export default basicPreferencesPane - const formArea = formContainer.appendChild(dom.createElement('div')) +/* ---------------- Rendering ---------------- */ - return formArea +interface Actions { + setRole: (role: UserRole) => Promise + setAppModes: (origin: string, modes: AccessMode[]) => Promise + setNewAppUrl: (value: string) => void + toggleNewAppMode: (mode: AccessMode, checked: boolean) => void + addApp: () => Promise } -export default basicPreferencesPane +function view (state: PreferencesState, actions: Actions): TemplateResult { + return html` +
+
+ ${state.loading + ? html`

Loading your preferences…

` + : state.loadError + ? html`
` + : html` + ${userTypesSection(state, actions)} + ${trustedAppsSection(state, actions)} + ${deleteAccountSection(state)} + `} +
+ +
+ ` +} -// ends +function infoIcon (text: string): TemplateResult { + return html`` +} -function addDeleteSection ( - container: HTMLElement, - store: IndexedFormula, - profile: NamedNode, - dom: HTMLDocument -): void { - const section = createSection(container, dom, 'Delete account') +function statusLine (status: Status): TemplateResult | typeof nothing { + if (!status) return nothing + return html`

${status.text}

` +} - const podServerNodes = store.each(profile, ns.space('storage'), null, profile.doc()) - const podServers = podServerNodes.map(node => node.value) +function userTypesSection (state: PreferencesState, actions: Actions): TemplateResult { + const selected = roleOptions.find(option => option.value === state.role) + return html` +
+

User types

+

+ The options presented to you when viewing data can be customised based on your role. +

+
+ + +

+ ${selected?.description} + Read more +

+
+ ${statusLine(state.roleStatus)} +
+ ` +} - const list = section.appendChild(dom.createElement('ul')) +function trustedAppsSection (state: PreferencesState, actions: Actions): TemplateResult { + const header = html` +

+ Manage your trusted applications + ${infoIcon('Trusted applications get access to everything you have access to, limited to the modes you tick. They never get more access than you have.')} +

+

+ Before you can use third-party applications, you need to add them to the allowlist via the Trusted Application table. +

` + + if (!state.profileEditable) { + return html` +
+ ${header} + +
` + } - podServers.forEach(async server => { - const deletionLink = await generateDeletionLink(server, dom) - if (deletionLink) { - const listItem = list.appendChild(dom.createElement('li')) - listItem.appendChild(deletionLink) - } - }) + const modeCell = (label: string, checked: boolean, disabled: boolean, onChange: (checked: boolean) => void) => html` + + onChange((event.target as HTMLInputElement).checked)}> + ` + + return html` +
+ ${header} +
+ + + + + ${accessModes.map(mode => html``)} + + + + + ${state.trustedApps.map(app => { + const busy = state.busyOrigins.has(app.origin) + return html` + + + ${accessModes.map(mode => modeCell( + `${mode} access for ${app.origin}`, + app.modes.includes(mode), + busy, + checked => actions.setAppModes(app.origin, + accessModes.filter(m => m === mode ? checked : app.modes.includes(m))) + ))} + + ` + })} + + + ${accessModes.map(mode => modeCell( + `${mode} access for the new application`, + state.newAppModes.includes(mode), + false, + checked => actions.toggleNewAppMode(mode, checked) + ))} + + + +
Application URL${mode}Remove
${app.origin} + +
+ actions.setNewAppUrl((event.target as HTMLInputElement).value)} + @keydown=${(event: KeyboardEvent) => { + if (event.key === 'Enter') { + event.preventDefault() + actions.addApp() + } + }} + @change=${() => actions.addApp()}> +
+
+

+ Tick the access modes first, then type the application's URL and press Enter, + for example https://trusted.app or http://localhost:3000. +

+ ${statusLine(state.appsStatus)} +
+ ` } -async function generateDeletionLink ( - podServer: string, - dom: HTMLDocument -): Promise { - const link = dom.createElement('a') - link.textContent = `Delete your account at ${podServer}` - const deletionUrl = await getDeletionUrlForServer(podServer) - if (typeof deletionUrl !== 'string') { - return null +function deleteAccountSection (state: PreferencesState): TemplateResult { + const { checking, links, servers } = state.deletion + let actionsArea: TemplateResult + if (checking) { + actionsArea = html`

Looking for your Pod provider's account deletion page…

` + } else if (links.length) { + actionsArea = html`${links.map(link => html` + + + ${links.length > 1 ? `Delete your account at ${link.server}` : 'Delete your account'} + (opens your Pod provider's site in a new tab) + `)}` + } else { + actionsArea = html` +

+ We could not find an account deletion page for ${servers.length ? servers.join(', ') : 'your Pod'}. + Please contact your Pod provider to delete your account. +

` } - link.href = deletionUrl - return link + + return html` +
+

+ Delete your Solid account + ${infoIcon('Account deletion is handled by your Pod provider. You will be taken to their site to confirm.')} +

+

If you no longer want your Solid Pod, you can delete your account.

+
+ +
+ Warning: +

When your account is deleted, all of the data is deleted and cannot be restored.

+
+
+
${actionsArea}
+
+ ` } -/** - * Hacky way to get the deletion link to a Pod - * - * This function infers the deletion link by assuming the URL structure of Node Solid server. - * In the future, Solid will hopefully provide a standardised way of discovering the deletion link: - * https://github.com/solidos/data-interoperability-panel/issues/18 - * - * If NSS is in multi-user mode (the case on inrupt.net and solid.community), the deletion URL for - * vincent.dev.inrupt.net would be at dev.inrupt.net/account/delete. In single-user mode, the - * deletion URL would be at vincent.dev.inrupt.net/account/delete. - * - * @param server Pod server containing the user's account. - * @returns URL of the page that Node Solid Server would offer to delete the account, or null if - * the URLs we tried give invalid responses. - */ -async function getDeletionUrlForServer ( - server: string -): Promise { - const singleUserUrl = new URL(server) - const multiUserUrl = new URL(server) - multiUserUrl.pathname = singleUserUrl.pathname = '/account/delete' - - const hostnameParts = multiUserUrl.hostname.split('.') - // Remove `vincent.` from `vincent.dev.inrupt.net`, for example: - multiUserUrl.hostname = hostnameParts.slice(1).join('.') - - const multiUserNssResponse = await fetch(multiUserUrl.href, { - method: 'HEAD' - }) - if (multiUserNssResponse.ok) { - return multiUserUrl.href - } +function helpSection (): TemplateResult { + return html` +
+

Help & Support

+

+ Your preferences are stored privately in your Pod. Trusted applications are listed in your + profile, and are used by your Pod to decide which apps may act on your behalf. +

+

+ + SolidOS user guide + +

+
+ ` +} - const singleUserNssResponse = await fetch(singleUserUrl.href, { - method: 'HEAD' - }) - if (singleUserNssResponse.ok) { - return singleUserUrl.href - } - return null +/* ---------------- Helpers ---------------- */ + +async function findDeletionLinks ( + store: Store, + me: NamedNode, + deletion: PreferencesState['deletion'] +): Promise { + const servers = store.each(me, ns.space('storage'), null, me.doc()).map(node => node.value) + deletion.servers = servers + const results = await Promise.all(servers.map(async server => { + try { + const url = await getDeletionUrlForServer(server) + return url ? { server, url } : null + } catch { + return null + } + })) + deletion.links = results.filter((link): link is { server: string, url: string } => !!link) + deletion.checking = false } -function createSection ( - container: Element, - dom: HTMLDocument, - title: string -): Element { - const section = container.appendChild(dom.createElement('div')) - section.style.border = '0.3em solid #418d99' - section.style.borderRadius = '0.5em' - section.style.padding = '0.7em' - section.style.marginTop = '0.7em' - - const titleElement = section.appendChild(dom.createElement('h3')) - titleElement.innerText = title - - return section +function messageOf (err: unknown): string { + return err instanceof Error ? err.message : String(err) } diff --git a/src/dashboard/preferencesData.ts b/src/dashboard/preferencesData.ts new file mode 100644 index 00000000..fbf9e888 --- /dev/null +++ b/src/dashboard/preferencesData.ts @@ -0,0 +1,166 @@ +/* + * Data helpers for the Preferences view (basicPreferences pane). + * + * Kept free of DOM code so they can be unit tested against a plain rdflib store. + */ +import { IndexedFormula, NamedNode, Statement, st, sym } from 'rdflib' +import { ns } from 'solid-ui' +import { generateRandomString, getStatementsToAdd, getStatementsToDelete } from '../trustedApplications/trustedApplications.utils' + +/* ---------------- User types (roles) ---------------- */ + +export type UserRole = 'user' | 'powerUser' | 'developer' + +export interface RoleOption { + value: UserRole + label: string + description: string +} + +export const roleOptions: RoleOption[] = [ + { value: 'user', label: 'Regular user', description: 'The standard views of your data.' }, + { value: 'powerUser', label: 'Power user', description: 'A more complex interface with more powerful features.' }, + { value: 'developer', label: 'Developer', description: 'Extra views useful when building Solid apps, such as raw data panes.' } +] + +/** The RDF class recorded in the preferences file for each role. 'user' is the default and has no class. */ +export function roleClass (role: UserRole): NamedNode | null { + if (role === 'powerUser') return ns.solid('PowerUser') + if (role === 'developer') return ns.solid('Developer') + return null +} + +const roleClasses = (): NamedNode[] => [ns.solid('Developer'), ns.solid('PowerUser')] + +/** Read the user's role from their preferences file. Developer wins if several are set. */ +export function getUserRole (store: IndexedFormula, me: NamedNode, preferencesFile: NamedNode): UserRole { + if (store.holds(me, ns.rdf('type'), ns.solid('Developer'), preferencesFile.doc())) return 'developer' + if (store.holds(me, ns.rdf('type'), ns.solid('PowerUser'), preferencesFile.doc())) return 'powerUser' + return 'user' +} + +/** Statements to delete and insert so that the preferences file records exactly `role`. */ +export function roleChange ( + store: IndexedFormula, + me: NamedNode, + preferencesFile: NamedNode, + role: UserRole +): { deletions: Statement[], insertions: Statement[] } { + const doc = preferencesFile.doc() + const wanted = roleClass(role) + const deletions = roleClasses() + .filter(klass => !wanted || !klass.equals(wanted)) + .flatMap(klass => store.statementsMatching(me, ns.rdf('type'), klass, doc)) + const insertions = wanted && !store.holds(me, ns.rdf('type'), wanted, doc) + ? [st(me, ns.rdf('type'), wanted, doc)] + : [] + return { deletions, insertions } +} + +/* ---------------- Trusted applications ---------------- */ + +export const accessModes = ['Read', 'Write', 'Append', 'Control'] as const +export type AccessMode = typeof accessModes[number] + +export interface TrustedApp { + origin: string + modes: AccessMode[] +} + +/** The trusted applications listed in the user's profile, sorted by origin. */ +export function listTrustedApps (store: IndexedFormula, me: NamedNode): TrustedApp[] { + return store.each(me, ns.acl('trustedApp'), null, null) + .flatMap(app => store.each(app as NamedNode, ns.acl('origin'), null, null).map(origin => ({ + origin: origin.value, + modes: accessModes.filter(mode => + store.holds(app as NamedNode, ns.acl('mode'), ns.acl(mode), null)) + }))) + .sort((a, b) => a.origin.localeCompare(b.origin)) +} + +/** + * Turn what the user typed into an application origin such as https://app.example + * Returns null when it is not a usable http(s) URL. + */ +export function normalizeOrigin (input: string): string | null { + const text = input.trim() + if (!text) return null + try { + const url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(text) ? text : `https://${text}`) + if (url.protocol !== 'https:' && url.protocol !== 'http:') return null + if (!url.hostname) return null + return url.origin + } catch { + return null + } +} + +/** + * Statements to delete and insert to set the modes of the app at `origin`. + * Any existing entry for `origin` is replaced. With no modes the app is removed. + */ +export function trustedAppChange ( + store: IndexedFormula, + me: NamedNode, + origin: string, + modes: AccessMode[] +): { deletions: Statement[], insertions: Statement[] } { + const originNode = sym(origin) + // Match on the value, so an origin stored as a literal is found too + const storedOrigins = store.statementsMatching(null, ns.acl('origin'), null, null) + .map(statement => statement.object) + .filter(node => node.value === origin) + const deletions = dedupe(storedOrigins.flatMap(node => getStatementsToDelete(node as NamedNode, me, store, ns))) + const insertions = modes.length + ? getStatementsToAdd(originNode, generateRandomString(), modes.map(mode => ns.acl(mode).uri), me, ns) + : [] + return { deletions, insertions } +} + +function dedupe (statements: Statement[]): Statement[] { + const seen = new Set() + return statements.filter(statement => { + const key = statement.toNT() + if (seen.has(key)) return false + seen.add(key) + return true + }) +} + +/* ---------------- Account deletion ---------------- */ + +/** + * Find the page where the user can delete their account on a pod server. + * + * There is no standard way to discover this yet + * (https://github.com/solidos/data-interoperability-panel/issues/18), so this assumes the + * Node Solid Server layout: /account/delete on the server, or on the parent domain in + * multi-user mode (alice.example.net → example.net/account/delete). + */ +export async function getDeletionUrlForServer ( + server: string, + fetchFn: typeof fetch = fetch +): Promise { + const singleUserUrl = new URL(server) + singleUserUrl.pathname = '/account/delete' + singleUserUrl.search = singleUserUrl.hash = '' + + const candidates: string[] = [] + const hostnameParts = singleUserUrl.hostname.split('.') + if (hostnameParts.length > 2) { + const multiUserUrl = new URL(singleUserUrl.href) + multiUserUrl.hostname = hostnameParts.slice(1).join('.') + candidates.push(multiUserUrl.href) + } + candidates.push(singleUserUrl.href) + + for (const candidate of candidates) { + try { + const response = await fetchFn(candidate, { method: 'HEAD' }) + if (response.ok) return candidate + } catch { + // Unreachable or blocked by CORS: try the next candidate + } + } + return null +} diff --git a/src/dashboard/preferencesFormText.ttl b/src/dashboard/preferencesFormText.ttl deleted file mode 100644 index 98c414d8..00000000 --- a/src/dashboard/preferencesFormText.ttl +++ /dev/null @@ -1,18 +0,0 @@ -@prefix rdf: . -@prefix solid: . -@prefix ui: . -@prefix : <#>. - -:this "Basic preferences" ; - a ui:Form ; - ui:part :categorizeUser, :privateComment, :personalInformationHeading; - ui:parts ( :personalInformationHeading :privateComment :categorizeUser ). - -:personalInformationHeading a ui:Heading; - ui:contents "Personal information". - -:privateComment a ui:Comment; - ui:contents "This information is private.". - -:categorizeUser a ui:Classifier; - ui:label "Level of user"; ui:property rdf:type ; ui:category solid:User. diff --git a/test/unit/dashboard/basicPreferences.test.ts b/test/unit/dashboard/basicPreferences.test.ts new file mode 100644 index 00000000..01cc1d07 --- /dev/null +++ b/test/unit/dashboard/basicPreferences.test.ts @@ -0,0 +1,121 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import * as $rdf from 'rdflib' +import { ns } from 'solid-ui' +import { screen, waitFor, within } from '@testing-library/dom' + +const { ensureLoadedPreferences } = vi.hoisted(() => ({ ensureLoadedPreferences: vi.fn() })) +vi.mock('solid-ui', async importOriginal => { + const actual = await importOriginal() + return { ...actual, login: { ...actual.login, ensureLoadedPreferences } } +}) + +import basicPreferencesPane from '../../../src/dashboard/basicPreferences' + +const me = $rdf.sym('https://alice.example/profile/card#me') +const prefs = $rdf.sym('https://alice.example/settings/prefs.ttl') + +function setup ({ editable = true, withPrefs = true } = {}) { + const store = $rdf.graph() as $rdf.Store + const update = vi.fn(async (deletions: $rdf.Statement[], insertions: $rdf.Statement[]) => { + store.remove(deletions) + insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) + }) + ;(store as any).updater = { editable: () => editable, update } + const app = $rdf.blankNode() + store.add(me, ns.acl('trustedApp'), app, me.doc()) + store.add(app, ns.acl('origin'), $rdf.sym('https://solid-ui.example.com'), me.doc()) + store.add(app, ns.acl('mode'), ns.acl('Read'), me.doc()) + store.add(me, ns.space('storage'), $rdf.sym('https://alice.example/'), me.doc()) + + ensureLoadedPreferences.mockResolvedValue({ + me, + preferencesFile: withPrefs ? prefs : undefined + } as any) + + const container = basicPreferencesPane.render(me, { + dom: document, + session: { store, paneRegistry: { byName: () => null } } + } as any) + document.body.appendChild(container) + return { store, update } +} + +afterEach(() => { + vi.restoreAllMocks() + document.body.replaceChildren() +}) + +describe('Preferences view', () => { + it('shows the sections of the design', async () => { + setup() + expect(await screen.findByRole('heading', { name: 'User types' })).toBeInTheDocument() + expect(screen.getByRole('heading', { name: /Manage your trusted applications/ })).toBeInTheDocument() + expect(screen.getByRole('heading', { name: /Delete your Solid account/ })).toBeInTheDocument() + expect(screen.getByRole('heading', { name: 'Help & Support' })).toBeInTheDocument() + expect(screen.queryByText(/Customize Theme/)).not.toBeInTheDocument() + }) + + it('saves the chosen role to the preferences file', async () => { + const { store, update } = setup() + const select = await screen.findByLabelText(/Role/) as HTMLSelectElement + expect(select.value).toBe('user') + select.value = 'developer' + select.dispatchEvent(new Event('change')) + await waitFor(() => expect(update).toHaveBeenCalled()) + expect(store.holds(me, ns.rdf('type'), ns.solid('Developer'), prefs)).toBe(true) + expect(await screen.findByText('Saved.')).toBeInTheDocument() + }) + + it('disables the role when the preferences file is unavailable', async () => { + setup({ withPrefs: false }) + const select = await screen.findByLabelText(/Role/) as HTMLSelectElement + expect(select.disabled).toBe(true) + expect(screen.getByText(/preferences file could not be loaded/)).toBeInTheDocument() + }) + + it('lists trusted apps and updates a mode when ticked', async () => { + const { update } = setup() + const row = (await screen.findByText('https://solid-ui.example.com')).closest('tr')! + const write = within(row).getByLabelText('Write access for https://solid-ui.example.com') as HTMLInputElement + expect(within(row).getByLabelText('Read access for https://solid-ui.example.com')).toBeChecked() + expect(write).not.toBeChecked() + write.click() + await waitFor(() => expect(update).toHaveBeenCalledTimes(1)) + await waitFor(() => expect(within(screen.getByText('https://solid-ui.example.com').closest('tr')!) + .getByLabelText('Write access for https://solid-ui.example.com')).toBeChecked()) + }) + + it('removes a trusted app with the trash button', async () => { + setup() + const remove = await screen.findByRole('button', { name: 'Remove https://solid-ui.example.com' }) + remove.click() + await waitFor(() => expect(screen.queryByText('https://solid-ui.example.com')).not.toBeInTheDocument()) + }) + + it('adds a new app on Enter and rejects invalid URLs', async () => { + setup() + const input = await screen.findByLabelText('New application URL') as HTMLInputElement + + input.value = 'not a url' + input.dispatchEvent(new Event('input')) + input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })) + expect(await screen.findByRole('alert')).toHaveTextContent(/valid application URL/) + + input.value = 'https://notepad.example.com/app' + input.dispatchEvent(new Event('input')) + input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })) + expect(await screen.findByText('https://notepad.example.com')).toBeInTheDocument() + }) + + it('explains when the profile cannot be edited', async () => { + setup({ editable: false }) + expect(await screen.findByText(/is not editable/)).toBeInTheDocument() + expect(screen.queryByRole('table')).not.toBeInTheDocument() + }) + + it('offers the account deletion page when one is found', async () => { + setup() + const link = await screen.findByRole('link', { name: /Delete your account/ }) + expect(link.getAttribute('href')).toMatch(/\/account\/delete$/) + }) +}) diff --git a/test/unit/dashboard/preferencesData.test.ts b/test/unit/dashboard/preferencesData.test.ts new file mode 100644 index 00000000..abd8499e --- /dev/null +++ b/test/unit/dashboard/preferencesData.test.ts @@ -0,0 +1,162 @@ +import { describe, expect, it, vi } from 'vitest' +import * as $rdf from 'rdflib' +import { ns } from 'solid-ui' +import { + getDeletionUrlForServer, + getUserRole, + listTrustedApps, + normalizeOrigin, + roleChange, + trustedAppChange +} from '../../../src/dashboard/preferencesData' + +const me = $rdf.sym('https://alice.example/profile/card#me') +const prefs = $rdf.sym('https://alice.example/settings/prefs.ttl') + +describe('user role', () => { + it('defaults to a regular user', () => { + expect(getUserRole($rdf.graph(), me, prefs)).toBe('user') + }) + + it('reads power user and developer from the preferences file', () => { + const store = $rdf.graph() + store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) + expect(getUserRole(store, me, prefs)).toBe('powerUser') + store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) + expect(getUserRole(store, me, prefs)).toBe('developer') + }) + + it('ignores types stated in other documents', () => { + const store = $rdf.graph() + store.add(me, ns.rdf('type'), ns.solid('Developer'), me.doc()) + expect(getUserRole(store, me, prefs)).toBe('user') + }) + + it('replaces the old role with the new one', () => { + const store = $rdf.graph() + store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) + const { deletions, insertions } = roleChange(store, me, prefs, 'developer') + expect(deletions.map(s => s.object.value)).toEqual([ns.solid('PowerUser').value]) + expect(insertions).toHaveLength(1) + expect(insertions[0].object.value).toBe(ns.solid('Developer').value) + expect(insertions[0].why.value).toBe(prefs.value) + }) + + it('removes all role classes when going back to a regular user', () => { + const store = $rdf.graph() + store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) + store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) + const { deletions, insertions } = roleChange(store, me, prefs, 'user') + expect(deletions).toHaveLength(2) + expect(insertions).toHaveLength(0) + }) + + it('does nothing when the role is already set', () => { + const store = $rdf.graph() + store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) + expect(roleChange(store, me, prefs, 'developer')).toEqual({ deletions: [], insertions: [] }) + }) +}) + +describe('normalizeOrigin', () => { + it.each([ + ['https://trusted.app', 'https://trusted.app'], + ['https://sub.trusted.app/some/path?x=1', 'https://sub.trusted.app'], + ['http://localhost:3000', 'http://localhost:3000'], + ['trusted.app', 'https://trusted.app'], + [' https://Trusted.App/ ', 'https://trusted.app'] + ])('turns %s into %s', (input, expected) => { + expect(normalizeOrigin(input)).toBe(expected) + }) + + it.each(['', ' ', 'ftp://files.example', 'javascript:alert(1)', 'https://'])('rejects %j', input => { + expect(normalizeOrigin(input)).toBeNull() + }) +}) + +describe('trusted applications', () => { + function storeWithApp (origin: $rdf.NamedNode | $rdf.Literal, modes: string[]) { + const store = $rdf.graph() + const app = $rdf.blankNode() + store.add(me, ns.acl('trustedApp'), app, me.doc()) + store.add(app, ns.acl('origin'), origin, me.doc()) + modes.forEach(mode => store.add(app, ns.acl('mode'), ns.acl(mode), me.doc())) + return store + } + + it('lists apps with their modes in a fixed order', () => { + const store = storeWithApp($rdf.sym('https://b.example'), ['Write', 'Read']) + const other = $rdf.blankNode() + store.add(me, ns.acl('trustedApp'), other, me.doc()) + store.add(other, ns.acl('origin'), $rdf.sym('https://a.example'), me.doc()) + store.add(other, ns.acl('mode'), ns.acl('Control'), me.doc()) + expect(listTrustedApps(store, me)).toEqual([ + { origin: 'https://a.example', modes: ['Control'] }, + { origin: 'https://b.example', modes: ['Read', 'Write'] } + ]) + }) + + it('adds a new app with the chosen modes', () => { + const store = $rdf.graph() + const { deletions, insertions } = trustedAppChange(store, me, 'https://new.example', ['Read', 'Append']) + expect(deletions).toHaveLength(0) + expect(insertions).toHaveLength(4) + insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) + expect(listTrustedApps(store, me)).toEqual([{ origin: 'https://new.example', modes: ['Read', 'Append'] }]) + }) + + it('replaces the modes of an existing app', () => { + const store = storeWithApp($rdf.sym('https://app.example'), ['Read']) + const { deletions, insertions } = trustedAppChange(store, me, 'https://app.example', ['Read', 'Write']) + expect(deletions).toHaveLength(3) + store.remove(deletions) + insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) + expect(listTrustedApps(store, me)).toEqual([{ origin: 'https://app.example', modes: ['Read', 'Write'] }]) + }) + + it('removes an app when no modes are left', () => { + const store = storeWithApp($rdf.sym('https://app.example'), ['Read', 'Control']) + const { deletions, insertions } = trustedAppChange(store, me, 'https://app.example', []) + expect(deletions).toHaveLength(4) + expect(insertions).toHaveLength(0) + }) + + it('finds apps whose origin was stored as a literal', () => { + const store = storeWithApp($rdf.lit('https://app.example'), ['Read']) + const { deletions } = trustedAppChange(store, me, 'https://app.example', []) + expect(deletions).toHaveLength(3) + }) +}) + +describe('getDeletionUrlForServer', () => { + const ok = { ok: true } as Response + const notFound = { ok: false } as Response + + it('prefers the multi-user server page', async () => { + const fetchFn = vi.fn().mockResolvedValue(ok) + await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)) + .resolves.toBe('https://solidcommunity.net/account/delete') + }) + + it('falls back to the single-user page', async () => { + const fetchFn = vi.fn() + .mockResolvedValueOnce(notFound) + .mockResolvedValueOnce(ok) + await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)) + .resolves.toBe('https://alice.solidcommunity.net/account/delete') + }) + + it('returns null when neither page exists or the fetch fails', async () => { + const fetchFn = vi.fn() + .mockRejectedValueOnce(new TypeError('CORS')) + .mockResolvedValueOnce(notFound) + await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)).resolves.toBeNull() + }) + + it('does not try a parent domain for a two-part host name', async () => { + const fetchFn = vi.fn().mockResolvedValue(notFound) + await getDeletionUrlForServer('https://example.net/', fetchFn) + expect(fetchFn).toHaveBeenCalledTimes(1) + expect(fetchFn).toHaveBeenCalledWith('https://example.net/account/delete', { method: 'HEAD' }) + }) +}) From a988192a305bcf41557a3a0a99d4397b280701e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 14:00:32 -0500 Subject: [PATCH 2/6] Preferences view: match Figma details (#710) - Orange ticks for access-mode checkboxes, as in the design - Lighter section titles, narrower role dropdown, softer field borders - Roomier warning box with grey body text; bolder delete button label - New-application row starts with no modes ticked (Read is still the fallback when none are chosen) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPTQkfDiRe2xrMJTcygUUo --- src/dashboard/basicPreferences.css | 34 +++++++++++++++++++----------- src/dashboard/basicPreferences.ts | 8 +++---- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/dashboard/basicPreferences.css b/src/dashboard/basicPreferences.css index d36afcee..98028cde 100644 --- a/src/dashboard/basicPreferences.css +++ b/src/dashboard/basicPreferences.css @@ -8,6 +8,8 @@ --preferences-danger: var(--solid-ui-color-red-600, #dc2626); --preferences-danger-bg: var(--solid-ui-color-red-50, #fef2f2); --preferences-header-bg: color-mix(in srgb, var(--preferences-primary) 10%, #ffffff); + /* Checked access modes are orange in the design */ + --preferences-check: var(--solid-ui-color-orange-500, #f97316); box-sizing: border-box; width: 100%; @@ -55,8 +57,8 @@ align-items: center; gap: 6px; margin: 0 0 8px; - font-size: 1.25rem; - font-weight: 600; + font-size: 1.125rem; + font-weight: 500; line-height: 1.3; } @@ -113,14 +115,17 @@ display: flex; flex-direction: column; gap: 8px; - max-width: 480px; +} + +.preferences-field .preferences-select { + max-width: 340px; } .preferences-label { display: flex; align-items: center; gap: 6px; - font-weight: 600; + font-weight: 500; } .preferences-select, @@ -128,7 +133,7 @@ width: 100%; min-height: 40px; padding: 8px 12px; - border: 1px solid var(--solid-ui-color-gray-400, #9ca3af); + border: 1px solid var(--solid-ui-color-gray-300, #d1d5db); border-radius: 5px; background: var(--solid-ui-color-white, #ffffff); color: inherit; @@ -168,7 +173,7 @@ .preferences-table thead th { background: var(--preferences-header-bg); - font-weight: 600; + font-weight: 500; text-align: left; } @@ -191,7 +196,7 @@ } .preferences-table__url { - font-weight: 500; + font-weight: 400; text-align: left; overflow-wrap: anywhere; } @@ -204,7 +209,7 @@ width: 16px; height: 16px; margin: 0; - accent-color: var(--preferences-primary); + accent-color: var(--preferences-check); cursor: pointer; } @@ -250,14 +255,18 @@ .preferences-warning { display: flex; gap: 8px; - margin-bottom: 16px; - padding: 12px 16px; + margin-bottom: 24px; + padding: 20px 24px; border-radius: 5px; background: var(--preferences-danger-bg); color: var(--preferences-danger); font-size: var(--solid-ui-font-size-sm, 0.875rem); } +.preferences-warning strong { + font-weight: 500; +} + .preferences-warning icon-lucide-triangle-alert { flex: 0 0 16px; width: 16px; @@ -266,8 +275,8 @@ } .preferences-warning p { - margin: 4px 0 0; - color: var(--preferences-text); + margin: 8px 0 0; + color: var(--preferences-muted); } .preferences-delete-actions { @@ -287,6 +296,7 @@ background: var(--solid-ui-color-white, #ffffff); color: var(--preferences-danger); font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 500; text-decoration: none; } diff --git a/src/dashboard/basicPreferences.ts b/src/dashboard/basicPreferences.ts index b847e199..2fd63d14 100644 --- a/src/dashboard/basicPreferences.ts +++ b/src/dashboard/basicPreferences.ts @@ -82,7 +82,7 @@ export const basicPreferencesPane: PaneDefinition = { profileEditable: false, trustedApps: [], newAppUrl: '', - newAppModes: ['Read'], + newAppModes: [], appsStatus: null, busyOrigins: new Set(), deletion: { checking: true, links: [], servers: [] } @@ -163,7 +163,7 @@ export const basicPreferencesPane: PaneDefinition = { } const modes = state.newAppModes.length ? state.newAppModes : ['Read' as AccessMode] state.newAppUrl = '' - state.newAppModes = ['Read'] + state.newAppModes = [] await actions.setAppModes(origin, modes) } } @@ -368,8 +368,8 @@ function trustedAppsSection (state: PreferencesState, actions: Actions): Templat

- Tick the access modes first, then type the application's URL and press Enter, - for example https://trusted.app or http://localhost:3000. + To add an application, tick its access modes, then type its URL and press Enter, + for example https://trusted.app or http://localhost:3000. With no modes ticked it gets Read access.

${statusLine(state.appsStatus)} From 317eb711c08c2c859b0e9e818daedab91a40dcff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 24 Nov 2026 19:20:26 +0000 Subject: [PATCH 3/6] chore: update solidos dependencies (dev: solid-logic@6.2.1-0 solid-ui@5.1.1-0 pane-registry@5.1.2-0 activitystreams-pane@2.1.1-0 chat-pane@4.1.1-0 contacts-pane@4.1.1-0 folder-pane@4.1.5-0 issue-pane@4.1.1-0 meeting-pane@4.1.1-0 profile-pane@4.1.1-0 source-pane@4.1.1-0) (latest: rdflib@2.4.1) --- package-lock.json | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1f6ab9d8..1522c701 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3760,9 +3760,9 @@ } }, "node_modules/@types/react": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", - "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.1.tgz", + "integrity": "sha512-HNTkBIm8zmHX8LUXX2vtZ/ONzehrV1J3abl2fUIiZ5qxTYRCj/z+rDeFwOltqCLl9lRdUTKWT41OLtYuFV/Arg==", "license": "MIT", "peer": true, "dependencies": { @@ -4012,23 +4012,23 @@ } }, "node_modules/@uiw/codemirror-theme-vscode": { - "version": "4.25.12", - "resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.25.12.tgz", - "integrity": "sha512-sIO/8/hJsT6meSa/d5RQHXw4isago+DP4iVQtqiULvaXaA3cQvtHVw0enbcZdwtVIT6rQEfERxqeoHiX9Psd5w==", + "version": "4.25.13", + "resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.25.13.tgz", + "integrity": "sha512-EaqMHexflhyio53qT5tmEVMOwGFdqGos4q9LY2M74EeAQBR1nP0LbHJBLxMLQGLtgpOLutce7jeIUyFZuA5g1g==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.6", "@lezer/highlight": "^1.0.0", - "@uiw/codemirror-themes": "4.25.12" + "@uiw/codemirror-themes": "4.25.13" }, "funding": { "url": "https://jaywcjlove.github.io/#/sponsor" } }, "node_modules/@uiw/codemirror-themes": { - "version": "4.25.12", - "resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.25.12.tgz", - "integrity": "sha512-3bLX6C+gstr82SmY2FAj2TfHXnl2SnC+whRZJmRsv82wMhG8RZlZVy+o0rLuGRIPD9acuY0gpouHVRNUnzBj3g==", + "version": "4.25.13", + "resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.25.13.tgz", + "integrity": "sha512-2sai+4dRRrbutz4jHyHaJDYf7beTdRYN3p1ciiE/spEH03grc58f8n2yNnUQRz3zjFRALDjMnzEu8A5LukMKyQ==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", @@ -4839,9 +4839,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001827", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001827.tgz", - "integrity": "sha512-YWEDr46gSO81M8w6uPbaIy4++IXsirx2asUqvllNiD4BPf75ibxclUjWEqp8ObCenRv+UM2n5Y8xuRPT8V8FrQ==", + "version": "1.0.30001828", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001828.tgz", + "integrity": "sha512-7MWeT+3DlrpuDybTWHl4Zb1Z80Z1fLLnOXuBjDXebzDVcqnEWUlV8JcbASg8B8BhcW8QT2UiR1KAtzYFIZHZYA==", "dev": true, "funding": [ { @@ -5335,9 +5335,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.492", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.492.tgz", - "integrity": "sha512-4uMs7omhajKiud0GqALLTazS/zyvHLTLmDWVTR+e6BnyJo5bSNrph/JoRWEFJJmY75ct9hCiSGsbFF9fLe5gDw==", + "version": "1.5.493", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.493.tgz", + "integrity": "sha512-/Wto2sKd0EpepzMqwSP2il2TNc+rnBDF6k1poCvhRKpaSSD4sLGRBE+FydqHs2QwcW9cXKLVDqnauzJy1oByYw==", "dev": true, "license": "ISC" }, @@ -8053,9 +8053,9 @@ } }, "node_modules/lucide": { - "version": "1.78.0", - "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.78.0.tgz", - "integrity": "sha512-4lMWPv+OZGL1N2jkTNGjw86Rd3+4gyCdBHHXw+emfCvbQEojOPwPQo20y4SEUxy5ZBc3IDp3KC1vA7PPiuLbQA==", + "version": "1.79.0", + "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.79.0.tgz", + "integrity": "sha512-y96g6/Pca8ZoMt1F8P2K3T5t1ABrFDeJW5h7IM2CyAGton1lbdMzHn4u0qAGI0j9nZ2OArUTqekDZyBTW2pRUQ==", "license": "ISC" }, "node_modules/lz-string": { @@ -8107,9 +8107,9 @@ } }, "node_modules/marked": { - "version": "18.2.1", - "resolved": "https://registry.npmjs.org/marked/-/marked-18.2.1.tgz", - "integrity": "sha512-ii4bxCTCqqwpT86XZWgJNs+ZnAIZksmLGYMViWA7PDIXYIeNo1x6cDdX3JOip9NM/cI6p8z57FxliACboTruMA==", + "version": "18.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-18.3.0.tgz", + "integrity": "sha512-ed8zmPXlBb3UfGXN5iHMQyMhFpdqLgoV5umUXx/Q1R+FW3q8VpqpyoKUwlENL9appo2UMvNLURDVaT3AMOryGA==", "license": "MIT", "bin": { "marked": "bin/marked.js" From 41b70143ce72ed47f15a80f7cb1b72d1e56dc14d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 12:35:57 -0500 Subject: [PATCH 4/6] Revert Preferences rewrite, to redo it as minimal changes (#710) Restores src/dashboard to staging and removes the new data module, CSS file and tests, so the design can be applied as small changes to the existing pane and form instead of a rewrite. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPTQkfDiRe2xrMJTcygUUo --- src/dashboard/basicPreferences.css | 364 ------------ src/dashboard/basicPreferences.ts | 570 +++++-------------- src/dashboard/preferencesData.ts | 166 ------ src/dashboard/preferencesFormText.ttl | 18 + test/unit/dashboard/basicPreferences.test.ts | 121 ---- test/unit/dashboard/preferencesData.test.ts | 162 ------ 6 files changed, 175 insertions(+), 1226 deletions(-) delete mode 100644 src/dashboard/basicPreferences.css delete mode 100644 src/dashboard/preferencesData.ts create mode 100644 src/dashboard/preferencesFormText.ttl delete mode 100644 test/unit/dashboard/basicPreferences.test.ts delete mode 100644 test/unit/dashboard/preferencesData.test.ts diff --git a/src/dashboard/basicPreferences.css b/src/dashboard/basicPreferences.css deleted file mode 100644 index 98028cde..00000000 --- a/src/dashboard/basicPreferences.css +++ /dev/null @@ -1,364 +0,0 @@ -/* Preferences view (basicPreferences pane). Design: SolidOS/solid-panes#710 */ - -.preferences-pane { - --preferences-border: var(--solid-ui-color-slate-200, #e2e8f0); - --preferences-primary: var(--solid-ui-color-primary, #7c4dff); - --preferences-text: var(--color-text, #101828); - --preferences-muted: var(--color-text-secondary, #4a5565); - --preferences-danger: var(--solid-ui-color-red-600, #dc2626); - --preferences-danger-bg: var(--solid-ui-color-red-50, #fef2f2); - --preferences-header-bg: color-mix(in srgb, var(--preferences-primary) 10%, #ffffff); - /* Checked access modes are orange in the design */ - --preferences-check: var(--solid-ui-color-orange-500, #f97316); - - box-sizing: border-box; - width: 100%; - padding: 16px; - background: var(--solid-ui-color-slate-50, #f8fafc); - color: var(--preferences-text); - font-size: var(--solid-ui-font-size-md, 1rem); -} - -.preferences-pane *, -.preferences-pane *::before, -.preferences-pane *::after { - box-sizing: border-box; -} - -.preferences-layout { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); - align-items: start; - gap: 16px; - max-width: 1200px; - margin: 0 auto; -} - -.preferences-main { - display: flex; - flex-direction: column; - gap: 16px; - min-width: 0; -} - -.preferences-card { - background: var(--solid-ui-color-white, #ffffff); - border: 1px solid var(--preferences-border); - border-radius: 5px; - padding: 24px; -} - -.preferences-card--compact { - padding: 16px; -} - -.preferences-card__title { - display: flex; - align-items: center; - gap: 6px; - margin: 0 0 8px; - font-size: 1.125rem; - font-weight: 500; - line-height: 1.3; -} - -.preferences-card__subtitle { - margin: 0 0 8px; - font-size: 1rem; - font-weight: 600; -} - -.preferences-card__description, -.preferences-muted { - margin: 0 0 16px; - color: var(--preferences-muted); - font-size: var(--solid-ui-font-size-sm, 0.875rem); - line-height: 1.5; -} - -.preferences-muted:last-child { - margin-bottom: 0; -} - -.preferences-pane a { - color: var(--preferences-primary); -} - -.preferences-pane a icon-lucide-external-link { - width: 12px; - height: 12px; - vertical-align: -1px; -} - -/* Info icon with tooltip */ -.preferences-info { - display: inline-flex; - width: 16px; - height: 16px; - color: var(--preferences-muted); - cursor: help; - border-radius: 50%; -} - -.preferences-info icon-lucide-info { - width: 16px; - height: 16px; -} - -.preferences-info:focus-visible { - outline: 2px solid var(--preferences-primary); - outline-offset: 2px; -} - -/* User types */ -.preferences-field { - display: flex; - flex-direction: column; - gap: 8px; -} - -.preferences-field .preferences-select { - max-width: 340px; -} - -.preferences-label { - display: flex; - align-items: center; - gap: 6px; - font-weight: 500; -} - -.preferences-select, -.preferences-input { - width: 100%; - min-height: 40px; - padding: 8px 12px; - border: 1px solid var(--solid-ui-color-gray-300, #d1d5db); - border-radius: 5px; - background: var(--solid-ui-color-white, #ffffff); - color: inherit; - font: inherit; - font-size: var(--solid-ui-font-size-sm, 0.875rem); -} - -.preferences-input { - min-height: 32px; - padding: 4px 8px; - border-color: transparent; -} - -.preferences-input:hover { - border-color: var(--preferences-border); -} - -.preferences-select:focus-visible, -.preferences-input:focus-visible { - outline: 2px solid var(--preferences-primary); - outline-offset: 1px; -} - -/* Trusted applications table */ -.preferences-table-wrapper { - overflow-x: auto; - margin-bottom: 12px; - border: 1px solid var(--preferences-border); - border-radius: 5px; -} - -.preferences-table { - width: 100%; - border-collapse: collapse; - font-size: var(--solid-ui-font-size-sm, 0.875rem); -} - -.preferences-table thead th { - background: var(--preferences-header-bg); - font-weight: 500; - text-align: left; -} - -.preferences-table th, -.preferences-table td { - padding: 12px 16px; - border-bottom: 1px solid var(--preferences-border); - vertical-align: middle; -} - -.preferences-table tbody tr:last-child th, -.preferences-table tbody tr:last-child td { - border-bottom: none; -} - -.preferences-table th:first-child, -.preferences-table td:first-child { - border-right: 1px solid var(--preferences-border); - min-width: 240px; -} - -.preferences-table__url { - font-weight: 400; - text-align: left; - overflow-wrap: anywhere; -} - -.preferences-table__new .preferences-table__url { - padding: 6px 8px; -} - -.preferences-table__mode input { - width: 16px; - height: 16px; - margin: 0; - accent-color: var(--preferences-check); - cursor: pointer; -} - -.preferences-table__action { - width: 48px; - text-align: right; -} - -.preferences-table tr[aria-busy='true'] { - opacity: 0.6; -} - -.preferences-icon-button { - display: inline-flex; - align-items: center; - justify-content: center; - width: 32px; - height: 32px; - padding: 0; - border: none; - border-radius: 5px; - background: transparent; - color: var(--solid-ui-color-gray-400, #9ca3af); - cursor: pointer; -} - -.preferences-icon-button icon-lucide-trash-2 { - width: 16px; - height: 16px; -} - -.preferences-icon-button:hover:not(:disabled), -.preferences-icon-button:focus-visible { - color: var(--preferences-danger); - background: var(--preferences-danger-bg); -} - -.preferences-icon-button:focus-visible { - outline: 2px solid var(--preferences-primary); -} - -/* Delete account */ -.preferences-warning { - display: flex; - gap: 8px; - margin-bottom: 24px; - padding: 20px 24px; - border-radius: 5px; - background: var(--preferences-danger-bg); - color: var(--preferences-danger); - font-size: var(--solid-ui-font-size-sm, 0.875rem); -} - -.preferences-warning strong { - font-weight: 500; -} - -.preferences-warning icon-lucide-triangle-alert { - flex: 0 0 16px; - width: 16px; - height: 16px; - margin-top: 2px; -} - -.preferences-warning p { - margin: 8px 0 0; - color: var(--preferences-muted); -} - -.preferences-delete-actions { - display: flex; - flex-wrap: wrap; - gap: 8px; -} - -.preferences-pane .preferences-danger-button { - display: inline-flex; - align-items: center; - gap: 6px; - min-height: 36px; - padding: 6px 12px; - border: 1px solid var(--preferences-danger); - border-radius: 5px; - background: var(--solid-ui-color-white, #ffffff); - color: var(--preferences-danger); - font-size: var(--solid-ui-font-size-sm, 0.875rem); - font-weight: 500; - text-decoration: none; -} - -.preferences-danger-button icon-lucide-trash-2 { - width: 14px; - height: 14px; -} - -.preferences-pane .preferences-danger-button:hover, -.preferences-pane .preferences-danger-button:focus-visible { - background: var(--preferences-danger-bg); -} - -.preferences-danger-button:focus-visible { - outline: 2px solid var(--preferences-danger); - outline-offset: 2px; -} - -/* Status messages */ -.preferences-status { - margin: 12px 0 0; - font-size: var(--solid-ui-font-size-sm, 0.875rem); -} - -.preferences-status--error { - color: var(--solid-ui-color-red-700, #b91c1c); -} - -.preferences-status--success { - color: var(--solid-ui-color-green-700, #15803d); -} - -.preferences-status--info { - color: var(--preferences-muted); -} - -.preferences-visually-hidden { - position: absolute; - width: 1px; - height: 1px; - overflow: hidden; - clip: rect(0 0 0 0); - white-space: nowrap; -} - -@media (max-width: 900px) { - .preferences-layout { - grid-template-columns: minmax(0, 1fr); - } -} - -@media (max-width: 600px) { - .preferences-pane { - padding: 8px; - } - - .preferences-card { - padding: 16px; - } - - .preferences-table th:first-child, - .preferences-table td:first-child { - min-width: 180px; - } -} diff --git a/src/dashboard/basicPreferences.ts b/src/dashboard/basicPreferences.ts index 2fd63d14..2b40e1b1 100644 --- a/src/dashboard/basicPreferences.ts +++ b/src/dashboard/basicPreferences.ts @@ -1,458 +1,202 @@ -/* - * Preferences view: the "Preferences" item in the logged-in user's menu. - * - * Design: https://github.com/SolidOS/solid-panes/issues/710 - * Sections: User types, Manage your trusted applications, Delete your Solid account, - * and a Help & Support sidebar. "Customize Theme" is not implemented yet (see the issue). - */ -import { html, nothing, render, type TemplateResult } from 'lit-html' import { PaneDefinition } from 'pane-registry' -import { NamedNode, parse, Statement, Store } from 'rdflib' -import { icons, login, ns } from 'solid-ui' -import '~icons/lucide/info' -import '~icons/lucide/trash-2' -import '~icons/lucide/triangle-alert' -import '~icons/lucide/external-link' -import './basicPreferences.css' +import { IndexedFormula, NamedNode, parse, Store } from 'rdflib' +import { icons, login, ns, widgets } from 'solid-ui' import ontologyData from './ontologyData.ttl' -import { - accessModes, - type AccessMode, - getDeletionUrlForServer, - getUserRole, - listTrustedApps, - normalizeOrigin, - roleChange, - roleOptions, - trustedAppChange, - type TrustedApp, - type UserRole -} from './preferencesData' - -const USER_GUIDE_URL = 'https://solidos.github.io/userguide/' -const USER_TYPES_GUIDE_URL = 'https://github.com/solidos/userguide/#role' - -type Status = { kind: 'info' | 'error' | 'success', text: string } | null - -interface PreferencesState { - me: NamedNode | null - loading: boolean - loadError: string | null - - preferencesFile: NamedNode | null - role: UserRole - roleStatus: Status - - profileEditable: boolean - trustedApps: TrustedApp[] - newAppUrl: string - newAppModes: AccessMode[] - appsStatus: Status - busyOrigins: Set - - deletion: { checking: boolean, links: Array<{ server: string, url: string }>, servers: string[] } -} +import preferencesFormText from './preferencesFormText.ttl' export const basicPreferencesPane: PaneDefinition = { icon: icons.iconBase + 'noun_Sliders_341315_000000.svg', name: 'basicPreferences', - label: _subject => null, + label: _subject => { + return null + }, + // Render the pane // The subject should be the logged in user. - render: (_subject, context) => { + render: (subject, context) => { const dom = context.dom // @ts-ignore const store = context.session.store as Store - const container = dom.createElement('div') - container.classList.add('preferences-pane') - // Labels for the user type classes, used elsewhere in the data browser - const ontologyDoc = store.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT') - if (!store.holds(undefined, undefined, undefined, ontologyDoc)) { - ;(parse as any)(ontologyData, store, ontologyDoc.uri, 'text/turtle', null) + function complainIfBad (ok: Boolean, mess: any) { + if (ok) return + container.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) } - const state: PreferencesState = { - me: null, - loading: true, - loadError: null, - preferencesFile: null, - role: 'user', - roleStatus: null, - profileEditable: false, - trustedApps: [], - newAppUrl: '', - newAppModes: [], - appsStatus: null, - busyOrigins: new Set(), - deletion: { checking: true, links: [], servers: [] } - } - - const update = () => render(view(state, actions), container) + const container = dom.createElement('div') - async function save (deletions: Statement[], insertions: Statement[]) { - if (!store.updater) throw new Error('Store has no updater') - if (!deletions.length && !insertions.length) return - await store.updater.update(deletions, insertions) - } + const formArea = setupUserTypesSection(container, dom) - const actions: Actions = { - async setRole (role) { - if (!state.me || !state.preferencesFile || role === state.role) return - const previous = state.role - state.role = role - state.roleStatus = { kind: 'info', text: 'Saving…' } - update() - try { - const { deletions, insertions } = roleChange(store, state.me, state.preferencesFile, role) - await save(deletions, insertions) - state.roleStatus = { kind: 'success', text: 'Saved.' } - } catch (err) { - state.role = previous - state.roleStatus = { kind: 'error', text: `Could not save your user type: ${messageOf(err)}` } - } - update() - }, - - async setAppModes (origin, modes) { - if (!state.me) return - state.busyOrigins.add(origin) - state.appsStatus = null - update() - try { - const { deletions, insertions } = trustedAppChange(store, state.me, origin, modes) - await save(deletions, insertions) - state.appsStatus = { - kind: 'success', - text: modes.length ? `Updated ${origin}.` : `Removed ${origin}.` - } - } catch (err) { - state.appsStatus = { kind: 'error', text: `Could not update ${origin}: ${messageOf(err)}` } - } - state.busyOrigins.delete(origin) - state.trustedApps = listTrustedApps(store, state.me) - update() - }, - - setNewAppUrl (value) { - state.newAppUrl = value - }, - - toggleNewAppMode (mode, checked) { - state.newAppModes = accessModes.filter(m => - m === mode ? checked : state.newAppModes.includes(m)) - update() - }, - - async addApp () { - if (!state.me) return - if (!state.newAppUrl.trim()) return - const origin = normalizeOrigin(state.newAppUrl) - if (!origin) { - state.appsStatus = { - kind: 'error', - text: 'Please enter a valid application URL, for example https://trusted.app or http://localhost:3000.' - } - update() - return - } - if (state.trustedApps.some(app => app.origin === origin)) { - state.appsStatus = { kind: 'error', text: `${origin} is already in the list.` } - update() - return - } - const modes = state.newAppModes.length ? state.newAppModes : ['Read' as AccessMode] - state.newAppUrl = '' - state.newAppModes = [] - await actions.setAppModes(origin, modes) + function loadData (doc: NamedNode, turtle: String) { + doc = doc.doc() // remove # from URI if nec + if (!store.holds(undefined, undefined, undefined, doc)) { + // If not loaded already + ;(parse as any)(turtle, store, doc.uri, 'text/turtle', null) // Load form directly } } - async function load () { - update() - try { - const authContext = await login.ensureLoadedPreferences({ dom, div: container }) - const me = authContext.me as NamedNode | undefined - if (!me) throw new Error('You need to be logged in to see your preferences.') - state.me = me - - if (authContext.preferencesFile) { - state.preferencesFile = authContext.preferencesFile as NamedNode - state.role = getUserRole(store, me, state.preferencesFile) - } else { - // Could be CORS - console.log('No access to preferences file. ' + (authContext as any).preferencesFileError) - state.roleStatus = { - kind: 'error', - text: 'Your preferences file could not be loaded, so your user type cannot be changed right now.' - } - } - - state.profileEditable = !!store.updater?.editable(me.doc().uri, store) - state.trustedApps = listTrustedApps(store, me) - } catch (err) { - state.loadError = messageOf(err) + const preferencesForm = store.sym( + 'urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597#this' + ) + loadData(preferencesForm, preferencesFormText) + + const ontologyExtra = store.sym( + 'urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT' + ) + loadData(ontologyExtra, ontologyData) + + async function doRender () { + const renderContext = await login.ensureLoadedPreferences({ + dom, + div: container + }) + if (!renderContext.preferencesFile) { + // Could be CORS + console.log( + 'Not doing private class preferences as no access to preferences file. ' + + renderContext.preferencesFileError + ) + return } - state.loading = false - update() - - if (state.me) { - await findDeletionLinks(store, state.me, state.deletion) - update() + const appendedForm = widgets.appendForm( + dom, + formArea, + {}, + renderContext.me, + preferencesForm, + renderContext.preferencesFile, + complainIfBad + ) + appendedForm.style.borderStyle = 'none' + + const trustedApplicationsView = context.session.paneRegistry.byName('trustedApplications') + if (trustedApplicationsView) { + container.appendChild(trustedApplicationsView.render(null, context)) } + + // @@ TODO Remove need for casting as any and bang (!) syntax + addDeleteSection(container, store, renderContext.me!, dom) } - load() + doRender() + return container } } -export default basicPreferencesPane +function setupUserTypesSection ( + container: Element, + dom: HTMLDocument +): Element { + const formContainer = createSection(container, dom, 'User types') -/* ---------------- Rendering ---------------- */ + const description = formContainer.appendChild(dom.createElement('p')) + description.innerText = 'Here you can self-assign user types to help the data browser know which views you would like to access.' -interface Actions { - setRole: (role: UserRole) => Promise - setAppModes: (origin: string, modes: AccessMode[]) => Promise - setNewAppUrl: (value: string) => void - toggleNewAppMode: (mode: AccessMode, checked: boolean) => void - addApp: () => Promise -} + const userTypesLink = formContainer.appendChild(dom.createElement('a')) + userTypesLink.href = 'https://github.com/solidos/userguide/#role' + userTypesLink.innerText = 'Read more' -function view (state: PreferencesState, actions: Actions): TemplateResult { - return html` -
-
- ${state.loading - ? html`

Loading your preferences…

` - : state.loadError - ? html`
` - : html` - ${userTypesSection(state, actions)} - ${trustedAppsSection(state, actions)} - ${deleteAccountSection(state)} - `} -
- -
- ` -} + const formArea = formContainer.appendChild(dom.createElement('div')) -function infoIcon (text: string): TemplateResult { - return html`` + return formArea } -function statusLine (status: Status): TemplateResult | typeof nothing { - if (!status) return nothing - return html`

${status.text}

` -} +export default basicPreferencesPane -function userTypesSection (state: PreferencesState, actions: Actions): TemplateResult { - const selected = roleOptions.find(option => option.value === state.role) - return html` -
-

User types

-

- The options presented to you when viewing data can be customised based on your role. -

-
- - -

- ${selected?.description} - Read more -

-
- ${statusLine(state.roleStatus)} -
- ` -} +// ends -function trustedAppsSection (state: PreferencesState, actions: Actions): TemplateResult { - const header = html` -

- Manage your trusted applications - ${infoIcon('Trusted applications get access to everything you have access to, limited to the modes you tick. They never get more access than you have.')} -

-

- Before you can use third-party applications, you need to add them to the allowlist via the Trusted Application table. -

` - - if (!state.profileEditable) { - return html` -
- ${header} - -
` - } +function addDeleteSection ( + container: HTMLElement, + store: IndexedFormula, + profile: NamedNode, + dom: HTMLDocument +): void { + const section = createSection(container, dom, 'Delete account') - const modeCell = (label: string, checked: boolean, disabled: boolean, onChange: (checked: boolean) => void) => html` - - onChange((event.target as HTMLInputElement).checked)}> - ` - - return html` -
- ${header} -
- - - - - ${accessModes.map(mode => html``)} - - - - - ${state.trustedApps.map(app => { - const busy = state.busyOrigins.has(app.origin) - return html` - - - ${accessModes.map(mode => modeCell( - `${mode} access for ${app.origin}`, - app.modes.includes(mode), - busy, - checked => actions.setAppModes(app.origin, - accessModes.filter(m => m === mode ? checked : app.modes.includes(m))) - ))} - - ` - })} - - - ${accessModes.map(mode => modeCell( - `${mode} access for the new application`, - state.newAppModes.includes(mode), - false, - checked => actions.toggleNewAppMode(mode, checked) - ))} - - - -
Application URL${mode}Remove
${app.origin} - -
- actions.setNewAppUrl((event.target as HTMLInputElement).value)} - @keydown=${(event: KeyboardEvent) => { - if (event.key === 'Enter') { - event.preventDefault() - actions.addApp() - } - }} - @change=${() => actions.addApp()}> -
-
-

- To add an application, tick its access modes, then type its URL and press Enter, - for example https://trusted.app or http://localhost:3000. With no modes ticked it gets Read access. -

- ${statusLine(state.appsStatus)} -
- ` -} + const podServerNodes = store.each(profile, ns.space('storage'), null, profile.doc()) + const podServers = podServerNodes.map(node => node.value) -function deleteAccountSection (state: PreferencesState): TemplateResult { - const { checking, links, servers } = state.deletion - let actionsArea: TemplateResult - if (checking) { - actionsArea = html`

Looking for your Pod provider's account deletion page…

` - } else if (links.length) { - actionsArea = html`${links.map(link => html` - - - ${links.length > 1 ? `Delete your account at ${link.server}` : 'Delete your account'} - (opens your Pod provider's site in a new tab) - `)}` - } else { - actionsArea = html` -

- We could not find an account deletion page for ${servers.length ? servers.join(', ') : 'your Pod'}. - Please contact your Pod provider to delete your account. -

` - } + const list = section.appendChild(dom.createElement('ul')) - return html` -
-

- Delete your Solid account - ${infoIcon('Account deletion is handled by your Pod provider. You will be taken to their site to confirm.')} -

-

If you no longer want your Solid Pod, you can delete your account.

-
- -
- Warning: -

When your account is deleted, all of the data is deleted and cannot be restored.

-
-
-
${actionsArea}
-
- ` + podServers.forEach(async server => { + const deletionLink = await generateDeletionLink(server, dom) + if (deletionLink) { + const listItem = list.appendChild(dom.createElement('li')) + listItem.appendChild(deletionLink) + } + }) } -function helpSection (): TemplateResult { - return html` -
-

Help & Support

-

- Your preferences are stored privately in your Pod. Trusted applications are listed in your - profile, and are used by your Pod to decide which apps may act on your behalf. -

-

- - SolidOS user guide - -

-
- ` +async function generateDeletionLink ( + podServer: string, + dom: HTMLDocument +): Promise { + const link = dom.createElement('a') + link.textContent = `Delete your account at ${podServer}` + const deletionUrl = await getDeletionUrlForServer(podServer) + if (typeof deletionUrl !== 'string') { + return null + } + link.href = deletionUrl + return link } -/* ---------------- Helpers ---------------- */ - -async function findDeletionLinks ( - store: Store, - me: NamedNode, - deletion: PreferencesState['deletion'] -): Promise { - const servers = store.each(me, ns.space('storage'), null, me.doc()).map(node => node.value) - deletion.servers = servers - const results = await Promise.all(servers.map(async server => { - try { - const url = await getDeletionUrlForServer(server) - return url ? { server, url } : null - } catch { - return null - } - })) - deletion.links = results.filter((link): link is { server: string, url: string } => !!link) - deletion.checking = false +/** + * Hacky way to get the deletion link to a Pod + * + * This function infers the deletion link by assuming the URL structure of Node Solid server. + * In the future, Solid will hopefully provide a standardised way of discovering the deletion link: + * https://github.com/solidos/data-interoperability-panel/issues/18 + * + * If NSS is in multi-user mode (the case on inrupt.net and solid.community), the deletion URL for + * vincent.dev.inrupt.net would be at dev.inrupt.net/account/delete. In single-user mode, the + * deletion URL would be at vincent.dev.inrupt.net/account/delete. + * + * @param server Pod server containing the user's account. + * @returns URL of the page that Node Solid Server would offer to delete the account, or null if + * the URLs we tried give invalid responses. + */ +async function getDeletionUrlForServer ( + server: string +): Promise { + const singleUserUrl = new URL(server) + const multiUserUrl = new URL(server) + multiUserUrl.pathname = singleUserUrl.pathname = '/account/delete' + + const hostnameParts = multiUserUrl.hostname.split('.') + // Remove `vincent.` from `vincent.dev.inrupt.net`, for example: + multiUserUrl.hostname = hostnameParts.slice(1).join('.') + + const multiUserNssResponse = await fetch(multiUserUrl.href, { + method: 'HEAD' + }) + if (multiUserNssResponse.ok) { + return multiUserUrl.href + } + + const singleUserNssResponse = await fetch(singleUserUrl.href, { + method: 'HEAD' + }) + if (singleUserNssResponse.ok) { + return singleUserUrl.href + } + return null } -function messageOf (err: unknown): string { - return err instanceof Error ? err.message : String(err) +function createSection ( + container: Element, + dom: HTMLDocument, + title: string +): Element { + const section = container.appendChild(dom.createElement('div')) + section.style.border = '0.3em solid #418d99' + section.style.borderRadius = '0.5em' + section.style.padding = '0.7em' + section.style.marginTop = '0.7em' + + const titleElement = section.appendChild(dom.createElement('h3')) + titleElement.innerText = title + + return section } diff --git a/src/dashboard/preferencesData.ts b/src/dashboard/preferencesData.ts deleted file mode 100644 index fbf9e888..00000000 --- a/src/dashboard/preferencesData.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Data helpers for the Preferences view (basicPreferences pane). - * - * Kept free of DOM code so they can be unit tested against a plain rdflib store. - */ -import { IndexedFormula, NamedNode, Statement, st, sym } from 'rdflib' -import { ns } from 'solid-ui' -import { generateRandomString, getStatementsToAdd, getStatementsToDelete } from '../trustedApplications/trustedApplications.utils' - -/* ---------------- User types (roles) ---------------- */ - -export type UserRole = 'user' | 'powerUser' | 'developer' - -export interface RoleOption { - value: UserRole - label: string - description: string -} - -export const roleOptions: RoleOption[] = [ - { value: 'user', label: 'Regular user', description: 'The standard views of your data.' }, - { value: 'powerUser', label: 'Power user', description: 'A more complex interface with more powerful features.' }, - { value: 'developer', label: 'Developer', description: 'Extra views useful when building Solid apps, such as raw data panes.' } -] - -/** The RDF class recorded in the preferences file for each role. 'user' is the default and has no class. */ -export function roleClass (role: UserRole): NamedNode | null { - if (role === 'powerUser') return ns.solid('PowerUser') - if (role === 'developer') return ns.solid('Developer') - return null -} - -const roleClasses = (): NamedNode[] => [ns.solid('Developer'), ns.solid('PowerUser')] - -/** Read the user's role from their preferences file. Developer wins if several are set. */ -export function getUserRole (store: IndexedFormula, me: NamedNode, preferencesFile: NamedNode): UserRole { - if (store.holds(me, ns.rdf('type'), ns.solid('Developer'), preferencesFile.doc())) return 'developer' - if (store.holds(me, ns.rdf('type'), ns.solid('PowerUser'), preferencesFile.doc())) return 'powerUser' - return 'user' -} - -/** Statements to delete and insert so that the preferences file records exactly `role`. */ -export function roleChange ( - store: IndexedFormula, - me: NamedNode, - preferencesFile: NamedNode, - role: UserRole -): { deletions: Statement[], insertions: Statement[] } { - const doc = preferencesFile.doc() - const wanted = roleClass(role) - const deletions = roleClasses() - .filter(klass => !wanted || !klass.equals(wanted)) - .flatMap(klass => store.statementsMatching(me, ns.rdf('type'), klass, doc)) - const insertions = wanted && !store.holds(me, ns.rdf('type'), wanted, doc) - ? [st(me, ns.rdf('type'), wanted, doc)] - : [] - return { deletions, insertions } -} - -/* ---------------- Trusted applications ---------------- */ - -export const accessModes = ['Read', 'Write', 'Append', 'Control'] as const -export type AccessMode = typeof accessModes[number] - -export interface TrustedApp { - origin: string - modes: AccessMode[] -} - -/** The trusted applications listed in the user's profile, sorted by origin. */ -export function listTrustedApps (store: IndexedFormula, me: NamedNode): TrustedApp[] { - return store.each(me, ns.acl('trustedApp'), null, null) - .flatMap(app => store.each(app as NamedNode, ns.acl('origin'), null, null).map(origin => ({ - origin: origin.value, - modes: accessModes.filter(mode => - store.holds(app as NamedNode, ns.acl('mode'), ns.acl(mode), null)) - }))) - .sort((a, b) => a.origin.localeCompare(b.origin)) -} - -/** - * Turn what the user typed into an application origin such as https://app.example - * Returns null when it is not a usable http(s) URL. - */ -export function normalizeOrigin (input: string): string | null { - const text = input.trim() - if (!text) return null - try { - const url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(text) ? text : `https://${text}`) - if (url.protocol !== 'https:' && url.protocol !== 'http:') return null - if (!url.hostname) return null - return url.origin - } catch { - return null - } -} - -/** - * Statements to delete and insert to set the modes of the app at `origin`. - * Any existing entry for `origin` is replaced. With no modes the app is removed. - */ -export function trustedAppChange ( - store: IndexedFormula, - me: NamedNode, - origin: string, - modes: AccessMode[] -): { deletions: Statement[], insertions: Statement[] } { - const originNode = sym(origin) - // Match on the value, so an origin stored as a literal is found too - const storedOrigins = store.statementsMatching(null, ns.acl('origin'), null, null) - .map(statement => statement.object) - .filter(node => node.value === origin) - const deletions = dedupe(storedOrigins.flatMap(node => getStatementsToDelete(node as NamedNode, me, store, ns))) - const insertions = modes.length - ? getStatementsToAdd(originNode, generateRandomString(), modes.map(mode => ns.acl(mode).uri), me, ns) - : [] - return { deletions, insertions } -} - -function dedupe (statements: Statement[]): Statement[] { - const seen = new Set() - return statements.filter(statement => { - const key = statement.toNT() - if (seen.has(key)) return false - seen.add(key) - return true - }) -} - -/* ---------------- Account deletion ---------------- */ - -/** - * Find the page where the user can delete their account on a pod server. - * - * There is no standard way to discover this yet - * (https://github.com/solidos/data-interoperability-panel/issues/18), so this assumes the - * Node Solid Server layout: /account/delete on the server, or on the parent domain in - * multi-user mode (alice.example.net → example.net/account/delete). - */ -export async function getDeletionUrlForServer ( - server: string, - fetchFn: typeof fetch = fetch -): Promise { - const singleUserUrl = new URL(server) - singleUserUrl.pathname = '/account/delete' - singleUserUrl.search = singleUserUrl.hash = '' - - const candidates: string[] = [] - const hostnameParts = singleUserUrl.hostname.split('.') - if (hostnameParts.length > 2) { - const multiUserUrl = new URL(singleUserUrl.href) - multiUserUrl.hostname = hostnameParts.slice(1).join('.') - candidates.push(multiUserUrl.href) - } - candidates.push(singleUserUrl.href) - - for (const candidate of candidates) { - try { - const response = await fetchFn(candidate, { method: 'HEAD' }) - if (response.ok) return candidate - } catch { - // Unreachable or blocked by CORS: try the next candidate - } - } - return null -} diff --git a/src/dashboard/preferencesFormText.ttl b/src/dashboard/preferencesFormText.ttl new file mode 100644 index 00000000..98c414d8 --- /dev/null +++ b/src/dashboard/preferencesFormText.ttl @@ -0,0 +1,18 @@ +@prefix rdf: . +@prefix solid: . +@prefix ui: . +@prefix : <#>. + +:this "Basic preferences" ; + a ui:Form ; + ui:part :categorizeUser, :privateComment, :personalInformationHeading; + ui:parts ( :personalInformationHeading :privateComment :categorizeUser ). + +:personalInformationHeading a ui:Heading; + ui:contents "Personal information". + +:privateComment a ui:Comment; + ui:contents "This information is private.". + +:categorizeUser a ui:Classifier; + ui:label "Level of user"; ui:property rdf:type ; ui:category solid:User. diff --git a/test/unit/dashboard/basicPreferences.test.ts b/test/unit/dashboard/basicPreferences.test.ts deleted file mode 100644 index 01cc1d07..00000000 --- a/test/unit/dashboard/basicPreferences.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import * as $rdf from 'rdflib' -import { ns } from 'solid-ui' -import { screen, waitFor, within } from '@testing-library/dom' - -const { ensureLoadedPreferences } = vi.hoisted(() => ({ ensureLoadedPreferences: vi.fn() })) -vi.mock('solid-ui', async importOriginal => { - const actual = await importOriginal() - return { ...actual, login: { ...actual.login, ensureLoadedPreferences } } -}) - -import basicPreferencesPane from '../../../src/dashboard/basicPreferences' - -const me = $rdf.sym('https://alice.example/profile/card#me') -const prefs = $rdf.sym('https://alice.example/settings/prefs.ttl') - -function setup ({ editable = true, withPrefs = true } = {}) { - const store = $rdf.graph() as $rdf.Store - const update = vi.fn(async (deletions: $rdf.Statement[], insertions: $rdf.Statement[]) => { - store.remove(deletions) - insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) - }) - ;(store as any).updater = { editable: () => editable, update } - const app = $rdf.blankNode() - store.add(me, ns.acl('trustedApp'), app, me.doc()) - store.add(app, ns.acl('origin'), $rdf.sym('https://solid-ui.example.com'), me.doc()) - store.add(app, ns.acl('mode'), ns.acl('Read'), me.doc()) - store.add(me, ns.space('storage'), $rdf.sym('https://alice.example/'), me.doc()) - - ensureLoadedPreferences.mockResolvedValue({ - me, - preferencesFile: withPrefs ? prefs : undefined - } as any) - - const container = basicPreferencesPane.render(me, { - dom: document, - session: { store, paneRegistry: { byName: () => null } } - } as any) - document.body.appendChild(container) - return { store, update } -} - -afterEach(() => { - vi.restoreAllMocks() - document.body.replaceChildren() -}) - -describe('Preferences view', () => { - it('shows the sections of the design', async () => { - setup() - expect(await screen.findByRole('heading', { name: 'User types' })).toBeInTheDocument() - expect(screen.getByRole('heading', { name: /Manage your trusted applications/ })).toBeInTheDocument() - expect(screen.getByRole('heading', { name: /Delete your Solid account/ })).toBeInTheDocument() - expect(screen.getByRole('heading', { name: 'Help & Support' })).toBeInTheDocument() - expect(screen.queryByText(/Customize Theme/)).not.toBeInTheDocument() - }) - - it('saves the chosen role to the preferences file', async () => { - const { store, update } = setup() - const select = await screen.findByLabelText(/Role/) as HTMLSelectElement - expect(select.value).toBe('user') - select.value = 'developer' - select.dispatchEvent(new Event('change')) - await waitFor(() => expect(update).toHaveBeenCalled()) - expect(store.holds(me, ns.rdf('type'), ns.solid('Developer'), prefs)).toBe(true) - expect(await screen.findByText('Saved.')).toBeInTheDocument() - }) - - it('disables the role when the preferences file is unavailable', async () => { - setup({ withPrefs: false }) - const select = await screen.findByLabelText(/Role/) as HTMLSelectElement - expect(select.disabled).toBe(true) - expect(screen.getByText(/preferences file could not be loaded/)).toBeInTheDocument() - }) - - it('lists trusted apps and updates a mode when ticked', async () => { - const { update } = setup() - const row = (await screen.findByText('https://solid-ui.example.com')).closest('tr')! - const write = within(row).getByLabelText('Write access for https://solid-ui.example.com') as HTMLInputElement - expect(within(row).getByLabelText('Read access for https://solid-ui.example.com')).toBeChecked() - expect(write).not.toBeChecked() - write.click() - await waitFor(() => expect(update).toHaveBeenCalledTimes(1)) - await waitFor(() => expect(within(screen.getByText('https://solid-ui.example.com').closest('tr')!) - .getByLabelText('Write access for https://solid-ui.example.com')).toBeChecked()) - }) - - it('removes a trusted app with the trash button', async () => { - setup() - const remove = await screen.findByRole('button', { name: 'Remove https://solid-ui.example.com' }) - remove.click() - await waitFor(() => expect(screen.queryByText('https://solid-ui.example.com')).not.toBeInTheDocument()) - }) - - it('adds a new app on Enter and rejects invalid URLs', async () => { - setup() - const input = await screen.findByLabelText('New application URL') as HTMLInputElement - - input.value = 'not a url' - input.dispatchEvent(new Event('input')) - input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })) - expect(await screen.findByRole('alert')).toHaveTextContent(/valid application URL/) - - input.value = 'https://notepad.example.com/app' - input.dispatchEvent(new Event('input')) - input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })) - expect(await screen.findByText('https://notepad.example.com')).toBeInTheDocument() - }) - - it('explains when the profile cannot be edited', async () => { - setup({ editable: false }) - expect(await screen.findByText(/is not editable/)).toBeInTheDocument() - expect(screen.queryByRole('table')).not.toBeInTheDocument() - }) - - it('offers the account deletion page when one is found', async () => { - setup() - const link = await screen.findByRole('link', { name: /Delete your account/ }) - expect(link.getAttribute('href')).toMatch(/\/account\/delete$/) - }) -}) diff --git a/test/unit/dashboard/preferencesData.test.ts b/test/unit/dashboard/preferencesData.test.ts deleted file mode 100644 index abd8499e..00000000 --- a/test/unit/dashboard/preferencesData.test.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { describe, expect, it, vi } from 'vitest' -import * as $rdf from 'rdflib' -import { ns } from 'solid-ui' -import { - getDeletionUrlForServer, - getUserRole, - listTrustedApps, - normalizeOrigin, - roleChange, - trustedAppChange -} from '../../../src/dashboard/preferencesData' - -const me = $rdf.sym('https://alice.example/profile/card#me') -const prefs = $rdf.sym('https://alice.example/settings/prefs.ttl') - -describe('user role', () => { - it('defaults to a regular user', () => { - expect(getUserRole($rdf.graph(), me, prefs)).toBe('user') - }) - - it('reads power user and developer from the preferences file', () => { - const store = $rdf.graph() - store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) - expect(getUserRole(store, me, prefs)).toBe('powerUser') - store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) - expect(getUserRole(store, me, prefs)).toBe('developer') - }) - - it('ignores types stated in other documents', () => { - const store = $rdf.graph() - store.add(me, ns.rdf('type'), ns.solid('Developer'), me.doc()) - expect(getUserRole(store, me, prefs)).toBe('user') - }) - - it('replaces the old role with the new one', () => { - const store = $rdf.graph() - store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) - const { deletions, insertions } = roleChange(store, me, prefs, 'developer') - expect(deletions.map(s => s.object.value)).toEqual([ns.solid('PowerUser').value]) - expect(insertions).toHaveLength(1) - expect(insertions[0].object.value).toBe(ns.solid('Developer').value) - expect(insertions[0].why.value).toBe(prefs.value) - }) - - it('removes all role classes when going back to a regular user', () => { - const store = $rdf.graph() - store.add(me, ns.rdf('type'), ns.solid('PowerUser'), prefs) - store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) - const { deletions, insertions } = roleChange(store, me, prefs, 'user') - expect(deletions).toHaveLength(2) - expect(insertions).toHaveLength(0) - }) - - it('does nothing when the role is already set', () => { - const store = $rdf.graph() - store.add(me, ns.rdf('type'), ns.solid('Developer'), prefs) - expect(roleChange(store, me, prefs, 'developer')).toEqual({ deletions: [], insertions: [] }) - }) -}) - -describe('normalizeOrigin', () => { - it.each([ - ['https://trusted.app', 'https://trusted.app'], - ['https://sub.trusted.app/some/path?x=1', 'https://sub.trusted.app'], - ['http://localhost:3000', 'http://localhost:3000'], - ['trusted.app', 'https://trusted.app'], - [' https://Trusted.App/ ', 'https://trusted.app'] - ])('turns %s into %s', (input, expected) => { - expect(normalizeOrigin(input)).toBe(expected) - }) - - it.each(['', ' ', 'ftp://files.example', 'javascript:alert(1)', 'https://'])('rejects %j', input => { - expect(normalizeOrigin(input)).toBeNull() - }) -}) - -describe('trusted applications', () => { - function storeWithApp (origin: $rdf.NamedNode | $rdf.Literal, modes: string[]) { - const store = $rdf.graph() - const app = $rdf.blankNode() - store.add(me, ns.acl('trustedApp'), app, me.doc()) - store.add(app, ns.acl('origin'), origin, me.doc()) - modes.forEach(mode => store.add(app, ns.acl('mode'), ns.acl(mode), me.doc())) - return store - } - - it('lists apps with their modes in a fixed order', () => { - const store = storeWithApp($rdf.sym('https://b.example'), ['Write', 'Read']) - const other = $rdf.blankNode() - store.add(me, ns.acl('trustedApp'), other, me.doc()) - store.add(other, ns.acl('origin'), $rdf.sym('https://a.example'), me.doc()) - store.add(other, ns.acl('mode'), ns.acl('Control'), me.doc()) - expect(listTrustedApps(store, me)).toEqual([ - { origin: 'https://a.example', modes: ['Control'] }, - { origin: 'https://b.example', modes: ['Read', 'Write'] } - ]) - }) - - it('adds a new app with the chosen modes', () => { - const store = $rdf.graph() - const { deletions, insertions } = trustedAppChange(store, me, 'https://new.example', ['Read', 'Append']) - expect(deletions).toHaveLength(0) - expect(insertions).toHaveLength(4) - insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) - expect(listTrustedApps(store, me)).toEqual([{ origin: 'https://new.example', modes: ['Read', 'Append'] }]) - }) - - it('replaces the modes of an existing app', () => { - const store = storeWithApp($rdf.sym('https://app.example'), ['Read']) - const { deletions, insertions } = trustedAppChange(store, me, 'https://app.example', ['Read', 'Write']) - expect(deletions).toHaveLength(3) - store.remove(deletions) - insertions.forEach(s => store.add(s.subject, s.predicate, s.object, s.why)) - expect(listTrustedApps(store, me)).toEqual([{ origin: 'https://app.example', modes: ['Read', 'Write'] }]) - }) - - it('removes an app when no modes are left', () => { - const store = storeWithApp($rdf.sym('https://app.example'), ['Read', 'Control']) - const { deletions, insertions } = trustedAppChange(store, me, 'https://app.example', []) - expect(deletions).toHaveLength(4) - expect(insertions).toHaveLength(0) - }) - - it('finds apps whose origin was stored as a literal', () => { - const store = storeWithApp($rdf.lit('https://app.example'), ['Read']) - const { deletions } = trustedAppChange(store, me, 'https://app.example', []) - expect(deletions).toHaveLength(3) - }) -}) - -describe('getDeletionUrlForServer', () => { - const ok = { ok: true } as Response - const notFound = { ok: false } as Response - - it('prefers the multi-user server page', async () => { - const fetchFn = vi.fn().mockResolvedValue(ok) - await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)) - .resolves.toBe('https://solidcommunity.net/account/delete') - }) - - it('falls back to the single-user page', async () => { - const fetchFn = vi.fn() - .mockResolvedValueOnce(notFound) - .mockResolvedValueOnce(ok) - await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)) - .resolves.toBe('https://alice.solidcommunity.net/account/delete') - }) - - it('returns null when neither page exists or the fetch fails', async () => { - const fetchFn = vi.fn() - .mockRejectedValueOnce(new TypeError('CORS')) - .mockResolvedValueOnce(notFound) - await expect(getDeletionUrlForServer('https://alice.solidcommunity.net/', fetchFn)).resolves.toBeNull() - }) - - it('does not try a parent domain for a two-part host name', async () => { - const fetchFn = vi.fn().mockResolvedValue(notFound) - await getDeletionUrlForServer('https://example.net/', fetchFn) - expect(fetchFn).toHaveBeenCalledTimes(1) - expect(fetchFn).toHaveBeenCalledWith('https://example.net/account/delete', { method: 'HEAD' }) - }) -}) From 6dd9ae58064ed83bd85fd8762ae1a465300aad8d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 12:41:20 -0500 Subject: [PATCH 5/6] Preferences view: apply the new design as minimal changes (#710) Keeps the existing architecture: the User types section is still the solid-ui form, and the trusted applications table is still the trustedApplications pane embedded in the Preferences pane. - Layout: white cards on a light background, with a Help & Support box beside them (wraps below on narrow screens) - User types: the form is restyled after solid-ui generates it. The form drops its heading and comment and labels the field "Role". solid:User is declared as owl:disjointUnionOf PowerUser and Developer, so solid-ui renders a single dropdown instead of a multi-select - Trusted applications: one checkbox column per access mode (saved as soon as it changes), a trash button per app instead of Update/Delete, Enter in the last row to add. The notes list moves into the (i) tooltip. This also restyles the standalone trustedApplications pane - Delete account: new title and text, warning box, and a red outlined "Delete your account" button; detection of the deletion page is unchanged Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPTQkfDiRe2xrMJTcygUUo --- src/dashboard/basicPreferences.ts | 141 +++++++++++++++--- src/dashboard/ontologyData.ttl | 5 +- src/dashboard/preferencesFormText.ttl | 12 +- .../trustedApplications.dom.ts | 132 ++++++++-------- .../trustedApplications.view.ts | 56 ++++--- 5 files changed, 223 insertions(+), 123 deletions(-) diff --git a/src/dashboard/basicPreferences.ts b/src/dashboard/basicPreferences.ts index 2b40e1b1..38fc9966 100644 --- a/src/dashboard/basicPreferences.ts +++ b/src/dashboard/basicPreferences.ts @@ -1,6 +1,9 @@ import { PaneDefinition } from 'pane-registry' import { IndexedFormula, NamedNode, parse, Store } from 'rdflib' import { icons, login, ns, widgets } from 'solid-ui' +import '~icons/lucide/info' +import '~icons/lucide/trash-2' +import '~icons/lucide/triangle-alert' import ontologyData from './ontologyData.ttl' import preferencesFormText from './preferencesFormText.ttl' @@ -20,12 +23,17 @@ export const basicPreferencesPane: PaneDefinition = { function complainIfBad (ok: Boolean, mess: any) { if (ok) return - container.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) + main.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) } + // Two columns, as in the design: the sections, and Help & Support beside them const container = dom.createElement('div') + container.setAttribute('style', styles.layout) + const main = container.appendChild(dom.createElement('div')) + main.setAttribute('style', styles.mainColumn) + addHelpSection(container, dom) - const formArea = setupUserTypesSection(container, dom) + const formArea = setupUserTypesSection(main, dom) function loadData (doc: NamedNode, turtle: String) { doc = doc.doc() // remove # from URI if nec @@ -67,15 +75,15 @@ export const basicPreferencesPane: PaneDefinition = { renderContext.preferencesFile, complainIfBad ) - appendedForm.style.borderStyle = 'none' + styleForm(appendedForm, dom) const trustedApplicationsView = context.session.paneRegistry.byName('trustedApplications') if (trustedApplicationsView) { - container.appendChild(trustedApplicationsView.render(null, context)) + main.appendChild(trustedApplicationsView.render(null, context)) } // @@ TODO Remove need for casting as any and bang (!) syntax - addDeleteSection(container, store, renderContext.me!, dom) + addDeleteSection(main, store, renderContext.me!, dom) } doRender() @@ -91,17 +99,33 @@ function setupUserTypesSection ( const formContainer = createSection(container, dom, 'User types') const description = formContainer.appendChild(dom.createElement('p')) - description.innerText = 'Here you can self-assign user types to help the data browser know which views you would like to access.' + description.setAttribute('style', styles.description) + description.textContent = 'The options presented to you when viewing data can be customised based on your role. ' - const userTypesLink = formContainer.appendChild(dom.createElement('a')) + const userTypesLink = description.appendChild(dom.createElement('a')) userTypesLink.href = 'https://github.com/solidos/userguide/#role' - userTypesLink.innerText = 'Read more' + userTypesLink.textContent = 'Read more' const formArea = formContainer.appendChild(dom.createElement('div')) return formArea } +/** + * The form is generated by solid-ui with its own inline styles. + * Restyle the generated elements to match the Preferences design. + */ +function styleForm (form: HTMLElement, dom: HTMLDocument): void { + form.style.border = 'none' + form.style.paddingLeft = '0' + form.querySelectorAll('.formFieldName').forEach(label => { + label.setAttribute('style', styles.fieldLabel) + label.querySelectorAll('a').forEach(link => link.setAttribute('style', 'color: inherit; text-decoration: none;')) + label.appendChild(infoIcon(dom, 'Power users and developers are offered extra views of their data. This is private, and stored in your preferences file.')) + }) + form.querySelectorAll('select').forEach(select => select.setAttribute('style', styles.select)) +} + export default basicPreferencesPane // ends @@ -112,18 +136,37 @@ function addDeleteSection ( profile: NamedNode, dom: HTMLDocument ): void { - const section = createSection(container, dom, 'Delete account') + const section = createSection(container, dom, 'Delete your Solid account', + 'Account deletion is handled by your Pod provider. You will be taken to their site to confirm.') + + const description = section.appendChild(dom.createElement('p')) + description.setAttribute('style', styles.description) + description.textContent = 'If you no longer want your Solid Pod, you can delete your account.' + + const warning = section.appendChild(dom.createElement('div')) + warning.setAttribute('style', styles.warning) + warning.setAttribute('role', 'note') + const warningIcon = warning.appendChild(dom.createElement('icon-lucide-triangle-alert')) + warningIcon.setAttribute('aria-hidden', 'true') + warningIcon.setAttribute('style', 'flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px;') + const warningText = warning.appendChild(dom.createElement('div')) + const warningTitle = warningText.appendChild(dom.createElement('strong')) + warningTitle.setAttribute('style', 'font-weight: 500;') + warningTitle.textContent = 'Warning:' + const warningBody = warningText.appendChild(dom.createElement('p')) + warningBody.setAttribute('style', 'margin: 8px 0 0; color: var(--color-text-secondary, #4a5565);') + warningBody.textContent = 'When your account is deleted, all of the data is deleted and cannot be restored.' const podServerNodes = store.each(profile, ns.space('storage'), null, profile.doc()) const podServers = podServerNodes.map(node => node.value) - const list = section.appendChild(dom.createElement('ul')) + const list = section.appendChild(dom.createElement('div')) + list.setAttribute('style', 'display: flex; flex-wrap: wrap; gap: 8px;') podServers.forEach(async server => { const deletionLink = await generateDeletionLink(server, dom) if (deletionLink) { - const listItem = list.appendChild(dom.createElement('li')) - listItem.appendChild(deletionLink) + list.appendChild(deletionLink) } }) } @@ -133,7 +176,12 @@ async function generateDeletionLink ( dom: HTMLDocument ): Promise { const link = dom.createElement('a') - link.textContent = `Delete your account at ${podServer}` + link.setAttribute('style', styles.dangerButton) + link.setAttribute('title', `Delete your account at ${podServer}`) + const icon = link.appendChild(dom.createElement('icon-lucide-trash-2')) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 14px; height: 14px;') + link.appendChild(dom.createTextNode('Delete your account')) const deletionUrl = await getDeletionUrlForServer(podServer) if (typeof deletionUrl !== 'string') { return null @@ -187,16 +235,71 @@ async function getDeletionUrlForServer ( function createSection ( container: Element, dom: HTMLDocument, - title: string + title: string, + info?: string ): Element { const section = container.appendChild(dom.createElement('div')) - section.style.border = '0.3em solid #418d99' - section.style.borderRadius = '0.5em' - section.style.padding = '0.7em' - section.style.marginTop = '0.7em' + section.setAttribute('style', styles.card) const titleElement = section.appendChild(dom.createElement('h3')) - titleElement.innerText = title + titleElement.setAttribute('style', styles.cardTitle) + titleElement.textContent = title + if (info) titleElement.appendChild(infoIcon(dom, info)) return section } + +function addHelpSection (container: Element, dom: HTMLDocument): void { + const aside = container.appendChild(dom.createElement('aside')) + aside.setAttribute('style', styles.aside) + const section = aside.appendChild(dom.createElement('div')) + section.setAttribute('style', styles.card + ' padding: 16px;') + + const title = section.appendChild(dom.createElement('h3')) + title.setAttribute('style', 'margin: 0 0 8px; font-size: 1rem; font-weight: 600;') + title.textContent = 'Help & Support' + + const text = section.appendChild(dom.createElement('p')) + text.setAttribute('style', styles.description) + text.textContent = 'Your preferences are stored privately in your Pod. Trusted applications are listed in your profile. ' + const link = text.appendChild(dom.createElement('a')) + link.href = 'https://solidos.github.io/userguide/' + link.target = '_blank' + link.rel = 'noopener noreferrer' + link.textContent = 'SolidOS user guide' +} + +/** A small (i) icon whose tooltip explains a section or field */ +export function infoIcon (dom: HTMLDocument, text: string): HTMLElement { + const span = dom.createElement('span') + span.setAttribute('role', 'img') + span.setAttribute('aria-label', text) + span.setAttribute('title', text) + span.setAttribute('tabindex', '0') + span.setAttribute('style', 'display: inline-flex; width: 16px; height: 16px; color: var(--color-text-secondary, #4a5565); cursor: help;') + const icon = span.appendChild(dom.createElement('icon-lucide-info')) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 16px; height: 16px;') + return span +} + +/** Inline styles for the Preferences design (SolidOS/solid-panes#710) */ +const styles = { + layout: 'display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; padding: 16px; ' + + 'background: var(--solid-ui-color-slate-50, #f8fafc); color: var(--color-text, #101828);', + mainColumn: 'display: flex; flex-direction: column; gap: 16px; flex: 1 1 480px; min-width: 0;', + aside: 'flex: 0 1 280px;', + card: 'background: var(--solid-ui-color-white, #ffffff); border: 1px solid var(--solid-ui-color-slate-200, #e2e8f0); ' + + 'border-radius: 5px; padding: 24px; box-sizing: border-box;', + cardTitle: 'display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1.125rem; font-weight: 500;', + description: 'margin: 0 0 16px; color: var(--color-text-secondary, #4a5565); font-size: 0.875rem; line-height: 1.5;', + fieldLabel: 'display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-weight: 500;', + select: 'width: 100%; max-width: 340px; min-height: 40px; padding: 8px 12px; margin: 0; ' + + 'border: 1px solid var(--solid-ui-color-gray-300, #d1d5dc); border-radius: 5px; ' + + 'background: var(--solid-ui-color-white, #ffffff); font: inherit; font-size: 0.875rem;', + warning: 'display: flex; gap: 8px; margin-bottom: 24px; padding: 20px 24px; border-radius: 5px; ' + + 'background: var(--solid-ui-color-red-50, #fef2f2); color: var(--solid-ui-color-red-600, #dc2626); font-size: 0.875rem;', + dangerButton: 'display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; ' + + 'border: 1px solid var(--solid-ui-color-red-600, #dc2626); border-radius: 5px; background: var(--solid-ui-color-white, #ffffff); ' + + 'color: var(--solid-ui-color-red-600, #dc2626); font-size: 0.875rem; font-weight: 500; text-decoration: none;' +} diff --git a/src/dashboard/ontologyData.ttl b/src/dashboard/ontologyData.ttl index 09393365..7a2da7fc 100644 --- a/src/dashboard/ontologyData.ttl +++ b/src/dashboard/ontologyData.ttl @@ -2,6 +2,7 @@ @prefix rdfs: . @prefix solid: . @prefix foaf: . +@prefix owl: . @prefix schema: . @prefix ui: . @prefix vcard: . @@ -10,7 +11,9 @@ solid:User a rdfs:Class; rdfs:label "user"@en, "utilisateur"@fr; rdfs:comment """Any person who might use a Solid-based system"""; - rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual. + rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual; + # One role at a time, so the preferences form shows a single dropdown + owl:disjointUnionOf ( solid:PowerUser solid:Developer ). # Since these options are opt-in, it is a bit strange to have new users opt in # That they are new users - also we do not use this class for anything specific diff --git a/src/dashboard/preferencesFormText.ttl b/src/dashboard/preferencesFormText.ttl index 98c414d8..feddf795 100644 --- a/src/dashboard/preferencesFormText.ttl +++ b/src/dashboard/preferencesFormText.ttl @@ -5,14 +5,8 @@ :this "Basic preferences" ; a ui:Form ; - ui:part :categorizeUser, :privateComment, :personalInformationHeading; - ui:parts ( :personalInformationHeading :privateComment :categorizeUser ). - -:personalInformationHeading a ui:Heading; - ui:contents "Personal information". - -:privateComment a ui:Comment; - ui:contents "This information is private.". + ui:part :categorizeUser; + ui:parts ( :categorizeUser ). :categorizeUser a ui:Classifier; - ui:label "Level of user"; ui:property rdf:type ; ui:category solid:User. + ui:label "Role"; ui:property rdf:type ; ui:category solid:User. diff --git a/src/trustedApplications/trustedApplications.dom.ts b/src/trustedApplications/trustedApplications.dom.ts index 404b870c..4ace6010 100644 --- a/src/trustedApplications/trustedApplications.dom.ts +++ b/src/trustedApplications/trustedApplications.dom.ts @@ -1,6 +1,7 @@ import { NamedNode, Statement, sym } from 'rdflib' import { ns } from 'solid-ui' import { store } from 'solid-logic' +import '~icons/lucide/trash-2' import { generateRandomString, getStatementsToAdd, getStatementsToDelete } from './trustedApplications.utils' interface FormElements { @@ -14,14 +15,15 @@ interface FormElements { export function createApplicationTable (subject: NamedNode) { const applicationsTable = createElement('table', { - class: 'results' + class: 'results', + style: styles.table }) - // creating headers + // creating headers: one column per access mode, as in the Preferences design const header = createContainer('tr', [ - createText('th', 'Application URL'), - createText('th', 'Access modes'), - createText('th', 'Actions') + createText('th', 'Application URL', { style: styles.th + styles.urlCell }), + ...modes.map(mode => createText('th', mode, { style: styles.th })), + createText('th', '', { style: styles.th }) ]) applicationsTable.appendChild(header); @@ -80,6 +82,8 @@ function createApplicationEntry ( { class: 'textinput', placeholder: 'Write new URL here', + 'aria-label': origin ? 'Application URL' : 'New application URL (press Enter to add)', + style: styles.urlInput, value: origin ? origin.value : '' }, {}, @@ -93,50 +97,24 @@ function createApplicationEntry ( submit: addOrEditApplication } ) - ]), - createContainer('td', [ - createContainer( - 'form', - createModesInput(trustedApplicationState), - {}, - { - submit: addOrEditApplication - } - ) - ]), - createContainer('td', [ - createContainer( - 'form', - origin - ? [ - createText('button', 'Update', { - class: 'controlButton', - style: 'background: LightGreen;' - }), - createText( - 'button', - 'Delete', - { - class: 'controlButton', - style: 'background: LightCoral;' - }, - { - click: removeApplication - } - ) - ] - : [ - createText('button', 'Add', { - class: 'controlButton', - style: 'background: LightGreen;' - }) - ], - {}, - { - submit: addOrEditApplication - } - ) - ]) + ], { style: styles.td + styles.urlCell }), + // Ticking a mode saves straight away for an existing app; + // for the new-app row, the modes are saved when the URL is entered + ...createModesInput(trustedApplicationState, origin ? addOrEditApplication : null) + .map(checkbox => createContainer('td', [checkbox], { style: styles.td })), + createContainer('td', origin + ? [ + createContainer('button', [createIcon('icon-lucide-trash-2')], { + type: 'button', + class: 'controlButton', + title: 'Remove', + 'aria-label': `Remove ${origin.value}`, + style: styles.trashButton + }, { + click: removeApplication + }) + ] + : [], { style: styles.td + 'text-align: right;' }) ]) function addOrEditApplication (event: Event) { @@ -251,26 +229,50 @@ export function createText ( return element } -function createModesInput ({ appModes, formElements }: { +const modes = ['Read', 'Write', 'Append', 'Control'] + +/** A 16px decorative icon, e.g. */ +export function createIcon (tagName: string): HTMLElement { + const icon = document.createElement(tagName) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 16px; height: 16px;') + return icon +} + +function createModesInput ({ appModes, formElements, origin }: { appModes: NamedNode[] formElements: FormElements -}) { - return ['Read', 'Write', 'Append', 'Control'].map(mode => { + origin: NamedNode | null +}, onChange: ((event: Event) => void) | null) { + return modes.map(mode => { const isChecked = appModes.some( appMode => appMode.value === ns.acl(mode).value ) - return createContainer('label', [ - createElement( - 'input', - { - type: 'checkbox', - ...(isChecked ? { checked: '' } : {}), - value: ns.acl(mode).uri - }, - {}, - element => formElements.modes.push(element) - ), - createText('span', mode) - ]) + return createElement( + 'input', + { + type: 'checkbox', + ...(isChecked ? { checked: '' } : {}), + value: ns.acl(mode).uri, + 'aria-label': `${mode} access for ${origin ? origin.value : 'the new application'}`, + style: styles.checkbox + }, + onChange ? { change: onChange } : {}, + element => formElements.modes.push(element) + ) }) } + +/** Inline styles for the trusted applications table, as in the Preferences design (#710) */ +const border = '1px solid var(--solid-ui-color-slate-200, #e2e8f0)' +const styles = { + table: `width: 100%; border-collapse: separate; border-spacing: 0; border: ${border}; border-bottom: none; border-radius: 5px; font-size: 0.875rem;`, + th: 'padding: 12px 16px; text-align: left; font-weight: 500; background: color-mix(in srgb, var(--solid-ui-color-primary, #7c4dff) 10%, #ffffff); ' + + `border-bottom: ${border};`, + td: `padding: 12px 16px; border-bottom: ${border}; vertical-align: middle;`, + urlCell: `border-right: ${border}; min-width: 240px;`, + urlInput: 'width: 100%; box-sizing: border-box; padding: 4px 0; border: none; background: transparent; font: inherit; color: inherit;', + checkbox: 'width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--solid-ui-color-orange-500, #f97316);', + trashButton: 'display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; ' + + 'border: none; border-radius: 5px; background: transparent; color: var(--solid-ui-color-gray-400, #9ca3af); cursor: pointer;' +} diff --git a/src/trustedApplications/trustedApplications.view.ts b/src/trustedApplications/trustedApplications.view.ts index 9cfe21bd..1c0113cb 100644 --- a/src/trustedApplications/trustedApplications.view.ts +++ b/src/trustedApplications/trustedApplications.view.ts @@ -2,9 +2,12 @@ import { PaneDefinition } from 'pane-registry' import { NamedNode } from 'rdflib' import { icons, login, widgets } from 'solid-ui' import { store } from 'solid-logic' -import { createApplicationTable, createContainer, createText } from './trustedApplications.dom' +import '~icons/lucide/info' +import { createApplicationTable, createIcon, createText } from './trustedApplications.dom' -const thisColor = '#418d99' +const cardStyle = 'background: var(--solid-ui-color-white, #ffffff); border: 1px solid var(--solid-ui-color-slate-200, #e2e8f0); ' + + 'border-radius: 5px; padding: 24px; box-sizing: border-box;' +const descriptionStyle = 'margin: 0 0 16px; color: var(--color-text-secondary, #4a5565); font-size: 0.875rem; line-height: 1.5;' const trustedApplicationView: PaneDefinition = { global: true, @@ -15,17 +18,13 @@ const trustedApplicationView: PaneDefinition = { const dom = context.dom const div = dom.createElement('div') div.classList.add('trusted-applications-pane') - div.setAttribute( - 'style', - 'border: 0.3em solid ' + - thisColor + - '; border-radius: 0.5em; padding: 0.7em; margin-top:0.7em;' - ) + div.setAttribute('style', cardStyle) const table = div.appendChild(dom.createElement('table')) + table.setAttribute('style', 'width: 100%;') const main = table.appendChild(dom.createElement('tr')) const bottom = table.appendChild(dom.createElement('tr')) const statusArea = bottom.appendChild(dom.createElement('div')) - statusArea.setAttribute('style', 'padding: 0.7em;') + statusArea.setAttribute('style', 'padding: 0;') render(dom, main, statusArea).catch(err => statusArea.appendChild(widgets.errorMessageBlock(dom, err))) return div } @@ -41,7 +40,19 @@ async function render (dom, main, statusArea): Promise { } const editable = store.updater.editable(profile.uri, store) - main.appendChild(createText('h3', 'Manage your trusted applications')) + const notes = 'Trusted applications will get access to all resources that you have access to. ' + + 'You can limit which modes they have by default. They will not gain more access than you have.' + const heading = main.appendChild(createText('h3', 'Manage your trusted applications', { + style: 'display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1.125rem; font-weight: 500;' + })) + const info = heading.appendChild(createText('span', null, { + role: 'img', + 'aria-label': notes, + title: notes, + tabindex: '0', + style: 'display: inline-flex; width: 16px; height: 16px; color: var(--color-text-secondary, #4a5565); cursor: help;' + })) + info.appendChild(createIcon('icon-lucide-info')) if (!editable) { main.appendChild( @@ -50,30 +61,17 @@ async function render (dom, main, statusArea): Promise { return } - main.appendChild(createText('p', 'Here you can manage the applications you trust.')) + main.appendChild(createText('p', 'Before you can use third-party applications, you need to add them to the allowlist via the Trusted Application table.', { + style: descriptionStyle + })) const applicationsTable = createApplicationTable(subject) main.appendChild(applicationsTable) - main.appendChild(createText('h4', 'Notes')) - main.appendChild( - createContainer('ol', [ - main.appendChild( - createText( - 'li', - 'Trusted applications will get access to all resources that you have access to.' - ) - ), - main.appendChild( - createText('li', 'You can limit which modes they have by default.') - ), - main.appendChild( - createText('li', 'They will not gain more access than you have.') - ) - ]) - ) main.appendChild( - createText('p', 'Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.') + createText('p', 'To add an application, type its URL in the last row and press Enter. Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.', { + style: descriptionStyle + ' margin: 12px 0 0;' + }) ) } From 396539208ebe889abe33fb48bd6fc0b082051b91 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 25 Nov 2026 17:42:23 +0000 Subject: [PATCH 6/6] chore: update solidos dependencies (dev: solid-logic@6.2.1-0 solid-ui@5.1.1-0 pane-registry@5.1.2-0 activitystreams-pane@2.1.1-0 chat-pane@4.1.1-0 contacts-pane@4.1.1-0 folder-pane@4.1.5-0 issue-pane@4.1.1-0 meeting-pane@4.1.1-0 profile-pane@4.1.1-0 source-pane@4.1.1-0) (latest: rdflib@2.4.1) --- package-lock.json | 92 +++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1522c701..a326f880 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1971,9 +1971,9 @@ } }, "node_modules/@codemirror/commands": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.1.tgz", - "integrity": "sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==", + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.2.tgz", + "integrity": "sha512-NbH6Q9lmcXvf9s5/mMJIwL2Hjl2NEdsN/dDlezGnaFOQgNZ59dT7ndKUf21/PIjJacD/Ti2Ifi4TsBkO6WHvsg==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", @@ -2117,9 +2117,9 @@ "license": "MIT" }, "node_modules/@codemirror/view": { - "version": "6.43.15", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz", - "integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==", + "version": "6.44.0", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.44.0.tgz", + "integrity": "sha512-kAUekx35l9u64jW/NzdO054l80lz+ri+Z5ZFS+dMpMrCbG5pFiTz58twWcWghzBEInWno0SPaURNSCnHHvipnQ==", "license": "MIT", "dependencies": { "@codemirror/state": "^6.7.0", @@ -2863,9 +2863,9 @@ "license": "MIT" }, "node_modules/@lezer/common": { - "version": "1.5.6", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.6.tgz", - "integrity": "sha512-NZxu3q49ck+YYbEJPuIPIyFP37XneBvzPIarBHEXBLBVfkZqQieZ/Y2boYnGNYtmjpOZLnAKs/lwqtmDpi365w==", + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.7.tgz", + "integrity": "sha512-3+3PN+M/3xSjrlQz8/wBPOl+JYGJ+G37ZszHfnhphFwj41qPUPxsz4WEic3ZyVpL23rX1qefaGqz0lA7jGUqwg==", "license": "MIT" }, "node_modules/@lezer/css": { @@ -2900,9 +2900,9 @@ } }, "node_modules/@lezer/javascript": { - "version": "1.5.6", - "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz", - "integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==", + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.7.tgz", + "integrity": "sha512-o3Rn+TzKuN25sdILOZFXi8hz4K/ed4OK0I+QrAi7Zzn3tXRBZmfsQrZpLX47ZYK/rZU8Vu4jLkz4SOSYRzBfjw==", "license": "MIT", "dependencies": { "@lezer/common": "^1.2.0", @@ -2922,18 +2922,18 @@ } }, "node_modules/@lezer/lr": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.12.tgz", - "integrity": "sha512-On9HU4oMMiHPMkQDgoTnGahjgG5n/MkN38CgG77sMraKLL+3JBbeQNi1FcCXV9QRqwF9/BUXP3caHyJC1fBOTQ==", + "version": "1.4.13", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.13.tgz", + "integrity": "sha512-Ez6qF9rXdnR/7hTcA6kHq1uTcPV+17hyUFjiHBVYNi0a81TgbkC0SwiNvxcuUMkvX7phuhTHo+QAXh9L2kjGdg==", "license": "MIT", "dependencies": { "@lezer/common": "^1.0.0" } }, "node_modules/@lezer/markdown": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.1.tgz", - "integrity": "sha512-M5YmEcKWO4mJ45Y1hECwqyu8cLv25EiXOK554PVOvDOWOP0olwelHHQUWr9sjF+d1bENVhy0nfJ8E57XZUTiXg==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.2.tgz", + "integrity": "sha512-q0kGuKOFrKEMi8d3ExryIOAT5XwjW86x1JO5scQB7gcXr8LobgXP3l6Gq6ArpXUQLeDju9cwRHF2Axjk6VMhLQ==", "license": "MIT", "dependencies": { "@lezer/common": "^1.5.0", @@ -3737,9 +3737,9 @@ "license": "MIT" }, "node_modules/@types/estree": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", - "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.11.tgz", + "integrity": "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg==", "dev": true, "license": "MIT" }, @@ -3751,18 +3751,18 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.20.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", - "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "version": "22.20.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.7.tgz", + "integrity": "sha512-F/Mcc4pD3YwXQCG50hb8BjB5RmrOere6hge7n2XHf0V8tpkZOVEjwYv9Ql7n0MpMn8Bv7+q12P9w6UHsBm0Sfw==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" } }, "node_modules/@types/react": { - "version": "19.3.1", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.1.tgz", - "integrity": "sha512-HNTkBIm8zmHX8LUXX2vtZ/ONzehrV1J3abl2fUIiZ5qxTYRCj/z+rDeFwOltqCLl9lRdUTKWT41OLtYuFV/Arg==", + "version": "19.3.3", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.3.tgz", + "integrity": "sha512-K8uWpJc4teiuOPdiP1umjeA9rGMgVPiXuoL66fcS1QlwBT1WMqY8PORmub9FadopIs+RCW6siYEs7Lpq+vDlog==", "license": "MIT", "peer": true, "dependencies": { @@ -3805,9 +3805,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.16", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz", - "integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==", + "version": "7.0.17", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.17.tgz", + "integrity": "sha512-0c3zcBRlWmcKhcIQWckzkYncJRv5HHB8O32wO/FcWL8DDXWDJgiEF6SX9ThbTv5h/eZ+xJK+VvDjjQ+cQJhp3Q==", "dev": true, "license": "MIT", "engines": { @@ -5335,9 +5335,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.493", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.493.tgz", - "integrity": "sha512-/Wto2sKd0EpepzMqwSP2il2TNc+rnBDF6k1poCvhRKpaSSD4sLGRBE+FydqHs2QwcW9cXKLVDqnauzJy1oByYw==", + "version": "1.5.494", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.494.tgz", + "integrity": "sha512-Tph7ohL4Xc0ft3DXElYEIVTmPI3H0MtPCTdgtz5AwWGZG6q+vMiT3IzJ3RJX/HJQ8pYzeimQyvi6SsBTOS0nyQ==", "dev": true, "license": "ISC" }, @@ -8053,9 +8053,9 @@ } }, "node_modules/lucide": { - "version": "1.79.0", - "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.79.0.tgz", - "integrity": "sha512-y96g6/Pca8ZoMt1F8P2K3T5t1ABrFDeJW5h7IM2CyAGton1lbdMzHn4u0qAGI0j9nZ2OArUTqekDZyBTW2pRUQ==", + "version": "1.80.0", + "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.80.0.tgz", + "integrity": "sha512-3tsjW2GIkBNMYHlpnOUA4bP5jAh20iRHksM92tSsCzu24BktkK103HJfOqPybqJtDgYnY5NEf6LEyBiq0N+KjA==", "license": "ISC" }, "node_modules/lz-string": { @@ -10147,9 +10147,9 @@ "license": "MIT" }, "node_modules/tinyexec": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", - "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.4.0.tgz", + "integrity": "sha512-PV6lIcJQh57aFeJDwx16JNHmgFRh5xguzallrDW1qe8nAghYgr5MKz2K5k7wEyV/ygZhdnIAP8+HZSarHPBCsg==", "dev": true, "license": "MIT", "engines": { @@ -10184,22 +10184,22 @@ } }, "node_modules/tldts": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.5.tgz", - "integrity": "sha512-Hy6IImaWALzJOgCIss4gIFi4G0M9lqk95pFKCUVxQPZw+biZ1Pv6f28JpYgahpJB+BufA0HYsIU/aP/WIx3KRg==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.6.0.tgz", + "integrity": "sha512-IFk9SJW/EhTZMpJA1zRdP+69JK4NmJbMx1aRdJvLBR9em1k62eWiwolSWlDRpRdkaAnZ1dDCwFPmRPBNuLGGHA==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.5.5" + "tldts-core": "^7.6.0" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.5.tgz", - "integrity": "sha512-rEJz/8cJFY/bdF354gl14yxavbrIbvM+FcbkYVQ6CSCMQTJdUFUIm39TTWSiGPvcpQh7/F6qHrD3SkwwdgtDCw==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.6.0.tgz", + "integrity": "sha512-0By9U6fw2hNzfJAbBMuo1bsX/OyVlsj0wjGyMPV50RZKoLCRwXBOX0FQqgZDaMo2WjjaEW/ZGyVXicLUFTmXqQ==", "dev": true, "license": "MIT" },