forked from modelab/DynamoDictionary_React
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds error message section components
- Loading branch information
Horatiu Bota
committed
Nov 4, 2019
1 parent
889a936
commit fc6b953
Showing
2 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import React from 'react'; | ||
import { hashHistory, withRouter, browserHistory } from 'react-router'; | ||
import classNames from 'classnames'; | ||
|
||
const buttonStyle = { | ||
paddingLeft: 20, | ||
paddingRight: 20 | ||
}; | ||
|
||
const sections = [ | ||
{ | ||
name: 'Scripting Errors', | ||
path: 'ScriptingErrors', | ||
children: [ | ||
{ | ||
name: 'Operation Failed', | ||
route: 'CommonErrorMessages/ScriptingErrors/OperationFailed' | ||
}, | ||
{ | ||
name: 'Deprecated', | ||
route: 'CommonErrorMessages/ScriptingErrors/Deprecated' | ||
}, | ||
{ | ||
name: 'Index Out of Range', | ||
route: 'CommonErrorMessages/ScriptingErrors/IndexOutOfRange' | ||
}, | ||
{ | ||
name: 'Method Not Found', | ||
route: 'CommonErrorMessages/ScriptingErrors/MethodNotFound' | ||
}, | ||
{ | ||
name: 'Unhandled Exception', | ||
route: 'CommonErrorMessages/ScriptingErrors/UnhandledException' | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'Other Errors', | ||
path: 'OtherErrors', | ||
children: [ | ||
{ | ||
name: 'Custom Node Not Loaded', | ||
route: 'CommonErrorMessages/OtherErrors/CustomNodeNotLoaded' | ||
}, | ||
{ | ||
name: 'Converted Array To Non Array', | ||
route: 'CommonErrorMessages/OtherErrors/ConvertArrayToNonArray' | ||
}, | ||
{ | ||
name: 'Property Of Class Not Found', | ||
route: 'CommonErrorMessages/OtherErrors/PropertyOfClassNotFound' | ||
}, | ||
{ | ||
name: 'Run Completed With Warnings', | ||
route: 'CommonErrorMessages/OtherErrors/RunCompletedWithWarnings' | ||
}, | ||
{ | ||
name: 'Excel Not Installed', | ||
route: 'CommonErrorMessages/OtherErrors/ExcelNotInstalled' | ||
} | ||
] | ||
} | ||
]; | ||
|
||
class CommonErrorMessagesSection extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { isActive: this.props.isActive }; | ||
|
||
} | ||
|
||
componentDidMount() { | ||
this.unlisten = browserHistory.listen(location => { | ||
this.setState({isActive: location.hash.includes(this.props.section.path)}); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.unlisten(); | ||
} | ||
|
||
render() { | ||
|
||
const classes = classNames('button', 'accordion', 'button2', | ||
{'active': this.state.isActive}) | ||
|
||
return ( | ||
<div> | ||
<button | ||
className={classes} | ||
style={buttonStyle} | ||
onClick={() => this.setState({ isActive: !this.state.isActive })}> | ||
{this.props.section.name} | ||
</button> | ||
{this.state.isActive ? (<div> | ||
{ this.props.section.children.map((item, i) => | ||
<div key={i}> | ||
<button | ||
className={'button accordion button3'} | ||
style={buttonStyle} | ||
onClick={() => hashHistory.push(item.route)}> | ||
{item.name} | ||
</button> | ||
</div>) } | ||
</div>) : null | ||
} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
class CommonErrorMessagesButton extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { isActive: props.location.pathname.includes('CommonErrorMessages') }; | ||
} | ||
|
||
componentDidMount() { | ||
this.unlisten = browserHistory.listen(location => { | ||
this.setState({isActive: location.hash.includes('CommonErrorMessages')}); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.unlisten(); | ||
} | ||
|
||
render() { | ||
const classes = classNames('button', 'accordion', 'button1', {'active': this.state.isActive}) | ||
|
||
return ( | ||
<div> | ||
<button | ||
className={classes} | ||
style={buttonStyle} | ||
onClick={() => this.setState({ isActive: !this.state.isActive })}> | ||
Common Error Messages | ||
</button> | ||
{this.state.isActive ? | ||
(<div> | ||
{ sections.map((item, i) => <CommonErrorMessagesSection | ||
key={i} section={item} | ||
isActive={this.props.location.pathname.includes(item.path)}/>) } | ||
</div>) | ||
: null | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withRouter(CommonErrorMessagesButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import { withRouter, browserHistory } from 'react-router'; | ||
|
||
import ErrorOperationFailedHTML from './error_pages/OperationFailType1.html' | ||
import ErrorMethodNotFoundHTML from './error_pages/kMethodNotFound.html' | ||
import ErrorIndexOutOfRangeHTML from './error_pages/kIndexOutOfRange.html' | ||
import ErrorDeprecatedHTML from './error_pages/Deprecated.html' | ||
import ErrorUnhandledExceptionHTML from './error_pages/UnhandledException.html' | ||
|
||
import ErrorCustomNodeNotLoadedHTML from './error_pages/CustomNodeNotLoaded.html' | ||
import ErrorConvertArrayToNonArrayHTML from './error_pages/kConvertArrayToNonArray.html' | ||
import ErrorPropertyOfClassNotFoundHTML from './error_pages/kPropertyOfClassNotFound.html' | ||
import ErrorRunCompletedWithWarningsHTML from './error_pages/RunCompletedWithWarningsMessage.html' | ||
import ErrorExcelNotInstalledHTML from './error_pages/ExcelNotInstalled.html' | ||
|
||
|
||
const containerStyle = { | ||
padding: 20 | ||
}; | ||
|
||
|
||
const contentSwitch = function(path) { | ||
|
||
if (path.endsWith('OperationFailed')) { | ||
return ErrorOperationFailedHTML | ||
} else if (path.endsWith('MethodNotFound')) { | ||
return ErrorMethodNotFoundHTML | ||
} else if (path.endsWith('IndexOutOfRange')) { | ||
return ErrorIndexOutOfRangeHTML | ||
} else if (path.endsWith('Deprecated')) { | ||
return ErrorDeprecatedHTML | ||
} else if (path.endsWith('UnhandledException')) { | ||
return ErrorUnhandledExceptionHTML | ||
} else if (path.endsWith('CustomNodeNotLoaded')) { | ||
return ErrorCustomNodeNotLoadedHTML | ||
} else if (path.endsWith('ConvertArrayToNonArray')) { | ||
return ErrorConvertArrayToNonArrayHTML | ||
} else if (path.endsWith('PropertyOfClassNotFound')) { | ||
return ErrorPropertyOfClassNotFoundHTML | ||
} else if (path.endsWith('RunCompletedWithWarnings')) { | ||
return ErrorRunCompletedWithWarningsHTML | ||
} else if (path.endsWith('ExcelNotInstalled')) { | ||
return ErrorExcelNotInstalledHTML | ||
} else { | ||
return ErrorOperationFailedHTML | ||
} | ||
} | ||
|
||
class CommonErrorMessagesContainer extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { path: props.location.pathname }; | ||
} | ||
|
||
componentDidMount() { | ||
this.unlisten = browserHistory.listen(location => { | ||
this.setState({path: location.hash}); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.unlisten(); | ||
} | ||
|
||
render() { | ||
return <div style={containerStyle} | ||
dangerouslySetInnerHTML={{__html: contentSwitch(this.state.path)}} /> | ||
} | ||
} | ||
|
||
export default withRouter(CommonErrorMessagesContainer); |