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

Show dialog to bookmark all tabs #2621

Conversation

alessandroboron
Copy link
Contributor

Task/Issue URL: https://app.asana.com/0/0/1207032400501907/f
CC: @samsymons

Description:

  • Show the dialog to bookmark all tabs when clicking on the “Bookmark All Tabs…” context menu items.
  • Fix a bug when adding a new folder multiple times that caused the folder picker not to be updated and the folder name text field to be prefilled with the previously created name.

Figma Mockup

Screenshots

Screenshot 2024-04-15 at 2 47 13 PM Screenshot 2024-04-15 at 2 47 51 PM Screenshot 2024-04-15 at 2 50 24 PM

Steps to test this PR:

Scenario 1: Shows "Bookmark All Tabs…” dialog view - Main Application Menu 🟢

  1. Ensure there are at least two unpinned Tabs with a web page loaded.
  2. Click on Bookmarks main application menu item.
  3. Click on Bookmark All Tabs… menu item.
    Expected Result: The Bookmark All Tabs dialog should appear on screen.

Scenario 2: Shows "Bookmark All Tabs…” dialog view - More Options Menu 🟢

  1. Ensure there are at least two unpinned Tabs with a web page loaded.
  2. Click on the ... button at the right-hand side of the address bar.
  3. Click on Bookmark All Tabs… menu item.
    Expected Result: The Bookmark All Tabs dialog should appear on screen.

Scenario 3: Shows "Bookmark All Tabs…” dialog view - Tab Contextual Menu 🟢

  1. Ensure there are at least two unpinned Tabs with a web page loaded.
  2. Right-click on the Tab and wait for the contextual menu to appear.
  3. Click on Bookmark All Tabs… menu item.
    Expected Result: The Bookmark All Tabs dialog should appear on screen.

Scenario 4: "Bookmark All Tabs…” dialog view shows right title 🟢

  1. Open 5 (you can choose any arbitrary number) tabs and load a web page for each tab.
  2. Show Bookmark All Tabs… dialog view.
    Expected Result: The dialog title should reflect the number of open tabs as per design. In the case there are 5 tabs with a web page loaded the title should be “Bookmark 5 Open Tabs”.

Scenario 5: "Bookmark All Tabs…” dialog view shows right folder name as suggestion 🟢

  1. Open 5 (you can choose any arbitrary number) tabs and load a web page for each tab.
  2. Show Bookmark All Tabs… dialog view.
  3. Expected Result: The folder name should reflect Today’s date and the number of open tabs as per design. In the case there are 5 tabs with a web page loaded the title should be “yyyy-mm—dd - 5 Tabs”.
Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link
Contributor

🚫 The Asana task linked in the PR description is not added to macOS App Board project.

  1. Verify that the correct task is linked in the PR.
    • ⚠️ Please use the actual implementation task, rather than the Code Review subtask.
  2. Verify that the task is added to macOS App Board project.
  3. When ready, remove the bot: not in app board label to retrigger the check.

@github-actions github-actions bot added the bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project label Apr 15, 2024
Copy link
Contributor

github-actions bot commented Apr 15, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 7bc0262

import SwiftUIExtensions

struct BookmarkAllTabsDialogView: ModalView {
@ObservedObject private var viewModel: BookmarkAllTabsDialogCoordinatorViewModel<BookmarkAllTabsDialogViewModel, AddEditBookmarkFolderDialogViewModel>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used same approach of AddEditBookmarkDialogView.

@@ -42,9 +42,13 @@ struct BookmarkDialogContainerView<Content: View, Buttons: View>: View {
Text(title)
.foregroundColor(.primary)
.fontWeight(.semibold)
.padding(.top, 20)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As BookmarkAllTabs dialog can have an educational message on multiple lines for long language I removed the fix height from the bookmark dialogs, moved the padding in here and let the subviews dictate the height. AddEditBookmarks still render properly.

@@ -42,8 +42,9 @@ final class AddEditBookmarkFolderDialogViewModel: BookmarkFolderDialogEditing {

@Published var folderName: String
@Published var selectedFolder: BookmarkFolder?
@Published private(set) var folders: [FolderViewModel]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Soooo, I found an issue when we present the Add folder dialog from AddEditBookmark and BookmarkAllTabs. Unfortunately this was missed during the project to address bookmark feedback (I’m pretty sure tho we would have tested this scenario, so I’m a bit 🙈) .

The issue happens when we add/edit a bookmark or bookmark all tabs, press the icon to add a folder, save and press again the icon to add a folder. The add folder dialog view shows the name of the previously saved folder rather than being empty and the picker selector is not updated.

I’ve fixed this and updated tests. I actually wrote an integration test.

import SwiftUI
import Combine

final class BookmarkAllTabsDialogCoordinatorViewModel<BookmarkViewModel: BookmarkAllTabsDialogEditing, AddFolderViewModel: BookmarkFolderDialogEditing>: ObservableObject {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same fashion on AddEditBookmarkDialogView

@@ -7567,55 +7567,55 @@
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will open a PR soon for the localization of these strings

@@ -39,7 +39,7 @@ private struct MultilineTextHeightFixer: ViewModifier {
}
}

extension View {
public extension View {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this ViewModifier which is helpful for multiline text from NetworkProtection to SwiftUIExtensions. I needed to render my text on multiple lines when I tested for long text. It wouldn’t work otherwise.

Copy link
Collaborator

@SabrinaTardio SabrinaTardio left a comment

Choose a reason for hiding this comment

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

Looks great and works as expected.
There are a couple of things to consider as concern copy! once we sort them we can merge (or if it is blocking you can merge it but we need to address thme before merging to main)

@@ -348,6 +348,11 @@ final class LocalBookmarkManager: BookmarkManager {
return results
}

func bookmarkAll(websitesInfo: [WebsiteInfo], withinParentFolder parent: ParentFolderType) {
// TODO: https://app.asana.com/0/0/1207032959154802/f
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess technically you can remove this? it does its duty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put had a TODO because I still have to call sync, reload the bookmarks and write tests so I won’t forget it.

#Preview("Bookmark All Tabs - Light") {
let parentFolder = BookmarkFolder(id: "7", title: "DuckDuckGo")
let bookmark = Bookmark(id: "1", url: "www.duckduckgo.com", title: "DuckDuckGo", isFavorite: true, parentFolderUUID: "7")
let bookmarkManager = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: [bookmark, parentFolder]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some failure here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It happens sometimes, I noticed that closing and re-opening Xcode fixes it 🙃

Screenshot 2024-04-17 at 1 42 07 PM

@@ -1077,15 +1077,24 @@ struct UserText {
static let editBookmark = NSLocalizedString("bookmarks.dialog.title.edit", value: "Edit Bookmark", comment: "Bookmark edit dialog title")
static let addFolder = NSLocalizedString("bookmarks.dialog.folder.title.add", value: "Add Folder", comment: "Bookmark folder creation dialog title")
static let editFolder = NSLocalizedString("bookmarks.dialog.folder.title.edit", value: "Edit Folder", comment: "Bookmark folder edit dialog title")
static let bookmarkOpenTabs = NSLocalizedString("bookmarks.dialog.allTabs.title.add", value: "Bookmark %1$d Open Tabs", comment: "Title of dialog to bookmark all open tabs. E.g. 'Bookmark 42 Open Tabs`")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there is an issue here since we do not support pluralisation we can really use "Bookmark %1$d Open Tabs”
We have to move towards something like “Bookmarks All Open Tabs (n)”
you should raise it with someone from copy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah very good catch with the plurals. I will speak with Product/Copy

static let folderName = NSLocalizedString("bookmarks.dialog.field.folderName", value: "Folder Name", comment: "Folder name field label for Bookmarks folder")
}
enum Value {
static let folderName = NSLocalizedString("bookmarks.dialog.field.folderName", value: "%1$@ - %2$d Tabs", comment: "The suggested name of the folder that will contain the bookmark tabs. Eg. 2024-02-12 - 50 Tabs")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here at the very list we can ask the translator to deal with it using Tabs (n) for languages in which we have different plural forms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah very good catch with the plurals. I will speak with Product/Copy

@alessandroboron
Copy link
Contributor Author

Looks great and works as expected. There are a couple of things to consider as concern copy! once we sort them we can merge (or if it is blocking you can merge it but we need to address thme before merging to main)

Thanks @SabrinaTardio!

Actually I was thinking we would never be in a scenario where we have

Bookmark 1 Tabs e 2024-04-17 - 1 Tabs because we need to have at least 2 open tabs to bookmark all tabs. Hence it will always be plural and not singular/plural depending if it’s 1 or n tabs.

@alessandroboron alessandroboron merged commit 4b87398 into alessandro/bookmark-all-tabs Apr 18, 2024
15 of 17 checks passed
@alessandroboron alessandroboron deleted the alessandro/bookmark-all-tabs-show-dialog branch April 18, 2024 02:03
alessandroboron added a commit that referenced this pull request Apr 18, 2024
Task/Issue URL: https://app.asana.com/0/0/1207032400501907/f

**Description**:
- Show the dialog to bookmark all tabs when clicking on the “Bookmark All Tabs…” context menu items.
- Fix a bug when adding a new folder multiple times that caused the folder picker not to be updated and the folder name text field to be prefilled with the previously created name.
alessandroboron added a commit that referenced this pull request Apr 23, 2024
Task/Issue URL: https://app.asana.com/0/0/1207032400501907/f

**Description**:
- Show the dialog to bookmark all tabs when clicking on the “Bookmark All Tabs…” context menu items.
- Fix a bug when adding a new folder multiple times that caused the folder picker not to be updated and the folder name text field to be prefilled with the previously created name.
alessandroboron added a commit that referenced this pull request Apr 24, 2024
Task/Issue URL: https://app.asana.com/0/0/1207032400501907/f

**Description**:
- Show the dialog to bookmark all tabs when clicking on the “Bookmark All Tabs…” context menu items.
- Fix a bug when adding a new folder multiple times that caused the folder picker not to be updated and the folder name text field to be prefilled with the previously created name.
alessandroboron added a commit that referenced this pull request Apr 24, 2024
Task/Issue URL: https://app.asana.com/0/0/1207032400501907/f

**Description**:
- Show the dialog to bookmark all tabs when clicking on the “Bookmark All Tabs…” context menu items.
- Fix a bug when adding a new folder multiple times that caused the folder picker not to be updated and the folder name text field to be prefilled with the previously created name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants