Skip to content

Commit e35b68f

Browse files
apply suggestions and fix bugs
1 parent 33e91bd commit e35b68f

5 files changed

Lines changed: 44 additions & 45 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/admin/user/RegisterUserKeysCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public List<Map<String, Object>> getRules() {
138138

139139
String description = detail.get(ApiConstants.DESCRIPTION);
140140
if (StringUtils.isNotEmpty(description)) {
141-
if (permission.length() > 255) {
141+
if (description.length() > 255) {
142142
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Description cannot be longer than 255 characters.");
143143
}
144144
ruleDetails.put(ApiConstants.DESCRIPTION, description);

ui/public/locales/pt_BR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@
20582058
"label.secondarystoragelimit": "Limites do armazenamento secund\u00e1rio (GiB)",
20592059
"label.secretkey": "Chave secreta",
20602060
"label.secret.key": "Chave secreta",
2061-
"label.apikeyaccess": "Accesso a pares de chaves de API",
2061+
"label.apikeyaccess": "Acesso a pares de chaves de API",
20622062
"label.secured": "Protegido",
20632063
"label.security.groups": "Grupos de seguran\u00e7a",
20642064
"label.securitygroup": "Grupo de seguran\u00e7a",

ui/src/components/view/ApiKeyPairsTab.vue

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
:columns="columns"
4242
:dataSource="keypairs"
4343
:rowKey="item => item.id"
44-
:key="item => item.id"
4544
:rowSelection="rowSelection()"
4645
:pagination="false" >
4746
<template #name="{ record }">
@@ -132,7 +131,6 @@
132131
:showAddKeyPair="showAddKeyPair"
133132
:resource="resource"
134133
@fetch-data="fetchData"
135-
@handle-cancel="handleCancelAddKeyPair"
136134
@refresh-data="handleRefreshData"
137135
@close-modal="closeModalAddKeyPair" />
138136
</div>
@@ -145,7 +143,6 @@ import BulkActionView from '@/components/view/BulkActionView.vue'
145143
import eventBus from '@/config/eventBus'
146144
import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
147145
import GenerateApiKeyPair from '@/views/iam/GenerateApiKeyPair.vue'
148-
import store from '@/store'
149146
150147
export default {
151148
name: 'ApiKeyPairsTab',
@@ -154,8 +151,7 @@ export default {
154151
Status,
155152
TooltipButton,
156153
BulkActionView,
157-
GenerateApiKeyPair,
158-
store
154+
GenerateApiKeyPair
159155
},
160156
props: {
161157
resource: {
@@ -286,31 +282,39 @@ export default {
286282
}
287283
this.deleteKeypairs(this.selectedItems)
288284
},
289-
deleteKeypairs (keypairs) {
285+
async deleteKeypairs (keypairs) {
286+
if (!keypairs || keypairs.length === 0) {
287+
this.fetchLoading = false
288+
return
289+
}
290+
290291
this.fetchLoading = true
291-
keypairs.forEach(async keypair => {
292-
try {
293-
const jobId = await this.deleteKeyPair({
294-
keypairid: keypair.id
295-
})
296-
await this.$pollJob({
297-
jobId,
298-
action: {
299-
isFetchData: false
300-
},
301-
successMethod: () => {
302-
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'success' })
303-
},
304-
catchMethod: () => {
305-
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
306-
}
307-
})
308-
} catch (e) {
309-
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
310-
} finally {
311-
this.fetchLoading = false
312-
}
313-
})
292+
try {
293+
await Promise.all(keypairs.map(async keypair => {
294+
try {
295+
const jobId = await this.deleteKeyPair({
296+
keypairid: keypair.id
297+
})
298+
await this.$pollJob({
299+
jobId,
300+
action: {
301+
isFetchData: false
302+
},
303+
successMethod: () => {
304+
console.log('success method')
305+
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'success' })
306+
},
307+
catchMethod: () => {
308+
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
309+
}
310+
})
311+
} catch (e) {
312+
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: keypair.id, state: 'failed' })
313+
}
314+
}))
315+
} finally {
316+
this.fetchLoading = false
317+
}
314318
},
315319
async deleteKeyPair (args) {
316320
const response = await postAPI('deleteUserKeys', args)
@@ -337,14 +341,11 @@ export default {
337341
closeModalAddKeyPair () {
338342
this.showAddKeyPair = false
339343
},
340-
handleCancelAddKeyPair () {
341-
this.showAddKeyPair = false
342-
},
343344
handleRefreshData () {
344345
this.$emit('refresh-data')
345346
},
346347
rowSelection () {
347-
if ('deleteUserKeys' in store.getters.apis) {
348+
if ('deleteUserKeys' in this.$store.getters.apis) {
348349
return {
349350
selectedRowKeys: this.selectedRowKeys,
350351
onChange: this.setSelection

ui/src/views/iam/ApiKeyPairPermissionTable.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</div>
3434
<div class="rules-table__col rules-table__col--permission">
3535
<permission-editable
36-
:defaultValue="newRulePermission"
36+
:default-value="newRulePermission"
3737
:value="newRulePermission"
3838
@onChange="updateNewPermission()" />
3939
</div>
@@ -173,14 +173,12 @@
173173
import { getAPI } from '@/api'
174174
import draggable from 'vuedraggable'
175175
import PermissionEditable from './PermissionEditable'
176-
import RuleDelete from './RuleDelete'
177176
import TooltipButton from '@/components/widgets/TooltipButton'
178177
import { genericCompare } from '@/utils/sort'
179178
180179
export default {
181180
name: 'ApiKeyPairPermissionTable',
182181
components: {
183-
RuleDelete,
184182
PermissionEditable,
185183
draggable,
186184
TooltipButton

ui/src/views/iam/GenerateApiKeyPair.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default {
150150
id: this.resource.id,
151151
description: values.description ? values.description : null,
152152
startdate: values.startDate ? parseDayJsObject({ value: values.startDate }) : null,
153-
endDate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
153+
enddate: values.endDate ? parseDayJsObject({ value: values.endDate }) : null
154154
}
155155
for (const i in this.rules) {
156156
const rule = this.rules[i]
@@ -161,7 +161,9 @@ export default {
161161
return params
162162
},
163163
handleSubmit (e) {
164-
e.preventDefault()
164+
if (e && typeof e.preventDefault === 'function') {
165+
e.preventDefault()
166+
}
165167
if (this.loading) return
166168
this.formRef.value.validate().then(() => {
167169
const params = this.buildRequestParams()
@@ -193,15 +195,13 @@ export default {
193195
})
194196
},
195197
closeModal () {
196-
this.form.name = ''
197-
this.form.description = ''
198+
this.form.name = null
199+
this.form.description = null
198200
this.form.startDate = null
199201
this.form.endDate = null
202+
this.rules = []
200203
this.$emit('close-modal')
201204
},
202-
handleCancel () {
203-
this.$emit('handle-cancel')
204-
},
205205
fetchData () {
206206
this.$emit('fetch-data')
207207
},

0 commit comments

Comments
 (0)