Repository navigation
Section manager: make "Set Selected Bios" honour the selection and show every error - #179
Merged
Merged
Conversation
"Set Selected Bios" was wired to the same handler as "Set Bios", which loops over every associated section, so it rewrote the profile page on sections the user had unchecked. applySectionProfiles and publishCourses now take the list of sections to act on; the "selected" buttons pass only the checked sections. Also in the section manager: - sectionError uses a functional state update, so every failing section keeps its error instead of only the last one in a pass. - Call course.isBlueprint() instead of testing the method reference, which was always truthy. - Drop unchecked (undefined) entries before publishing, and skip and report sections without a numeric id rather than sending "undefined" to Canvas. - Key sections by sectionKey(), which falls back to name and course code when a section has no usable id, so several id-less sections are each listed and reported instead of collapsing onto one entry. - Catch a failed publish request and a failed post-publish refresh, so the modal shows the error and always leaves the loading state. The CHANGELOG entries go in a new [Unreleased] section above 3.3.0, since this is intended for the release after 3.3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Build artifact available: Download here |
Contributor
|
I tested in my test course, and the behavior matches. Didn't run with actual bios, but it did throw the error message only on the courses I selected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the blueprint section manager ("Manage Sections"), "Set Selected Bios" ignored the checkboxes. It was wired to the same handler as "Set Bios", which loops over every associated section. If an LXD unchecked sections whose instructors had customised their bios and clicked "Set Selected Bios", every section's profile page was still rewritten.
This PR builds on #160 (target-page profile names and the write warning) and leaves its behaviour unchanged. It fixes four problems in
PublishInterface.tsx:applySectionProfilesnow takes the list of sections to update. "Set Bios" passes every section, and "Set Selected Bios" passes only the checked ones. "Publish all" and "Publish selected" use the same two lists.sectionErrorcopiederrorsByCourseIdfrom the render it was created in, so each call in the loop started from the same stale snapshot. When five sections failed, only one row showed an error. It now uses a functional state update, so every failing row shows its error. This also makes thesetErrorsByCourseId({})reset at the start of a run take effect, and stops the old code mutating the previous run's error arrays in place.course.isBlueprintwas never called.Course.isBlueprintis a method, so!course?.isBlueprinton the four action buttons was alwaysfalse.setIsBlueprint(course.isBlueprint)worked only because React treats a function argument as a state updater and calls it. Both now callcourse.isBlueprint().undefinedids sent to Canvas. Unchecking a section storesundefinedunder its id insectionsToPublish. "Publish selected" passed those entries straight toCourse.publishAll, which sentcourse_ids[]=undefinedand counted them in "Published N sections". Unchecked entries are now dropped. Any section whoseidis not a number is skipped and named in the status message (for example "Skipped 1 section(s) with no course id: …"), and is never passed togetProfilePageorpublishAll. Sections were stored undersection.id, so every id-less section shared oneNaNentry and only one of them was listed or reported. They now get separate entries, so each one is listed and named.Publishing also no longer gets stuck. Before, if the publish request failed, or the section-list refresh 500 ms later failed,
loadingwas never cleared, so the modal couldn't be closed. The refresh failure was also an unhandled rejection. Both failures now show a message and end the loading state.User impact: "Set Selected Bios" and "Publish selected" now act only on checked sections. When several sections fail, each failing row shows its own error. A failed publish or refresh shows an error instead of hanging. "Set Bios" and "Publish all" behave as before.
Changes
src/publish/publishInterface/PublishInterface.tsxapplySectionProfiles(targetSections)andpublishCourses(event, targetSections)take aCourse[]. The buttons pass either all sections or the selected ones.selectedOnly(record)drops unchecked (undefined) entries, andsplitByValidId(courses)separates sections with a numeric id from those without. A privateskippedMessageadds the skipped section names to the status line.sectionErrorusessetErrorsByCourseId(prev => …).course.isBlueprint()is called in the effect and on the buttons.Course.publishAllis wrapped in a try/catch. A failed request now shows "Publishing failed: …" and clearsloading, so the modal can be closed.course.getAssociatedCourses()) runs in a try/catch/finally. If it fails, the message reads "Published N sections, but the section list could not be refreshed: …".loadingis always cleared.sectionsandsectionsToPublishare keyed bysectionKey(section)in the load path, the post-publish refresh and the checkbox toggle._currentProfilescopy.src/publish/publishInterface/sectionKey.ts(new):sectionKey(section)returns the Canvas id, orno-id:<name>:<course code>when the id isn't a finite number.src/publish/publishInterface/SectionRows.tsx: usessectionKeyto read a row's checkbox state and as the Reactkey, so rows for id-less sections show their real selection state.src/publish/publishInterface/__tests__/PublishInterface.sections.test.tsx(new). It covers:course_idsentries in the actualPUT /api/v1/accounts/:id/coursesform body, and none is"undefined".getProfilePageorpublishAll.isBlueprint()is called and the tools are enabled for a blueprint, and a non-blueprint, non-DEV course gets the disabled "Not BP or DEV" button and no section tools.selectedOnlyandsplitByValidId.CHANGELOG.md: see the note below.Known, not changed
After a publish, the refresh replaces
sectionswith newCourseobjects.RenderBpInterfacedecides whether to show "Set Selected Bios" and "Publish selected" withisEqual(sections, sectionsToPublish). EachCoursecarries its own arrow-function properties (isBlueprint,getAssociatedCourses), soisEqualsees the new objects as different even when every section is still selected. As a result, the two "selected" buttons can appear after a publish when nothing has been unchecked. This happened before this PR too and is left for a separate change.CHANGELOG placement
The current
[Unreleased]section onrelease/3.2.5holds the 3.3.0 notes. #169 copies that section as its description. Adding these entries there would list them under 3.3.0. This PR therefore does the release-cut step already used for 3.2.5 (d34d552): it renames that section to## 3.3.0and opens a new empty[Unreleased]above it, with these entries in it. When this PR is retargeted onto the next release branch, that branch will already have the same## 3.3.0heading, so the rename either merges cleanly or leaves a trivial conflict around the new entries. In both cases the entries cannot slip into the 3.3.0 notes unnoticed.Testing
Run locally after a clean
npm ci:npm test(rebased onto the currentrelease/3.2.5): 65 suites passed and 1 skipped. 463 tests passed and 11 skipped, out of 474. The skipped suite and tests are already skipped onrelease/3.2.5.PublishInterface.tsx, with only the two new helpers added so it compiles. 6 of the first 10 tests failed: selected-only bios, every error shown, the ambiguous-page selection, publish ids, missing id, and theisBlueprint()call. The other 4 cover behaviour that was already correct: "Set Bios writes every section", the non-blueprint check and the two helper unit tests. The three later tests were checked against the version before the keying and refresh fixes. "Two id-less sections" and "refresh failure" failed there. "Publish request failure" passed, because that catch was already in place.npm run lint: clean.npm run typecheck: clean.npm run build(production): compiled with webpack's 3 usual asset-size warnings and no errors.Not verified
There is no Canvas test instance available, so nothing here was run against real Canvas. All results come from Jest with Canvas mocked. In particular:
PUT /api/v1/accounts/:id/coursesrequest with a partialcourse_ids[]list. Canvas runs that batch as an asynchronous Progress job. The existing fixed 500 ms wait before refreshing the section list is unchanged, so the list can still show sections as unpublished for a moment after "Published N sections". Polling the Progress job is left for a separate change.alert-warning) in Canvas's styles.Out of scope, left unchanged:
src/ui/module/index.tshas the sameif (course?.isBlueprint)method-reference check. It means the "Lock All" and "Unlock Profile & Home" buttons on the Modules page are also added to non-blueprint courses. That is a separate UI surface and is not changed here.🤖 Generated with Claude Code