Skip to content

Commit bca6076

Browse files
authored
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 <abhishek.mrt22@gmail.com>
1 parent 404b579 commit bca6076

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

ui/src/components/view/ListView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
</span>
9999

100100
<span v-if="record.hasannotations">
101-
<span v-if="record.id && $route.path !== '/ssh'">
101+
<span v-if="record.id">
102102
<router-link :to="{ path: $route.path + '/' + record.id }">{{ text }}</router-link>
103103
<router-link :to="{ path: $route.path + '/' + record.id, query: { tab: 'comments' } }"><message-filled style="padding-left: 10px" size="small"/></router-link>
104104
</span>
@@ -110,7 +110,7 @@
110110
<router-link :to="{ path: $route.path + '/' + record.name }" v-else>{{ $t(text.toLowerCase()) }}</router-link>
111111
</span>
112112
<span v-else>
113-
<router-link :to="{ path: $route.path + '/' + record.id }" v-if="record.id && $route.path !== '/ssh'">{{ text }}</router-link>
113+
<router-link :to="{ path: $route.path + '/' + record.id }" v-if="record.id">{{ text }}</router-link>
114114
<router-link :to="{ path: $route.path + '/' + record.name }" v-else>{{ text }}</router-link>
115115
</span>
116116
</span>

ui/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
showIconPlugin,
3535
resourceTypePlugin,
3636
fileSizeUtilPlugin,
37+
genericUtilPlugin,
3738
localesPlugin
3839
} from './utils/plugins'
3940
import { VueAxios } from './utils/request'
@@ -49,6 +50,7 @@ vueApp.use(showIconPlugin)
4950
vueApp.use(resourceTypePlugin)
5051
vueApp.use(fileSizeUtilPlugin)
5152
vueApp.use(localesPlugin)
53+
vueApp.use(genericUtilPlugin)
5254
vueApp.use(extensions)
5355
vueApp.use(directives)
5456

ui/src/utils/plugins.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,12 @@ export const fileSizeUtilPlugin = {
464464
}
465465
}
466466
}
467+
468+
export const genericUtilPlugin = {
469+
install (app) {
470+
app.config.globalProperties.$isValidUuid = function (uuid) {
471+
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
472+
return regexExp.test(uuid)
473+
}
474+
}
475+
}

ui/src/views/AutogenView.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,10 @@ export default {
851851
if (this.$route.params && this.$route.params.id) {
852852
params.id = this.$route.params.id
853853
if (['listSSHKeyPairs'].includes(this.apiName)) {
854-
delete params.id
855-
params.name = this.$route.params.id
854+
if (!this.$isValidUuid(params.id)) {
855+
delete params.id
856+
params.name = this.$route.params.id
857+
}
856858
}
857859
if (['listPublicIpAddresses'].includes(this.apiName)) {
858860
params.allocatedonly = false

ui/tests/common/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import {
3030
apiMetaUtilPlugin,
3131
showIconPlugin,
3232
resourceTypePlugin,
33-
fileSizeUtilPlugin
33+
fileSizeUtilPlugin,
34+
genericUtilPlugin
3435
} from '@/utils/plugins'
3536

3637
function createMockRouter (newRoutes = []) {
@@ -86,6 +87,7 @@ function createFactory (component, options) {
8687
showIconPlugin,
8788
resourceTypePlugin,
8889
fileSizeUtilPlugin,
90+
genericUtilPlugin,
8991
StoragePlugin
9092
],
9193
mocks

0 commit comments

Comments
 (0)