diff --git a/app/client/src/ce/constants/tenantConstants.ts b/app/client/src/ce/constants/tenantConstants.ts index 2c12b0a68e..19b4a43192 100644 --- a/app/client/src/ce/constants/tenantConstants.ts +++ b/app/client/src/ce/constants/tenantConstants.ts @@ -8,3 +8,9 @@ export const tenantConfigConnection: string[] = [ export const RESTART_POLL_TIMEOUT = 2 * 150 * 1000; export const RESTART_POLL_INTERVAL = 2000; + +export enum MIGRATION_STATUS { + COMPLETED = "COMPLETED", + IN_PROGRESS = "IN_PROGRESS", + PENDING = "PENDING", +} diff --git a/app/client/src/ce/sagas/SuperUserSagas.tsx b/app/client/src/ce/sagas/SuperUserSagas.tsx index 3a2c623038..ad907d313c 100644 --- a/app/client/src/ce/sagas/SuperUserSagas.tsx +++ b/app/client/src/ce/sagas/SuperUserSagas.tsx @@ -5,7 +5,10 @@ import { ReduxActionErrorTypes, ReduxActionTypes, } from "@appsmith/constants/ReduxActionConstants"; -import { APPLICATIONS_URL } from "constants/routes"; +import { + APPLICATIONS_URL, + WORKSPACE_SETTINGS_BILLING_PAGE_URL, +} from "constants/routes"; import type { User } from "constants/userConstants"; import { call, put, delay, select } from "redux-saga/effects"; import history from "utils/history"; @@ -26,9 +29,12 @@ import { getCurrentTenant } from "@appsmith/actions/tenantActions"; import { toast } from "design-system"; import AnalyticsUtil from "utils/AnalyticsUtil"; import { + MIGRATION_STATUS, RESTART_POLL_INTERVAL, RESTART_POLL_TIMEOUT, } from "@appsmith/constants/tenantConstants"; +import type { FetchCurrentTenantConfigResponse } from "@appsmith/api/TenantApi"; +import TenantApi from "@appsmith/api/TenantApi"; export function* FetchAdminSettingsSaga() { const response: ApiResponse = yield call(UserApi.fetchAdminSettings); @@ -144,16 +150,23 @@ export function* RestartServerPoll() { yield call(RestryRestartServerPoll); } -export function* RestryRestartServerPoll() { +export function* RestryRestartServerPoll(isMigration = false) { let pollCount = 0; const maxPollCount = RESTART_POLL_TIMEOUT / RESTART_POLL_INTERVAL; while (pollCount < maxPollCount) { pollCount++; yield delay(RESTART_POLL_INTERVAL); try { - const response: ApiResponse = yield call(UserApi.getCurrentUser); - if (response.responseMeta.status === 200) { - window.location.reload(); + const response: FetchCurrentTenantConfigResponse = yield call( + TenantApi.fetchCurrentTenantConfig, + ); + if ( + response.responseMeta.status === 200 && + response.data?.tenantConfiguration?.migrationStatus === + MIGRATION_STATUS.COMPLETED + ) { + if (!isMigration) window.location.reload(); + else location.href = WORKSPACE_SETTINGS_BILLING_PAGE_URL; } } catch (e) {} } diff --git a/app/client/src/constants/routes/baseRoutes.ts b/app/client/src/constants/routes/baseRoutes.ts index fc1fda7400..583419d6db 100644 --- a/app/client/src/constants/routes/baseRoutes.ts +++ b/app/client/src/constants/routes/baseRoutes.ts @@ -7,6 +7,7 @@ export const PAGE_NOT_FOUND_URL = "/404"; export const SERVER_ERROR_URL = "/500"; export const APPLICATIONS_URL = `/applications`; export const LICENSE_CHECK_PATH = "/license"; +export const MIGRATIONS_URL = "/migrations"; export const TEMPLATES_PATH = "/templates"; export const TEMPLATES_ID_PATH = "/templates/:templateId"; @@ -27,6 +28,7 @@ export const WORKSPACE_INVITE_USERS_PAGE_URL = `${WORKSPACE_URL}/invite`; export const WORKSPACE_SETTINGS_PAGE_URL = `${WORKSPACE_URL}/settings`; export const WORKSPACE_SETTINGS_GENERAL_PAGE_URL = `${WORKSPACE_URL}/settings/general`; export const WORKSPACE_SETTINGS_MEMBERS_PAGE_URL = `${WORKSPACE_URL}/settings/members`; +export const WORKSPACE_SETTINGS_BILLING_PAGE_URL = `/settings/billing`; export const matchApplicationPath = match(APPLICATIONS_URL); export const matchTemplatesPath = match(TEMPLATES_PATH);