From f593cca83a9fcc2f065ee25d9651bd397aacc1cc Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Wed, 3 Sep 2025 14:50:03 +0200 Subject: [PATCH] Fleet add fallback getting user info before store init Signed-off-by: Francesco Torchia --- shell/edit/fleet.cattle.io.gitrepo.vue | 9 +++++---- shell/models/fleet-application.js | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/shell/edit/fleet.cattle.io.gitrepo.vue b/shell/edit/fleet.cattle.io.gitrepo.vue index 8a16aa51ad..cd70dde1e9 100644 --- a/shell/edit/fleet.cattle.io.gitrepo.vue +++ b/shell/edit/fleet.cattle.io.gitrepo.vue @@ -58,7 +58,7 @@ export default { mixins: [CreateEditView, FormValidation], async fetch() { - // Nothing to do + this.currentUser = await this.value.getCurrentUser(); }, data() { @@ -92,13 +92,14 @@ export default { const refValue = this.value.spec?.[ref] || ''; return { + currentUser: {}, tempCachedValues: {}, username: null, password: null, publicKey: null, privateKey: null, - caBundle: null, -tlsMode, + caBundle: null, + tlsMode, correctDriftEnabled, pollingInterval, ref, @@ -406,7 +407,7 @@ tlsMode, this.value.spec['correctDrift'] = { enabled: this.correctDriftEnabled }; if (this.mode === _CREATE) { - this.value.metadata.labels[FLEET_LABELS.CREATED_BY_USER_ID] = this.value.currentUser.id; + this.value.metadata.labels[FLEET_LABELS.CREATED_BY_USER_ID] = this.currentUser.id; } }, diff --git a/shell/models/fleet-application.js b/shell/models/fleet-application.js index 6e9f8626e2..6c9f8f2552 100644 --- a/shell/models/fleet-application.js +++ b/shell/models/fleet-application.js @@ -29,8 +29,19 @@ function normalizeStateCounts(data) { } export default class FleetApplication extends SteveModel { - get currentUser() { - return this.$rootGetters['auth/v3User'] || {}; + async getCurrentUser() { + const user = this.$rootGetters['auth/v3User']; + + if (user?.id) { + return user; + } + + const res = await this.$dispatch('rancher/request', { + url: '/v3/users?me=true', + method: 'get', + }, { root: true }); + + return res?.data?.[0] || {}; } pause() {