Skip to content

Commit dd09534

Browse files
author
Tim Berners-Lee
committed
Add webapp selection to ACL pane; tweak trusted apps pane
1 parent c508b58 commit dd09534

3 files changed

Lines changed: 38 additions & 33 deletions

File tree

sharing/sharingPane.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const UI = require('solid-ui')
1313

1414
module.exports = {
1515

16-
icon: UI.icons.iconBase + 'noun_locked_2160665_000000.svg', // noun_locked_2160665_000000.svg padlock
16+
icon: UI.icons.iconBase + 'padlock-timbl.svg', // noun_locked_2160665_000000.svg padlock
1717
// noun_123691.svg was rainbow
1818

1919
name: 'sharing',

trustedApplications/trustedApplicationsPane.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/* Profile Editing Pane
1+
/* Trusted Apps Editing Pane
22
**
33
** Unlike most panes, this is available any place whatever the real subject,
4-
** and allows the user to edit their own profile.
4+
** and allows the user to edit their own profil, sepciufically the set of apps they trust.
55
**
6-
** Usage: paneRegistry.register('profile/profilePane')
76
** or standalone script adding onto existing mashlib.
87
*/
98

9+
/* global alert */
1010
const nodeMode = (typeof module !== 'undefined')
1111
var panes, UI
1212

@@ -29,11 +29,11 @@ const thisPane = {
2929
name: 'trustedApplications',
3030

3131
label: function (subject) {
32-
var types = kb.findTypeURIs(subject)
33-
if (types[UI.ns.foaf('Person').uri] || types[UI.ns.vcard('Individual').uri]) {
34-
return 'Manage your trusted applications'
35-
}
36-
return null
32+
// var types = kb.findTypeURIs(subject) // Show aloways like home pane
33+
// if (types[UI.ns.foaf('Person').uri] || types[UI.ns.vcard('Individual').uri]) {
34+
return 'Manage your trusted applications'
35+
// }
36+
// return null
3737
},
3838

3939
render: function (subject, dom) {
@@ -53,7 +53,7 @@ const thisPane = {
5353
var profile = subject.doc()
5454
var editable = UI.store.updater.editable(profile.uri, kb)
5555

56-
main.appendChild(createText('h3', 'Manage your trusted applications'))
56+
main.appendChild(createText('h3', 'Manage your trusted Web Applications'))
5757

5858
if (!editable) {
5959
main.appendChild(UI.widgets.errorMessageBlock(dom, `Your profile ${subject.doc().uri} is not editable, so we cannot do much here.`))
@@ -67,27 +67,28 @@ const thisPane = {
6767

6868
main.appendChild(createText('h4', 'Notes'))
6969
main.appendChild(createContainer('ol', [
70-
main.appendChild(createText('li', 'Trusted applications will get access to all resources that you have access to.')),
71-
main.appendChild(createText('li', 'You can limit which modes they have by default.')),
72-
main.appendChild(createText('li', 'They will not gain more access than you have.'))
70+
main.appendChild(createText('li', 'If put a web app in this list, you can then add it to specific files or folders in the sharing pane.')),
71+
main.appendChild(createText('li', 'You can also give an app acecss to ALL of you data, by checking the box here. Only do that if you know the app very well.')),
72+
main.appendChild(createText('li', 'When a person uses the web app, they AND the app must both have access.'))
7373
]))
74-
main.appendChild(createText('p', 'Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.'))
74+
main.appendChild(createText('p', `Application URLs must be valid URL, without the trailing slash. Examples are https://mine.gihub.io,
75+
http://localhost:3000, https://trusted.app, and https://sub.trusted.app.`))
7576
}, err => {
7677
statusArea.appendChild(UI.widgets.errorMessageBlock(dom, err))
7778
})
7879
return div
7980
} // render()
8081
} //
8182

82-
function createApplicationTable(subject) {
83+
function createApplicationTable (subject) {
8384
var applicationsTable = createElement('table', {
8485
'class': 'results'
8586
})
8687

8788
// creating headers
8889
var header = createContainer('tr', [
8990
createText('th', 'Application URL'),
90-
createText('th', 'Access modes'),
91+
createText('th', 'Access modes to ALL your data'),
9192
createText('th', 'Actions')
9293
])
9394
applicationsTable.appendChild(header)
@@ -103,12 +104,12 @@ function createApplicationTable(subject) {
103104

104105
return applicationsTable
105106

106-
function updateTable() {
107+
function updateTable () {
107108
applicationsTable.parentElement.replaceChild(createApplicationTable(subject), applicationsTable)
108109
}
109110
}
110111

111-
function createApplicationEntry(subject, origin, appModes, updateTable) {
112+
function createApplicationEntry (subject, origin, appModes, updateTable) {
112113
var trustedApplicationState = { origin, appModes, formElements: { modes: [] } }
113114
return createContainer('tr', [
114115
createContainer('td', [
@@ -125,7 +126,7 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
125126
'class': 'controlButton',
126127
style: 'background: LightGreen;'
127128
}, {
128-
click: () => addOrEditApplication()
129+
click: () => addOrEditApplication(subject)
129130
}),
130131
createText('button', 'Delete', {
131132
'class': 'controlButton',
@@ -139,15 +140,16 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
139140
'class': 'controlButton',
140141
style: 'background: LightGreen;'
141142
}, {
142-
click: () => addOrEditApplication()
143+
click: () => addOrEditApplication(subject)
143144
})
144145
])
145146
])
146147

147-
function addOrEditApplication() {
148+
function addOrEditApplication (me) {
149+
const profile = me.doc()
148150
let origin
149151
try {
150-
origin = $rdf.sym(trustedApplicationState.formElements.origin.value)
152+
origin = $rdf.sym(trustedApplicationState.formElements.origin.value.trim())
151153
} catch (err) {
152154
return alert('Please provide an application URL you want to trust')
153155
}
@@ -160,19 +162,19 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
160162

161163
// add new triples
162164
const application = new $rdf.BlankNode()
163-
kb.add(subject, ns.acl('trustedApp'), application, subject)
164-
kb.add(application, ns.acl('origin'), origin, subject)
165+
kb.add(subject, ns.acl('trustedApp'), application, profile) // @@ Add to profile or preferences for private ones
166+
kb.add(application, ns.acl('origin'), origin, profile)
165167
trustedApplicationState.formElements.modes
166168
.filter(checkbox => checkbox.checked)
167169
.map(checkbox => $rdf.sym(checkbox.value))
168170
.forEach(mode => {
169-
kb.add(application, ns.acl('mode'), mode)
171+
kb.add(application, ns.acl('mode'), mode, profile)
170172
})
171173

172174
save()
173175
}
174176

175-
function removeApplication() {
177+
function removeApplication () {
176178
let origin
177179
try {
178180
origin = $rdf.sym(trustedApplicationState.formElements.origin.value)
@@ -189,7 +191,7 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
189191
save()
190192
}
191193

192-
function save() {
194+
function save () {
193195
// remove response triples - this should not be necessary, but do not know how to turn it off
194196
kb.statementsMatching(null, ns.link('response')).forEach(st => {
195197
kb.removeStatements([...kb.statementsMatching(st.subject)])
@@ -213,7 +215,7 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
213215
}
214216
}
215217

216-
function createElement(elementName, attributes = {}, eventListeners = {}, onCreated = null) {
218+
function createElement (elementName, attributes = {}, eventListeners = {}, onCreated = null) {
217219
var element = document.createElement(elementName)
218220
if (onCreated) {
219221
onCreated(element)
@@ -227,19 +229,19 @@ function createElement(elementName, attributes = {}, eventListeners = {}, onCrea
227229
return element
228230
}
229231

230-
function createContainer(elementName, children, attributes = {}, eventListeners = {}, onCreated = null) {
232+
function createContainer (elementName, children, attributes = {}, eventListeners = {}, onCreated = null) {
231233
var element = createElement(elementName, attributes, eventListeners, onCreated)
232234
children.forEach(child => element.appendChild(child))
233235
return element
234236
}
235237

236-
function createText(elementName, textContent, attributes = {}, eventListeners = {}, onCreated = null) {
238+
function createText (elementName, textContent, attributes = {}, eventListeners = {}, onCreated = null) {
237239
var element = createElement(elementName, attributes, eventListeners, onCreated)
238240
element.textContent = textContent
239241
return element
240242
}
241243

242-
function createModesInput({ appModes, formElements }) {
244+
function createModesInput ({ appModes, formElements }) {
243245
return ['Read', 'Write', 'Append', 'Control'].map(mode => {
244246
var isChecked = appModes.some(appMode => appMode.value === ns.acl(mode).value)
245247
return createContainer('label', [

ui/pane.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const panes = require('pane-registry')
77

88
module.exports = {
99

10-
icon: (module.__dirname || __dirname) + '22-builder.png',
10+
// noun_170702.svg' builder noun_122196.svg form
11+
icon: UI.icons.iconBase + 'noun_170702.svg',
1112

1213
name: 'ui',
1314

@@ -62,7 +63,9 @@ module.exports = {
6263
}
6364
if (!store) store = kb.any(kb.sym(docuri), ns.link('annotationStore'))
6465
if (!store) store = UI.widgets.defaultAnnotationStore(subject)
65-
if (!store) store = kb.sym('http://tabulator.org/wiki/ontologyAnnotation/common') // fallback
66+
67+
if (!store) store = kb.sym('https://formsregistry.solid.community/public/formRegistry/') // fallback
68+
// if (!store) store = kb.sym('http://tabulator.org/wiki/ontologyAnnotation/common') // fallback
6669

6770
// A fallback which gives a different store page for each ontology would be good @@
6871

0 commit comments

Comments
 (0)