-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathindex.tsx
More file actions
64 lines (52 loc) · 1.62 KB
/
Copy pathindex.tsx
File metadata and controls
64 lines (52 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* Profile Editing Pane
**
** Unlike most panes, this is available any place whatever the real subject,
** and allows the user to edit their own profile.
**
** Usage: paneRegistry.register('profile/profilePane')
** or standalone script adding onto existing mashlib.
*/
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import solidUi, { SolidUi } from 'solid-ui'
import { IndexedFormula } from 'rdflib'
import paneRegistry from 'pane-registry'
import { PaneDefinition } from '../types'
import { Container } from './container'
const nodeMode = (typeof module !== 'undefined')
let panes
let UI: SolidUi
if (nodeMode) {
UI = solidUi
panes = paneRegistry
} else { // Add to existing mashlib
panes = (window as any).panes
UI = panes.UI
}
const kb: IndexedFormula = UI.store
const thisPane: PaneDefinition = {
icon: UI.icons.iconBase + 'noun_15177.svg', // Looks like an A - could say it's for Applications?
name: 'trustedApplications',
label: function (subject) {
var types = kb.findTypeURIs(subject)
if (types[UI.ns.foaf('Person').uri] || types[UI.ns.vcard('Individual').uri]) {
return 'Manage your trusted applications'
}
return null
},
render: function (subject, _dom) {
const container = document.createElement('div')
UI.authn.solidAuthClient.currentSession().then((session: any) => {
ReactDOM.render(
<Container store={UI.store} subject={subject} session={session}/>,
container
)
})
return container
}
}
export default thisPane
if (!nodeMode) {
console.log('*** patching in live pane: ' + thisPane.name)
panes.register(thisPane)
}