Skip to content

Commit

Permalink
Feature/1319 open desktop app in infoclick (#1341)
Browse files Browse the repository at this point in the history
* (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
  • Loading branch information
Hallbergs authored May 30, 2023
1 parent f669abd commit 144c368
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions new-admin/src/views/tools/infoclick.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var defaultState = {
anchorY: 1,
allowDangerousHtml: true,
useNewInfoclick: false,
transformLinkUri: true,
};

const ColorButtonBlue = withStyles((theme) => ({
Expand Down Expand Up @@ -70,6 +71,8 @@ class ToolOptions extends Component {
tool.options.allowDangerousHtml || this.state.allowDangerousHtml,
useNewInfoclick:
tool.options.useNewInfoclick || this.state.useNewInfoclick,
transformLinkUri:
tool.options.transformLinkUri ?? this.state.transformLinkUri,
visibleForGroups: tool.options.visibleForGroups
? tool.options.visibleForGroups
: [],
Expand Down Expand Up @@ -143,6 +146,7 @@ class ToolOptions extends Component {
fillColor: this.state.fillColor,
allowDangerousHtml: this.state.allowDangerousHtml,
useNewInfoclick: this.state.useNewInfoclick,
transformLinkUri: this.state.transformLinkUri,
visibleForGroups: this.state.visibleForGroups.map(
Function.prototype.call,
String.prototype.trim
Expand Down Expand Up @@ -386,6 +390,22 @@ class ToolOptions extends Component {
Använd ny Infoclick-variant (se GitHub issue #1034)
</label>
</div>
<div>
<input
id="transformLinkUri"
name="transformLinkUri"
type="checkbox"
onChange={(e) => {
this.handleInputChange(e);
}}
checked={this.state.transformLinkUri}
/>
&nbsp;
<label htmlFor="transformLinkUri" style={{ width: "auto" }}>
URL-verifiering aktiverad. (Verifieringen måste avaktiveras för
att tillåta länkar till desktop-programvaror.)
</label>
</div>
<div className="separator">Länkarnas utseende</div>

<div>
Expand Down
4 changes: 4 additions & 0 deletions new-client/src/components/FeatureInfo/FeaturePropsParsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default class FeaturePropsParsing {

// Default to true to ensure backwards compatibility with old configs that predominately use HTML
this.allowDangerousHtml = this.options.allowDangerousHtml ?? true;
// Do we want the markdown-renderer to transform the provided uri's or not? Defaults to true to make sure un-safe uri's are not passed by mistake.
// Disabling the transformer could be used to allow for links to desktop applications, for example app://open.
this.transformLinkUri = this.options.transformLinkUri ?? true;

// Here we define the components used by ReactMarkdown, see https://github.com/remarkjs/react-markdown#appendix-b-components
// Note that we import customComponentsForReactMarkdown from our shared library, spread those
Expand Down Expand Up @@ -423,6 +426,7 @@ export default class FeaturePropsParsing {
// will make use of the results in this.resolvedPromises, so that's why we had to wait.
return (
<ReactMarkdown
transformLinkUri={this.transformLinkUri ? undefined : (x) => x} // If transformLinksUri is set to false, we pass a function that simply returns the uri as-is.
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
Expand Down

0 comments on commit 144c368

Please sign in to comment.