feat: implement cancelTranslation for the Smartling connector - #710
Draft
markdaugherty wants to merge 2 commits into
Draft
feat: implement cancelTranslation for the Smartling connector#710markdaugherty wants to merge 2 commits into
markdaugherty wants to merge 2 commits into
Conversation
Confirmed the correct endpoint against Smartling's official OpenAPI
spec before implementing: DELETE
.../jobs/{translationJobUid}/locales/{targetLocaleId}
(removeLocaleFromJob), not the job-level cancelJob endpoint, which
would cancel every other language sharing the same job since
sendAllLanguages bundles all target languages into one job. Polls the
returned process to completion on a 202 response.
Smartling previously had no cancelTranslation at all, so translate.js's
canCancel getter was always false and the Cancel buttons never
rendered for Smartling projects.
Also extends getStatusAll's existing "don't revert completed
languages" guard to cover 'cancelled', since the next status poll would
otherwise undo a fresh cancel the same way it was re-triggering saves
for completed languages.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 8379daf)
renderCancelLang's guard only excluded 'cancelled' status, never 'complete', so a completed language's Cancel button stayed visible as long as some other language in the project was still in progress. Separately, incompleteLangs counted a language as cancellable even with no translation object at all (never sent), so "Cancel project" could show with nothing actually cancellable. Extracted a single canCancelLang(lang) predicate used consistently by renderCancelLang, incompleteLangs, and the with-cancel grid-column class, so they can't drift out of sync with each other again. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 0801b22)
| */ | ||
| async function pollJobProcess(endpoint, projectId, jobUid, processUid) { | ||
| const url = `${endpoint}/jobs-api/v3/projects/${projectId}/jobs/${jobUid}/processes/${processUid}`; | ||
| const opts = { headers: { Authorization: `Bearer ${token}` } }; |
Member
There was a problem hiding this comment.
token is module state here, so cancel/poll silently rely on connect() having run first. matches the file's existing style, just flagging in case we want it threaded through explicitly.
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
cancelTranslation: removes a language's locale from its shared translation job (removeLocaleFromJob), polling Smartling's async-process endpoint to completion on a 202 responserenderCancelLang/incompleteLangs/thewith-cancelgrid class to consistently treat'complete'(not just'cancelled') as non-cancellable, via a single sharedcanCancelLang(lang)predicate