-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ui: fix form data double fetch/reset form data by ownership selection #11705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.20
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |||||||||||||||||
| <a-form layout="vertical" > | ||||||||||||||||||
| <a-form-item :label="$t('label.owner.type')"> | ||||||||||||||||||
| <a-select | ||||||||||||||||||
| @change="changeDomain" | ||||||||||||||||||
| @change="changeAccountTypeOrDomain" | ||||||||||||||||||
| v-model:value="selectedAccountType" | ||||||||||||||||||
| defaultValue="account" | ||||||||||||||||||
| autoFocus | ||||||||||||||||||
|
|
@@ -37,7 +37,7 @@ | |||||||||||||||||
| </a-form-item> | ||||||||||||||||||
| <a-form-item :label="$t('label.domain')" required> | ||||||||||||||||||
| <a-select | ||||||||||||||||||
| @change="changeDomain" | ||||||||||||||||||
| @change="changeAccountTypeOrDomain" | ||||||||||||||||||
| v-model:value="selectedDomain" | ||||||||||||||||||
| showSearch | ||||||||||||||||||
| optionFilterProp="label" | ||||||||||||||||||
|
|
@@ -136,14 +136,16 @@ export default { | |||||||||||||||||
| components: { ResourceIcon }, | ||||||||||||||||||
| data () { | ||||||||||||||||||
| return { | ||||||||||||||||||
| initialized: false, | ||||||||||||||||||
| domains: [], | ||||||||||||||||||
| accounts: [], | ||||||||||||||||||
| projects: [], | ||||||||||||||||||
| selectedAccountType: this.$store.getters.project?.id ? 'Project' : 'Account', | ||||||||||||||||||
| selectedDomain: null, | ||||||||||||||||||
| selectedAccount: null, | ||||||||||||||||||
| selectedProject: null, | ||||||||||||||||||
| loading: false | ||||||||||||||||||
| loading: false, | ||||||||||||||||||
| requestToken: 0 | ||||||||||||||||||
| } | ||||||||||||||||||
| }, | ||||||||||||||||||
| props: { | ||||||||||||||||||
|
|
@@ -177,7 +179,7 @@ export default { | |||||||||||||||||
| const domainIds = this.domains?.map(domain => domain.id) | ||||||||||||||||||
| const ownerDomainId = this.$store.getters.project?.domainid || this.$store.getters.userInfo.domainid | ||||||||||||||||||
| this.selectedDomain = domainIds?.includes(ownerDomainId) ? ownerDomainId : this.domains?.[0]?.id | ||||||||||||||||||
| this.changeDomain() | ||||||||||||||||||
| this.fetchOwnerData() | ||||||||||||||||||
| }) | ||||||||||||||||||
| .catch((error) => { | ||||||||||||||||||
| this.$notifyError(error) | ||||||||||||||||||
|
|
@@ -186,8 +188,13 @@ export default { | |||||||||||||||||
| this.loading = false | ||||||||||||||||||
| }) | ||||||||||||||||||
| }, | ||||||||||||||||||
| increamentAndGetRequestToken () { | ||||||||||||||||||
| this.requestToken += 1 | ||||||||||||||||||
| return this.requestToken | ||||||||||||||||||
| }, | ||||||||||||||||||
| fetchAccounts () { | ||||||||||||||||||
| this.loading = true | ||||||||||||||||||
| const currentToken = this.increamentAndGetRequestToken() | ||||||||||||||||||
shwstppr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||
| api('listAccounts', { | ||||||||||||||||||
| response: 'json', | ||||||||||||||||||
| domainId: this.selectedDomain, | ||||||||||||||||||
|
|
@@ -196,6 +203,9 @@ export default { | |||||||||||||||||
| isrecursive: false | ||||||||||||||||||
| }) | ||||||||||||||||||
| .then((response) => { | ||||||||||||||||||
| if (currentToken !== this.requestToken) { | ||||||||||||||||||
| return | ||||||||||||||||||
| } | ||||||||||||||||||
| this.accounts = response.listaccountsresponse.account || [] | ||||||||||||||||||
| if (this.override?.accounts && this.accounts) { | ||||||||||||||||||
| this.accounts = this.accounts.filter(item => this.override.accounts.has(item.name)) | ||||||||||||||||||
|
|
@@ -214,10 +224,12 @@ export default { | |||||||||||||||||
| }) | ||||||||||||||||||
| .finally(() => { | ||||||||||||||||||
| this.loading = false | ||||||||||||||||||
| this.initialized = true | ||||||||||||||||||
| }) | ||||||||||||||||||
| }, | ||||||||||||||||||
| fetchProjects () { | ||||||||||||||||||
| this.loading = true | ||||||||||||||||||
| const currentToken = this.increamentAndGetRequestToken() | ||||||||||||||||||
| api('listProjects', { | ||||||||||||||||||
| response: 'json', | ||||||||||||||||||
| domainId: this.selectedDomain, | ||||||||||||||||||
|
|
@@ -227,6 +239,9 @@ export default { | |||||||||||||||||
| isrecursive: false | ||||||||||||||||||
| }) | ||||||||||||||||||
| .then((response) => { | ||||||||||||||||||
| if (currentToken !== this.requestToken) { | ||||||||||||||||||
| return | ||||||||||||||||||
| } | ||||||||||||||||||
| this.projects = response.listprojectsresponse.project | ||||||||||||||||||
| if (this.override?.projects && this.projects) { | ||||||||||||||||||
| this.projects = this.projects.filter(item => this.override.projects.has(item.id)) | ||||||||||||||||||
|
|
@@ -240,9 +255,14 @@ export default { | |||||||||||||||||
| }) | ||||||||||||||||||
| .finally(() => { | ||||||||||||||||||
| this.loading = false | ||||||||||||||||||
| this.initialized = true | ||||||||||||||||||
| }) | ||||||||||||||||||
| }, | ||||||||||||||||||
| changeDomain () { | ||||||||||||||||||
| changeAccountTypeOrDomain () { | ||||||||||||||||||
| this.initialized = true | ||||||||||||||||||
| this.fetchOwnerData() | ||||||||||||||||||
|
Comment on lines
+262
to
+263
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be
Suggested change
or
Suggested change
?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is fine as it is. The method |
||||||||||||||||||
| }, | ||||||||||||||||||
| fetchOwnerData () { | ||||||||||||||||||
| if (this.selectedAccountType === 'Account') { | ||||||||||||||||||
| this.fetchAccounts() | ||||||||||||||||||
| } else { | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.