make it somewhat work

This commit is contained in:
Pierre Martin 2022-03-19 01:10:26 +01:00
parent 016c085f87
commit af80aff12b
4 changed files with 104 additions and 0 deletions

20
etc/csp_whitelist.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="commandbar" type="host">https://frames-*.commandbar.com</value>
</values>
</policy>
<policy id="frame-src">
<values>
<value id="commandbar" type="host">https://frames-*.commandbar.com</value>
</values>
</policy>
<policy id="style-src">
<values>
<value id="commandbar" type="host">https://frames-*.commandbar.com</value>
</values>
</policy>
</policies>
</csp_whitelist>

View File

@ -41,3 +41,8 @@ Test mode https://www.commandbar.com/docs/commands/overview#testing-commands
## Login ## Login
Opengento c'est trop beau ! Opengento c'est trop beau !
## TODO
- [ ] customize user `window.CommandBar.boot(userid)`
- [ ] make it work with session key

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="Magento\Framework\View\Element\Template" name="page.commandbar" template="Opengento_Commandbar::commandbar.phtml" />
<!-- <block class="Magento\AdminNotification\Block\ToolbarEntry" name="notification.messages" before="user" aclResource="Magento_AdminNotification::show_toolbar" template="Magento_AdminNotification::toolbar_entry.phtml"/> -->
</referenceContainer>
</body>
</page>

View File

@ -0,0 +1,64 @@
<script>
const COMMANDBAR_ID = "3a1b1160";
(function() {
var o = COMMANDBAR_ID,
n = ["Object.assign", "Symbol", "Symbol.for"].join("%2C"),
a = window;
function r(o, n) {
void 0 === n && (n = !1), "complete" !== document.readyState && window.addEventListener("load", r.bind(null, o, n), {
capture: !1,
once: !0
});
var a = document.createElement("script");
a.type = "text/javascript", a.async = n, a.src = o, document.head.appendChild(a)
}
function t() {
var n;
if (void 0 === a.CommandBar) {
delete a.__CommandBarBootstrap__;
var t = Symbol.for("CommandBar::configuration"),
e = Symbol.for("CommandBar::orgConfig"),
i = Symbol.for("CommandBar::disposed"),
m = Symbol.for("CommandBar::isProxy"),
l = Symbol.for("CommandBar::queue"),
c = Symbol.for("CommandBar::unwrap"),
d = [],
s = localStorage.getItem("commandbar.lc"),
u = s && s.includes("local") ? "http://localhost:8000" : "https://api.commandbar.com",
f = Object.assign(((n = {})[t] = {
uuid: o
}, n[e] = {}, n[i] = !1, n[m] = !0, n[l] = new Array, n[c] = function() {
return f
}, n), a.CommandBar),
p = ["addCommand", "boot", "getShortcuts"],
y = f;
Object.assign(f, {
shareCallbacks: function() {
return {}
},
shareContext: function() {
return {}
}
}), a.CommandBar = new Proxy(f, {
get: function(o, n) {
return n in y ? f[n] : p.includes(n) ? function() {
var o = Array.prototype.slice.call(arguments);
return new Promise((function(a, r) {
o.unshift(n, a, r), f[l].push(o)
}))
} : function() {
var o = Array.prototype.slice.call(arguments);
o.unshift(n), f[l].push(o)
}
}
}), null !== s && d.push("lc=" + s), d.push("version=2"), r(u + "/latest/" + o + "?" + d.join("&"), !0)
}
}
void 0 === Object.assign || "undefined" == typeof Symbol || void 0 === Symbol.for ? (a.__CommandBarBootstrap__ = t, r("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features=" + n)) : t();
})();
window.CommandBar.boot();
</script>