mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 00:22:36 +08:00
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:
@ -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 {
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
@ -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 };
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user