Problem/Motivation
Currently through the sources bulk overview, we can submit a source item to a job anytime.
This might also apply to the cart.
The same item in progress for multiple times can result in inconsistent situations when accepting.
Proposed resolution
Only allow the same item once as part of the job. Well manage this situation in TMGMT core.
Skip items that are not allowed and show a message.
This requires us to cleanly take care of aborting jobs or single items instead of deleting them.
See: #2672924: Disallow item deletion after submission and support item abort
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | interdiff-2679949-31-34.txt | 3.19 KB | MarinkoIg |
| #34 | 2679949-34.patch | 14.18 KB | MarinkoIg |
Comments
Comment #2
miro_dietikerComment #3
MarinkoIg commentedAssigned to me.
Comment #4
MarinkoIg commentedInitial patch. Not sure is this the right direction..
Comment #6
miro_dietikerI think there should be a helper provided to check if there is a pending item // or if adding an item is allowed. Otherwise too repetitive: There are multiple UI channels to create a job to cover this.
Comment #7
berdirWe have an API for this? tmgmt_job_item_load_latest()
Comment #8
MarinkoIg commentedWithout test..
Comment #10
miro_dietikerAs part of this issue, the method also needs to return continuous job items. And also continuous jobs need to use this method.
Note that we only allow one item per language pair (source + translation), and NOT in general on item across all jobs of all languages.
So you can only skip the items before job submission when the source and target language is set - and not when adding job items to the job.
Redefinition:
When on the job checkout form, we could check the job items that are not allowed for the language pair and output a warning with a count.
We will currently not add an indicator in the view per item!
Take no action yet as the user can change the target language. The warning might disappear for the newly selected language.
If the user still submits, the items will be dropped before submission in requestTranslation.
BTW there are some codestyle issues in the patch.
Comment #11
MarinkoIg commentedWork in progress..
Comment #13
miro_dietikerHm, raising priority here. Mostly because of the bug in tmgmt_job_item_load_latest(). If the issue isn't progressing fast enough, we should put it into a separate issue.
Comment #14
berdirYou mean the bug that's fixed here: #2685479: Active items of continuous jobs not showing up on the sources overview?
Comment #15
miro_dietikerYeah right. Good to know there's an issue.
Still keeping it at that level since the new rule to only have one item submitted adds integrity boundaries that are majorly helping with management. ;-)
Comment #16
MarinkoIg commentedWork in progress..
Comment #17
MarinkoIg commented..and screenshot.
Comment #19
MarinkoIg commentedWithout solution/part for 'Cart' and without test..
Comment #21
MarinkoIg commentedFixed failing test..
Comment #22
miro_dietikerI think we should add a notification (as a warning again? or just info?) that these items have been dropped.
The original general statement that "Already exist" is too general, does not explicitly mention that they will be dropped on submission and there is no reference to what item affected.
IMHO the message should be taken from the $form['message'] rebuilt above instead of duplicating build code.
In any cas the row overlength formatting is also much onfortunate.
There could be other warnings created. We should not hide this. Why is this needed?!
Comment #23
miro_dietikerFrom discussions, more specifically:
On the job form i would display WARNING:
"5 items conflict with pending items and will be dropped on submission."
Then after submission, as an INFO
"5 conflicting items have been dropped."
With a follow up that we would want to annotate the conflicting items somehow more specifically so they can be identified in the item list.
Comment #24
MarinkoIg commentedFixed bugs from #22, #23, covered 'Cart' but without test..
Comment #26
MarinkoIg commentedImproved code, but I'm not sure how to fix tests.
Comment #28
johnchqueI think here it should be '1 conflicting item has been dropped'.
Also the problem with the tests is that we were submitting twice an item while it was in progress, it had to fail but I wonder why when we dropped the conflicting items we allow to create empty jobs? maybe would be better to discuss that too.
Comment #29
mbovan commentedDoes "existing_items" needs to be "existing-items"?
Extra line, unrelated.
What about $existing_items_ids?
Maybe $job_items instead of $return for the variable name.
Regarding failing tests,
1. Line 228 (TmgmtUiTest), looks like "Save" on empty translation will not actually save a translation which results that "Save as completed" does not appear.
2. Line 351 (TmgmtUiTest) - there is a wrong label. This happens when there are no job items in the job... Since this issue prevents adding duplicated items, the job label should be either updated or tests changed.
Btw, with dropping job items, we can have a situation where we create "empty" jobs (jobs with no job items)
The message looks a bit contradictory in that case... Not sure if we want to prevent job creation in case there is only one (duplicated) job item. Could be a followup.
Creating an empty jobs, leads to something like:

Comment #30
mbovan commentedComment #31
MarinkoIg commentedFixed mistakes and bugs from #28 and #29.
Comment #33
johnchqueThe test fail is caused by an old test, maybe we should delete those lines since the progress bar is already being tested somewhere else.
In TMGMTUiReviewTest.
Comment #34
MarinkoIg commentedAdded tests for other parts of new code and fixed bug in existing test.
Comment #35
berdirI knew this was surprisingly easy on tests. The patch did remove conflicting fine enough, but it also ended up happily submitting completely empty jobs.
I refactored the check so that we can fail validation if that happens. And unsurprisingly, tests explode all over the place. Started fixing some, lets see how many fails are left.
Comment #37
berdirFixed that failing test too. Added another node so that we are testing the case where one item is deleted.
Not done yet, don't really understand \Drupal\tmgmt\Entity\Job::getConflictingItemIds() yet.
Comment #38
MarinkoIg commented@Berdir, do I need to check this or you will continue with it?
Comment #39
berdirI'm on it.
I think I understand what you were trying to do with the second last query. But that assumed that the one you're checking is the one that was changed last. That's not guaranteed.
What I didn't understand is all the logic with check target language and why you did two different checks. There is *always* a target language.
So I tried to simplify this. Only did manual testing now, lets see about tests.
Comment #41
berdirFixed the tests. The previous code also matched on inactive, not yet submitted job items, the cart test relied on that incorrect behavior. Fixed the test.
Will commit this when green I think. Did quite a lot of testing and this feels solid now.
Comment #42
berdirCommitted.
Comment #44
miro_dietikerHm, no idea why this state is not on fixed anymore..