Skip to content

Commit d817ed9

Browse files
committed
Writing out use of window.location
Using suggested solution from Tim. Also made code a bit more verbose, to make it easier to fix hacks when we have a standard way of handling this.
1 parent af8cd60 commit d817ed9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/acl-control.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,18 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
615615
// @@ TODO: The methods used for targetIsStorage are HACKs - it should not be relied upon, and work is
616616
// @@ underway to standardize a behavior that does not rely upon this hack
617617
// @@ hopefully fixed as part of https://github.com/solid/data-interoperability-panel/issues/10
618-
const targetIsStorage = kb.holds(targetDoc, UI.ns.rdf('type'), UI.ns.space('Storage'), targetACLDoc) ||
619-
(window.location && window.location.pathname === '/')
618+
const targetIsStorage = kb.holds(targetDoc, UI.ns.rdf('type'), UI.ns.space('Storage'), targetACLDoc)
619+
const targetAclIsProtected = hasProtectedAcl(targetDoc)
620+
const targetIsProtected = targetIsStorage || targetAclIsProtected
620621

621-
if (!targetIsStorage && targetDocDir) {
622+
if (!targetIsProtected && targetDocDir) {
622623
UI.acl.getACLorDefault($rdf.sym(targetDocDir), function (ok2, p22, targetDoc2, targetACLDoc2, defaultHolder2, defaultACLDoc2) {
623624
if (ok2) {
624625
prospectiveDefaultHolder = p22 ? targetDoc2 : defaultHolder2
625626
}
626627
addDefaultButton(prospectiveDefaultHolder)
627628
})
628-
} else if (!targetIsStorage) {
629+
} else if (!targetIsProtected) {
629630
addDefaultButton()
630631
}
631632

@@ -691,4 +692,10 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
691692
renderBox()
692693
return table
693694
} // ACLControlBox
695+
696+
function hasProtectedAcl (targetDoc) {
697+
// @@ TODO: This is hacky way of knowing whether or not a certain ACL file can be removed
698+
// Hopefully we'll find a better, standardized solution to this - https://github.com/solid/specification/issues/37
699+
return targetDoc.uri === targetDoc.site().uri
700+
}
694701
// ends

0 commit comments

Comments
 (0)