feat: modify polling api to /current (#27787)

This commit is contained in:
Dipyaman Biswas 2023-10-04 18:39:47 +05:30 committed by GitHub
parent 0c258e20bb
commit 38b66b4505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

View File

@ -8,3 +8,9 @@ export const tenantConfigConnection: string[] = [
export const RESTART_POLL_TIMEOUT = 2 * 150 * 1000; export const RESTART_POLL_TIMEOUT = 2 * 150 * 1000;
export const RESTART_POLL_INTERVAL = 2000; export const RESTART_POLL_INTERVAL = 2000;
export enum MIGRATION_STATUS {
COMPLETED = "COMPLETED",
IN_PROGRESS = "IN_PROGRESS",
PENDING = "PENDING",
}

View File

@ -5,7 +5,10 @@ import {
ReduxActionErrorTypes, ReduxActionErrorTypes,
ReduxActionTypes, ReduxActionTypes,
} from "@appsmith/constants/ReduxActionConstants"; } 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 type { User } from "constants/userConstants";
import { call, put, delay, select } from "redux-saga/effects"; import { call, put, delay, select } from "redux-saga/effects";
import history from "utils/history"; import history from "utils/history";
@ -26,9 +29,12 @@ import { getCurrentTenant } from "@appsmith/actions/tenantActions";
import { toast } from "design-system"; import { toast } from "design-system";
import AnalyticsUtil from "utils/AnalyticsUtil"; import AnalyticsUtil from "utils/AnalyticsUtil";
import { import {
MIGRATION_STATUS,
RESTART_POLL_INTERVAL, RESTART_POLL_INTERVAL,
RESTART_POLL_TIMEOUT, RESTART_POLL_TIMEOUT,
} from "@appsmith/constants/tenantConstants"; } from "@appsmith/constants/tenantConstants";
import type { FetchCurrentTenantConfigResponse } from "@appsmith/api/TenantApi";
import TenantApi from "@appsmith/api/TenantApi";
export function* FetchAdminSettingsSaga() { export function* FetchAdminSettingsSaga() {
const response: ApiResponse = yield call(UserApi.fetchAdminSettings); const response: ApiResponse = yield call(UserApi.fetchAdminSettings);
@ -144,16 +150,23 @@ export function* RestartServerPoll() {
yield call(RestryRestartServerPoll); yield call(RestryRestartServerPoll);
} }
export function* RestryRestartServerPoll() { export function* RestryRestartServerPoll(isMigration = false) {
let pollCount = 0; let pollCount = 0;
const maxPollCount = RESTART_POLL_TIMEOUT / RESTART_POLL_INTERVAL; const maxPollCount = RESTART_POLL_TIMEOUT / RESTART_POLL_INTERVAL;
while (pollCount < maxPollCount) { while (pollCount < maxPollCount) {
pollCount++; pollCount++;
yield delay(RESTART_POLL_INTERVAL); yield delay(RESTART_POLL_INTERVAL);
try { try {
const response: ApiResponse = yield call(UserApi.getCurrentUser); const response: FetchCurrentTenantConfigResponse = yield call(
if (response.responseMeta.status === 200) { TenantApi.fetchCurrentTenantConfig,
window.location.reload(); );
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) {} } catch (e) {}
} }

View File

@ -7,6 +7,7 @@ export const PAGE_NOT_FOUND_URL = "/404";
export const SERVER_ERROR_URL = "/500"; export const SERVER_ERROR_URL = "/500";
export const APPLICATIONS_URL = `/applications`; export const APPLICATIONS_URL = `/applications`;
export const LICENSE_CHECK_PATH = "/license"; export const LICENSE_CHECK_PATH = "/license";
export const MIGRATIONS_URL = "/migrations";
export const TEMPLATES_PATH = "/templates"; export const TEMPLATES_PATH = "/templates";
export const TEMPLATES_ID_PATH = "/templates/:templateId"; 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_PAGE_URL = `${WORKSPACE_URL}/settings`;
export const WORKSPACE_SETTINGS_GENERAL_PAGE_URL = `${WORKSPACE_URL}/settings/general`; 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_MEMBERS_PAGE_URL = `${WORKSPACE_URL}/settings/members`;
export const WORKSPACE_SETTINGS_BILLING_PAGE_URL = `/settings/billing`;
export const matchApplicationPath = match(APPLICATIONS_URL); export const matchApplicationPath = match(APPLICATIONS_URL);
export const matchTemplatesPath = match(TEMPLATES_PATH); export const matchTemplatesPath = match(TEMPLATES_PATH);