You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sh...@apache.org on 2022/08/09 07:59:55 UTC
[cloudstack] branch 4.17 updated: ui: use ssh keypair uuid for listing (#6616)
This is an automated email from the ASF dual-hosted git repository.
shwstppr pushed a commit to branch 4.17
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.17 by this push:
new bca60761c5 ui: use ssh keypair uuid for listing (#6616)
bca60761c5 is described below
commit bca60761c502f1fa04c1d462128ef537c0e7ce73
Author: Abhishek Kumar <ab...@gmail.com>
AuthorDate: Tue Aug 9 13:29:49 2022 +0530
ui: use ssh keypair uuid for listing (#6616)
Addresses #6569
Use uuid to list SSH keypair wherever uuid is available.
Signed-off-by: Abhishek Kumar <ab...@gmail.com>
---
ui/src/components/view/ListView.vue | 4 ++--
ui/src/main.js | 2 ++
ui/src/utils/plugins.js | 9 +++++++++
ui/src/views/AutogenView.vue | 6 ++++--
ui/tests/common/index.js | 4 +++-
5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue
index 292460541a..981152fe21 100644
--- a/ui/src/components/view/ListView.vue
+++ b/ui/src/components/view/ListView.vue
@@ -98,7 +98,7 @@
</span>
<span v-if="record.hasannotations">
- <span v-if="record.id && $route.path !== '/ssh'">
+ <span v-if="record.id">
<router-link :to="{ path: $route.path + '/' + record.id }">{{ text }}</router-link>
<router-link :to="{ path: $route.path + '/' + record.id, query: { tab: 'comments' } }"><message-filled style="padding-left: 10px" size="small"/></router-link>
</span>
@@ -110,7 +110,7 @@
<router-link :to="{ path: $route.path + '/' + record.name }" v-else>{{ $t(text.toLowerCase()) }}</router-link>
</span>
<span v-else>
- <router-link :to="{ path: $route.path + '/' + record.id }" v-if="record.id && $route.path !== '/ssh'">{{ text }}</router-link>
+ <router-link :to="{ path: $route.path + '/' + record.id }" v-if="record.id">{{ text }}</router-link>
<router-link :to="{ path: $route.path + '/' + record.name }" v-else>{{ text }}</router-link>
</span>
</span>
diff --git a/ui/src/main.js b/ui/src/main.js
index bd465bcfc0..2f1d892fbd 100644
--- a/ui/src/main.js
+++ b/ui/src/main.js
@@ -34,6 +34,7 @@ import {
showIconPlugin,
resourceTypePlugin,
fileSizeUtilPlugin,
+ genericUtilPlugin,
localesPlugin
} from './utils/plugins'
import { VueAxios } from './utils/request'
@@ -49,6 +50,7 @@ vueApp.use(showIconPlugin)
vueApp.use(resourceTypePlugin)
vueApp.use(fileSizeUtilPlugin)
vueApp.use(localesPlugin)
+vueApp.use(genericUtilPlugin)
vueApp.use(extensions)
vueApp.use(directives)
diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js
index 63a0e609c5..6f7954ef2d 100644
--- a/ui/src/utils/plugins.js
+++ b/ui/src/utils/plugins.js
@@ -464,3 +464,12 @@ export const fileSizeUtilPlugin = {
}
}
}
+
+export const genericUtilPlugin = {
+ install (app) {
+ app.config.globalProperties.$isValidUuid = function (uuid) {
+ const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
+ return regexExp.test(uuid)
+ }
+ }
+}
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index ff75a6d269..39967fe84c 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -851,8 +851,10 @@ export default {
if (this.$route.params && this.$route.params.id) {
params.id = this.$route.params.id
if (['listSSHKeyPairs'].includes(this.apiName)) {
- delete params.id
- params.name = this.$route.params.id
+ if (!this.$isValidUuid(params.id)) {
+ delete params.id
+ params.name = this.$route.params.id
+ }
}
if (['listPublicIpAddresses'].includes(this.apiName)) {
params.allocatedonly = false
diff --git a/ui/tests/common/index.js b/ui/tests/common/index.js
index 545e9915f5..a517fc2d08 100644
--- a/ui/tests/common/index.js
+++ b/ui/tests/common/index.js
@@ -30,7 +30,8 @@ import {
apiMetaUtilPlugin,
showIconPlugin,
resourceTypePlugin,
- fileSizeUtilPlugin
+ fileSizeUtilPlugin,
+ genericUtilPlugin
} from '@/utils/plugins'
function createMockRouter (newRoutes = []) {
@@ -86,6 +87,7 @@ function createFactory (component, options) {
showIconPlugin,
resourceTypePlugin,
fileSizeUtilPlugin,
+ genericUtilPlugin,
StoragePlugin
],
mocks