@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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.
- package/.eslintignore +1 -0
- package/.eslintrc.js +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +136 -0
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -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,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,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 };
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { createBrowserHistory } from "history";
|
2
|
+
import { reduxRouter } from "redux-router-middleware";
|
3
|
+
import { createStore, applyMiddleware, compose, combineReducers } from "redux";
|
4
|
+
import thunk from "redux-thunk";
|
5
|
+
import promiseMiddleware from "../middleware/PromiseMiddleware";
|
6
|
+
import rootReducer from "../reducers";
|
7
|
+
|
8
|
+
//import logger from "redux-logger";
|
9
|
+
//import { createLogger } from "redux-logger";
|
10
|
+
import { createLogger } from "redux-logger";
|
11
|
+
import DevTools from "../containers/DevTools";
|
12
|
+
import getUrls from "../appUrls";
|
13
|
+
import { historyChange } from "../historyChange";
|
14
|
+
|
15
|
+
const configureStore = preloadedState => {
|
16
|
+
let history = createBrowserHistory();
|
17
|
+
|
18
|
+
let { historyMiddleware, routing } = reduxRouter(
|
19
|
+
history,
|
20
|
+
getUrls(),
|
21
|
+
historyChange
|
22
|
+
);
|
23
|
+
|
24
|
+
//console.log(createLogger);
|
25
|
+
let middleWare = compose(
|
26
|
+
applyMiddleware(
|
27
|
+
thunk,
|
28
|
+
promiseMiddleware,
|
29
|
+
historyMiddleware,
|
30
|
+
createLogger({ collapsed: true })
|
31
|
+
),
|
32
|
+
DevTools.instrument()
|
33
|
+
);
|
34
|
+
|
35
|
+
const store = createStore(
|
36
|
+
combineReducers(Object.assign(rootReducer, { routing })),
|
37
|
+
preloadedState,
|
38
|
+
middleWare
|
39
|
+
);
|
40
|
+
|
41
|
+
if (module.hot) {
|
42
|
+
// Enable Webpack hot module replacement for reducers
|
43
|
+
module.hot.accept("../reducers", () => {
|
44
|
+
store.replaceReducer(rootReducer);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
return store;
|
49
|
+
};
|
50
|
+
|
51
|
+
export default configureStore;
|