[COMPASS-5686] Add default link handler to Compass Created: 04/Apr/22  Updated: 22/Jun/23  Resolved: 22/Jun/23

Status: Closed
Project: Compass
Component/s: Electron, Tech debt
Affects Version/s: None
Fix Version/s: No version

Type: Task Priority: Major - P3
Reporter: Rhys Howell Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to COMPASS-5187 Refactor deprecated on('new-window') ... Closed
is related to COMPASS-6145 Clicking the information icon opens d... Closed
Story Points: 3
Documentation Changes: Not Needed

 Description   

Currently in Compass we handle links in two main ways:

1. If the link has `_blank` on it then when it is clicked it is handled by the `new-window` event in electron:
https://github.com/mongodb-js/compass/blob/main/packages/compass/src/main/window-manager.ts#L139

2. If the link doesn't have `_blank` on it then we currently do not handle the link handling unless the target of the event is an `a` element. This isn't always the case with links without `_blank` as there might be a `span` or something inside of the `a` tag which means this check isn't very robust. The check happens here in the `onLinkClick` function:
https://github.com/mongodb-js/compass/blob/main/packages/compass/src/app/index.js#L263

In this ticket let's add another handler for the `will-navigate` web contents event to handle links that are clicked without `_blank`. Let's remove the handling that has the not fully covering `a` tag check as well (and keep the `new-window` handler) since it will no longer need to be used.

Something like:
window.webContents.on('will-navigate', function (event, url)

{ event.preventDefault(); void shell.openExternal(url); }

);

`will-navigate` docs: https://www.electronjs.org/docs/latest/api/web-contents#event-will-navigate



 Comments   
Comment by Sergey Petushkov [ 22/Jun/23 ]

Done in https://github.com/mongodb-js/compass/pull/4106

Comment by Githook User [ 21/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: COMPASS-6427-export-json
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 05/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: github-link
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 03/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: COMPASS-6538-import-button-disable
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 01/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: COMPASS-6537-add-confirmation-on-add-data-empty-state
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 01/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: use-new-import
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 01/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: autocopmletion-compartment
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Comment by Githook User [ 01/Mar/23 ]

Author:

{'name': 'Maurizio Casimirri', 'email': 'maurizio.cas@gmail.com', 'username': 'mcasimir'}

Message: feat(compass-schema,compass-schema-validation): more darkmode and maps fixes COMPASS-5686, COMPASS-6553, COMPASS-6569 (#4106)

  • feat(compass-schema): more darkmode and maps fixes
  • also add sample documents
  • Update packages/compass-schema/src/components/coordinates-minichart/utils.js

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>

  • open links in a separate window + remove unused styles
  • fix check

---------

Co-authored-by: Sergey Petushkov <petushkov.sergey@gmail.com>
Branch: main
https://github.com/mongodb-js/compass/commit/822c4798e772a8751cb7333bfeaeff3efbb3cb88

Generated at Wed Feb 07 22:40:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.