From 8208837e3b31d2b6a4a1f5daa3f2a37470bc25c4 Mon Sep 17 00:00:00 2001 From: Benjamin Zengin Date: Fri, 17 Apr 2020 13:26:32 +0200 Subject: [PATCH 1/4] Fixes #56 --- tools/enter-data-helper/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/enter-data-helper/package.json b/tools/enter-data-helper/package.json index 2cdba73c..b39a2a78 100644 --- a/tools/enter-data-helper/package.json +++ b/tools/enter-data-helper/package.json @@ -49,7 +49,7 @@ "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "electron": "concurrently \"BROWSER=none HOST=localhost yarn start\" \"wait-on http://localhost:3000 && electron . ../..\"", + "electron": "concurrently --kill-others \"BROWSER=none HOST=localhost yarn start\" \"wait-on http://localhost:3000 && electron . ../..\"", "package-linux": "electron-builder -l", "package-mac": "electron-builder -m && tar -czf dist/enter-data-helper-mac.tar.gz -C dist/mac enter-data-helper.app" }, From 27ffad3f33339e79e3c12db11b7b5eb07e0e75ef Mon Sep 17 00:00:00 2001 From: Benjamin Zengin Date: Fri, 17 Apr 2020 13:27:01 +0200 Subject: [PATCH 2/4] Fixes #57 --- .../enter-data-helper/src/components/BaseComponents.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/enter-data-helper/src/components/BaseComponents.js b/tools/enter-data-helper/src/components/BaseComponents.js index e732c1ac..03f9c35a 100644 --- a/tools/enter-data-helper/src/components/BaseComponents.js +++ b/tools/enter-data-helper/src/components/BaseComponents.js @@ -149,7 +149,13 @@ class JsonFormsContainer extends React.Component { class SelectList extends React.Component { constructor(props) { super(props); - this.entries = props.entries; + this.state = {entries: props.entries}; + } + + componentDidUpdate(prevProps, prevState) { + if (prevProps.entries !== this.props.entries) { + this.setState({ entries: this.props.entries }); + } } render() { @@ -157,7 +163,7 @@ class SelectList extends React.Component { { - this.entries.map(entry => ( + this.state.entries.map(entry => ( this.props.action(entry)}> From ef315698856c62b381a5689615979167aee52248 Mon Sep 17 00:00:00 2001 From: Benjamin Zengin Date: Fri, 17 Apr 2020 13:53:23 +0200 Subject: [PATCH 3/4] Implements #58 --- schema/flavor.json | 3 +- schema/implementation.json | 3 +- schema/paramset.json | 3 +- schema/scheme.json | 3 +- tools/enter-data-helper/src/App.js | 6 +-- .../src/components/BaseComponents.js | 1 + .../src/components/FlavorOverview.js | 38 +++++++++---------- .../src/components/SchemeOverview.js | 26 ++++++------- .../src/components/SelectScheme.js | 16 ++++---- 9 files changed, 52 insertions(+), 47 deletions(-) diff --git a/schema/flavor.json b/schema/flavor.json index af7f1a7a..2fb938a9 100644 --- a/schema/flavor.json +++ b/schema/flavor.json @@ -4,7 +4,8 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "$comment": "Human readable name" }, "comment": { "type": "string" diff --git a/schema/implementation.json b/schema/implementation.json index 9acd9ebc..439d235a 100644 --- a/schema/implementation.json +++ b/schema/implementation.json @@ -4,7 +4,8 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "$comment": "Human readable name" }, "comment": { "type": "string" diff --git a/schema/paramset.json b/schema/paramset.json index fe5e040f..0e48fdb8 100644 --- a/schema/paramset.json +++ b/schema/paramset.json @@ -4,7 +4,8 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "$comment": "Human readable name" }, "comment": { "type": "string" diff --git a/schema/scheme.json b/schema/scheme.json index 8fe25587..472d781c 100644 --- a/schema/scheme.json +++ b/schema/scheme.json @@ -12,7 +12,8 @@ "$comment": "`enc` stands for all types of key exchange (KEMs etc)" }, "name": { - "type": "string" + "type": "string", + "$comment": "Human readable name" }, "comment": { "type": "string" diff --git a/tools/enter-data-helper/src/App.js b/tools/enter-data-helper/src/App.js index f04c98b9..b5feaab5 100644 --- a/tools/enter-data-helper/src/App.js +++ b/tools/enter-data-helper/src/App.js @@ -66,9 +66,9 @@ class App extends React.Component { - - - + + + x.endsWith('.yaml')).map(x => x.substring(0, x.length - 5)); } - submitForm(name, type, create) { - if (create === fs.existsSync(path.join(this.baseDir, type, name + ".yaml"))) { + submitForm(identifier, type, create) { + if (create === fs.existsSync(path.join(this.baseDir, type, identifier + ".yaml"))) { showAlert('Error. Unexpected existance or non-existance of flavor file.', 'error'); return; } @@ -134,11 +134,11 @@ class FlavorOverview extends React.Component { try { var dir = path.join(this.baseDir, type); if (!fs.existsSync(dir)) fs.mkdirSync(dir); - var data = (type === 'bench') ? { platform: name.split('_')[2] } : { name: name }; - fs.writeFileSync(path.join(dir, name + ".yaml"), yaml.dump(data)); - showAlert('"' + name + '" was successfully created.', 'success'); + var data = {}; + fs.writeFileSync(path.join(dir, identifier + ".yaml"), yaml.dump(data)); + showAlert('"' + identifier + '" was successfully created.', 'success'); } catch { - showAlert('"' + name + '" could not be created.', 'error'); + showAlert('"' + identifier + '" could not be created.', 'error'); } var newState = {}; @@ -148,7 +148,7 @@ class FlavorOverview extends React.Component { return; } - this.history.push(this.history.location.pathname + type + '/' + name + '/'); + this.history.push(this.history.location.pathname + type + '/' + identifier + '/'); window.scrollTo(0, 0); } @@ -159,7 +159,7 @@ class FlavorOverview extends React.Component {

Flavor Properties

- +
diff --git a/tools/enter-data-helper/src/components/SchemeOverview.js b/tools/enter-data-helper/src/components/SchemeOverview.js index c934a548..66c62bd6 100644 --- a/tools/enter-data-helper/src/components/SchemeOverview.js +++ b/tools/enter-data-helper/src/components/SchemeOverview.js @@ -13,8 +13,8 @@ class EditScheme extends JsonFormsContainer { constructor(props) { super(props) this.type = props.type; - this.name = props.name; - this.schemeFile = path.join(typeDirs[this.type], this.name, this.name + '.yaml'); + this.identifier = props.identifier; + this.schemeFile = path.join(typeDirs[this.type], this.identifier, this.identifier + '.yaml'); this.dataStore = yaml.load(fs.readFileSync(this.schemeFile, 'utf-8')); this.dataStore.type = this.type; if (!('stateful' in this.dataStore)) @@ -56,36 +56,36 @@ class EditScheme extends JsonFormsContainer { class SchemeOverview extends React.Component { constructor(props) { super(props) - this.name = props.match.params.name; + this.identifier = props.match.params.schemeIdentifier; this.type = props.match.params.type; - this.baseDir = path.join(typeDirs[this.type], this.name); + this.baseDir = path.join(typeDirs[this.type], this.identifier); this.state = { flavors: listDirs(this.baseDir) }; this.history = props.history; } - submitForm(name, create) { - if (create === fs.existsSync(path.join(this.baseDir, name, name + ".yaml"))) { + submitForm(identifier, create) { + if (create === fs.existsSync(path.join(this.baseDir, identifier, identifier + ".yaml"))) { showAlert("Error. Unexpected existance or non-existance of flavor file.", "error"); return; } if (create) { try { - var dir = path.join(this.baseDir, name); + var dir = path.join(this.baseDir, identifier); if (!fs.existsSync(dir)) fs.mkdirSync(dir); ['', 'bench', 'impl', 'param'].map(x => path.join(dir, x)) .filter(x => !fs.existsSync(x)).forEach(x => fs.mkdirSync(x)); - var data = { name: name }; - fs.writeFileSync(path.join(dir, name + ".yaml"), yaml.dump(data)); - showAlert('Flavor "' + name + '" was successfully created.', 'success'); + var data = {}; + fs.writeFileSync(path.join(dir, identifier + ".yaml"), yaml.dump(data)); + showAlert('Flavor "' + identifier + '" was successfully created.', 'success'); } catch { - showAlert('Flavor "' + name + '" could not be created.', 'error'); + showAlert('Flavor "' + identifier + '" could not be created.', 'error'); } this.setState({ flavors: listDirs(this.baseDir) }); return; } - var link = this.history.location.pathname + name + "/"; + var link = this.history.location.pathname + identifier + "/"; this.history.push(link); window.scrollTo(0, 0); } @@ -97,7 +97,7 @@ class SchemeOverview extends React.Component {

Scheme Properties

- +
diff --git a/tools/enter-data-helper/src/components/SelectScheme.js b/tools/enter-data-helper/src/components/SelectScheme.js index 705d3d81..37c48169 100644 --- a/tools/enter-data-helper/src/components/SelectScheme.js +++ b/tools/enter-data-helper/src/components/SelectScheme.js @@ -18,21 +18,21 @@ class SelectScheme extends React.Component { }; } - submitForm(type, name, create) { - if (create === fs.existsSync(path.join(this.typeDirs[type], name, name + ".yaml"))) { + submitForm(type, identifier, create) { + if (create === fs.existsSync(path.join(this.typeDirs[type], identifier, identifier + ".yaml"))) { showAlert("Error. Unexpected existance or non-existance of scheme file.", "error"); return; } if (create) { try { - var dir = path.join(this.typeDirs[type], name); + var dir = path.join(this.typeDirs[type], identifier); if (!fs.existsSync(dir)) fs.mkdirSync(dir); - var data = { name: name }; - fs.writeFileSync(path.join(dir, name + ".yaml"), yaml.dump(data)); - showAlert('Scheme "' + name + '" was successfully created.', 'success'); + var data = {}; + fs.writeFileSync(path.join(dir, identifier + ".yaml"), yaml.dump(data)); + showAlert('Scheme "' + identifier + '" was successfully created.', 'success'); } catch { - showAlert('Scheme "' + name + '" could not be created.', 'error'); + showAlert('Scheme "' + identifier + '" could not be created.', 'error'); } var newState = {}; @@ -42,7 +42,7 @@ class SelectScheme extends React.Component { return; } - this.history.push('/' + type + '/' + name + '/'); + this.history.push('/' + type + '/' + identifier + '/'); window.scrollTo(0, 0); } From 150a29a8b2aa17858e947648908ae31a7a020278 Mon Sep 17 00:00:00 2001 From: Marian Sigler Date: Fri, 17 Apr 2020 13:27:48 +0200 Subject: [PATCH 4/4] Add comments on how to use `name` fields. (Based on how they are used currently.) --- schema/flavor.json | 2 +- schema/implementation.json | 2 +- schema/paramset.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/schema/flavor.json b/schema/flavor.json index 2fb938a9..57fe8a54 100644 --- a/schema/flavor.json +++ b/schema/flavor.json @@ -5,7 +5,7 @@ "properties": { "name": { "type": "string", - "$comment": "Human readable name" + "$comment": "Human readable name (full, including the scheme name)" }, "comment": { "type": "string" diff --git a/schema/implementation.json b/schema/implementation.json index 439d235a..7fa950cc 100644 --- a/schema/implementation.json +++ b/schema/implementation.json @@ -5,7 +5,7 @@ "properties": { "name": { "type": "string", - "$comment": "Human readable name" + "$comment": "Human readable name (don't include scheme/flavor name, but do include the parameter set if the implementation is specific to it)" }, "comment": { "type": "string" diff --git a/schema/paramset.json b/schema/paramset.json index 0e48fdb8..ec8e3bce 100644 --- a/schema/paramset.json +++ b/schema/paramset.json @@ -5,7 +5,7 @@ "properties": { "name": { "type": "string", - "$comment": "Human readable name" + "$comment": "Human readable name (full, including scheme and flavor name)" }, "comment": { "type": "string"