mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
* running a new migration should only invalidate the list of migration runs * correctly select the last migration result, not the first
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
export * from './endpoints.gen';
|
|
import { BaseQueryFn, QueryDefinition } from '@reduxjs/toolkit/dist/query';
|
|
|
|
import { generatedAPI } from './endpoints.gen';
|
|
|
|
export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({
|
|
addTagTypes: ['cloud-migration-config', 'cloud-migration-run', 'cloud-migration-run-list'],
|
|
endpoints: {
|
|
// List Cloud Configs
|
|
getMigrationList: {
|
|
providesTags: ['cloud-migration-config'] /* should this be a -list? */,
|
|
},
|
|
|
|
// Create Cloud Config
|
|
createMigration: {
|
|
invalidatesTags: ['cloud-migration-config'],
|
|
},
|
|
|
|
// Get one Cloud Config
|
|
getCloudMigration: {
|
|
providesTags: ['cloud-migration-config'],
|
|
},
|
|
|
|
// Delete one Cloud Config
|
|
deleteCloudMigration: {
|
|
invalidatesTags: ['cloud-migration-config'],
|
|
},
|
|
|
|
getCloudMigrationRunList: {
|
|
providesTags: ['cloud-migration-run-list'],
|
|
},
|
|
|
|
getCloudMigrationRun: {
|
|
providesTags: ['cloud-migration-run'],
|
|
},
|
|
|
|
runCloudMigration: {
|
|
invalidatesTags: ['cloud-migration-run-list'],
|
|
},
|
|
|
|
getDashboardByUid(endpoint) {
|
|
suppressErrorsOnQuery(endpoint);
|
|
},
|
|
},
|
|
});
|
|
|
|
function suppressErrorsOnQuery<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType>(
|
|
endpoint: QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType>
|
|
) {
|
|
if (!endpoint.query) {
|
|
return;
|
|
}
|
|
|
|
const originalQuery = endpoint.query;
|
|
endpoint.query = (...args) => {
|
|
const baseQuery = originalQuery(...args);
|
|
baseQuery.showErrorAlert = false;
|
|
return baseQuery;
|
|
};
|
|
}
|