diff options
author | liamfallon <liam.fallon@est.tech> | 2021-11-09 15:22:22 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2021-11-10 08:57:23 +0000 |
commit | 2022e5ce5a03788a6edc5761c495cfadc5ded485 (patch) | |
tree | 2df93f088fb323440945ce93ce67be1f2208c9bf /runtime/ui-react/src/components/loop_viewer/logs | |
parent | 579085240812aa593ebafe787d97868e16fc3318 (diff) |
Align ui-react file in policy-clamp and policy-gui
When the ui-react code was transferred to policy-gui, the white space
was cleaned up and reformatted. This makes it difficult to track the
real functional changes if any between ui-react in policy-clamp and
policy-gui.
This review brings the white space changes into ui-react in policy-clamp
to make file comparisons easier.
Issue-ID: POLICY-3358
Change-Id: Ic303e71b341e5c0f7ca0de0ed4c4962ebf2f988a
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'runtime/ui-react/src/components/loop_viewer/logs')
-rw-r--r-- | runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.js | 107 | ||||
-rw-r--r-- | runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js | 76 |
2 files changed, 92 insertions, 91 deletions
diff --git a/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.js b/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.js index e3d9f601f..3435ba3bc 100644 --- a/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.js +++ b/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.js @@ -26,71 +26,72 @@ import LoopCache from '../../../api/LoopCache'; import styled from 'styled-components'; const LoopLogsHeaderDivStyled = styled.div` - background-color: ${props => props.theme.loopLogsHeaderBackgroundColor}; - padding: 10px 10px; - color: ${props => props.theme.loopLogsHeaderFontColor}; + background-color: ${ props => props.theme.loopLogsHeaderBackgroundColor }; + padding: 10px 10px; + color: ${ props => props.theme.loopLogsHeaderFontColor }; ` const TableStyled = styled(Table)` - - overflow: auto; + + overflow: auto; ` const TableRow = ({ logRow }) => ( - <tr> - <td>{logRow.logInstant}</td> - <td>{logRow.logType}</td> - <td>{logRow.logComponent}</td> - <td>{logRow.message}</td> - </tr> + <tr> + <td>{ logRow.logInstant }</td> + <td>{ logRow.logType }</td> + <td>{ logRow.logComponent }</td> + <td>{ logRow.message }</td> + </tr> ) export default class LoopLogs extends React.Component { - state = { - loopCache: new LoopCache({}) - } - constructor(props) { - super(props); - this.renderLogs = this.renderLogs.bind(this); - this.state.loopCache = props.loopCache; - } + state = { + loopCache: new LoopCache({}) + } + + constructor(props) { + super(props); + this.renderLogs = this.renderLogs.bind(this); + this.state.loopCache = props.loopCache; + } - shouldComponentUpdate(nextProps, nextState) { - return this.state.loopCache !== nextState.loopCache; - } + shouldComponentUpdate(nextProps, nextState) { + return this.state.loopCache !== nextState.loopCache; + } - componentWillReceiveProps(newProps) { - this.setState({ - loopCache: newProps.loopCache - }); - } + componentWillReceiveProps(newProps) { + this.setState({ + loopCache: newProps.loopCache + }); + } - renderLogs() { - let logsArray = this.state.loopCache.getLoopLogsArray(); - if (logsArray != null) { - return (logsArray.map(row => <TableRow key={row.id} logRow={row} />)); - } - } + renderLogs() { + let logsArray = this.state.loopCache.getLoopLogsArray(); + if (logsArray != null) { + return (logsArray.map(row => <TableRow key={ row.id } logRow={ row }/>)); + } + } - render() { - return ( - <LoopLogsHeaderDivStyled> - <label>Loop Logs</label> - <TableStyled striped hover variant responsive> - <thead> - <tr> - <th><span align="left">Date</span></th> - <th><span align="left">Type</span></th> - <th><span align="left">Component</span></th> - <th><span align="right">Log</span></th> - </tr> - </thead> - <tbody> - {this.renderLogs()} - </tbody> - </TableStyled> - </LoopLogsHeaderDivStyled> + render() { + return ( + <LoopLogsHeaderDivStyled> + <label>Loop Logs</label> + <TableStyled striped hover variant responsive> + <thead> + <tr> + <th><span align="left">Date</span></th> + <th><span align="left">Type</span></th> + <th><span align="left">Component</span></th> + <th><span align="right">Log</span></th> + </tr> + </thead> + <tbody> + { this.renderLogs() } + </tbody> + </TableStyled> + </LoopLogsHeaderDivStyled> - ); - } + ); + } } diff --git a/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js b/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js index 3b7fd413a..d3a21d80d 100644 --- a/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js +++ b/runtime/ui-react/src/components/loop_viewer/logs/LoopLogs.test.js @@ -27,44 +27,44 @@ import LoopCache from '../../../api/LoopCache'; describe('Verify LoopLogs', () => { - const loopCache = new LoopCache({ - "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", - "loopLogs": [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - } - ] - }); + const loopCache = new LoopCache({ + "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", + "loopLogs": [ + { + "id": 1, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational policies UPDATED", + "logInstant": "2019-07-08T09:44:37Z" + } + ] + }); - it('Test the render method', () => { - const component = shallow(<LoopLogs loopCache={loopCache}/>) - expect(component).toMatchSnapshot(); + it('Test the render method', () => { + const component = shallow(<LoopLogs loopCache={ loopCache }/>) + expect(component).toMatchSnapshot(); - const loopCacheUpdated = new LoopCache({ - "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", - "loopLogs": [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - }, - { - "id": 2, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational policies UPDATED", - "logInstant": "2019-07-08T09:44:50Z" - } - ] - }); + const loopCacheUpdated = new LoopCache({ + "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", + "loopLogs": [ + { + "id": 1, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational policies UPDATED", + "logInstant": "2019-07-08T09:44:37Z" + }, + { + "id": 2, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational policies UPDATED", + "logInstant": "2019-07-08T09:44:50Z" + } + ] + }); - component.setProps({ loopCache: loopCacheUpdated }); - expect(component.find('TableRow').length).toEqual(2); - }); -});
\ No newline at end of file + component.setProps({ loopCache: loopCacheUpdated }); + expect(component.find('TableRow').length).toEqual(2); + }); +}); |