foreman_inventory_upload 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_inventory_upload/version.rb +1 -1
  3. data/package.json +124 -0
  4. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +34 -0
  5. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +72 -0
  6. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +18 -0
  7. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +65 -0
  8. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +9 -0
  9. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
  10. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +55 -0
  11. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
  12. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
  13. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +16 -0
  14. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
  15. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -0
  16. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +26 -0
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +7 -0
  18. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +1 -0
  19. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
  20. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +23 -0
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +13 -0
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +18 -0
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +1 -0
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -0
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +39 -0
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +13 -0
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +48 -0
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +1 -0
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +6 -0
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +43 -0
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +29 -0
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +14 -0
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +78 -0
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +1 -0
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +16 -0
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +13 -0
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +20 -0
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
  43. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +60 -0
  44. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +26 -0
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +41 -0
  46. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +47 -0
  47. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +66 -0
  48. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +40 -0
  49. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
  50. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +30 -0
  51. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
  52. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +146 -0
  53. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +19 -0
  54. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +87 -0
  55. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +9 -0
  56. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
  57. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +68 -0
  58. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +17 -0
  59. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +25 -0
  60. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +39 -0
  61. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +16 -0
  62. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +64 -0
  63. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +45 -0
  64. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +36 -0
  65. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +76 -0
  66. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +44 -0
  67. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +42 -0
  68. data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
  69. data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +37 -0
  70. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
  71. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +22 -0
  72. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
  73. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -0
  74. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +25 -0
  75. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +3 -0
  76. data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +1 -0
  77. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
  78. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +50 -0
  79. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
  80. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +13 -0
  81. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +64 -0
  82. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +10 -0
  83. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +1 -0
  84. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +10 -0
  85. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +83 -0
  86. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
  87. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +26 -0
  88. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +89 -0
  89. data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +1 -0
  90. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -0
  91. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +16 -0
  92. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +57 -0
  93. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
  94. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +14 -0
  95. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +45 -0
  96. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +1 -0
  97. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
  98. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +18 -0
  99. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +57 -0
  100. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
  101. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +14 -0
  102. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +45 -0
  103. data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +1 -0
  104. data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
  105. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +3 -0
  106. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +27 -0
  107. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
  108. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +14 -0
  109. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +25 -0
  110. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -0
  111. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +11 -0
  112. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
  113. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +53 -0
  114. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
  115. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +13 -0
  116. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
  117. data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +1 -0
  118. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +8 -0
  119. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
  120. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +31 -0
  121. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
  122. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +13 -0
  123. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +19 -0
  124. data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +1 -0
  125. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +3 -0
  126. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
  127. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +24 -0
  128. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
  129. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +13 -0
  130. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
  131. data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +1 -0
  132. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +8 -0
  133. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
  134. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +19 -0
  135. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
  136. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +13 -0
  137. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
  138. data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +1 -0
  139. data/webpack/ForemanInventoryUpload/Components/TabFooter/tabFooter.scss +0 -0
  140. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.fixtures.js +0 -0
  141. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +45 -0
  142. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
  143. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +13 -0
  144. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +53 -0
  145. data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +1 -0
  146. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +21 -0
  147. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +10 -0
  148. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +112 -0
  149. data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +6 -0
  150. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +35 -0
  151. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +98 -0
  152. data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +1 -0
  153. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +31 -0
  154. data/webpack/ForemanInventoryUpload/Components/Tree/Tree.fixtures.js +3 -0
  155. data/webpack/ForemanInventoryUpload/Components/Tree/Tree.js +29 -0
  156. data/webpack/ForemanInventoryUpload/Components/Tree/TreeHelper.js +0 -0
  157. data/webpack/ForemanInventoryUpload/Components/Tree/__tests__/Tree.test.js +14 -0
  158. data/webpack/ForemanInventoryUpload/Components/Tree/__tests__/__snapshots__/Tree.test.js.snap +63 -0
  159. data/webpack/ForemanInventoryUpload/Components/Tree/index.js +1 -0
  160. data/webpack/ForemanInventoryUpload/Components/Tree/tree.scss +0 -0
  161. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +15 -0
  162. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +10 -0
  163. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +12 -0
  164. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
  165. data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +16 -0
  166. data/webpack/ForemanInventoryUpload/index.js +1 -0
  167. data/webpack/__mocks__/foremanReact/API.js +7 -0
  168. data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
  169. data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
  170. data/webpack/index.js +18 -0
  171. data/webpack/stories/ForemanInventoryUploadReducers.js +3 -0
  172. data/webpack/stories/configureStore.js +15 -0
  173. data/webpack/stories/decorators/index.js +1 -0
  174. data/webpack/stories/decorators/withCardsDecorator.js +14 -0
  175. data/webpack/stories/index.js +10 -0
  176. data/webpack/stories/index.scss +7 -0
  177. data/webpack/test_setup.js +6 -0
  178. metadata +177 -2
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { noop, Grid, Button, Icon } from 'patternfly-react';
4
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
5
+ import './tabHeader.scss';
6
+
7
+ const TabHeader = ({ exitCode, onRestart, onDownload, toggleFullScreen }) => (
8
+ <Grid.Row className="tab-header">
9
+ <Grid.Col sm={6}>
10
+ <p>{sprintf(__('Exit Code: %s'), exitCode)}</p>
11
+ </Grid.Col>
12
+ <Grid.Col sm={6}>
13
+ <div className="tab-action-buttons">
14
+ <Button bsStyle="primary" onClick={onRestart}>
15
+ {__('Restart')}
16
+ </Button>
17
+ {onDownload ? (
18
+ <Button onClick={onDownload}>
19
+ {__('Download Report')} <Icon name="download" />
20
+ </Button>
21
+ ) : null}
22
+ <Button onClick={toggleFullScreen}>
23
+ {__('Full Screen')}
24
+ <Icon name="arrows-alt" />
25
+ </Button>
26
+ </div>
27
+ </Grid.Col>
28
+ </Grid.Row>
29
+ );
30
+
31
+ TabHeader.propTypes = {
32
+ onRestart: PropTypes.func,
33
+ onDownload: PropTypes.func,
34
+ exitCode: PropTypes.string,
35
+ toggleFullScreen: PropTypes.func,
36
+ };
37
+
38
+ TabHeader.defaultProps = {
39
+ onRestart: noop,
40
+ exitCode: '',
41
+ onDownload: null,
42
+ toggleFullScreen: noop,
43
+ };
44
+
45
+ export default TabHeader;
@@ -0,0 +1,13 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import TabHeader from '../TabHeader';
4
+
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
9
+
10
+ describe('TabHeader', () => {
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(TabHeader, fixtures));
13
+ });
@@ -0,0 +1,53 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TabHeader rendering render without Props 1`] = `
4
+ <Row
5
+ bsClass="row"
6
+ className="tab-header"
7
+ componentClass="div"
8
+ >
9
+ <Col
10
+ bsClass="col"
11
+ componentClass="div"
12
+ sm={6}
13
+ >
14
+ <p>
15
+ Exit Code:
16
+ </p>
17
+ </Col>
18
+ <Col
19
+ bsClass="col"
20
+ componentClass="div"
21
+ sm={6}
22
+ >
23
+ <div
24
+ className="tab-action-buttons"
25
+ >
26
+ <Button
27
+ active={false}
28
+ block={false}
29
+ bsClass="btn"
30
+ bsStyle="primary"
31
+ disabled={false}
32
+ onClick={[Function]}
33
+ >
34
+ Restart
35
+ </Button>
36
+ <Button
37
+ active={false}
38
+ block={false}
39
+ bsClass="btn"
40
+ bsStyle="default"
41
+ disabled={false}
42
+ onClick={[Function]}
43
+ >
44
+ Full Screen
45
+ <Icon
46
+ name="arrows-alt"
47
+ type="fa"
48
+ />
49
+ </Button>
50
+ </div>
51
+ </Col>
52
+ </Row>
53
+ `;
@@ -0,0 +1 @@
1
+ export { default } from './TabHeader';
@@ -0,0 +1,21 @@
1
+ .tab-header {
2
+ h1 {
3
+ margin-top: 0;
4
+ }
5
+
6
+ p {
7
+ font-size: 16px;
8
+ }
9
+
10
+ .tab-action-buttons {
11
+ float: right;
12
+
13
+ button {
14
+ margin-left: 5px;
15
+
16
+ span {
17
+ margin-left: 5px;
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,10 @@
1
+ export const logs = [
2
+ 'Generating...',
3
+ 'Hosts: 1000',
4
+ 'writing host 1/1000',
5
+ 'writing host 2/1000',
6
+ ];
7
+
8
+ export const exitCode = 'Running pid 1111111';
9
+
10
+ export const props = { logs, exitCode };
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Grid, Spinner } from 'patternfly-react';
4
+ import isEqual from 'lodash/isEqual';
5
+ import './terminal.scss';
6
+ import { isTerminalScrolledDown } from './TerminalHelper';
7
+
8
+ class Terminal extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.terminal = React.createRef();
12
+ this.state = {
13
+ didUserScroll: false,
14
+ };
15
+ }
16
+
17
+ componentDidMount() {
18
+ this.scrollBottom();
19
+ }
20
+
21
+ componentDidUpdate({ logs: prevLogs }) {
22
+ const { logs: currentLogs, autoScroll } = this.props;
23
+ const { didUserScroll } = this.state;
24
+ if (autoScroll && !didUserScroll && !isEqual(prevLogs, currentLogs)) {
25
+ this.scrollBottom();
26
+ }
27
+ }
28
+
29
+ handleScroll = e => {
30
+ const { scrollTop, scrollHeight, offsetHeight } = e.target;
31
+ const didUserScroll = isTerminalScrolledDown(
32
+ scrollHeight,
33
+ scrollTop,
34
+ offsetHeight,
35
+ 100
36
+ );
37
+ this.setState({
38
+ didUserScroll,
39
+ });
40
+ };
41
+
42
+ scrollBottom = () => {
43
+ const element = this.terminal.current;
44
+ if (!element) {
45
+ return;
46
+ }
47
+ const setHeightToBottom = () => {
48
+ element.scrollTop = element.scrollHeight;
49
+ };
50
+ /** happens on tab switching when the terminal wasn't visible yet
51
+ * and there was nothing to scroll, 250ms is enough to wait for the terminal to appear.
52
+ */
53
+ if (element.scrollHeight === 0) {
54
+ setTimeout(setHeightToBottom, 250);
55
+ } else {
56
+ setHeightToBottom();
57
+ }
58
+ };
59
+
60
+ render() {
61
+ const { logs, error, exitCode } = this.props;
62
+ let modifiedLogs = null;
63
+ if (error !== null) {
64
+ modifiedLogs = <p className="terminal_error">{error}</p>;
65
+ } else if (Array.isArray(logs)) {
66
+ modifiedLogs = logs.map((log, index) => <p key={index}>{log}</p>);
67
+ } else {
68
+ modifiedLogs = <p>{logs}</p>;
69
+ }
70
+ const exitCodeLowerCase = exitCode.toLowerCase();
71
+ const loading =
72
+ exitCodeLowerCase.indexOf('running') !== -1 ||
73
+ exitCodeLowerCase.indexOf('restarting') !== -1;
74
+ return (
75
+ <Grid.Col sm={12}>
76
+ <div
77
+ className="terminal"
78
+ ref={this.terminal}
79
+ onScroll={this.handleScroll}
80
+ >
81
+ <Grid fluid>
82
+ <Grid.Row>
83
+ <Grid.Col sm={12}>
84
+ {modifiedLogs}
85
+ <Spinner loading={loading} inverse inline size="xs" />
86
+ </Grid.Col>
87
+ </Grid.Row>
88
+ </Grid>
89
+ </div>
90
+ </Grid.Col>
91
+ );
92
+ }
93
+ }
94
+
95
+ Terminal.propTypes = {
96
+ logs: PropTypes.oneOfType([
97
+ PropTypes.arrayOf(PropTypes.string),
98
+ PropTypes.string,
99
+ ]),
100
+ error: PropTypes.string,
101
+ exitCode: PropTypes.string,
102
+ autoScroll: PropTypes.bool,
103
+ };
104
+
105
+ Terminal.defaultProps = {
106
+ logs: null,
107
+ error: null,
108
+ exitCode: '',
109
+ autoScroll: true,
110
+ };
111
+
112
+ export default Terminal;
@@ -0,0 +1,6 @@
1
+ export const isTerminalScrolledDown = (
2
+ scrollHeight,
3
+ scrollTop,
4
+ terminalHeight,
5
+ tolerance
6
+ ) => scrollTop <= scrollHeight - terminalHeight - tolerance;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
3
+ import { mount } from 'enzyme';
4
+ import Terminal from '../Terminal';
5
+ import { props, logs } from '../Terminal.fixtures';
6
+
7
+ const fixtures = {
8
+ 'render without Props': {},
9
+ 'render with props': props,
10
+ };
11
+
12
+ describe('Terminal', () => {
13
+ describe('rendering', () =>
14
+ testComponentSnapshotsWithFixtures(Terminal, fixtures));
15
+
16
+ it('handles terminal scroll on componentDidUpdate', () => {
17
+ const wrapper = mount(<Terminal {...props} />);
18
+ jest.spyOn(wrapper.instance(), 'scrollBottom');
19
+ wrapper.setProps({ logs: [...logs, 'new-log'] });
20
+ expect(wrapper.instance().scrollBottom).toBeCalled();
21
+ });
22
+
23
+ it('error should be displayed in terminal', () => {
24
+ const modifiedProps = { ...props, error: 'some-error' };
25
+ const wrapper = mount(<Terminal {...modifiedProps} />);
26
+ expect(wrapper.find('p.terminal_error').exists()).toBeTruthy();
27
+ });
28
+
29
+ it('logs as a string instead of an array should be displayed', () => {
30
+ const text = 'some-string-log';
31
+ const modifiedProps = { ...props, logs: text };
32
+ const wrapper = mount(<Terminal {...modifiedProps} />);
33
+ expect(wrapper.find('.terminal p').text()).toEqual(text);
34
+ });
35
+ });
@@ -0,0 +1,98 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Terminal rendering render with props 1`] = `
4
+ <Col
5
+ bsClass="col"
6
+ componentClass="div"
7
+ sm={12}
8
+ >
9
+ <div
10
+ className="terminal"
11
+ onScroll={[Function]}
12
+ >
13
+ <Grid
14
+ bsClass="container"
15
+ componentClass="div"
16
+ fluid={true}
17
+ >
18
+ <Row
19
+ bsClass="row"
20
+ componentClass="div"
21
+ >
22
+ <Col
23
+ bsClass="col"
24
+ componentClass="div"
25
+ sm={12}
26
+ >
27
+ <p
28
+ key="0"
29
+ >
30
+ Generating...
31
+ </p>
32
+ <p
33
+ key="1"
34
+ >
35
+ Hosts: 1000
36
+ </p>
37
+ <p
38
+ key="2"
39
+ >
40
+ writing host 1/1000
41
+ </p>
42
+ <p
43
+ key="3"
44
+ >
45
+ writing host 2/1000
46
+ </p>
47
+ <Spinner
48
+ className=""
49
+ inline={true}
50
+ inverse={true}
51
+ loading={true}
52
+ size="xs"
53
+ />
54
+ </Col>
55
+ </Row>
56
+ </Grid>
57
+ </div>
58
+ </Col>
59
+ `;
60
+
61
+ exports[`Terminal rendering render without Props 1`] = `
62
+ <Col
63
+ bsClass="col"
64
+ componentClass="div"
65
+ sm={12}
66
+ >
67
+ <div
68
+ className="terminal"
69
+ onScroll={[Function]}
70
+ >
71
+ <Grid
72
+ bsClass="container"
73
+ componentClass="div"
74
+ fluid={true}
75
+ >
76
+ <Row
77
+ bsClass="row"
78
+ componentClass="div"
79
+ >
80
+ <Col
81
+ bsClass="col"
82
+ componentClass="div"
83
+ sm={12}
84
+ >
85
+ <p />
86
+ <Spinner
87
+ className=""
88
+ inline={true}
89
+ inverse={true}
90
+ loading={false}
91
+ size="xs"
92
+ />
93
+ </Col>
94
+ </Row>
95
+ </Grid>
96
+ </div>
97
+ </Col>
98
+ `;
@@ -0,0 +1 @@
1
+ export { default } from './Terminal';
@@ -0,0 +1,31 @@
1
+ .terminal {
2
+ height: 200px;
3
+ background-color: #222;
4
+ padding: 10px 0;
5
+ margin-bottom: 20px;
6
+ overflow-y: scroll;
7
+ overflow-x: hidden;
8
+
9
+ p {
10
+ font-family: monospace;
11
+ font-size: 16px;
12
+ color: #22da26;
13
+
14
+ &.terminal_error {
15
+ color: #f00;
16
+ }
17
+ }
18
+
19
+ &::-webkit-scrollbar {
20
+ width: 12px;
21
+ height: 12px;
22
+ background: #aaa;
23
+ }
24
+
25
+ &::-webkit-scrollbar-thumb {
26
+ background: #222;
27
+ border-radius: 6px;
28
+ border: 3px solid transparent;
29
+ background-clip: content-box;
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ export const props = {
2
+ files: ['file1', 'file2', 'file3'],
3
+ };
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { default as RATTree } from 'react-animated-tree';
4
+ import { Grid } from 'patternfly-react';
5
+
6
+ const Tree = ({ files }) => {
7
+ const filesAmount = files.length;
8
+ const fileTrees = files.map((file, index) => (
9
+ <RATTree key={index} content={file} />
10
+ ));
11
+ return (
12
+ <Grid.Col sm={9}>
13
+ <p>There are currently {filesAmount} report files ready</p>
14
+ <RATTree content="Reports" open canHide visible>
15
+ {fileTrees}
16
+ </RATTree>
17
+ </Grid.Col>
18
+ );
19
+ };
20
+
21
+ Tree.propTypes = {
22
+ files: PropTypes.arrayOf(PropTypes.string),
23
+ };
24
+
25
+ Tree.defaultProps = {
26
+ files: [],
27
+ };
28
+
29
+ export default Tree;
@@ -0,0 +1,14 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import Tree from '../Tree';
4
+ import { props } from '../Tree.fixtures';
5
+
6
+ const fixtures = {
7
+ 'render without Props': {},
8
+ 'render with props': props,
9
+ };
10
+
11
+ describe('Tree', () => {
12
+ describe('rendering', () =>
13
+ testComponentSnapshotsWithFixtures(Tree, fixtures));
14
+ });
@@ -0,0 +1,63 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Tree rendering render with props 1`] = `
4
+ <Col
5
+ bsClass="col"
6
+ componentClass="div"
7
+ sm={9}
8
+ >
9
+ <p>
10
+ There are currently
11
+ 3
12
+ report files ready
13
+ </p>
14
+ <Tree
15
+ canHide={true}
16
+ content="Reports"
17
+ open={true}
18
+ visible={true}
19
+ >
20
+ <Tree
21
+ canHide={false}
22
+ content="file1"
23
+ key="0"
24
+ open={false}
25
+ visible={true}
26
+ />
27
+ <Tree
28
+ canHide={false}
29
+ content="file2"
30
+ key="1"
31
+ open={false}
32
+ visible={true}
33
+ />
34
+ <Tree
35
+ canHide={false}
36
+ content="file3"
37
+ key="2"
38
+ open={false}
39
+ visible={true}
40
+ />
41
+ </Tree>
42
+ </Col>
43
+ `;
44
+
45
+ exports[`Tree rendering render without Props 1`] = `
46
+ <Col
47
+ bsClass="col"
48
+ componentClass="div"
49
+ sm={9}
50
+ >
51
+ <p>
52
+ There are currently
53
+ 0
54
+ report files ready
55
+ </p>
56
+ <Tree
57
+ canHide={true}
58
+ content="Reports"
59
+ open={true}
60
+ visible={true}
61
+ />
62
+ </Col>
63
+ `;
@@ -0,0 +1 @@
1
+ export { default } from './Tree';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { IntlProvider } from 'react-intl';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import AccountList from './Components/AccountList';
5
+
6
+ const ForemanInventoryUpload = () => (
7
+ <IntlProvider locale={navigator.language}>
8
+ <div className="inventory-upload">
9
+ <h1>{__('Red Hat Inventory Uploads')}</h1>
10
+ <AccountList />
11
+ </div>
12
+ </IntlProvider>
13
+ );
14
+
15
+ export default ForemanInventoryUpload;
@@ -0,0 +1,10 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import ForemanInventoryUpload from './ForemanInventoryUpload';
4
+
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ };
8
+
9
+ describe('ForemanInventoryUpload', () =>
10
+ testComponentSnapshotsWithFixtures(ForemanInventoryUpload, fixtures));
@@ -0,0 +1,12 @@
1
+ import { combineReducers } from 'redux';
2
+ import { reducers as accountListReducers } from './Components/AccountList';
3
+ import { reducers as dashboardReducers } from './Components/Dashboard';
4
+
5
+ const reducers = {
6
+ ForemanInventoryUpload: combineReducers({
7
+ ...accountListReducers,
8
+ ...dashboardReducers,
9
+ }),
10
+ };
11
+
12
+ export default reducers;
@@ -0,0 +1,4 @@
1
+ // export const selectForemanInventoryUpload = state => state.ForemanInventoryUpload || {};
2
+ // Added 'state' to use redux in storybook only, should be removed.
3
+ export const selectForemanInventoryUpload = state =>
4
+ state.ForemanInventoryUpload || state || {};
@@ -0,0 +1,16 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ForemanInventoryUpload render without Props 1`] = `
4
+ <IntlProvider
5
+ locale="en-US"
6
+ >
7
+ <div
8
+ className="inventory-upload"
9
+ >
10
+ <h1>
11
+ Red Hat Inventory Uploads
12
+ </h1>
13
+ <Connect(AccountList) />
14
+ </div>
15
+ </IntlProvider>
16
+ `;
@@ -0,0 +1 @@
1
+ export { default } from './ForemanInventoryUpload';
@@ -0,0 +1,7 @@
1
+ export default {
2
+ get: jest.fn(),
3
+ put: jest.fn(),
4
+ post: jest.fn(),
5
+ delete: jest.fn(),
6
+ patch: jest.fn(),
7
+ };
@@ -0,0 +1,5 @@
1
+ export { sprintf } from 'jed';
2
+
3
+ export const translate = s => s;
4
+
5
+ export const ngettext = s => s;
@@ -0,0 +1,3 @@
1
+ export const getURIQuery = jest.fn(() => ({}));
2
+
3
+ export const noop = Function.prototype;
data/webpack/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /* eslint import/no-unresolved: [2, { ignore: [foremanReact/*] }] */
2
+ /* eslint-disable import/no-extraneous-dependencies */
3
+ /* eslint-disable import/extensions */
4
+ import componentRegistry from 'foremanReact/components/componentRegistry';
5
+ import { registerReducer } from 'foremanReact/common/MountingService';
6
+ import reducers from './ForemanInventoryUpload/ForemanInventoryUploadReducers';
7
+ import ForemanInventoryUpload from './ForemanInventoryUpload';
8
+
9
+ // register reducers
10
+ Object.entries(reducers).forEach(([key, reducer]) =>
11
+ registerReducer(key, reducer)
12
+ );
13
+
14
+ // register components
15
+ componentRegistry.register({
16
+ name: 'ForemanInventoryUpload',
17
+ type: ForemanInventoryUpload,
18
+ });
@@ -0,0 +1,3 @@
1
+ import reducers from '../ForemanInventoryUpload/ForemanInventoryUploadReducers';
2
+
3
+ export default reducers.ForemanInventoryUpload;