1. showing the currently loaded xmlfile in the topbar

2. new file show save
master
Malar Kannan 2017-07-31 11:23:24 +05:30
parent 6c92ac627c
commit c1952dc8ac
2 changed files with 41 additions and 37 deletions

View File

@ -255,32 +255,32 @@ module.exports = {
new ManifestPlugin({ new ManifestPlugin({
fileName: 'asset-manifest.json', fileName: 'asset-manifest.json',
}), }),
new SWPrecacheWebpackPlugin({ // new SWPrecacheWebpackPlugin({
// By default, a cache-busting query parameter is appended to requests // // By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh. // // used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern // // If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped. // // about it being stale, and the cache-busting can be skipped.
dontCacheBustUrlsMatching: /\.\w{8}\./, // dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js', // filename: 'service-worker.js',
logger(message) { // logger(message) {
if (message.indexOf('Total precache size is') === 0) { // if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy. // // This message occurs for every build and is a bit too noisy.
return; // return;
} // }
console.log(message); // console.log(message);
}, // },
minify: true, // minify: true,
// For unknown URLs, fallback to the index page // // For unknown URLs, fallback to the index page
navigateFallback: publicUrl + '/index.html', // navigateFallback: publicUrl + '/index.html',
// Ignores URLs starting from /__ (useful for Firebase): // // Ignores URLs starting from /__ (useful for Firebase):
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 // // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
navigateFallbackWhitelist: [/^(?!\/__).*/], // navigateFallbackWhitelist: [/^(?!\/__).*/],
// Don't precache sourcemaps (they're large) and build asset manifest: // // Don't precache sourcemaps (they're large) and build asset manifest:
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], // staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
// Work around Windows path issue in SWPrecacheWebpackPlugin: // // Work around Windows path issue in SWPrecacheWebpackPlugin:
// https://github.com/facebookincubator/create-react-app/issues/2235 // // https://github.com/facebookincubator/create-react-app/issues/2235
stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/', // stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/',
}), // }),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// new WriteFilePlugin() // new WriteFilePlugin()
], ],

View File

@ -10,29 +10,31 @@ export class LexXMLSelect extends React.Component<any, any> {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
this.state = { this.state = {
xmlFiles: [], xmlFileName: 'new_es.xml' xmlFiles: [], xmlFileName: props.xmlFileName
}; };
} }
public componentDidMount() { public componentDidMount() {
this.getXMLFiles(); this.getXMLFiles();
} }
render() { render() {
let files: string[] = [].concat(this.state.xmlFiles); let dropOptions = this.state.xmlFiles.map((k: any, i: any, c: any) => {
if (files.indexOf(this.state.xmlFileName as string) === -1) {
files.push(this.state.xmlFileName);
}
let dropOptions = files.map((k: any, i: any, c: any) => {
return { key: i, value: k, text: k }; return { key: i, value: k, text: k };
}); });
let onFileChange = (e: any, d: any) => { let onFileChange = (e: any, d: any) => {
this.setState({ xmlFileName: d.value as string }); let xmlFileName = d.value as string;
this.props.onFileSelected(d.value); 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 ( return (
<Dropdown <Dropdown
options={dropOptions} options={dropOptions}
onChange={onFileChange} onChange={onFileChange}
onAddItem={onFileChange}
value={this.state.xmlFileName} value={this.state.xmlFileName}
compact={true} compact={true}
selection={true} selection={true}
@ -97,9 +99,11 @@ export class LexSetup extends React.Component<any, any> {
{saveButton} {saveButton}
{loadButton} {loadButton}
<LexXMLSelect <LexXMLSelect
onFileSelected={(nf: string) => { onFileSelected={(fileName: string, newFile: Boolean) => {
this.xmlFileName = nf; this.xmlFileName = fileName;
this.setState({ dirty: newFile });
}} }}
xmlFileName={this.xmlFileName}
/> />
<Icon name="edit" size="small" /> <Icon name="edit" size="small" />
<Header.Content> <Header.Content>