E2C: Show latest migration run instead of the first (#85666)

* running a new migration should only invalidate the list of migration runs

* correctly select the last migration result, not the first
This commit is contained in:
Josh Hunt 2024-04-05 16:28:57 +01:00 committed by GitHub
parent 45c56d208f
commit 040966220e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@ import { BaseQueryFn, QueryDefinition } from '@reduxjs/toolkit/dist/query';
import { generatedAPI } from './endpoints.gen'; import { generatedAPI } from './endpoints.gen';
export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({ export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({
addTagTypes: ['cloud-migration-config', 'cloud-migration-run'], addTagTypes: ['cloud-migration-config', 'cloud-migration-run', 'cloud-migration-run-list'],
endpoints: { endpoints: {
// List Cloud Configs // List Cloud Configs
getMigrationList: { getMigrationList: {
@ -27,7 +27,7 @@ export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({
}, },
getCloudMigrationRunList: { getCloudMigrationRunList: {
providesTags: ['cloud-migration-run'] /* should this be a -list? */, providesTags: ['cloud-migration-run-list'],
}, },
getCloudMigrationRun: { getCloudMigrationRun: {
@ -35,7 +35,7 @@ export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({
}, },
runCloudMigration: { runCloudMigration: {
invalidatesTags: ['cloud-migration-run'], invalidatesTags: ['cloud-migration-run-list'],
}, },
getDashboardByUid(endpoint) { getDashboardByUid(endpoint) {

View File

@ -33,7 +33,7 @@ import { ResourcesTable } from './ResourcesTable';
function useGetLatestMigrationDestination() { function useGetLatestMigrationDestination() {
const result = useGetMigrationListQuery(); const result = useGetMigrationListQuery();
const latestMigration = result.data?.migrations?.[0]; const latestMigration = result.data?.migrations?.at(-1);
return { return {
...result, ...result,
@ -43,7 +43,7 @@ function useGetLatestMigrationDestination() {
function useGetLatestMigrationRun(migrationId?: number) { function useGetLatestMigrationRun(migrationId?: number) {
const listResult = useGetCloudMigrationRunListQuery(migrationId ? { id: migrationId } : skipToken); const listResult = useGetCloudMigrationRunListQuery(migrationId ? { id: migrationId } : skipToken);
const latestMigrationRun = listResult.data?.runs?.[0]; const latestMigrationRun = listResult.data?.runs?.at(-1);
const runResult = useGetCloudMigrationRunQuery( const runResult = useGetCloudMigrationRunQuery(
latestMigrationRun?.id && migrationId ? { runId: latestMigrationRun.id, id: migrationId } : skipToken latestMigrationRun?.id && migrationId ? { runId: latestMigrationRun.id, id: migrationId } : skipToken