From a2741cb37f127f416c6bfdc2e25af512517f4362 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 10 Mar 2020 15:41:56 -0700 Subject: [PATCH] Refactor modes and adding edit action to Gatekeeper --- components/GatekeeperConfig.vue | 39 ++++++++++++++++++---- models/project.cattle.io.v3.app.js | 47 +++++++++++++++++++++++++++ pages/c/_cluster/gatekeeper/index.vue | 32 ++++++++++++++---- 3 files changed, 105 insertions(+), 13 deletions(-) create mode 100644 models/project.cattle.io.v3.app.js diff --git a/components/GatekeeperConfig.vue b/components/GatekeeperConfig.vue index 5c527d5575..b283d7daf3 100644 --- a/components/GatekeeperConfig.vue +++ b/components/GatekeeperConfig.vue @@ -3,7 +3,7 @@ import CodeMirror from './CodeMirror'; import AsyncButton from '@/components/AsyncButton'; import Footer from '@/components/form/Footer'; import { NAMESPACE } from '@/config/types'; -import { _VIEW } from '@/config/query-params'; +import { _VIEW, _EDIT } from '@/config/query-params'; import GatekeeperTables from '@/components/GatekeeperTables'; import { findBy } from '@/utils/array'; @@ -55,7 +55,8 @@ export default { return { gatekeeperEnabled, showYamlEditor: false, - errors: null, + errors: [], + saving: false, }; }, @@ -98,6 +99,16 @@ export default { }, }, + watch: { + mode() { + if (this.mode === _EDIT) { + this.showYamlEditor = true; + } else { + this.showYamlEditor = false; + } + }, + }, + methods: { async ensureNamespace() { if ( findBy(this.namespaces, 'metadata.name', 'gatekeeper-system') ) { @@ -118,6 +129,12 @@ export default { // await newSystemNs.waitForState('active'); }, + showActions() { + this.$store.commit('actionMenu/show', { + resources: this.config, + elem: this.$refs.actions, + }); + }, /** * Gets called when the user clicks on the button * Checks for the system namespace and creates that first if it does not exist @@ -142,6 +159,8 @@ export default { } buttonCb(false); } + + this.saving = false; }, /** @@ -150,7 +169,11 @@ export default { */ openYamlEditor() { if (this.showYamlEditor) { - this.showYamlEditor = false; + if (this.mode === _EDIT) { + this.$router.push({ name: this.$route.name }); + } else { + this.showYamlEditor = false; + } } else { this.showYamlEditor = true; } @@ -271,10 +294,13 @@ export default { v-bind="$attrs" @click="disable" /> + -
- +
+

@@ -313,6 +339,7 @@ export default {