Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-2441 Focus draft tab on draft nav #2486

Merged
merged 2 commits into from
May 24, 2024

Conversation

siltomato
Copy link
Collaborator

@siltomato siltomato commented May 24, 2024

  • Editor looks for URL query param draft-active=true to focus the draft tab.
  • Modified updateAutoDraftTabVisibility() to only add a draft tab to 'source' if one isn't already in the tab state for either 'source' or 'target'.
  • Removes 'draft-active' query string from url when another tab from 'source' is selected.

This change is Reviewable

@siltomato siltomato added the will require testing PR should not be merged until testers confirm testing is complete label May 24, 2024
Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 77.53%. Comparing base (2655dcb) to head (890685b).

Files Patch % Lines
...shared/sf-tab-group/tab-state/tab-state.service.ts 80.00% 1 Missing and 1 partial ⚠️
...ntApp/src/app/translate/editor/editor.component.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2486      +/-   ##
==========================================
- Coverage   77.53%   77.53%   -0.01%     
==========================================
  Files         511      511              
  Lines       29260    29272      +12     
  Branches     4753     4757       +4     
==========================================
+ Hits        22687    22696       +9     
- Misses       5829     5831       +2     
- Partials      744      745       +1     

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

@Nateowami
Copy link
Collaborator

This is working great; thanks. Are there still changes coming that make it a draft PR?

@siltomato siltomato force-pushed the feature/SF-2441-select-draft-tab branch from 62a6b99 to 3dd2e38 Compare May 24, 2024 21:50
@siltomato siltomato marked this pull request as ready for review May 24, 2024 21:50
Copy link
Collaborator

@Nateowami Nateowami left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 4 files at r1, 1 of 2 files at r2.
Reviewable status: 2 of 5 files reviewed, 1 unresolved discussion (waiting on @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.ts line 1332 at r2 (raw file):

          .subscribe(() => {
            this.router.navigate([], {
              queryParams: { 'draft-active': null },

Good catch. I was about to comment this when I saw you had updated the PR. However, I tested this locally before you made the update, and it worked. It seems like it shouldn't have...

Also, if you wanted to keep paramKey as a variable, you should be able to do that with queryParams: { [paramKey]: null },

Copy link
Collaborator Author

@siltomato siltomato left a comment

Choose a reason for hiding this comment

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

I added the query param to router link in DraftPreviewBooksComponent. Is there another place it needs to be added?

Reviewable status: 2 of 5 files reviewed, all discussions resolved (waiting on @Nateowami)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.ts line 1332 at r2 (raw file):

Previously, Nateowami (Nathaniel Paulus) wrote…

Good catch. I was about to comment this when I saw you had updated the PR. However, I tested this locally before you made the update, and it worked. It seems like it shouldn't have...

Also, if you wanted to keep paramKey as a variable, you should be able to do that with queryParams: { [paramKey]: null },

Ah, cool, nice one. I'll have to remember that!

Copy link
Collaborator

@Nateowami Nateowami left a comment

Choose a reason for hiding this comment

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

I added the query param to router link in DraftPreviewBooksComponent. Is there another place it needs to be added?

No; that's the only place, at least for now.

Reviewed 1 of 4 files at r1, 1 of 2 files at r2, all commit messages.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.spec.ts line 3826 at r2 (raw file):

      env.component.tabState.tabs$.pipe(take(1)).subscribe(tabs => {
        expect(tabs.filter(tab => tab.type === 'draft')[0]?.isSelected).toBe(true);

Filtering an array and taking the first result is the same as Array.find. This could just be:

expect(tabs.find(tab => tab.type === 'draft')?.isSelected).toBe(true);

(Same below)

Also, having expectations only in a subscription makes it difficult to be certain your expectations actually run.

Copy link
Collaborator

@Nateowami Nateowami left a comment

Choose a reason for hiding this comment

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

:lgtm:

I've commented some things that could be improved, but I'd be happy to merge as-is after I do a bit more testing.

Reviewed 1 of 4 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @siltomato)

Copy link
Collaborator

@Nateowami Nateowami left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @siltomato)

Copy link
Collaborator Author

@siltomato siltomato left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.spec.ts line 3826 at r2 (raw file):

Previously, Nateowami (Nathaniel Paulus) wrote…

Filtering an array and taking the first result is the same as Array.find. This could just be:

expect(tabs.find(tab => tab.type === 'draft')?.isSelected).toBe(true);

(Same below)

Also, having expectations only in a subscription makes it difficult to be certain your expectations actually run.

Good catch. Fixed. What's the best way to not run in the subscription?

Copy link
Collaborator

@Nateowami Nateowami left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.spec.ts line 3826 at r2 (raw file):

Previously, siltomato wrote…

Good catch. Fixed. What's the best way to not run in the subscription?

One option would be awaiting a promise. But it's not critical. Do you want to just go ahead and merge it? It can be tested after merging. This is the final piece of the puzzle for next week's release.

Copy link
Collaborator Author

@siltomato siltomato left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.spec.ts line 3826 at r2 (raw file):

Previously, Nateowami (Nathaniel Paulus) wrote…

One option would be awaiting a promise. But it's not critical. Do you want to just go ahead and merge it? It can be tested after merging. This is the final piece of the puzzle for next week's release.

Sure.

@siltomato siltomato merged commit d4621d0 into master May 24, 2024
16 checks passed
@siltomato siltomato deleted the feature/SF-2441-select-draft-tab branch May 24, 2024 22:48
@siltomato siltomato added ready to test and removed will require testing PR should not be merged until testers confirm testing is complete labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants