Skip to content

feat: keyboard shortcut to export all bookmarks #25827

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

Merged
merged 15 commits into from
Nov 11, 2024
Merged

feat: keyboard shortcut to export all bookmarks #25827

merged 15 commits into from
Nov 11, 2024

Conversation

hamirmahal
Copy link
Contributor

@hamirmahal hamirmahal commented Oct 4, 2024

Resolves brave/brave-browser#41412

Allow users to create a keyboard shortcut that exports all bookmarks.

This is an action that some users, like myself, do very often. It would improve the user experience (UX) if there was a way to do this with one keyboard shortcut, as opposed to several, successive clicks.

CI: #26113

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@hamirmahal
Copy link
Contributor Author

Current behavior

Screencast.from.10-06-2024.10.58.15.AM.webm

@fallaciousreasoning
Copy link
Contributor

Nice work @hamirmahal! If you want to show a FilePicker this seems like a good place to start looking:

https://source.chromium.org/chromium/chromium/src/+/main:ui/shell_dialogs/select_file_dialog.h?q=symbol:%5Cbui::SelectFileDialog::Create%5Cb%20case:yes

(it sounds like you can pass nullptr as the second argument 😄)

@hamirmahal hamirmahal marked this pull request as ready for review October 17, 2024 23:55
@hamirmahal hamirmahal requested a review from a team as a code owner October 17, 2024 23:55
@hamirmahal
Copy link
Contributor Author

With this pull request

I recommend watching this at 2x speed.

Screencast.from.10-17-2024.03.54.15.PM.webm

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

This is looking great! Few more changes and I think I can kick off CI

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

This is looking great - I'm kicking of CI

@fallaciousreasoning
Copy link
Contributor

The PR seems to be failing to build on Windows with the following:
image

@fallaciousreasoning
Copy link
Contributor

fallaciousreasoning commented Oct 22, 2024

Would you mind rebasing? I just tried to run CI on latest but the rebase failed for conflicts

@hamirmahal
Copy link
Contributor Author

I can try! The last time I did, brave/brave-browser#40509 happened.

What are the instructions to rebase properly? Is it just following the steps in https://github.com/brave/brave-browser/wiki/Chromium-rebases, exactly?

I think I rebased both repositories last time, which may have caused issues.

@fallaciousreasoning
Copy link
Contributor

fallaciousreasoning commented Oct 23, 2024

Ah yeah so in the brave repo (probably at brave-browser/src/brave):

git fetch
git rebase --onto origin/master
npm run sync
npm run build
npm run start

I think those instructions are for rebasing brave on top of the latest Chromium, which is done by our rebase team. You shouldn't need to do anything in the Chromium repo (at brave-browser/src)

@hamirmahal
Copy link
Contributor Author

Thanks for the detailed instructions.

$  npm run build
 
> [email protected] build
> node ./build/commands/scripts/commands.js build

touch original files overridden by chromium_src...
...touch original files overridden by chromium_src done
update branding...
Recursing through GRD to find GRDP files...
Done recursing through GRD to find GRDP files.
...update branding done
generate ninja files...
Widevine cdm host verification is disabled
...generate ninja files done
build brave (Component, id=526f7522-97bb-469d-a182-6a44a59a20ab)...
---------------------------------------------------------------------------------------------------
/home/hamir/brave-browser/src
> autoninja -C /home/hamir/brave-browser/src/out/Component brave -k 1 --offline
ninja: Entering directory `/home/hamir/brave-browser/src/out/Component'
ninja: no work to do.
...build brave (Component, id=526f7522-97bb-469d-a182-6a44a59a20ab) done

Should I git pull? I think this branch lost changes locally after git rebase --onto origin/master.

On branch feat/keyboard-shortcut-to-export-all-bookmarks
Your branch is behind 'fork/feat/keyboard-shortcut-to-export-all-bookmarks' by 15 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working tree clean

@fallaciousreasoning
Copy link
Contributor

fallaciousreasoning commented Oct 24, 2024

Hmm yeah, maybe do a git pull so you don't lose your changes.

if you do a

git remote -v

what does it output? I'm wondering whether its using your fork as the remote, rather than brave-core? If it is, there are two options:

  1. Sync your fork with brave-core (there should be a button on your Github, I think)
  2. Add another remote for brave-core: git remote add brave [email protected]:brave/brave-core.git

Afterwards, do a fetch

# if you added a new remote
git fetch brave

# if you synced instead
git fetch

and try (maybe I was wrong about the --onto)


# if synced
git rebase origin/master

# if new remote
git rebase brave/master

and then

npm run sync
npm run build
npm run start

@hamirmahal
Copy link
Contributor Author

feat/keyboard-shortcut-to-export-all-bookmarks ~/brave-browser/src/brave 0 $  git remote -v
fork	https://github.com/hamirmahal/brave-core (fetch)
fork	https://github.com/hamirmahal/brave-core (push)
origin	https://github.com/brave/brave-core (fetch)
origin	https://github.com/brave/brave-core (push)

I'm taking a look at the other commands now...

@fallaciousreasoning
Copy link
Contributor

Use fork instead of origin

git fetch fork
git rebase fork/master

@hamirmahal hamirmahal requested review from deeppandya, a team and iefremov as code owners October 25, 2024 03:24
@hamirmahal
Copy link
Contributor Author

No worries!

I think it'd be nice if users could export bookmarks from any page without having to navigate to chrome://bookmarks, first, but that behavior could be a bit unexpected.

How much work would it be to add a shortcut to the WebUI itself?

I can look into enabling the command only if the active page is chrome://bookmarks. I'm not sure if there are any downsides to that implementation.

@fallaciousreasoning
Copy link
Contributor

I think the approach is fine for now - I think if you add the shortcut you won't be too surprised if it works from anywhere (and I don't expect a huge number of people will add one).

The other advantage of this way is it will show up in the list of quick commands (i.e if you press Ctrl+Space)

@bsclifton
Copy link
Member

Nice work @hamirmahal! I remember you were keen on shortcuts a while back and wow - you dug in for sure!

Since this isn't a bound shortcut by default, it should be fine to be a global shortcut (ex: not restricted to a Web UI). Like @fallaciousreasoning is saying, it'll show in the quick commands which is kind of a nice touch

@hamirmahal a good rule of thumb when doing browser dev when you're not sure about something: check what our existing code does or what Chromium does. I don't think we have any page specific shortcuts and I doubt Chromium does either. If that's the case, then you're safe having it as a global one. I would only change if there was a good example that Chromium had (ex: they set a precedent)

@hamirmahal
Copy link
Contributor Author

Thanks @bsclifton! Speaking of checking existing code, I saw base::FilePath GetDefaultFilepathForBookmarkExport() in chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc.

That seems to have a lot of the functionality we want, but it looks like it's not in this repository, so maybe we want to reproduce the function in its entirety in browser/ui/browser_commands.cc. It looks like it gives a file in the format bookmarks_10_31_24.html.

@fallaciousreasoning
Copy link
Contributor

@hamirmahal yeah that seems like a reasonable approach to me (just taking what that function does). Nice work 😄

the default filepath for bookmark export.

This changes the default bookmark filename from

`YYYY_MM_DD_brave_browser_bookmarks.html` to

`bookmarks_MM_DD_YY.html`
@fallaciousreasoning
Copy link
Contributor

looks good - kicked off CI again 🤞

@bsclifton
Copy link
Member

#26113 looks good! Merging 😄 Thanks @hamirmahal!

@bsclifton bsclifton merged commit 79ab3df into brave:master Nov 11, 2024
3 checks passed
@brave-builds
Copy link
Collaborator

Released in v1.75.9

@hamirmahal
Copy link
Contributor Author

You're welcome, @bsclifton!

@hamirmahal hamirmahal deleted the feat/keyboard-shortcut-to-export-all-bookmarks branch November 11, 2024 18:54
@fallaciousreasoning
Copy link
Contributor

Great work @hamirmahal!

@hamirmahal
Copy link
Contributor Author

Thanks @fallaciousreasoning!

@fallaciousreasoning
Copy link
Contributor

fallaciousreasoning commented Nov 11, 2024

Glad we got it in eventually, sorry for the endless rebase-CI cycles :/

Looks like it made it into todays Nightly!

@rebron rebron added this to the 1.75.x - Nightly milestone Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add keyboard shortcut for exporting all bookmarks
7 participants