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

[ISSUE#1397] Fix file explorer opening when clicking on HeroCard button #1631

Merged
merged 16 commits into from
Jul 8, 2019

Conversation

denscollo
Copy link
Contributor

Fixes #1397

Description

Added validation to check the value of the URL before using it because if it's empty, the file explorer will open by default.

Specific changes

  • Add URL validation when hyperlink is open

Testing

We used the user hero card to test the fix.
image

@@ -52,6 +52,8 @@ export default function interceptHyperlink() {

// Monkey patch window.open
window.open = (url: string): any => {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is nothing wrong with this approach however, I'm confident this logic should be reviewed for incorporation into WebChat at this location. It seems like an enhancement that could have value there.

@justinwilaby
Copy link
Contributor

This is related to #1504 and #368 in webchat.

@cwhitten - can you please provide definitive guidance on an action item here? Although not ideal, we can adopt this PR as an interim solution until a WebChat solution is available or I can work with @compulim and @corinagum to revive #1604

@cwhitten
Copy link
Member

The window.open ponyfill in WebChat landed here.

@justinwilaby
Copy link
Contributor

justinwilaby commented Jun 13, 2019

I'm seeing that just now. It looks like we want to implement the cardActionMiddleware in the Emulator and then perform the checks when a URL is opened.

@denscollo - From the information @cwhitten provided, you should work towards the implementation listed in this example as it represents a more idiomatic approach to this solution.

Copy link
Contributor

@justinwilaby justinwilaby left a comment

Choose a reason for hiding this comment

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

Please use this example to solve this defect. Feel free to reach out if you need help.

@denscollo
Copy link
Contributor Author

@justinwilaby @cwhitten thanks for the feedback! We'll be working by using the example and let you know as soon as we have the new solution.

@cwhitten
Copy link
Member

@denscollo is this ready for review? At the moment we're seeing an extremely small diff.

@tonyanziano
Copy link
Contributor

@denscollo I believe what Justin meant by using that example, is that we want to implement the cardActionMiddleware in the Emulator and then pass it into the Web Chat component as a prop when we render it here.

So it would look something like:

chat.tsx

const cardActionMiddleware = () => next => async ({ cardAction, getSignInUrl }) => {
  // your fix
};

public render() {

  <ReactWebChat
    cardActionMiddleware={cardActionMiddleware}
    ...
  />

@justinwilaby
Copy link
Contributor

Thank you for providing this clarification @tonyanziano

@denscollo
Copy link
Contributor Author

@justinwilaby @tonyanziano Thanks for the clarification! This is still a WIP, we are working on it. We are reviewing the changes on our fork and then we'll push them.

@denscollo
Copy link
Contributor Author

@justinwilaby @tonyanziano the PR is now ready for review!

Copy link
Contributor

@justinwilaby justinwilaby left a comment

Choose a reason for hiding this comment

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

Sorry to have to do this again. It's our fault for not being specific on the original github issue. I'm requesting changes to remove confirm and use a custom dialog using the DialogService. This will maintain consistency across the app and prevent possible side-effects from a blocking operation.

Also, since this is new functionality, unit tests need to accompany this PR.

case 'playVideo':
case 'showImage':
case 'openUrl':
if (confirm(`Do you want to open this URL?\n\n${value}`)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We typically favor custom dialogs over native since UX continuity is better across the app. Also, confirm is thread-blocking and may have side-effects if the main process sends IPC messages during the display of this confirmation modal.

I realize this is more work to create a custom prompt using the DialogService but I believe it's the right thing to do. Please feel free to reach out to me if you need guidance on implementing this.

@denscollo
Copy link
Contributor Author

@justinwilaby Ok, we'll be working on this approach and let you know if we have doubts. Thanks!

@denscollo denscollo changed the title Fix file explorer opening when clicking on HeroCard button [ISSUE#1397] Fix file explorer opening when clicking on HeroCard button Jun 25, 2019
@denscollo denscollo force-pushed the fix/hero-card-open-file-explorer branch from f156821 to 85443fd Compare June 26, 2019 21:14
@denscollo
Copy link
Contributor Author

@justinwilaby we finished applying the feedback, so it's ready for review!

Copy link
Contributor

@tonyanziano tonyanziano left a comment

Choose a reason for hiding this comment

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

Going to pull the branch down and test it out locally. I had some minor comments.

Copy link
Contributor

@tonyanziano tonyanziano 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 now!

@tonyanziano tonyanziano merged commit 268b814 into master Jul 8, 2019
@tonyanziano tonyanziano deleted the fix/hero-card-open-file-explorer branch July 8, 2019 17:57
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.

File explorer opening when clicking on HeroCard button
6 participants