Service accounts: API key migration refactoring to parse as json object of the results (#69771)

refactoring to parse as json object of the results
This commit is contained in:
Eric Leijonmarck
2023-06-08 12:12:26 +02:00
committed by GitHub
parent 39fa918492
commit 5dceb5dff3
3 changed files with 7 additions and 8 deletions

View File

@ -38,11 +38,11 @@ var (
) )
type MigrationResult struct { type MigrationResult struct {
Total int Total int `json:"total"`
Migrated int Migrated int `json:"migrated"`
Failed int Failed int `json:"failed"`
FailedApikeyIDs []int64 FailedApikeyIDs []int64 `json:"failedApikeyIDs"`
FailedDetails []string FailedDetails []string `json:"failedDetails"`
} }
type ServiceAccount struct { type ServiceAccount struct {

View File

@ -36,7 +36,7 @@ export function migrateAll(): ThunkResult<void> {
return async (dispatch) => { return async (dispatch) => {
try { try {
const payload = await getBackendSrv().post('/api/serviceaccounts/migrate'); const payload = await getBackendSrv().post('/api/serviceaccounts/migrate');
dispatch(setMigrationResult({ payload })); dispatch(setMigrationResult(payload));
} finally { } finally {
dispatch(loadApiKeys()); dispatch(loadApiKeys());
} }

View File

@ -39,8 +39,7 @@ const apiKeysSlice = createSlice({
return { ...state, hasFetched: false }; return { ...state, hasFetched: false };
}, },
setMigrationResult: (state, action): ApiKeysState => { setMigrationResult: (state, action): ApiKeysState => {
const { migrationResult } = action.payload; return { ...state, migrationResult: action.payload };
return { ...state, migrationResult: migrationResult };
}, },
}, },
}); });