Skip to content

Commit

Permalink
fix(ui): namespace tweaks (#4368)
Browse files Browse the repository at this point in the history
* fix(ui): namespace flows filtered by single namespace

* fix(ui): namespace key value pairs filtered by single namespace

* fix(ui): single namespace properly filtered
  • Loading branch information
MilosPaunovic authored Jul 19, 2024
1 parent ca78d85 commit 7f17a97
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
14 changes: 5 additions & 9 deletions ui/src/components/namespace/Namespace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
...mapState("auth", ["user"]),
...mapState("namespace", ["dependencies"]),
canCreateSecret() {
return this.$route.params.namespace && this.user &&
this.user.isAllowed(permission.SECRET, action.CREATE, this.$route.params.namespace);
return this.$route.params.id && this.user &&
this.user.isAllowed(permission.SECRET, action.CREATE, this.$route.params.id);
},
canCreateKv() {
return this.$route.params.namespace;
return this.$route.params.id;
},
routeInfo() {
return {
Expand Down Expand Up @@ -217,12 +217,8 @@
},
methods: {
loadItem() {
if (this.$route.params.namespace) {
this.$store
.dispatch(
"namespace/load",
this.$route.params
)
if (this.$route.params.id) {
this.$store.dispatch("namespace/load",this.$route.params.id)
}
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NamespaceDependencies :id="route.params.namespace" />
<NamespaceDependencies :id="route.params.id" />
</template>

<script setup>
Expand Down
14 changes: 12 additions & 2 deletions ui/src/components/namespace/NamespaceFlows.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<data-table :total="total">
<data-table @page-changed="onPageChanged" :size="pageSize" :page="pageNumber" :total="total">
<template #table>
<el-table
:data="flows"
Expand Down Expand Up @@ -111,6 +111,7 @@
import StateChart from "../stats/StateChart.vue";
import TriggerAvatar from "../flows/TriggerAvatar.vue";
import Kicon from "../Kicon.vue"
import _merge from "lodash/merge";
import TextSearch from "vue-material-design-icons/TextSearch.vue";
Expand All @@ -128,8 +129,17 @@
}
},
methods: {
loadQuery(base) {
return _merge(base, this.queryWithFilter())
},
loadData(callback) {
this.$store.dispatch("flow/findFlows", {namespace: this.$route.params.namespace}).then((flows) => {
const params = {
namespace: this.$route.params.id,
page: this.$route.query.page || this.internalPageNumber,
size: this.$route.query.size || this.internalPageSize
}
this.$store.dispatch("flow/findFlows", this.loadQuery(params)).then((flows) => {
this.dailyGroupByFlowReady = false;
this.lastExecutionByFlowReady = false;
Expand Down
13 changes: 6 additions & 7 deletions ui/src/components/namespace/NamespaceKV.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@
return this.kv.key ? this.$t("kv.update", {key: this.kv.key}) : this.$t("kv.add");
},
canUpdateKv() {
return this.$route.params.namespace
return this.$route.params.id
},
canDeleteKv() {
return this.$route.params.namespace
return this.$route.params.id
},
addKvDrawerVisible: {
get() {
Expand Down Expand Up @@ -216,8 +216,7 @@
}
},
loadKvs() {
this.$store
.dispatch("namespace/kvsList", {id: this.$route.params.namespace})
this.$store.dispatch("namespace/kvsList", {id: this.$route.params.id})
},
kvKeyDuplicate(rule, value, callback) {
if (this.kv.update === undefined && this.kvs && this.kvs.find(r => r.key === value)) {
Expand All @@ -228,7 +227,7 @@
},
async updateKvModal(key) {
this.kv.key = key;
const {type, value} = await this.$store.dispatch("namespace/kv", {namespace: this.$route.params.namespace, key});
const {type, value} = await this.$store.dispatch("namespace/kv", {namespace: this.$route.params.id, key});
this.kv.type = type;
if (type === "JSON") {
this.kv.value = JSON.stringify(value);
Expand All @@ -243,7 +242,7 @@
removeKv(key) {
this.$toast().confirm(this.$t("delete confirm", {name: key}), () => {
return this.$store
.dispatch("namespace/deleteKv", {namespace: this.$route.params.namespace, key: key})
.dispatch("namespace/deleteKv", {namespace: this.$route.params.id, key: key})
.then(() => {
this.$toast().deleted(key);
});
Expand All @@ -270,7 +269,7 @@
return this.$store
.dispatch(
"namespace/createKv",
{namespace: this.$route.params.namespace, ...this.kv, value}
{namespace: this.$route.params.id, ...this.kv, value}
)
.then(() => {
this.$toast().saved(this.kv.key);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/namespace/Overview.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div>
<home
:namespace="$route.params.namespace || $route.query.id"
:namespace="$route.params.id || $route.query.id"
:restore-url="false"
:description="$route.params.namespace ? namespace?.description : undefined"
:description="$route.params.id ? namespace?.description : undefined"
embed
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/stores/namespaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default {
return response.data.results;
})
},
load({commit}, options) {
return this.$http.get(`${apiUrl(this)}/namespaces/${options.id}`, VALIDATE)
load({commit}, id) {
return this.$http.get(`${apiUrl(this)}/namespaces/${id}`, VALIDATE)
.then(response => {
if(response.status === 200) commit("setNamespace", response.data)
return response.data;
Expand Down

0 comments on commit 7f17a97

Please sign in to comment.