weblate icon indicating copy to clipboard operation
weblate copied to clipboard

memory: implement delete entry from automatic suggestions

Open ParthS007 opened this issue 3 years ago • 9 comments

Proposed changes

closes #6440

  • Added a Delete entry button for removing translation suggestion from Automatic Suggestions

Checklist

  • [x] Lint and unit tests pass locally with my changes.
  • [x] I have added tests that prove my fix is effective or that my feature works.
  • [x] I have added documentation to describe my feature.
  • [x] I have squashed my commits into logic units.
  • [x] I have described the changes in the commit messages.

ParthS007 avatar Aug 09 '22 10:08 ParthS007

Codecov Report

Merging #7984 (b77b201) into main (e92cb03) will increase coverage by 0.12%. The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7984      +/-   ##
==========================================
+ Coverage   90.82%   90.95%   +0.12%     
==========================================
  Files         685      685              
  Lines       51251    51256       +5     
  Branches     7400     7934     +534     
==========================================
+ Hits        46550    46619      +69     
+ Misses       3305     3248      -57     
+ Partials     1396     1389       -7     
Impacted Files Coverage Δ
weblate/memory/machine.py 90.90% <100.00%> (+0.43%) :arrow_up:
weblate/memory/tests.py 100.00% <100.00%> (ø)
weblate/vcs/ssh.py 73.10% <0.00%> (ø)
weblate/checks/data.py 100.00% <0.00%> (ø)
...blate/trans/migrations/0127_fix_source_glossary.py 62.50% <0.00%> (ø)
...te/trans/migrations/0133_glossary_missing_files.py 59.37% <0.00%> (ø)
weblate/trans/models/component.py 82.90% <0.00%> (+0.06%) :arrow_up:
weblate/vcs/git.py 85.34% <0.00%> (+0.12%) :arrow_up:
weblate/trans/models/translation.py 88.60% <0.00%> (+0.36%) :arrow_up:
weblate/vcs/apps.py 91.37% <0.00%> (+1.72%) :arrow_up:
... and 4 more

codecov[bot] avatar Aug 12 '22 00:08 codecov[bot]

@nijel One thing that we discussed earlier for multiple origin suggestions, Should I add multiple delete buttons for them or an Icon with delete functionality would be more intuitive.

In the later case, then instead of delete button, we can have delete icon just next to origin instead of a Delete entry button.

What do you think would be good to go?

For example Screenshot 2022-08-12 at 14 03 47

ParthS007 avatar Aug 12 '22 12:08 ParthS007

We definitely need a way to delete it in selected origins only. I can see two approaches:

  • Move the delete action to the origin column, probably making it icon only. This will pollute the UI quite a lot.
  • Add confirmation dialog which would list all origins with checkboxes. That way the UI is consistent, and it is possible to uncheck origins which the user doesn't want to delete.

That reminds me cases which is not addressed in this PR yet:

  • The code currently picks only first delete URL, and thus it always deletes first origin only.
  • In case the matching string is first obtained from other sources (machine translation service), the delete button will not be present, even if later the suggestions from the translation memory arrives.

The preferred solution as I see it now (feedback welcome):

  1. Collect the delete URLs at origin element.
  2. Once there is at least one delete URL, display the Delete button in the row.
  3. Make the Delete button open a popup listing all origins for current translation which have the delete URL. All selected by default.
  4. The callback would then fire DELETE on all selected URLs.

nijel avatar Aug 15 '22 09:08 nijel

The solution sounds good to me however it will result in more clicks required to delete an entry, imo it's not good for UX. Incase of the delete icon, the number of clicks remain same and user can just click on the delete icon of entries.

I am not sure what do you mean here by:

This will pollute the UI quite a lot.

I am okay with implementing the preferred solution though. Please point me to any similar popup implementations if we have any just in case.

wdyt?

ParthS007 avatar Aug 16 '22 13:08 ParthS007

I think we want confirmation here anyway - having a delete button next to copy without a confirmation doesn't sound good. The confirmation popups are used in several places, for example here:

https://github.com/WeblateOrg/weblate/blob/c8f507972102558803f29abb0f1cfacd048c3a96/weblate/templates/trans/project-access-row.html#L44-L59

nijel avatar Aug 17 '22 14:08 nijel

@nijel I worked on the proposed solution. Apologies for the delay.

The preferred solution as I see it now (feedback welcome):

  • [x] Collect the delete URLs at origin element.
  • [x] Once there is at least one delete URL, display the Delete button in the row.
  • [x] Make the Delete button open a popup listing all origins for current translation which have the delete URL. All selected by default.

The popup looks like this Screenshot 2022-09-09 at 23 12 34

  • [x] The callback would then fire DELETE on all selected URLs.

I am able to callback the DELETE request but the request gets blocked by firefox (I am not sure what;s the reason, might be related to csrf token or something else) and I get the following error notification

Screenshot 2022-09-09 at 23 12 13

Screenshot 2022-09-09 at 23 27 44

ParthS007 avatar Sep 09 '22 21:09 ParthS007

I've tested that and I can see few issues:

  1. The UI looks weird when the delete button is not shown:

    image

    I suggest adding empty cell instead.

  2. The delete button is rendered for some services where it should not be present:

    image

    Clicking on it yields empty dialog

  3. The dialog is not cleared before display, so when you abort it, and show it again, it includes duplicate entries:

    image

nijel avatar Sep 15 '22 07:09 nijel

Thanks for review, I could reproduce 1 and 3.

  1. The empty cell screenshot if delete button is not present.

Screenshot 2022-09-18 at 15 26 42

  1. I couldn't reproduce 2, I am assuming 2 might have happened because of inconsistent state so I have simplified the logic for showing the delete button. I tried on multiple pages and cannot see unexpected delete button.

  2. The modal screenshot after closing it several times, no duplicate entries present

Screenshot 2022-09-18 at 15 26 58

ParthS007 avatar Sep 18 '22 13:09 ParthS007

Thanks, looks better. There is still some issue with the dismissed popup - the dialog shows three checkboxes, but the DELETE request is fired multiple times (it seems that each dismiss adds one repetition):

Snímek z 2022-09-19 08-54-03

nijel avatar Sep 19 '22 06:09 nijel

@nijel Please let me know if there is something left for this PR. Thanks

ParthS007 avatar Sep 26 '22 07:09 ParthS007

Tests passing 🎉

ParthS007 avatar Sep 27 '22 07:09 ParthS007

Merged, thanks for your contribution!

nijel avatar Sep 27 '22 09:09 nijel