forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsharingPane.js
More file actions
69 lines (57 loc) · 2.42 KB
/
sharingPane.js
File metadata and controls
69 lines (57 loc) · 2.42 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
65
66
67
68
69
/* Sharing Pane
**
** This outline pane allows a user to view and adjust the sharing -- accesss control lists
** for anything which has that capability.
**
** I am using in places single quotes strings like 'this'
** where internationalization ("i18n") is not a problem, and double quoted
** like "this" where the string is seen by the user and so I18n is an issue.
*/
// These used to be in js/init/icons.js but are better in the pane.
const UI = require('solid-ui')
module.exports = {
icon: UI.icons.iconBase + 'padlock-timbl.svg', // noun_locked_2160665_000000.svg padlock
// noun_123691.svg was rainbow
name: 'sharing',
// Does the subject deserve an contact pane?
label: function (subject) {
var kb = UI.store
var ns = UI.ns
var t = kb.findTypeURIs(subject)
if (t[ns.ldp('Resource').uri]) return 'Sharing' // @@ be more sophisticated?
if (t[ns.ldp('Container').uri]) return 'Sharing' // @@ be more sophisticated?
if (t[ns.ldp('BasicContainer').uri]) return 'Sharing' // @@ be more sophisticated?
// check being allowed to see/change shgaring?
return null // No under other circumstances
},
render: function (subject, dom) {
var kb = UI.store
var ns = UI.ns
var div = dom.createElement('div')
div.setAttribute('class', 'sharingPane')
var t = kb.findTypeURIs(subject)
var noun = 'file'
if (t[ns.ldp('BasicContainer').uri] || t[ns.ldp('Container').uri]) noun = 'folder'
var pane = dom.createElement('div')
var table = pane.appendChild(dom.createElement('table'))
table.setAttribute('style', 'font-size:120%; margin: 1em; border: 0.1em #ccc ;')
var statusRow = table.appendChild(dom.createElement('tr'))
var statusBlock = statusRow.appendChild(dom.createElement('div'))
statusBlock.setAttribute('style', 'padding: 2em;')
var MainRow = table.appendChild(dom.createElement('tr'))
var box = MainRow.appendChild(dom.createElement('table'))
// var bottomRow = table.appendChild(dom.createElement('tr'));
var context = { target: subject, me: null, noun: noun, div: pane, dom: dom, statusRegion: statusBlock }
var uri = UI.authn.currentUser()
context.me = uri
UI.aclControl.preventBrowserDropEvents(dom)
box.appendChild(UI.aclControl.ACLControlBox5(subject, dom, noun, kb, function (ok, body) {
if (!ok) {
box.innerHTML = 'ACL control box Failed: ' + body
}
}))
div.appendChild(pane)
return div
}
}
// ends