Skip to content

SF-3741 Allow admins to apply drafts to books they do not have write access to#3733

Merged
Nateowami merged 3 commits intomasterfrom
fix/SF-3741
Mar 18, 2026
Merged

SF-3741 Allow admins to apply drafts to books they do not have write access to#3733
Nateowami merged 3 commits intomasterfrom
fix/SF-3741

Conversation

@pmachapman
Copy link
Collaborator

@pmachapman pmachapman commented Mar 10, 2026

This PR updates the apply draft logic to add permissions for the current user when applying the draft to an existing book or chapter, and the user does not have permissions for that book/chapter despite being an administrator.


Open with Devin

This change is Reviewable

@pmachapman pmachapman added the will require testing PR should not be merged until testers confirm testing is complete label Mar 10, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 54.83871% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.31%. Comparing base (885d742) to head (7d8b9d8).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...aft-import-wizard/draft-import-wizard.component.ts 0.00% 9 Missing ⚠️
...c/SIL.XForge.Scripture/Services/ParatextService.cs 50.00% 0 Missing and 3 partials ⚠️
...SIL.XForge.Scripture/Services/MachineApiService.cs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3733      +/-   ##
==========================================
- Coverage   81.32%   81.31%   -0.02%     
==========================================
  Files         620      620              
  Lines       39056    39075      +19     
  Branches     6374     6351      -23     
==========================================
+ Hits        31764    31774      +10     
- Misses       6310     6329      +19     
+ Partials      982      972      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RaymondLuong3 RaymondLuong3 self-assigned this Mar 12, 2026
Copy link
Collaborator

@RaymondLuong3 RaymondLuong3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RaymondLuong3 reviewed 10 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on pmachapman).


src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):

                    // Ensure the current user has permission to update the specified books,
                    // adding them if they are missing and are an administrator.

Nit: This comment is a little awkward. I think it should start with "When the user is a project administrator..."

Code quote:

                    // Ensure the current user has permission to update the specified books,
                    // adding them if they are missing and are an administrator.

src/SIL.XForge.Scripture/Services/ParatextService.cs line 1743 at r1 (raw file):

    /// <param name="booksToUpdate">
    /// The book numbers to update.
    /// If specified these books will be updated, otherwise only new books not disk will be updated.

Nit: "not on disk" is what I think it should say

Code quote:

otherwise only new books not disk will be updated.

src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):

            TextInfo text = projectDoc.Data.Texts[i];
            int bookNum = text.BookNum;
            if (booksToUpdate.Length == 0 ? scrText.BookPresent(bookNum) : !booksToUpdate.Contains(bookNum))

This is kind of an awkward if statement. Could you simplify this?

Code quote:

 if (booksToUpdate.Length == 0 ? scrText.BookPresent(bookNum) : !booksToUpdate.Contains(bookNum))

Copy link
Collaborator

@RaymondLuong3 RaymondLuong3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this PR aims at allowing administrators to successfully import a draft to their project even if they do not have permission. When I try to import a draft to Matthew, it fails because I don't have permission (the book exists but I do not have permission in PT). This seems wrong that I can get to the import step. It should notify me that I cannot import on the first step of the wizard. Or if the aim is to change the behaviour, I should have been able to successfully override the permissions and Matthew should have successfully imported.

@RaymondLuong3 made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on pmachapman).

Copy link
Collaborator Author

@pmachapman pmachapman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have been able to successfully override the permissions and Matthew should have successfully imported.

Yes, it should have done that. Can you add me to the project you tested this PR with, so I can see why it failed? Also, I am assuming you restarted the dotnet process when testing this PR?

@pmachapman made 4 comments and resolved 2 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on RaymondLuong3).


src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

Nit: This comment is a little awkward. I think it should start with "When the user is a project administrator..."

Done. Is this better?


src/SIL.XForge.Scripture/Services/ParatextService.cs line 1743 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

Nit: "not on disk" is what I think it should say

Done. Yes, thank you.


src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

This is kind of an awkward if statement. Could you simplify this?

Done. Is this easier to read?

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Collaborator

@RaymondLuong3 RaymondLuong3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for giving that a try. I forgot that my user was a translator. When I updated the role to administrator, it successfully imported the draft of Matthew. It is working as expected.

@RaymondLuong3 reviewed 6 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on pmachapman).


src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):

Previously, pmachapman (Peter Chapman) wrote…

Done. Is this better?

It should say, "... and do not have permission."


src/SIL.XForge.Scripture/Services/ParatextService.cs line 1776 at r1 (raw file):

Previously, pmachapman (Peter Chapman) wrote…

Done. Is this easier to read?

Yes, that is better.

@RaymondLuong3 RaymondLuong3 added ready to test and removed will require testing PR should not be merged until testers confirm testing is complete labels Mar 17, 2026
Copy link
Collaborator Author

@pmachapman pmachapman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmachapman made 1 comment and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on pmachapman).


src/SIL.XForge.Scripture/Services/MachineApiService.cs line 506 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

It should say, "... and do not have permission."

Done. Thanks!

@Nateowami Nateowami added testing complete Testing of PR is complete and should no longer hold up merging of the PR and removed ready to test labels Mar 18, 2026
@Nateowami Nateowami enabled auto-merge (squash) March 18, 2026 15:30
@Nateowami Nateowami merged commit 6a27b10 into master Mar 18, 2026
20 of 22 checks passed
@Nateowami Nateowami deleted the fix/SF-3741 branch March 18, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing complete Testing of PR is complete and should no longer hold up merging of the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants