From 5dceb5dff36e85e124eb30c77a504b3ca06b081a Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Thu, 8 Jun 2023 12:12:26 +0200 Subject: [PATCH] Service accounts: API key migration refactoring to parse as json object of the results (#69771) refactoring to parse as json object of the results --- pkg/services/serviceaccounts/models.go | 10 +++++----- public/app/features/api-keys/state/actions.ts | 2 +- public/app/features/api-keys/state/reducers.ts | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/services/serviceaccounts/models.go b/pkg/services/serviceaccounts/models.go index 1be9b033908..876817b23a8 100644 --- a/pkg/services/serviceaccounts/models.go +++ b/pkg/services/serviceaccounts/models.go @@ -38,11 +38,11 @@ var ( ) type MigrationResult struct { - Total int - Migrated int - Failed int - FailedApikeyIDs []int64 - FailedDetails []string + Total int `json:"total"` + Migrated int `json:"migrated"` + Failed int `json:"failed"` + FailedApikeyIDs []int64 `json:"failedApikeyIDs"` + FailedDetails []string `json:"failedDetails"` } type ServiceAccount struct { diff --git a/public/app/features/api-keys/state/actions.ts b/public/app/features/api-keys/state/actions.ts index 73a9165221f..f81a8310d48 100644 --- a/public/app/features/api-keys/state/actions.ts +++ b/public/app/features/api-keys/state/actions.ts @@ -36,7 +36,7 @@ export function migrateAll(): ThunkResult { return async (dispatch) => { try { const payload = await getBackendSrv().post('/api/serviceaccounts/migrate'); - dispatch(setMigrationResult({ payload })); + dispatch(setMigrationResult(payload)); } finally { dispatch(loadApiKeys()); } diff --git a/public/app/features/api-keys/state/reducers.ts b/public/app/features/api-keys/state/reducers.ts index 075388f9c31..6e5ad5d277e 100644 --- a/public/app/features/api-keys/state/reducers.ts +++ b/public/app/features/api-keys/state/reducers.ts @@ -39,8 +39,7 @@ const apiKeysSlice = createSlice({ return { ...state, hasFetched: false }; }, setMigrationResult: (state, action): ApiKeysState => { - const { migrationResult } = action.payload; - return { ...state, migrationResult: migrationResult }; + return { ...state, migrationResult: action.payload }; }, }, });