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

Add support for opening external programs in infoclick #1319

Closed
linusfj opened this issue Apr 12, 2023 · 6 comments · Fixed by #1341
Closed

Add support for opening external programs in infoclick #1319

linusfj opened this issue Apr 12, 2023 · 6 comments · Fixed by #1341
Assignees
Labels
module:client/plugin Functionality that goes into plugins in client
Milestone

Comments

@linusfj
Copy link
Member

linusfj commented Apr 12, 2023

Description
The current infoclick functionality does not support including links that open external programs, causing inconvenience for users. They must manually switch between programs or use less efficient workarounds while working with infoclick.

Example
In the layers configuration file, the link can look like the example below:
a href=\"appcontainer:ExternalApp/OpenIssue?issueid={issueid}

However, when rendered in infoclick, it is converted to a href="javascript:void(0)", which results in a client error and prevents the link from functioning as intended.

Suggested solution
Implement a feature that allows users to include links within infoclick that can open external programs, such as installed desktop applications or other non-browser-based tools.

@linusfj linusfj added the module:client/plugin Functionality that goes into plugins in client label Apr 12, 2023
@linusfj linusfj added this to the 3.x milestone Apr 12, 2023
@Hallbergs
Copy link
Member

I've had a look at this.

When we're using markdown, the component rendering the markdown does some uri-transformations. (We're using react-markdown, see: their GitHub page.

React-markdown makes sure that the provided url follows a few rules, one of which is that the protocol has to be one of the following: const protocols = ['http', 'https', 'mailto', 'tel']. I found no way to allow for protocol injection to the component...

However, i found that the uri-tranformer can be overridden, see below:

        <ReactMarkdown
          transformLinkUri={(x) => x}
          remarkPlugins={[gfm]} // GitHub Formatted Markdown adds support for Tables in MD
          rehypePlugins={rehypePlugins} // Needed to parse HTML, activated in admin
          components={this.components} // Custom renderers for components, see definition in this.components
          children={this.markdown} // Our MD, as a text string
        />

We could create out own function and pass it in the transformLinkUri-prop. If we would do that, we could allow for setting allowed protocols in appConfig.json for example.

I made a quick test with transformLinkUri={(x) => x} and it worked as expected, see below:
image

Hallbergs added a commit that referenced this issue Apr 25, 2023
This solution must be properly tested. Also, the `transformLinkUri` key must be added to the admin-application.
@Hallbergs
Copy link
Member

Added a solution that could possibly work. Feel free to check out and test for yourself.

@jacobwod
Copy link
Member

I'll check it out later today, seems promising!

@Hallbergs Hallbergs self-assigned this Apr 25, 2023
@Hallbergs
Copy link
Member

I added the setting to admin as well in the branch

@lina-sbk-gbg
Copy link

I have tested now and it works very well. However, the check box in admin does not seem to read the saved value in the config file. The checkbox is checked regardless of the value in config. Could it be related to the .NET backend or is it the same in NodeJS?

Great job regardless!

@jacobwod
Copy link
Member

PR please, @Hallbergs?

@Hallbergs Hallbergs linked a pull request May 29, 2023 that will close this issue
Hallbergs added a commit that referenced this issue May 30, 2023
* (Proposal) simple solution for #1319 (WIP, see desc)

This solution must be properly tested. Also, the `transformLinkUri` key must be added to the admin-application.

* Added proposed url-setting to admin

* Fixed default value in admin for `transformLinkUri`

* Fixed bad default value for `transformLinkUri` in infoClick
@Hallbergs Hallbergs modified the milestones: 3.x, 3.12 May 31, 2023
@jacobwod jacobwod closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:client/plugin Functionality that goes into plugins in client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants