Skip to content

Commit 4bed4df

Browse files
Trim connect-time warning, structure save-failure dialog into sections
Feedback from in-editor testing: the connect-time read-only warning was too wordy for a popup that appears on every connect to a read-only board, and the save-failure dialog was a wall of prose that's hard to scan at the moment a user actually has a problem. Connect-time warning is now a single line with a 'How to fix' link: Filesystem is read-only - you can browse files, but saving will fail until USB Mass Storage is released. [How to fix]. Save-failure dialog is now structured with real <p>, <strong>, <ul>, <code>, <em>, and <a> markup (MessageModal renders via innerHTML): Could not save '/code.py'. The board's filesystem is locked, usually because CIRCUITPY is mounted on a computer over USB. To fix: - Disconnect the USB cable, or - Disable USB Mass Storage in boot.py, then reset the board. Note: ejecting the drive in your OS isn't always enough on its own. [Disabling USB Mass Storage (Adafruit Learn)] Your edits are still here - save again once the filesystem is writable. CSS already handles anchor styling in #message; the <ul> uses a small inline margin to keep bullet indent compact inside the modal.
1 parent ca6ed80 commit 4bed4df

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

‎js/script.js‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,13 @@ async function checkReadOnly() {
331331
await showMessage(readOnly);
332332
return false;
333333
} else if (readOnly) {
334-
// Same wording as the per-save dialog, with the Learn-guide
335-
// link, so the very first popup users see at connect already
336-
// points them at the right fix.
334+
// Concise connect-time notice that the filesystem is read-only,
335+
// with a link to the Learn guide for users who want the fix now.
337336
const learnUrl = "https://learn.adafruit.com/getting-started-with-web-workflow-using-the-code-editor/device-setup#disabling-usb-mass-storage-3125964";
338-
const learnLabel = "Disabling USB Mass Storage (Adafruit Learn)";
339337
await showMessage(
340-
"Warning: the board's filesystem is read-only, usually because " +
341-
"CIRCUITPY is mounted on a computer over USB. You can browse and " +
342-
"open files, but saving will fail until the lock is released. " +
343-
"Disconnect the USB cable, or disable USB Mass Storage in boot.py, " +
344-
"then reset the board. (Ejecting the drive in your OS may not be " +
345-
`enough on its own.) <a href="${learnUrl}" target="_blank" rel="noopener noreferrer">${learnLabel}</a>.`
338+
"Filesystem is read-only — you can browse files, but saving " +
339+
"will fail until USB Mass Storage is released. " +
340+
`<a href="${learnUrl}" target="_blank" rel="noopener noreferrer">How to fix</a>.`
346341
);
347342
}
348343
return true;
@@ -616,18 +611,24 @@ async function saveFileContents(path) {
616611
// with `writeProtected` so we can treat them the same way.
617612
if (e && e.writeProtected) {
618613
setSaved(false);
619-
const hint = e.hint || "The filesystem is currently read-only.";
620-
let helpLink = "";
621-
if (e.helpUrl) {
622-
const label = e.helpLabel || "More info";
623-
// MessageModal renders via innerHTML, so a real <a>
624-
// tag is clickable. target=_blank + noopener so we
625-
// don't nav away from the editor.
626-
helpLink = ` <a href="${e.helpUrl}" target="_blank" rel="noopener noreferrer">${label}</a>.`;
627-
}
614+
const learnUrl = e.helpUrl || "https://learn.adafruit.com/getting-started-with-web-workflow-using-the-code-editor/device-setup#disabling-usb-mass-storage-3125964";
615+
const learnLabel = e.helpLabel || "Disabling USB Mass Storage (Adafruit Learn)";
616+
// MessageModal renders via innerHTML, so real markup
617+
// (sections, list, link) is fine. Sections separate the
618+
// 'what happened', 'why', and 'how to fix' so users can
619+
// scan instead of parsing a wall of prose.
628620
await showMessage(
629-
`Saving file '${workflow.currentFilename}' failed. ${hint}${helpLink} ` +
630-
`Your edits are still here in the editor -- save again once the board's filesystem is writable.`
621+
`<p><strong>Could not save '${workflow.currentFilename}'.</strong></p>` +
622+
`<p>The board's filesystem is locked, usually because ` +
623+
`CIRCUITPY is mounted on a computer over USB.</p>` +
624+
`<p><strong>To fix:</strong></p>` +
625+
`<ul style="margin: 0.25em 0 0.5em 1.25em; padding: 0;">` +
626+
`<li>Disconnect the USB cable, <em>or</em></li>` +
627+
`<li>Disable USB Mass Storage in <code>boot.py</code>, then reset the board.</li>` +
628+
`</ul>` +
629+
`<p><em>Note:</em> ejecting the drive in your OS isn't always enough on its own.</p>` +
630+
`<p><a href="${learnUrl}" target="_blank" rel="noopener noreferrer">${learnLabel}</a></p>` +
631+
`<p>Your edits are still here — save again once the filesystem is writable.</p>`
631632
);
632633
return false;
633634
}

0 commit comments

Comments
 (0)