From c1952dc8ac315e4b3afddc58e98fcdfbf153057d Mon Sep 17 00:00:00 2001 From: Malar Kannan Date: Mon, 31 Jul 2017 11:23:24 +0530 Subject: [PATCH] 1. showing the currently loaded xmlfile in the topbar 2. new file show save --- config/webpack.config.flask.js | 52 +++++++++++++++++----------------- src/LexSetup.tsx | 26 ++++++++++------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/config/webpack.config.flask.js b/config/webpack.config.flask.js index 0905ada..2659e45 100644 --- a/config/webpack.config.flask.js +++ b/config/webpack.config.flask.js @@ -255,32 +255,32 @@ module.exports = { new ManifestPlugin({ fileName: 'asset-manifest.json', }), - new SWPrecacheWebpackPlugin({ - // By default, a cache-busting query parameter is appended to requests - // used to populate the caches, to ensure the responses are fresh. - // If a URL is already hashed by Webpack, then there is no concern - // about it being stale, and the cache-busting can be skipped. - dontCacheBustUrlsMatching: /\.\w{8}\./, - filename: 'service-worker.js', - logger(message) { - if (message.indexOf('Total precache size is') === 0) { - // This message occurs for every build and is a bit too noisy. - return; - } - console.log(message); - }, - minify: true, - // For unknown URLs, fallback to the index page - navigateFallback: publicUrl + '/index.html', - // Ignores URLs starting from /__ (useful for Firebase): - // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 - navigateFallbackWhitelist: [/^(?!\/__).*/], - // Don't precache sourcemaps (they're large) and build asset manifest: - staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], - // Work around Windows path issue in SWPrecacheWebpackPlugin: - // https://github.com/facebookincubator/create-react-app/issues/2235 - stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/', - }), + // new SWPrecacheWebpackPlugin({ + // // By default, a cache-busting query parameter is appended to requests + // // used to populate the caches, to ensure the responses are fresh. + // // If a URL is already hashed by Webpack, then there is no concern + // // about it being stale, and the cache-busting can be skipped. + // dontCacheBustUrlsMatching: /\.\w{8}\./, + // filename: 'service-worker.js', + // logger(message) { + // if (message.indexOf('Total precache size is') === 0) { + // // This message occurs for every build and is a bit too noisy. + // return; + // } + // console.log(message); + // }, + // minify: true, + // // For unknown URLs, fallback to the index page + // navigateFallback: publicUrl + '/index.html', + // // Ignores URLs starting from /__ (useful for Firebase): + // // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 + // navigateFallbackWhitelist: [/^(?!\/__).*/], + // // Don't precache sourcemaps (they're large) and build asset manifest: + // staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], + // // Work around Windows path issue in SWPrecacheWebpackPlugin: + // // https://github.com/facebookincubator/create-react-app/issues/2235 + // stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/', + // }), new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // new WriteFilePlugin() ], diff --git a/src/LexSetup.tsx b/src/LexSetup.tsx index 7024864..62ec9df 100644 --- a/src/LexSetup.tsx +++ b/src/LexSetup.tsx @@ -10,29 +10,31 @@ export class LexXMLSelect extends React.Component { constructor(props: any) { super(props); this.state = { - xmlFiles: [], xmlFileName: 'new_es.xml' + xmlFiles: [], xmlFileName: props.xmlFileName }; } public componentDidMount() { this.getXMLFiles(); } render() { - let files: string[] = [].concat(this.state.xmlFiles); - if (files.indexOf(this.state.xmlFileName as string) === -1) { - files.push(this.state.xmlFileName); - } - let dropOptions = files.map((k: any, i: any, c: any) => { + let dropOptions = this.state.xmlFiles.map((k: any, i: any, c: any) => { return { key: i, value: k, text: k }; }); let onFileChange = (e: any, d: any) => { - this.setState({ xmlFileName: d.value as string }); - this.props.onFileSelected(d.value); + let xmlFileName = d.value as string; + let xmlFiles: string[] = [].concat(this.state.xmlFiles); + if (xmlFiles.indexOf(xmlFileName as string) === -1) { + xmlFiles.push(xmlFileName); + this.props.onFileSelected(xmlFileName, true); + } else { + this.props.onFileSelected(xmlFileName, false); + } + this.setState({ xmlFileName, xmlFiles }); }; return ( { {saveButton} {loadButton} { - this.xmlFileName = nf; + onFileSelected={(fileName: string, newFile: Boolean) => { + this.xmlFileName = fileName; + this.setState({ dirty: newFile }); }} + xmlFileName={this.xmlFileName} />