@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +708 -0
  5. package/bin/cli.js +134 -27
  6. package/cert/cert.pem +37 -129
  7. package/cert/key.pem +27 -27
  8. package/cert/passphrase.pem +1 -0
  9. package/files/eslintrc.js +62 -0
  10. package/files/prettierrc.js +3 -0
  11. package/lib/babel/cmjs-plugins-presets.js +16 -9
  12. package/lib/babel/es-plugins-presets.js +26 -14
  13. package/lib/common/getEntries.js +33 -24
  14. package/lib/common/getPublicPathConfig.js +40 -0
  15. package/lib/common/index.js +27 -13
  16. package/lib/common/splitChunks.js +64 -26
  17. package/lib/common/sslcertUpdater.js +59 -0
  18. package/lib/common/templateParameters.js +25 -0
  19. package/lib/configs/jest.config.js +26 -27
  20. package/lib/configs/libAlias.js +31 -0
  21. package/lib/configs/webpack.component.umd.config.js +31 -37
  22. package/lib/configs/webpack.css.umd.config.js +44 -44
  23. package/lib/configs/webpack.dev.config.js +96 -56
  24. package/lib/configs/webpack.docs.config.js +104 -98
  25. package/lib/configs/webpack.impact.config.js +116 -0
  26. package/lib/configs/webpack.prod.config.js +137 -85
  27. package/lib/hooks/docsProptypeHook.js +32 -38
  28. package/lib/jest/commitedFilesResult.js +144 -71
  29. package/lib/jest/coverageCollector.js +62 -29
  30. package/lib/jest/jsonMaker.js +54 -0
  31. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  32. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  33. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  34. package/lib/jest/result.js +91 -41
  35. package/lib/jest/run.js +74 -27
  36. package/lib/jest/setup.js +103 -102
  37. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  38. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  39. package/lib/loaderUtils/index.js +14 -7
  40. package/lib/loaders/docsLoader.js +15 -15
  41. package/lib/loaders/docsPropsLoader.js +14 -17
  42. package/lib/loaders/fileBountryLoader.js +17 -0
  43. package/lib/loaders/fileLoader.js +47 -38
  44. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  45. package/lib/loaders/selectorMappingLoader.js +75 -0
  46. package/lib/loaders/workerLoader.js +136 -0
  47. package/lib/middlewares/HMRMiddleware.js +59 -41
  48. package/lib/middlewares/SSTMiddleware.js +21 -0
  49. package/lib/pluginUtils/getDevPlugins.js +175 -26
  50. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  51. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  52. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  53. package/lib/pluginUtils/getProdPlugins.js +240 -37
  54. package/lib/pluginUtils/getServerPlugins.js +8 -11
  55. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  56. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  57. package/lib/pluginUtils/index.js +36 -43
  58. package/lib/plugins/CdnChangePlugin.js +77 -0
  59. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  60. package/lib/plugins/EFCPlugin.js +241 -0
  61. package/lib/plugins/EFCPlugin.md +6 -0
  62. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  63. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  68. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  69. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  70. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  71. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  76. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  77. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  78. package/lib/plugins/ManifestPlugin.js +59 -62
  79. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  80. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  81. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  82. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  83. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  84. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  85. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  86. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  87. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  88. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  89. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  90. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  91. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  92. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  93. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  94. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  95. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  96. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  97. package/lib/plugins/index.js +118 -55
  98. package/lib/plugins/libraryImpactPlugin.js +190 -0
  99. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  100. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  101. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  102. package/lib/schemas/index.js +466 -52
  103. package/lib/servers/clusterHubServer.js +22 -26
  104. package/lib/servers/docsServer.js +3 -5
  105. package/lib/servers/docsServerCore.js +93 -85
  106. package/lib/servers/helpServer.js +19 -21
  107. package/lib/servers/httpsOptions.js +19 -0
  108. package/lib/servers/impactServer.js +99 -92
  109. package/lib/servers/mockserver.js +44 -0
  110. package/lib/servers/nowatchserver.js +275 -0
  111. package/lib/servers/scrServer.js +147 -0
  112. package/lib/servers/server.js +118 -124
  113. package/lib/servers/ssServer.js +107 -65
  114. package/lib/sh/reportPublish.sh +16 -10
  115. package/lib/templates/CoverageScriptTemplate.js +45 -18
  116. package/lib/templates/WMSTemplate.js +17 -18
  117. package/lib/templates/linterConstant.js +10 -0
  118. package/lib/utils/babelPresets.js +12 -5
  119. package/lib/utils/buildstats.html +148 -0
  120. package/lib/utils/clean.js +12 -11
  121. package/lib/utils/copy.js +13 -127
  122. package/lib/utils/copyTimezones.js +21 -0
  123. package/lib/utils/createEventStream.js +24 -19
  124. package/lib/utils/cssClassNameGenerate.js +77 -0
  125. package/lib/utils/cssURLReplacer.js +67 -54
  126. package/lib/utils/dependencyPostPublish.js +42 -0
  127. package/lib/utils/fileUtils.js +125 -0
  128. package/lib/utils/folderIterator.js +47 -0
  129. package/lib/utils/getComponents.js +126 -0
  130. package/lib/utils/getCurrentBranch.js +11 -17
  131. package/lib/utils/getDependenciesImpactList.js +151 -0
  132. package/lib/utils/getHash.js +26 -0
  133. package/lib/utils/getIp.js +20 -0
  134. package/lib/utils/getOptions.js +55 -30
  135. package/lib/utils/getServerURL.js +25 -8
  136. package/lib/utils/index.js +259 -82
  137. package/lib/utils/init.js +2 -2
  138. package/lib/utils/initPreCommitHook.js +40 -31
  139. package/lib/utils/jsonHelper.js +97 -0
  140. package/lib/utils/libraryImpactConfig.js +63 -0
  141. package/lib/utils/lint/addScripts.js +27 -0
  142. package/lib/utils/lint/checkExistingConfig.js +67 -0
  143. package/lib/utils/lint/copyConfigs.js +24 -0
  144. package/lib/utils/lint/index.js +54 -0
  145. package/lib/utils/lint/lintScripts.js +11 -0
  146. package/lib/utils/lint/lintSetup.js +31 -0
  147. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  148. package/lib/utils/lint/question.js +30 -0
  149. package/lib/utils/lintReporter.js +142 -0
  150. package/lib/utils/mailSender.js +16 -25
  151. package/lib/utils/pullOrigin.js +28 -0
  152. package/lib/utils/reinstallDependencies.js +133 -0
  153. package/lib/utils/removeAttributes.js +25 -23
  154. package/lib/utils/repoClone.js +56 -63
  155. package/lib/utils/request.js +64 -77
  156. package/lib/utils/resultSchema.json +73 -0
  157. package/lib/utils/rtl.js +42 -0
  158. package/lib/utils/setEnvVariables.js +5 -6
  159. package/lib/utils/ssTestHack.js +48 -0
  160. package/lib/utils/switchBranch.js +28 -0
  161. package/lib/utils/urlConcat.js +22 -0
  162. package/package.json +92 -64
  163. package/templates/app/.eslintrc.js +140 -0
  164. package/templates/app/README.md +12 -12
  165. package/templates/app/app/index.html +24 -8
  166. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  167. package/templates/app/app/properties/i18nkeys.json +3 -3
  168. package/templates/app/docs/all.html +69 -69
  169. package/templates/app/mockapi/index.js +18 -13
  170. package/templates/app/package.json +37 -17
  171. package/templates/app/src/actions/SampleActions/index.js +37 -0
  172. package/templates/app/src/actions/index.js +65 -0
  173. package/templates/app/src/appUrls.js +19 -0
  174. package/templates/app/src/components/Alert/Alert.js +134 -0
  175. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  176. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  177. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  178. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  179. package/templates/app/src/components/Sample/SampleList.js +61 -0
  180. package/templates/app/src/components/Slider/Slider.css +41 -0
  181. package/templates/app/src/components/Slider/Slider.js +55 -0
  182. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  183. package/templates/app/src/containers/AppContainer/index.js +96 -0
  184. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  185. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  186. package/templates/app/src/containers/DevTools/index.js +10 -0
  187. package/templates/app/src/containers/Header/index.js +67 -0
  188. package/templates/app/src/containers/Header/index.module.css +43 -0
  189. package/templates/app/src/containers/Redirect/index.js +63 -0
  190. package/templates/app/src/containers/Redirector/index.js +47 -0
  191. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  192. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  193. package/templates/app/src/historyChange.js +5 -0
  194. package/templates/app/src/index.html +10 -0
  195. package/templates/app/src/index.js +24 -0
  196. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  197. package/templates/app/src/reducers/alertData.js +11 -0
  198. package/templates/app/src/reducers/index.js +6 -0
  199. package/templates/app/src/reducers/samples.js +19 -0
  200. package/templates/app/src/store/configureStore.dev.js +51 -0
  201. package/templates/app/src/store/configureStore.js +5 -0
  202. package/templates/app/src/store/configureStore.prod.js +26 -0
  203. package/templates/app/src/util/Common.js +5 -0
  204. package/templates/app/src/util/RequestAPI.js +132 -0
  205. package/templates/appold/README.md +12 -0
  206. package/templates/appold/app/index.html +8 -0
  207. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  208. package/templates/appold/app/properties/i18nkeys.json +3 -0
  209. package/templates/appold/docs/all.html +69 -0
  210. package/templates/appold/mockapi/index.js +13 -0
  211. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  212. package/templates/appold/package.json +17 -0
  213. package/templates/appold/src/components/Text/Text.css +0 -0
  214. package/templates/appold/src/components/Text/Text.js +23 -0
  215. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  216. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  217. package/templates/appold/src/components/docs.js +1 -0
  218. package/templates/appold/src/components/index.js +5 -0
  219. package/templates/appold/src/index.js +13 -0
  220. package/templates/docs/all.html +1 -1
  221. package/templates/docs/component.html +110 -69
  222. package/templates/docs/components.html +221 -0
  223. package/templates/docs/css/component.css +12 -14
  224. package/templates/docs/css/componentTest.css +7 -0
  225. package/templates/docs/css/style.css +150 -206
  226. package/templates/docs/impactReportTemplate.html +154 -0
  227. package/templates/docs/index.html +1482 -1336
  228. package/templates/library/src/index.js +0 -0
@@ -0,0 +1,55 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import style from "./Slider.css";
4
+ import FreezeLayer from "../FreezeLayer/FreezeLayer";
5
+
6
+ import { Animation } from "@zohodesk/components";
7
+ export default class Slider extends React.Component {
8
+ render() {
9
+ let { children, needFreeze, isActive, onClick, palette, size } = this.props;
10
+ return needFreeze ? (
11
+ <FreezeLayer
12
+ onClick={onClick}
13
+ isActive={isActive}
14
+ animationName="fadeIn"
15
+ childAnimationName="slideLeft"
16
+ palette={palette}
17
+ >
18
+ <div
19
+ className={`${style.container} ${isActive ? "" : style.close} ${
20
+ style[size]
21
+ }`}
22
+ onClick={e => {
23
+ e.stopPropagation();
24
+ }}
25
+ >
26
+ {children}
27
+ </div>
28
+ </FreezeLayer>
29
+ ) : (
30
+ <Animation isActive={isActive} name="slideLeft">
31
+ <div
32
+ className={`${style.container} ${style[size]}`}
33
+ onClick={e => {
34
+ e.stopPropagation();
35
+ }}
36
+ >
37
+ {children}
38
+ </div>
39
+ </Animation>
40
+ );
41
+ }
42
+ }
43
+ Slider.propTypes = {
44
+ children: PropTypes.node,
45
+ isActive: PropTypes.bool,
46
+ needFreeze: PropTypes.bool,
47
+ onClick: PropTypes.func,
48
+ palette: PropTypes.oneOf(["dark", "default", "darkLight", "plain"]),
49
+ size: PropTypes.oneOf(["small", "xsmall", "medium", "large"])
50
+ };
51
+ Slider.defaultProps = {
52
+ isActive: false,
53
+ palette: "default",
54
+ size: "xsmall"
55
+ };
@@ -0,0 +1,15 @@
1
+ import { connect } from "react-redux";
2
+ import Alert from "../../components/Alert/Alert";
3
+ import { alertAction } from "../../actions/index.js";
4
+
5
+ function mapStateToProps() {
6
+ return {
7
+ onSubmitClick: alertAction.ob.resolve,
8
+ onCancelClick: alertAction.ob.reject
9
+ };
10
+ }
11
+
12
+ export default connect(
13
+ mapStateToProps,
14
+ {}
15
+ )(Alert);
@@ -0,0 +1,96 @@
1
+ import React from "react";
2
+ import { PropTypes } from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import CustomMatch from "../CustomMatch";
5
+ import Redirector from "../Redirector";
6
+ import { Container, Box } from "@zohodesk/components";
7
+ import style from "./index.module.css";
8
+ import Header from "../Header";
9
+ import SampleListContainer from "../SampleListContainer/ListContainer";
10
+
11
+ import { push, alertAction } from "../../actions";
12
+
13
+ class AppContainer extends React.Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.state = {};
17
+ }
18
+ componentDidMount() {
19
+ /*const { showConfirmBox } = this.props;
20
+
21
+ showConfirmBox({
22
+ type: "confirmation",
23
+ submitText: "Yes",
24
+ cancelText: "Cancel",
25
+ title: "Alert",
26
+ iconName: "notifiExclamation",
27
+ message: "Are you sure?",
28
+ isActive: true,
29
+ palette: "danger"
30
+ })
31
+ .then(() => {
32
+ logger.log("Suceess");
33
+ })
34
+ .catch(() => {
35
+ logger.log("Cancel");
36
+ });*/
37
+ }
38
+ render() {
39
+ const { alertData, paramMap = {} } = this.props;
40
+
41
+ return (
42
+ <Container
43
+ className={style.deskContainer}
44
+ onMouseOver={this.handleOver}
45
+ scroll="none"
46
+ tagName="div"
47
+ >
48
+ <Redirector />
49
+
50
+ <Box tagName="header">
51
+ <Header />
52
+ </Box>
53
+
54
+ <Box className={style.posrel} flexible tagName="section">
55
+ <Container
56
+ alignBox="row"
57
+ className={`${style.container}`}
58
+ tagName="section"
59
+ >
60
+ <Box className={""} flexible tagName="article" scroll="vertical">
61
+ <CustomMatch name="sampleList" isExactly>
62
+ <SampleListContainer />
63
+ </CustomMatch>
64
+ </Box>
65
+ </Container>
66
+
67
+ {alertData.isActive && (
68
+ <AlertContainer
69
+ alertData={alertData}
70
+ isActive={alertData.isActive}
71
+ palette={alertData.palette}
72
+ type={alertData.type}
73
+ />
74
+ )}
75
+ </Box>
76
+ </Container>
77
+ );
78
+ }
79
+ }
80
+
81
+ AppContainer.propTypes = {
82
+ push: PropTypes.func,
83
+ alertData: PropTypes.object,
84
+ paramMap: PropTypes.object,
85
+ showConfirmBox: PropTypes.func
86
+ };
87
+
88
+ const mapStateToProps = (state, ownProps) => {
89
+ const { alertData, routing } = state;
90
+ const { paramMap } = routing;
91
+ return { alertData, paramMap };
92
+ };
93
+ export default connect(
94
+ mapStateToProps,
95
+ { push, showConfirmBox: alertAction.showConfirmBox }
96
+ )(AppContainer);
@@ -0,0 +1,27 @@
1
+ .container,
2
+ .rightPanel {
3
+ position: relative;
4
+ }
5
+ .leftPanel {
6
+ position: relative;
7
+ transition: width 0.3s ease, transform 0.3s ease;
8
+ will-change: width, transform;
9
+ background-color: #f4f6f9;
10
+ }
11
+ .open {
12
+ width: 13.75rem;
13
+ }
14
+ .leftPanelContainer {
15
+ width: 100%;
16
+ height: 100%;
17
+ display: flex;
18
+ -webkit-box-orient: vertical;
19
+ -webkit-box-direction: normal;
20
+ -webkit-flex-direction: column;
21
+ -ms-flex-direction: column;
22
+ flex-direction: column;
23
+ }
24
+
25
+ .deskContainer {
26
+ height: 100vh;
27
+ }
@@ -0,0 +1,65 @@
1
+ import React, { Component } from "react";
2
+ import { connect } from "react-redux";
3
+ import PropTypes from "prop-types";
4
+ import { replace } from "../../actions";
5
+ class CustomMatch extends Component {
6
+ render() {
7
+ let { children, isMatch } = this.props;
8
+ return (isMatch && React.Children.only(children)) || null;
9
+ }
10
+ }
11
+
12
+ export default connect(
13
+ (state, props) => {
14
+ let isMatch;
15
+ if (Array.isArray(props.names)) {
16
+ isMatch = props.names.some(urlObj => {
17
+ let { name, module, isExactly } = urlObj || {};
18
+ const { paramMap = {}, urls } = state.routing;
19
+ let url = urls[name] || {};
20
+
21
+ let { moduleName } = paramMap;
22
+ if ((isExactly && url.match === 2) || (!isExactly && url.match)) {
23
+ isMatch = true;
24
+ return module ? moduleName === module : isMatch;
25
+ }
26
+ return false;
27
+ });
28
+ } else {
29
+ let url = state.routing.urls[props.name];
30
+ if (url) {
31
+ isMatch =
32
+ (props.isExactly && url.match === 2) ||
33
+ (!props.isExactly && url.match);
34
+ if (isMatch && Array.isArray(props.module)) {
35
+ let modules = props.module;
36
+ isMatch = modules.some(module => {
37
+ return state.routing.paramMap.moduleName === module;
38
+ });
39
+ } else if (isMatch && props.module) {
40
+ isMatch = state.routing.paramMap.moduleName === props.module;
41
+ }
42
+ }
43
+ }
44
+ isMatch =
45
+ !isMatch && props.orMapStateMatch
46
+ ? props.orMapStateMatch(state)
47
+ : isMatch;
48
+ return {
49
+ isMatch: isMatch ? true : false,
50
+ isAuthenticate: props.checkAuthenticate
51
+ ? props.checkAuthenticate(state)
52
+ : true
53
+ };
54
+ },
55
+ { replace }
56
+ )(CustomMatch);
57
+
58
+ CustomMatch.defaultProps = {
59
+ isExactly: false
60
+ };
61
+ CustomMatch.propTypes = {
62
+ children: PropTypes.element,
63
+ isExactly: PropTypes.bool,
64
+ isMatch: PropTypes.bool
65
+ };
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { createDevTools } from "redux-devtools";
3
+ import LogMonitor from "redux-devtools-log-monitor";
4
+ import DockMonitor from "redux-devtools-dock-monitor";
5
+
6
+ export default createDevTools(
7
+ <DockMonitor toggleVisibilityKey="ctrl-h" changePositionKey="ctrl-w">
8
+ <LogMonitor />
9
+ </DockMonitor>
10
+ );
@@ -0,0 +1,67 @@
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import style from "./index.module.css";
5
+ import { push, alertAction } from "../../actions";
6
+
7
+ import { URL_PREFIX } from "../../util/Common";
8
+
9
+ class Header extends Component {
10
+ constructor(props) {
11
+ super(props);
12
+ this.state = {
13
+ tabs: [
14
+ {
15
+ url: `${URL_PREFIX}/sample`,
16
+ name: "Sample",
17
+ apiName: "sample",
18
+ id: "1"
19
+ }
20
+ ],
21
+ selectedTab: "sample"
22
+ };
23
+ this.changeTab = this.changeTab.bind(this);
24
+ }
25
+ changeTab(e) {
26
+ e.preventDefault();
27
+ let { push } = this.props;
28
+
29
+ push({ pathname: e.target.getAttribute("href") });
30
+ }
31
+ render() {
32
+ let { tabs, selectedTab } = this.state;
33
+ const { topbar, menuUl, menuli, menuliActive, menuLink } = style;
34
+
35
+ tabs = tabs.map((tab, index) => {
36
+ const { apiName, url, name } = tab;
37
+
38
+ const tabClass =
39
+ selectedTab === apiName ? menuli + " " + menuliActive : menuli;
40
+ return (
41
+ <li className={tabClass} key={index}>
42
+ <a href={url} className={menuLink} onClick={this.changeTab}>
43
+ {name}
44
+ </a>
45
+ </li>
46
+ );
47
+ });
48
+ return (
49
+ <div className={topbar}>
50
+ <ul className={menuUl}>{tabs}</ul>
51
+ </div>
52
+ );
53
+ }
54
+ }
55
+
56
+ Header.propTypes = {
57
+ push: PropTypes.func
58
+ };
59
+
60
+ const mapStateToProps = (state, ownProps) => {
61
+ return {};
62
+ };
63
+
64
+ export default connect(
65
+ mapStateToProps,
66
+ { push, showConfirmBox: alertAction.showConfirmBox }
67
+ )(Header);
@@ -0,0 +1,43 @@
1
+ .topbar {
2
+ min-height: 45px;
3
+ background: #1e2633;
4
+
5
+ box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.25);
6
+ width: 100%;
7
+ z-index: 5;
8
+ color: #fff;
9
+ }
10
+
11
+ :global ul,
12
+ :global li {
13
+ padding: 0;
14
+ margin: 0;
15
+ }
16
+
17
+ .menuUl {
18
+ list-style: none;
19
+ }
20
+
21
+ .menuli {
22
+ float: left;
23
+ box-sizing: border-box;
24
+ cursor: pointer;
25
+ position: relative;
26
+ font-size: 12px;
27
+ letter-spacing: 0.6px;
28
+ text-transform: uppercase;
29
+ }
30
+
31
+ .menuliActive {
32
+ background: #4b515c;
33
+ }
34
+
35
+ .menuLink {
36
+ padding: 17px 14px 15px;
37
+ float: left;
38
+ line-height: 13px;
39
+ color: #fff;
40
+ max-width: 110px;
41
+ -webkit-font-smoothing: antialiased;
42
+ -moz-osx-font-smoothing: grayscale;
43
+ }
@@ -0,0 +1,63 @@
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { replace } from "../../actions";
5
+ class Redirect extends Component {
6
+ constructor(props) {
7
+ super(props);
8
+ }
9
+
10
+ render() {
11
+ return null;
12
+ }
13
+
14
+ componentDidMount() {
15
+ if (this.props.isMatch) {
16
+ this.props.replace(this.props.to(this.props.location));
17
+ }
18
+ }
19
+
20
+ componentDidUpdate() {
21
+ if (this.props.isMatch) {
22
+ this.props.replace(this.props.to(this.props.location));
23
+ }
24
+ }
25
+ }
26
+
27
+ Redirect.propTypes = {
28
+ from: PropTypes.shape({
29
+ name: PropTypes.string,
30
+ module: PropTypes.string
31
+ }),
32
+ to: PropTypes.func
33
+ };
34
+ function mapStateToProps(state, props) {
35
+ let url = state.routing.urls[props.from.name];
36
+
37
+ if (url && url.match == 2) {
38
+ let { module } = props.from;
39
+ if (props.from.module) {
40
+ if (state.routing.paramMap.moduleName == props.from.module) {
41
+ return {
42
+ isMatch: true,
43
+ location: state.routing.location
44
+ };
45
+ }
46
+ return {
47
+ isMatch: false
48
+ };
49
+ }
50
+ return {
51
+ isMatch: true
52
+ };
53
+ }
54
+ return {
55
+ isMatch: false,
56
+ location: state.routing.location
57
+ };
58
+ }
59
+
60
+ export default connect(
61
+ mapStateToProps,
62
+ { replace }
63
+ )(Redirect);
@@ -0,0 +1,47 @@
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+
5
+ import Redirect from "../Redirect";
6
+
7
+ class Redirector extends Component {
8
+ constructor(props) {
9
+ super(props);
10
+ }
11
+
12
+ render() {
13
+ let { urls } = this.props;
14
+ return (
15
+ <div style={{ display: "none" }}>
16
+ {urls.map((url, i) => (
17
+ <Redirect
18
+ key={`redirect${i}`}
19
+ from={{ name: url.name, module: url.module }}
20
+ to={location =>
21
+ Object.assign({}, location, {
22
+ pathname: `${url.pathname}`
23
+ })
24
+ }
25
+ />
26
+ ))}
27
+ </div>
28
+ );
29
+ }
30
+ }
31
+
32
+ Redirector.propTypes = {
33
+ urls: PropTypes.array.isRequired
34
+ };
35
+
36
+ function mapStateToProps(state, props) {
37
+ const urls = [
38
+ {
39
+ name: "sampleList",
40
+ module: "sample",
41
+ pathname: `${state.routing.location.pathname}/sample`
42
+ }
43
+ ];
44
+
45
+ return { urls };
46
+ }
47
+ export default connect(mapStateToProps)(Redirector);
@@ -0,0 +1,42 @@
1
+ import React, { Component } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { push, alertAction } from "../../actions";
5
+ import { getSampleList } from "../../actions/SampleActions";
6
+ import style from "./ListContainer.module.css";
7
+ import SampleList from "../../components/Sample/SampleList";
8
+
9
+ class ListContainer extends Component {
10
+ constructor(props) {
11
+ super(props);
12
+ }
13
+
14
+ componentDidMount() {
15
+ const { getSampleList } = this.props;
16
+ getSampleList().then(res => {});
17
+ }
18
+ render() {
19
+ const { samples = [] } = this.props;
20
+ return (
21
+ <div className={style.container}>
22
+ <SampleList samples={samples} />
23
+ </div>
24
+ );
25
+ }
26
+ }
27
+
28
+ ListContainer.propTypes = {
29
+ push: PropTypes.func,
30
+ getSampleList: PropTypes.func,
31
+ samples: PropTypes.array.isRequired
32
+ };
33
+
34
+ const mapStateToProps = (state, ownProps) => {
35
+ const { samples = [] } = state;
36
+ return { samples };
37
+ };
38
+
39
+ export default connect(
40
+ mapStateToProps,
41
+ { push, getSampleList }
42
+ )(ListContainer);
@@ -0,0 +1,3 @@
1
+ .container {
2
+ padding: 20px;
3
+ }
@@ -0,0 +1,5 @@
1
+ export const historyChange = (routing, res, { getState, dispatch }) => {
2
+ let state = getState();
3
+
4
+ res();
5
+ };
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title></title>
6
+ </head>
7
+ <body>
8
+ <div id="container"></div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
3
+ import { Provider } from "react-redux";
4
+ import { ConnectI18NProvider } from "fz-i18n";
5
+ import configureStore from "./store/configureStore";
6
+ import AppContainer from "./containers/AppContainer";
7
+
8
+ const store = configureStore();
9
+ setTimeout(() => {
10
+ ReactDOM.render(
11
+ <Provider store={store}>
12
+ <ConnectI18NProvider
13
+ direction={document.getElementsByTagName("html")[0].dir}
14
+ i18n={() => {}}
15
+ permission={{}}
16
+ timeZone={state => ""}
17
+ license={""}
18
+ >
19
+ <AppContainer />
20
+ </ConnectI18NProvider>
21
+ </Provider>,
22
+ document.getElementById("container")
23
+ );
24
+ }, 1);
@@ -0,0 +1,59 @@
1
+ export default function promiseMiddleware({ dispatch, getState }) {
2
+ return function(next) {
3
+ return function(action) {
4
+ const { types, callAPI, shouldCallAPI = () => true, payload } = action;
5
+ if (!types) {
6
+ // Normal action: pass it o
7
+ return next(action);
8
+ }
9
+
10
+ if (
11
+ !Array.isArray(types) ||
12
+ types.length !== 3 ||
13
+ !types.every(type => typeof type === 'string')
14
+ ) {
15
+ throw new Error('Expected an array of three string types.');
16
+ }
17
+
18
+ if (typeof callAPI !== 'function') {
19
+ throw new Error('Expected fetch to be a function.');
20
+ }
21
+
22
+ if (!shouldCallAPI(getState())) {
23
+ return Promise.resolve();
24
+ }
25
+ const [requestType, successType, failureType] = types;
26
+
27
+ dispatch({
28
+ type: requestType,
29
+ data: typeof payload === 'function' ? payload(getState()) : payload
30
+ });
31
+ return callAPI(getState(), getState).then(
32
+ response => {
33
+ let action = dispatch(
34
+ Object.assign(
35
+ {},
36
+ {
37
+ data: response,
38
+ type: successType
39
+ }
40
+ )
41
+ );
42
+ return action;
43
+ },
44
+ error => {
45
+ dispatch(
46
+ Object.assign(
47
+ {},
48
+ {
49
+ data: error,
50
+ type: failureType
51
+ }
52
+ )
53
+ );
54
+ throw error;
55
+ }
56
+ );
57
+ };
58
+ };
59
+ }
@@ -0,0 +1,11 @@
1
+ export const alertData = (state = {}, { type, data }) => {
2
+ switch (type) {
3
+ case "ALERT_SHOW":
4
+ return data;
5
+ case "ALERT_HIDE":
6
+ return {};
7
+
8
+ default:
9
+ }
10
+ return state;
11
+ };
@@ -0,0 +1,6 @@
1
+ import { samples } from "./samples";
2
+ import { alertData } from "./alertData";
3
+
4
+ const reducers = { samples, alertData };
5
+
6
+ export default reducers;
@@ -0,0 +1,19 @@
1
+ function samples(state = [], { data, type }) {
2
+ switch (type) {
3
+ case "SAMPLE_LIST_SUCCESS": {
4
+ return data;
5
+ break;
6
+ }
7
+
8
+ case "ADD_SAMPLE_SUCCESS": {
9
+ let newState = Object.assign({}, state);
10
+ return [...state, ...[data]];
11
+ break;
12
+ }
13
+
14
+ default:
15
+ return state;
16
+ }
17
+ }
18
+
19
+ export { samples };