pinokiod 8.0.13 → 8.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/views/setup.ejs +1 -30
- package/server/views/tools.ejs +2 -46
- package/test/tools-reinstall-ui.test.js +15 -56
package/package.json
CHANGED
package/server/views/setup.ejs
CHANGED
|
@@ -179,16 +179,11 @@
|
|
|
179
179
|
|
|
180
180
|
<div class="setup-secondary-actions">
|
|
181
181
|
<span class="task-inline-help">Not working?</span>
|
|
182
|
-
<button class="task-button" type="
|
|
182
|
+
<button class="task-button" type="submit" form="install-form">
|
|
183
183
|
<i class="fa-solid fa-trash" aria-hidden="true"></i>
|
|
184
184
|
<span>Try a fresh install</span>
|
|
185
185
|
</button>
|
|
186
186
|
</div>
|
|
187
|
-
|
|
188
|
-
<div class="reset-bin-loading hidden setup-reset-loading">
|
|
189
|
-
<i class="fa-solid fa-circle-notch fa-spin" aria-hidden="true"></i>
|
|
190
|
-
<span>Stand by. Do not close this window.</span>
|
|
191
|
-
</div>
|
|
192
187
|
</section>
|
|
193
188
|
</div>
|
|
194
189
|
</div>
|
|
@@ -383,30 +378,6 @@
|
|
|
383
378
|
showWaitError(error && error.message ? error.message : "Failed to restart Pinokio")
|
|
384
379
|
}
|
|
385
380
|
<% } %>
|
|
386
|
-
if (document.querySelector("#del-bin")) {
|
|
387
|
-
document.querySelector("#del-bin").addEventListener("click", async () => {
|
|
388
|
-
let proceed = confirm("Are you sure you wish to delete the bin folder?")
|
|
389
|
-
if (proceed) {
|
|
390
|
-
document.querySelector(".reset-bin-loading").classList.remove("hidden")
|
|
391
|
-
document.querySelector("#del-bin").classList.add("hidden")
|
|
392
|
-
let res = await PinokioPathRemoval.request((background) => fetch("/pinokio/delete", {
|
|
393
|
-
method: "post",
|
|
394
|
-
headers: {
|
|
395
|
-
"Content-Type": "application/json"
|
|
396
|
-
},
|
|
397
|
-
body: JSON.stringify({ type: "bin", background })
|
|
398
|
-
}))
|
|
399
|
-
document.querySelector(".reset-bin-loading").classList.add("hidden")
|
|
400
|
-
if (res.cancelled) {
|
|
401
|
-
document.querySelector("#del-bin").classList.remove("hidden")
|
|
402
|
-
} else if (res.error) {
|
|
403
|
-
alert(res.error)
|
|
404
|
-
} else {
|
|
405
|
-
document.querySelector("#install-form").submit()
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
})
|
|
409
|
-
}
|
|
410
381
|
})
|
|
411
382
|
</script>
|
|
412
383
|
<%- include('partials/app_common_scripts') %>
|
package/server/views/tools.ejs
CHANGED
|
@@ -154,9 +154,6 @@
|
|
|
154
154
|
justify-items: end;
|
|
155
155
|
min-width: 118px;
|
|
156
156
|
}
|
|
157
|
-
body.tools-page .tools-reinstall-form {
|
|
158
|
-
margin: 0;
|
|
159
|
-
}
|
|
160
157
|
body.tools-page .tools-bundle-status {
|
|
161
158
|
display: inline-flex;
|
|
162
159
|
align-items: center;
|
|
@@ -498,10 +495,10 @@
|
|
|
498
495
|
<span>Install</span>
|
|
499
496
|
</a>
|
|
500
497
|
<% } else { %>
|
|
501
|
-
<form
|
|
498
|
+
<form method="post" action="/pinokio/install">
|
|
502
499
|
<input type="hidden" name="requirements" value="<%= JSON.stringify(bundle.requirements) %>">
|
|
503
500
|
<input type="hidden" name="callback" value="/tools">
|
|
504
|
-
<button class="task-link-button" type="
|
|
501
|
+
<button class="task-link-button" type="submit">
|
|
505
502
|
<i class="fa-solid fa-rotate" aria-hidden="true"></i>
|
|
506
503
|
<span>Reinstall</span>
|
|
507
504
|
</button>
|
|
@@ -840,46 +837,6 @@
|
|
|
840
837
|
});
|
|
841
838
|
};
|
|
842
839
|
|
|
843
|
-
const registerToolsReinstall = () => {
|
|
844
|
-
document.querySelectorAll("[data-tools-reinstall]").forEach((button) => {
|
|
845
|
-
button.addEventListener("click", async () => {
|
|
846
|
-
const bundleTitle = button.dataset.bundleTitle || "this bundle";
|
|
847
|
-
const proceed = confirm(`Reinstall ${bundleTitle} from scratch? This removes the entire managed tools folder before reinstalling the selected bundle.`);
|
|
848
|
-
if (!proceed) return;
|
|
849
|
-
|
|
850
|
-
const form = button.closest("form");
|
|
851
|
-
const icon = button.querySelector("i");
|
|
852
|
-
const restoreButton = () => {
|
|
853
|
-
button.disabled = false;
|
|
854
|
-
button.removeAttribute("aria-busy");
|
|
855
|
-
if (icon) icon.classList.remove("fa-spin");
|
|
856
|
-
};
|
|
857
|
-
button.disabled = true;
|
|
858
|
-
button.setAttribute("aria-busy", "true");
|
|
859
|
-
if (icon) icon.classList.add("fa-spin");
|
|
860
|
-
let result;
|
|
861
|
-
try {
|
|
862
|
-
result = await PinokioPathRemoval.request((background) => fetch("/pinokio/delete", {
|
|
863
|
-
method: "post",
|
|
864
|
-
headers: { "Content-Type": "application/json" },
|
|
865
|
-
body: JSON.stringify({ type: "bin", background })
|
|
866
|
-
}));
|
|
867
|
-
} catch (error) {
|
|
868
|
-
restoreButton();
|
|
869
|
-
alert(error && error.message ? error.message : "Unable to reset managed tools.");
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
if (result.cancelled || result.error) {
|
|
874
|
-
restoreButton();
|
|
875
|
-
if (result.error) alert(result.error);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
form.submit();
|
|
879
|
-
});
|
|
880
|
-
});
|
|
881
|
-
};
|
|
882
|
-
|
|
883
840
|
document.addEventListener("DOMContentLoaded", function() {
|
|
884
841
|
const isPending = <%= pending ? 'true' : 'false' %>;
|
|
885
842
|
|
|
@@ -892,7 +849,6 @@
|
|
|
892
849
|
|
|
893
850
|
registerPackageInstallSheets();
|
|
894
851
|
registerPackageInstallForms();
|
|
895
|
-
registerToolsReinstall();
|
|
896
852
|
|
|
897
853
|
const tabs = document.querySelectorAll(".tools-tab-button");
|
|
898
854
|
const panels = document.querySelectorAll(".tools-package-panel");
|
|
@@ -6,6 +6,7 @@ const ejs = require("ejs")
|
|
|
6
6
|
const { JSDOM } = require("jsdom")
|
|
7
7
|
|
|
8
8
|
const viewPath = path.resolve(__dirname, "../server/views/tools.ejs")
|
|
9
|
+
const setupViewPath = path.resolve(__dirname, "../server/views/setup.ejs")
|
|
9
10
|
|
|
10
11
|
async function renderTools() {
|
|
11
12
|
const source = await fs.readFile(viewPath, "utf8")
|
|
@@ -27,43 +28,25 @@ async function renderTools() {
|
|
|
27
28
|
})
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
test("Tools reinstall
|
|
31
|
+
test("Tools reinstall immediately submits a fresh install request", async (t) => {
|
|
31
32
|
const html = await renderTools()
|
|
32
|
-
let request
|
|
33
33
|
let submission
|
|
34
34
|
const dom = new JSDOM(html, {
|
|
35
|
-
runScripts: "dangerously",
|
|
36
35
|
url: "http://localhost/tools",
|
|
37
|
-
beforeParse(window) {
|
|
38
|
-
window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} })
|
|
39
|
-
window.requestAnimationFrame = (callback) => window.setTimeout(callback, 0)
|
|
40
|
-
window.confirm = () => true
|
|
41
|
-
window.PinokioPathRemoval = {
|
|
42
|
-
request: async (remove) => {
|
|
43
|
-
request = await remove(false)
|
|
44
|
-
return { success: true }
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
window.fetch = async (url, options) => ({ url, options })
|
|
48
|
-
window.HTMLFormElement.prototype.submit = function () {
|
|
49
|
-
submission = {
|
|
50
|
-
action: new URL(this.action).pathname,
|
|
51
|
-
fields: Object.fromEntries(new window.FormData(this)),
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
36
|
})
|
|
56
37
|
t.after(() => dom.window.close())
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
const form = dom.window.document.querySelector('.tools-bundle-actions form[action="/pinokio/install"]')
|
|
40
|
+
form.addEventListener("submit", (event) => {
|
|
41
|
+
event.preventDefault()
|
|
42
|
+
submission = {
|
|
43
|
+
action: new URL(form.action).pathname,
|
|
44
|
+
fields: Object.fromEntries(new dom.window.FormData(form)),
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
const button = form.querySelector("button[type=submit]")
|
|
61
48
|
button.click()
|
|
62
|
-
await new Promise((resolve) => dom.window.setTimeout(resolve, 0))
|
|
63
49
|
|
|
64
|
-
assert.equal(request.url, "/pinokio/delete")
|
|
65
|
-
assert.equal(request.options.method, "post")
|
|
66
|
-
assert.deepEqual(JSON.parse(request.options.body), { type: "bin", background: false })
|
|
67
50
|
assert.deepEqual(submission, {
|
|
68
51
|
action: "/pinokio/install",
|
|
69
52
|
fields: {
|
|
@@ -73,32 +56,8 @@ test("Tools reinstall removes bin and submits the selected bundle", async (t) =>
|
|
|
73
56
|
})
|
|
74
57
|
})
|
|
75
58
|
|
|
76
|
-
test("
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const dom = new JSDOM(html, {
|
|
81
|
-
runScripts: "dangerously",
|
|
82
|
-
url: "http://localhost/tools",
|
|
83
|
-
beforeParse(window) {
|
|
84
|
-
window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} })
|
|
85
|
-
window.requestAnimationFrame = (callback) => window.setTimeout(callback, 0)
|
|
86
|
-
window.fetch = async () => ({ ok: true, json: async () => ({ status: "off" }) })
|
|
87
|
-
window.confirm = () => false
|
|
88
|
-
window.PinokioPathRemoval = {
|
|
89
|
-
request: async () => {
|
|
90
|
-
removed = true
|
|
91
|
-
return { success: true }
|
|
92
|
-
},
|
|
93
|
-
}
|
|
94
|
-
window.HTMLFormElement.prototype.submit = () => { submitted = true }
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
t.after(() => dom.window.close())
|
|
98
|
-
|
|
99
|
-
await new Promise((resolve) => dom.window.setTimeout(resolve, 0))
|
|
100
|
-
dom.window.document.querySelector("[data-tools-reinstall]").click()
|
|
101
|
-
await new Promise((resolve) => dom.window.setTimeout(resolve, 0))
|
|
102
|
-
assert.equal(removed, false)
|
|
103
|
-
assert.equal(submitted, false)
|
|
59
|
+
test("setup fresh install immediately submits the existing install form", async () => {
|
|
60
|
+
const source = await fs.readFile(setupViewPath, "utf8")
|
|
61
|
+
assert.match(source, /<button class="task-button" type="submit" form="install-form">/)
|
|
62
|
+
assert.doesNotMatch(source, /id="del-bin"|setup-reset-loading/)
|
|
104
63
|
})
|