Repository navigation
OpenConceptLab/ocl_issues#3008 | Convert resource-versioned references, showing what each conversion keeps - #111
snyaggarwal wants to merge 4 commits into
Conversation
…s: a dialog shows what each conversion keeps and converts them server side
snyaggarwal
left a comment
There was a problem hiding this comment.
Round 1 verdict: not ready to merge yet. One important finding and three nits on 3a99323. Fixes follow in this PR.
Checked against OpenConceptLab/oclapi2#1033's reference_conversions.py and views:
- Request shapes:
- preview takes
{ids: [...]}, at most 500, or{ids: "*", offset}, paged bysummary.next_offset; - convert takes
{conversions: [{id, to}]}.
- preview takes
- Response fields:
supported,reason,members_count, and per conversionkeeps_members,added_count,removed_countandcreates_lock. The 202 from a queued task andconverted,already_present,not_convertedandrolled_backare handled too. - APIService: success checks
response.status, and errors come back aserror.response.datawithdetailshown when there is one. - i18n: all 30 keys are in en, es, pt-BR and zh, and those files change only by the new keys.
- The old transform dialog: it now routes resource-versioned references here. Repo-versioned references still transform client side, with tests.
- Reachability: the actions menu is disabled outside HEAD, so the dialog only ever works on HEAD, as the API does.
- Open core: nothing commercial.
The important finding: the preview reloads, and resets the owner's choices, whenever Search re-renders (inline).
…selected ids, names its controls, says when there's nothing to convert, and stays open on a rollback
|
All four round 1 points are fixed in the latest commit.
The four new keys are in en, es, pt-BR and zh. Three new tests cover the id key, telling a rollback apart, and the rollback messages, so 202 tests in all. They pass, ESLint is clean, and the production build compiles. |
snyaggarwal
left a comment
There was a problem hiding this comment.
Round 2 verdict: ready to merge once OpenConceptLab/oclapi2#1033 is deployed. No findings on f5f5202.
The four round 1 fixes check out:
- Preview key: the preview loads by a sorted, joined key of the selected resource-versioned ids (
getResourceVersionedIds). The effect depends onselectedKey, so a re-render of Search no longer reloads it or resets the choices. - Accessible names: each row's Select is labelled with its expression, and the scope toggle has a label.
- Empty preview: an info alert shows when there's nothing to convert.
- Rollback: a conversion that changed nothing because it was rolled back keeps the dialog open, with the API's messages from each shape of
errors(a string, a list, or an object ofdescriptionentries). Because the API's swap is all or nothing,changed === 0 && rolled_back > 0is the right test.
I looked over the rest of the PR again and found nothing else:
- the request and response shapes match #1033;
"*"pages untilnext_offsetis null;- a 202 and errors are handled;
- the four new keys are in all four locales;
- the old transform routes resource-versioned references here.
CI ("Lint and test") passes. The dialog still hasn't run against live endpoints. That's for staging once #1033 is deployed there.
paynejd
left a comment
There was a problem hiding this comment.
Review at f5f5202. An independent defect pass (Codex, high effort), with every finding checked against the code and against oclapi2#1033's real response shapes.
Verdict: comment. Jon will look at the dialog in a browser once oclapi2#1033 is on staging. The default never picks a conversion the API says changes members, which is right.
Worth fixing
- A failed or empty preview keeps the last scope's choices. The load effect (
ConvertReferencesDialog.jsx~107-123) clears neitherpreviewnorchoices. After an error the old table stays under the alert. Going from All to Selected with nothing selected leaves "Convert N" enabled with no table. Suggestion inline: clear both at the start of every load. - Queued conversions never report back. On 202, the dialog calls
onConverted({queued: true}), and the task id is dropped. The synchronous wait is about 40 s, and the collections with the most pinned references will mostly queue. Keep the id and poll/tasks/<id>/asuseQueuedTasksdoes, then show the same outcome or rollback message. - Show what each conversion keeps.
repo_version,chosen_by,addedandremovedcome back from the API but aren't shown (ConversionCell, ~48-70). Show the version under each expression. When a conversion doesn't keep members, list what it adds and removes (capped, with counts) in an expandable row. That's the ticket's "showing what each keeps". - Exclusion rows look like inclusions. The API returns
item.exclude, but the dialog ignores it. Please label those rows; the API fix is in oclapi2#1033, point 3. That PR's review also adds two reasons, "it has no system" and "it is an exclusion", so add them toREASON_KEYS. - Once oclapi2#1033 accepts an expected
repo_version, send the previewed one with each conversion. - Default choice: unversioned first. Pre-select unversioned when it keeps the members; otherwise repo-versioned when it keeps them; otherwise leave the reference as it is. That's the order ocl_issues#2280 sets. When unversioned sets the collection's lock (
creates_lock), keep the note that says so. Never pre-select a repo-versioned conversion the API reports withchosen_by: "HEAD": it names/S/HEAD/..., so its member moves with the next edit in HEAD. Offer it, labelled "follows HEAD". The "repo-versioned first" test inreferenceConversionUtils.test.jschanges with this.
Minor
7. When some references can't be converted, the "every reference keeps its members" banner overstates, and the final alert doesn't count them. Word it as "every reference that can be converted", and say how many couldn't be.
| if(!open || !collectionUrl || (scope === 'selected' && !selectedIds.length)) { | ||
| setPreview(null) | ||
| return | ||
| } |
There was a problem hiding this comment.
Point 1: every load starts from no preview and no choices, so a failed or empty load shows no old table and leaves Convert disabled.
| if(!open || !collectionUrl || (scope === 'selected' && !selectedIds.length)) { | |
| setPreview(null) | |
| return | |
| } | |
| setPreview(null) | |
| setChoices({}) | |
| if(!open || !collectionUrl || (scope === 'selected' && !selectedIds.length)) | |
| return |
…sioned, shows each conversion's version and changes, follows queued conversions, and sends back the previewed version
|
Thanks, Jon. All seven points are addressed in the latest commit.
New and changed keys are in en, es, pt-BR and zh. |
paynejd
left a comment
There was a problem hiding this comment.
Thanks, Sunny. Points 1 and 3 to 7 are met.
- The default order matches the rule exactly.
- The payload carries
repo_versionin the shape oclapi2#1033 compares. - Tests and lint pass.
Point 2 needs one line changed (suggestion inline). The poll asks /tasks/<id>/?result=true, and the API leaves result out unless it's json or all (TaskDetailSerializer.to_representation). On staging, result=true returns no result key, while verbose=true&result=all does. So every queued conversion ends with "The background conversion failed", successful or not. It also needs oclapi2#1033's fix, so that the result is JSON.
Smaller:
APIServicenever rejects, so a task that keeps returning 404 or 500 is polled every 3 seconds until the dialog closes. Stop after a few failures.- A
{refusal}result shows the generic failure. Showing the refusal's message would tell the user why. - The not-converted reasons, such as "changed since the preview", are only counted, never shown.
- The scope toggle stays enabled while converting.
- See oclapi2#1033 on labelling an unversioned conversion that resolves to HEAD.
The browser check on staging follows once #1033 is there.
| return | ||
| let active = true | ||
| let timer = null | ||
| const poll = () => APIService.new().overrideURL(`/tasks/${queuedTaskId}/`).get(null, null, { result: true }).then( |
There was a problem hiding this comment.
Asks for the result: result=true leaves it out.
| const poll = () => APIService.new().overrideURL(`/tasks/${queuedTaskId}/`).get(null, null, { result: true }).then( | |
| // verbose with result=all returns the task's result; result=true leaves it out | |
| const query = { verbose: true, result: 'all' } | |
| const poll = () => APIService.new().overrideURL(`/tasks/${queuedTaskId}/`).get(null, null, query).then( |
… its stored result, stops after repeated failures, shows refusals and why references were left, and labels HEAD targets
|
Thanks, Jon. Your Nov 24 review is addressed in 157bb61.
New keys are in en, es, pt-BR and zh. |
The web half of OpenConceptLab/ocl_issues#3008 (epic OpenConceptLab/ocl_issues#2942). It uses the API from OpenConceptLab/oclapi2#1033, so it needs OpenConceptLab/oclapi2#1033 deployed first; until then the dialog's preview call fails and shows the error.
What it adds
A "Convert resource-versioned references" action in the references actions menu. It opens a new dialog (
ConvertReferencesDialog):Scope: the selected resource-versioned references, or every one in the collection (
"*", fetched page by page).Per reference: what it holds now, and, for each conversion (repo-versioned and unversioned):
References the API can't convert (a filter, a value set) are shown with the reason.
Choice per reference: repo-versioned, unversioned, or leave as is. It starts on a conversion that keeps the members, repo-versioned first.
Converting everything at once: when every reference keeps its members under one conversion, the dialog says so and offers to set them all to it (the ticket's "convert them all in one step").
Converting: one call to
references/conversions/, which swaps them in HEAD in one transaction. An alert then says how many were converted and how many were left as they were. A queued run (202) says it's running in the background.The existing "Transform to non-versioned reference" now leaves resource-versioned references to this dialog, marked "Use Convert resource-versioned references". Its client-side add-then-delete stays only for repo-versioned references.
Translations: en, es, pt-BR and zh, with 30 new keys each.
Checks
npm testpasses, 199 tests. New ones cover the conversion helpers: merging the pages of"*", the default choices, setting all, the payload and the outcome. Two more cover the transform change.🤖 Generated with Claude Code