Skip to content

Commit f2b7c78

Browse files
committed
This should fix timbl's PR
1 parent 1235f4c commit f2b7c78

3 files changed

Lines changed: 43 additions & 38 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: 37 additions & 35 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,48 +67,49 @@ 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)
9495

9596
// creating rows
9697
kb.each(subject, ns.acl('trustedApp'))
97-
.flatMap(app => kb.each(app, ns.acl('origin')).map(origin => ({appModes: kb.each(app, ns.acl('mode')), origin})))
98-
.sort(({origin: a}, {origin: b}) => a.value < b.value ? -1 : 1)
99-
.forEach(({appModes, origin}) => applicationsTable.appendChild(createApplicationEntry(subject, origin, appModes, updateTable)))
98+
.flatMap(app => kb.each(app, ns.acl('origin')).map(origin => ({ appModes: kb.each(app, ns.acl('mode')), origin })))
99+
.sort(({ origin: a }, { origin: b }) => a.value < b.value ? -1 : 1)
100+
.forEach(({ appModes, origin }) => applicationsTable.appendChild(createApplicationEntry(subject, origin, appModes, updateTable)))
100101

101102
// adding a row for new applications
102103
applicationsTable.appendChild(createApplicationEntry(subject, null, [ns.acl('Read')], updateTable))
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
var profile = subject.doc()
114115

@@ -127,7 +128,7 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
127128
'class': 'controlButton',
128129
style: 'background: LightGreen;'
129130
}, {
130-
click: () => addOrEditApplication()
131+
click: () => addOrEditApplication(subject)
131132
}),
132133
createText('button', 'Delete', {
133134
'class': 'controlButton',
@@ -141,25 +142,26 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
141142
'class': 'controlButton',
142143
style: 'background: LightGreen;'
143144
}, {
144-
click: () => addOrEditApplication()
145+
click: () => addOrEditApplication(subject)
145146
})
146147
])
147148
])
148149

149-
function addOrEditApplication() {
150-
var origin
150+
function addOrEditApplication (me) {
151+
const profile = me.doc()
152+
let origin
151153
try {
152-
origin = $rdf.sym(trustedApplicationState.formElements.origin.value)
154+
origin = $rdf.sym(trustedApplicationState.formElements.origin.value.trim())
153155
} catch (err) {
154156
return alert('Please provide an application URL you want to trust')
155157
}
156158

157159
var deletions = getStatementsToDelete(origin)
158-
var additions = getStatementsToAdd(origin)
160+
var additions = getStatementsToAdd(origin, profile)
159161
kb.updater.update(deletions, additions, handleUpdateResponse)
160162
}
161163

162-
function removeApplication() {
164+
function removeApplication () {
163165
var origin
164166
try {
165167
origin = $rdf.sym(trustedApplicationState.formElements.origin.value)
@@ -171,7 +173,7 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
171173
kb.updater.update(deletions, null, handleUpdateResponse)
172174
}
173175

174-
function getStatementsToAdd(origin) {
176+
function getStatementsToAdd (origin, profile) {
175177
var application = new $rdf.BlankNode(`bn_${generateRandomString()}`)
176178
return [
177179
$rdf.st(subject, ns.acl('trustedApp'), application, profile),
@@ -183,23 +185,23 @@ function createApplicationEntry(subject, origin, appModes, updateTable) {
183185
]
184186
}
185187

186-
function getStatementsToDelete(origin) {
188+
function getStatementsToDelete (origin) {
187189
var applicationStatements = kb.statementsMatching(null, ns.acl('origin'), origin)
188190
return applicationStatements.reduce((memo, st) => memo
189191
.concat(kb.statementsMatching(subject, ns.acl('trustedApp'), st.subject))
190192
.concat(kb.statementsMatching(st.subject)),
191193
[])
192194
}
193195

194-
function handleUpdateResponse(uri, success, errorBody) {
196+
function handleUpdateResponse (uri, success, errorBody) {
195197
if (success) {
196198
return updateTable()
197199
}
198200
console.error(uri, errorBody)
199201
}
200202
}
201203

202-
function createElement(elementName, attributes = {}, eventListeners = {}, onCreated = null) {
204+
function createElement (elementName, attributes = {}, eventListeners = {}, onCreated = null) {
203205
var element = document.createElement(elementName)
204206
if (onCreated) {
205207
onCreated(element)
@@ -213,19 +215,19 @@ function createElement(elementName, attributes = {}, eventListeners = {}, onCrea
213215
return element
214216
}
215217

216-
function createContainer(elementName, children, attributes = {}, eventListeners = {}, onCreated = null) {
218+
function createContainer (elementName, children, attributes = {}, eventListeners = {}, onCreated = null) {
217219
var element = createElement(elementName, attributes, eventListeners, onCreated)
218220
children.forEach(child => element.appendChild(child))
219221
return element
220222
}
221223

222-
function createText(elementName, textContent, attributes = {}, eventListeners = {}, onCreated = null) {
224+
function createText (elementName, textContent, attributes = {}, eventListeners = {}, onCreated = null) {
223225
var element = createElement(elementName, attributes, eventListeners, onCreated)
224226
element.textContent = textContent
225227
return element
226228
}
227229

228-
function createModesInput({ appModes, formElements }) {
230+
function createModesInput ({ appModes, formElements }) {
229231
return ['Read', 'Write', 'Append', 'Control'].map(mode => {
230232
var isChecked = appModes.some(appMode => appMode.value === ns.acl(mode).value)
231233
return createContainer('label', [
@@ -239,7 +241,7 @@ function createModesInput({ appModes, formElements }) {
239241
})
240242
}
241243

242-
function generateRandomString() {
244+
function generateRandomString () {
243245
return Math.random().toString(36).substring(7)
244246
}
245247

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)