Skip to content

Commit

Permalink
Merge pull request #111 from openworm/feature/110
Browse files Browse the repository at this point in the history
Uses properties in GeppettoConfiguration.json (if present)
  • Loading branch information
gidili authored Oct 21, 2019
2 parents 769918d + e612493 commit 0bd0683
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions js/components/controls/modals/ErrorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,45 @@ define(function (require) {
text: '',
code: '',
source: '',
exception: ''
exception: '',
githubButton : {
enabled : true,
url : "https://github.com/openworm/org.geppetto/issues/new"
},
twitterButton : {
enabled : true,
url : "http://geppetto.org",
message : "Whoops, I broke Geppetto! @geppettoengine help!"
}
}
},

// Searches for property in GEPPETTO_CONFIGURATION JSON object, if not found returns undefined.
getGeppettoConfigurationProperty: function (property) {
return property.split(".").reduce(function(o, x) {
return (typeof o == "undefined" || o === null) ? o : o[x];
}, GEPPETTO_CONFIGURATION);
},

shareTwitter: function () {
GEPPETTO.Share.twitter('http://geppetto.org','Whoops, I broke Geppetto! @geppettoengine help!');
let urlProperty = this.getGeppettoConfigurationProperty("properties.errorDialog.twitterButton.url");
let url = ( urlProperty != undefined ? urlProperty : this.props.twitterButton.url)
let messageProperty = this.getGeppettoConfigurationProperty("properties.errorDialog.twitterButton.message");
let message = ( messageProperty != undefined ? messageProperty : this.props.twitterButton.message)
window.open('http://twitter.com/share?url=' + encodeURIComponent(url) + '&text='
+ encodeURIComponent(message), '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
},

render: function (){
let twiButProp = (this.getGeppettoConfigurationProperty("properties.errorDialog.twitterButton.enabled") == undefined
? this.props.twitterButton.enabled : this.getGeppettoConfigurationProperty("properties.errorDialog.twitterButton.enabled"));
let twitterButtonVisible = ( twiButProp ? null : { display: "none" })
let gitButProp = (this.getGeppettoConfigurationProperty("properties.errorDialog.githubButton.enabled") == undefined
? this.props.githubButton.enabled : this.getGeppettoConfigurationProperty("properties.errorDialog.githubButton.enabled"));
let githubButtonVisible = ( gitButProp ? null : { display: "none" })
let confGitURL = this.getGeppettoConfigurationProperty("properties.errorDialog.githubButton.url");
let githubButtonURL = (confGitURL != undefined ? confGitURL : this.props.githubButton.url)
let githubMessage = this.getGeppettoConfigurationProperty("properties.errorDialog.message")
return (
<div className="modal fade" id="errormodal">
<div className="modal-dialog">
Expand All @@ -39,7 +69,7 @@ define(function (require) {
</div>
<div className="modal-body">
<p id="errormodal-text">
{this.props.message}
{githubMessage != undefined ? githubMessage : this.props.message}
</p>
<div className="panel panel-default">
<div className="panel-heading">
Expand All @@ -56,10 +86,10 @@ define(function (require) {
</div>
</div>
<div className="modal-footer" id="errormodal-footer">
<button className="btn" onClick={this.shareTwitter} aria-hidden="true">
<button className="btn" onClick={this.shareTwitter} aria-hidden="true" style={twitterButtonVisible}>
<i className="fa fa-twitter"></i> Shame on you
</button>
<a className="btn" href="https://github.com/openworm/org.geppetto/issues/new" target="_blank" aria-hidden="true">
<a className="btn" href={githubButtonURL} target="_blank" aria-hidden="true" style={githubButtonVisible}>
<i className="fa fa-bug"></i> Open issue
</a>
<button id="errormodal-btn" className="btn" data-dismiss="modal" aria-hidden="true">Close</button>
Expand Down

0 comments on commit 0bd0683

Please sign in to comment.