Skip to content

Enforce more modal behavior on edit view dialogs (BL-16376)#7959

Open
StephenMcConnel wants to merge 2 commits into
Version6.4from
BL-16376-ImageWronglyDeleted
Open

Enforce more modal behavior on edit view dialogs (BL-16376)#7959
StephenMcConnel wants to merge 2 commits into
Version6.4from
BL-16376-ImageWronglyDeleted

Conversation

@StephenMcConnel

@StephenMcConnel StephenMcConnel commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This change is Reviewable

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR enforces more modal behavior on edit-view dialogs by (1) posting editView/setModalState from four React dialogs so the C# layer knows when a dialog is open, and (2) extending EditingView.SetModalState to also disable workspace navigation tabs (not just the page list) while any modal dialog is active.

  • Four dialogs (ProcessVideoProgressDialog, BookAndPageSettingsDialog, BookGridSetupDialog, LinkTargetChooserDialog) each add a useEffect that calls postBoolean(\"editView/setModalState\", …) on open/close, mirroring a pattern already used in LinkTargetChooserDialog.
  • EditingView.SetModalState gains a single _workspaceView?.SetTabsEnabled(!isActuallyModal) call, safely guarded with ?..
  • CollectionApi.HandleBookFileRequest drops the redundant HttpUtility.UrlDecode wrappers; RequiredParam already returns values decoded by HttpUtility.ParseQueryString, so the old code was double-decoding.

Important Files Changed

Filename Overview
src/BloomBrowserUI/bookEdit/ProcessVideoProgressDialog.tsx Adds a useEffect to post modal state to the C# layer when isOpen changes; missing required justification comment per AGENTS.md.
src/BloomBrowserUI/bookEdit/bookAndPageSettings/BookAndPageSettingsDialog.tsx Adds a guarded useEffect to post modal state when the dialog opens/closes; missing required justification comment per AGENTS.md.
src/BloomBrowserUI/react_components/BookGridSetup/BookGridSetupDialog.tsx Adds a guarded useEffect to post modal state when the dialog opens/closes; missing required justification comment per AGENTS.md.
src/BloomBrowserUI/react_components/LinkTargetChooser/LinkTargetChooserDialog.tsx Adds a guarded useEffect with a justifying comment to enforce modal state; correctly follows AGENTS.md pattern.
src/BloomExe/Edit/EditingView.cs Extends SetModalState to also call _workspaceView?.SetTabsEnabled, disabling workspace navigation tabs while any modal dialog is open.
src/BloomExe/web/controllers/CollectionApi.cs Removes explicit HttpUtility.UrlDecode calls from HandleBookFileRequest; correct because RequiredParam already returns values decoded by HttpUtility.ParseQueryString, so the old code was double-decoding.

Reviews (8): Last reviewed commit: "Enforce better modal behavior for edit v..." | Re-trigger Greptile

Comment thread src/BloomExe/web/BloomServer.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
Comment thread src/BloomExe/Book/BookStorage.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
@StephenMcConnel StephenMcConnel force-pushed the BL-16376-ImageWronglyDeleted branch from 8b36be9 to c74da97 Compare June 15, 2026 17:44

@StephenMcConnel StephenMcConnel left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephenMcConnel made 4 comments.
Reviewable status: 0 of 2 files reviewed, all discussions resolved.

Comment thread src/BloomExe/Book/BookStorage.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
@StephenMcConnel StephenMcConnel force-pushed the BL-16376-ImageWronglyDeleted branch from c74da97 to 4d2f61c Compare June 15, 2026 18:17
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@StephenMcConnel

Copy link
Copy Markdown
Contributor Author

AI reviews have been addressed.

@JohnThomson JohnThomson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all feels like only half a solution. See comment in the issue. At best this only helps when the bookref is in the SAME book. But it's very likely to be in a DIFFERENT book that we aren't even scanning.

@JohnThomson reviewed 2 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on StephenMcConnel).


src/BloomExe/Book/BookStorage.cs line 1351 at r2 (raw file):

            {
                /// I've seen a query parameter value that contains a literal ? (essentially the parameter itself
                /// contains a subquery string), which breaks the automatic parsing.  See BL-16376.

Have/should we fix the bug that causes Bloom to append ?book-id=... when it should use &book-id=...? (At least I think your comments in the issue and here indicate that something is making invalid URLs with more than one question mark? Or maybe the issue is that something may wrongly add ?thumbnail or similar AFTER the book-id and file params?) If we have fixed it, or think someone might one day, then don't we need to handle bookfile&book-id=...? But then bookfile is not part of the param string at all, so if book-id might not be the FIRST param and file the second one, there are still more possibilities to consider. My new "transparent=" param is always added as the last param (and properly uses & if there are others), but I'm not sure about the PDF publishing code that adds something like OriginalImage as a param.


src/BloomExe/Book/BookStorage.cs line 1356 at r2 (raw file):

                    "bookFile\\?book-id=([^?&]*)&file=([^?&]*)"
                );
                // Bloom doesn't allow + in its filenames.  If it exists here, it's an extra level of encoding.

Sorry, but it does. I tried adding an image called "giraffe + baby.jpg" and Bloom put exactly that file into the book folder, with url of "giraffe%20%2b%20baby.jpg".


src/BloomExe/Book/BookStorage.cs line 1361 at r2 (raw file):

                    filenames.Add(matches[0].Groups[2].Value.Replace("+", " "));
                }
            }

Should we consider the possibility that the book id is not for this book? If the image belongs to some other book in the collection, then it's not at risk for deletion here...I suppose it's a small risk that this book has an otherwise unused image that has the same name as the cover image of another book.

@StephenMcConnel StephenMcConnel force-pushed the BL-16376-ImageWronglyDeleted branch from 4d2f61c to 928f586 Compare June 22, 2026 18:30
@StephenMcConnel StephenMcConnel changed the title Handle bookInfo queries copied to img src attributes (BL-16376) Enforce more modal behavior on edit view dialogs (BL-16376) Jun 22, 2026

@StephenMcConnel StephenMcConnel left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've totally changed the pull request to keep the problem from happening in the front cover image.

@StephenMcConnel made 6 comments.
Reviewable status: 0 of 8 files reviewed, 3 unresolved discussions (waiting on JohnThomson and StephenMcConnel).


src/BloomExe/Book/BookStorage.cs line 1351 at r2 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Have/should we fix the bug that causes Bloom to append ?book-id=... when it should use &book-id=...? (At least I think your comments in the issue and here indicate that something is making invalid URLs with more than one question mark? Or maybe the issue is that something may wrongly add ?thumbnail or similar AFTER the book-id and file params?) If we have fixed it, or think someone might one day, then don't we need to handle bookfile&book-id=...? But then bookfile is not part of the param string at all, so if book-id might not be the FIRST param and file the second one, there are still more possibilities to consider. My new "transparent=" param is always added as the last param (and properly uses & if there are others), but I'm not sure about the PDF publishing code that adds something like OriginalImage as a param.

I removed this code.


src/BloomExe/Book/BookStorage.cs line 1356 at r2 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Sorry, but it does. I tried adding an image called "giraffe + baby.jpg" and Bloom put exactly that file into the book folder, with url of "giraffe%20%2b%20baby.jpg".

I hate URL encoding that isn't consistent and sometimes uses old standards and sometimes new.


src/BloomExe/Book/BookStorage.cs line 1361 at r2 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Should we consider the possibility that the book id is not for this book? If the image belongs to some other book in the collection, then it's not at risk for deletion here...I suppose it's a small risk that this book has an otherwise unused image that has the same name as the cover image of another book.

I've removed this code altogether. I fixed code in another place that was doubly decoding and changing a valid + character to a space before looking for a file.

Comment thread src/BloomExe/web/BloomServer.cs Outdated
Comment thread src/BloomExe/web/BloomServer.cs Outdated
@StephenMcConnel StephenMcConnel force-pushed the BL-16376-ImageWronglyDeleted branch 3 times, most recently from d41150a to dfb2880 Compare June 22, 2026 19:56
@StephenMcConnel StephenMcConnel force-pushed the BL-16376-ImageWronglyDeleted branch from dfb2880 to 726b4a4 Compare June 22, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants