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

feature/110 Uses properties in GeppettoConfiguration.json (if present) #111

Merged
merged 2 commits into from
Oct 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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