From b9bed3e5fb2f3acd8af04a484ac6ce971171069d Mon Sep 17 00:00:00 2001 From: Yasss Date: Fri, 29 Mar 2019 17:39:09 +0100 Subject: [PATCH 1/4] Add latest ruleset page --- ui/app/src/components/Sidebar.vue | 2 +- ui/app/src/router.js | 1 + .../src/views/LatestRuleset/LatestRuleset.vue | 134 +++++++++++++++++- ui/app/src/views/NewRuleset/Rules.vue | 37 +++-- ui/app/src/views/NewRuleset/ruleset.js | 4 +- 5 files changed, 159 insertions(+), 19 deletions(-) diff --git a/ui/app/src/components/Sidebar.vue b/ui/app/src/components/Sidebar.vue index 6b783c1..437d9bb 100644 --- a/ui/app/src/components/Sidebar.vue +++ b/ui/app/src/components/Sidebar.vue @@ -58,7 +58,7 @@ export default { }, navigateToLatestRulesetPage(item) { - this.$router.push(`/rulesets/${item.path}/latest`); + this.$router.push({ name: 'latest-ruleset', params: { path: `${item.path}` }}); }, }, }; diff --git a/ui/app/src/router.js b/ui/app/src/router.js index 448297b..ca20c7b 100644 --- a/ui/app/src/router.js +++ b/ui/app/src/router.js @@ -25,6 +25,7 @@ export default new Router({ { path: '/rulesets/:path/latest', name: 'latest-ruleset', + props: true, // route level code-splitting // this generates a separate chunk (latestRuleset.[hash].js) for this route // which is lazy-loaded when the route is visited. diff --git a/ui/app/src/views/LatestRuleset/LatestRuleset.vue b/ui/app/src/views/LatestRuleset/LatestRuleset.vue index f1db407..786d02f 100644 --- a/ui/app/src/views/LatestRuleset/LatestRuleset.vue +++ b/ui/app/src/views/LatestRuleset/LatestRuleset.vue @@ -1,4 +1,134 @@ + + + + \ No newline at end of file diff --git a/ui/app/src/views/NewRuleset/Rules.vue b/ui/app/src/views/NewRuleset/Rules.vue index 369525a..f515d40 100644 --- a/ui/app/src/views/NewRuleset/Rules.vue +++ b/ui/app/src/views/NewRuleset/Rules.vue @@ -62,7 +62,7 @@ class="text-sm-center" > mdi-minus ({ - // validation rules for S-Expressions. Only check if they're not empty. - codeRules: [v => !!v || 'Code is required'], - // validation rules for return values. Only check if thery're not empty. - resultsRules: [v => !!v || 'Result is required'], - // editor customization - editorOptions: { - showGutter: false, - showLineNumbers: false, - highlightActiveLine: false, - fontSize: '1.5em', - }, - }), + data() { + return { + // validation rules for S-Expressions. Only check if they're not empty. + codeRules: [v => !!v || 'Code is required'], + // validation rules for return values. Only check if thery're not empty. + resultsRules: [v => !!v || 'Result is required'], + // editor customization + editorOptions: { + readOnly: !this.editMode, // true: disable the edit when used from the LatestRuleset component + showGutter: false, + showLineNumbers: false, + highlightActiveLine: false, + fontSize: '1.5em', + }, + } + }, computed: { // select the right input type based on the selected ruleset return type. JSON is handled separately in the component html. diff --git a/ui/app/src/views/NewRuleset/ruleset.js b/ui/app/src/views/NewRuleset/ruleset.js index 13561d1..d011830 100644 --- a/ui/app/src/views/NewRuleset/ruleset.js +++ b/ui/app/src/views/NewRuleset/ruleset.js @@ -26,10 +26,12 @@ class Signature { // Describes the ruleset payload sent to the server when creating a ruleset. class Ruleset { - constructor({ path = '', signature = new Signature(), rules = [] }) { + constructor({ path = '', signature = new Signature(), rules = [], version = '', versions = [] }) { this.path = path; this.signature = signature; this.rules = rules; + this.version = version; + this.versions = versions; } } From 1c852156ccbeab048acbf5cfc85748278381637c Mon Sep 17 00:00:00 2001 From: Yasss Date: Mon, 1 Apr 2019 12:35:02 +0200 Subject: [PATCH 2/4] Fix minor things --- .../src/views/LatestRuleset/LatestRuleset.vue | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/ui/app/src/views/LatestRuleset/LatestRuleset.vue b/ui/app/src/views/LatestRuleset/LatestRuleset.vue index 786d02f..a8f3ad0 100644 --- a/ui/app/src/views/LatestRuleset/LatestRuleset.vue +++ b/ui/app/src/views/LatestRuleset/LatestRuleset.vue @@ -35,12 +35,7 @@ - - Edit - + Edit @@ -69,20 +64,7 @@ export default { data() { return { - ruleset: new Ruleset({}), - } - }, - - mounted() { - this.fetchRuleset(); - }, - - methods: { - fetchRuleset() { - axios - .get('/ui/i/rulesets/'+this.path) - .then(({ data = {} }) => { - this.ruleset = new Ruleset({ + ruleset: new Ruleset({ path: this.path, signature: new Signature( "string", @@ -109,11 +91,9 @@ export default { 'ghi123', 'xyz123', ] - }) - }) - .catch(console.error); + }), } - } + }, } From badddef3ade9c9fb503a76b46e0de41a0fab57c4 Mon Sep 17 00:00:00 2001 From: Yasss Date: Mon, 1 Apr 2019 14:43:22 +0200 Subject: [PATCH 3/4] Disable ruleset return value textarea when consulting --- ui/app/src/views/NewRuleset/Rules.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/app/src/views/NewRuleset/Rules.vue b/ui/app/src/views/NewRuleset/Rules.vue index f515d40..72745b9 100644 --- a/ui/app/src/views/NewRuleset/Rules.vue +++ b/ui/app/src/views/NewRuleset/Rules.vue @@ -46,6 +46,7 @@ label="Result" required v-model="rule.returnValue" + :disabled="editorOptions.readOnly" > Date: Tue, 9 Apr 2019 10:23:01 +0200 Subject: [PATCH 4/4] Fix eslint errors --- ui/app/src/components/Sidebar.vue | 20 ++---- .../src/views/LatestRuleset/LatestRuleset.vue | 69 +++++++++---------- ui/app/src/views/NewRuleset/Rules.vue | 63 ++++------------- ui/app/src/views/NewRuleset/ruleset.js | 4 +- 4 files changed, 55 insertions(+), 101 deletions(-) diff --git a/ui/app/src/components/Sidebar.vue b/ui/app/src/components/Sidebar.vue index 437d9bb..751f2ad 100644 --- a/ui/app/src/components/Sidebar.vue +++ b/ui/app/src/components/Sidebar.vue @@ -1,15 +1,7 @@