## Description Added ESLint rule to force blank lines between statements. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > 🔴 🔴 🔴 Some tests have failed. > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10924926728> > Commit: 34f57714a1575ee04e94e03cbcaf95e57a96c86c > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10924926728&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank">Cypress dashboard</a>. > Tags: @tag.All > Spec: > The following are new failures, please fix them before merging the PR: <ol> > <li>cypress/e2e/Regression/ClientSide/Anvil/AnvilModal_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCheckboxGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilIconButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInlineButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilParagraphWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilToolbarButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilZoneSectionWidgetSnapshot_spec.ts</ol> > <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">List of identified flaky tests</a>. > <hr>Wed, 18 Sep 2024 16:33:36 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No --------- Co-authored-by: Valera Melnikov <valera@appsmith.com>
301 lines
7.3 KiB
TypeScript
301 lines
7.3 KiB
TypeScript
import Api from "api/Api";
|
|
import type { ApiResponse } from "./ApiResponses";
|
|
import type { AxiosPromise, CancelTokenSource } from "axios";
|
|
import axios from "axios";
|
|
import type {
|
|
LayoutOnLoadActionErrors,
|
|
PageAction,
|
|
} from "constants/AppsmithActionConstants/ActionConstants";
|
|
import type { DSLWidget } from "WidgetProvider/constants";
|
|
import type { FetchApplicationResponse } from "ee/api/ApplicationApi";
|
|
import type { APP_MODE } from "entities/App";
|
|
|
|
export interface FetchPageRequest {
|
|
pageId: string;
|
|
isFirstLoad?: boolean;
|
|
handleResponseLater?: boolean;
|
|
migrateDSL?: boolean;
|
|
pageWithMigratedDsl?: FetchPageResponse;
|
|
}
|
|
|
|
export interface FetchPublishedPageRequest {
|
|
pageId: string;
|
|
bustCache?: boolean;
|
|
}
|
|
|
|
export interface SavePageRequest {
|
|
dsl: DSLWidget;
|
|
layoutId: string;
|
|
pageId: string;
|
|
applicationId: string;
|
|
}
|
|
|
|
export interface PageLayout {
|
|
id: string;
|
|
dsl: Partial<DSLWidget>;
|
|
layoutOnLoadActions: PageAction[][];
|
|
layoutActions: PageAction[];
|
|
layoutOnLoadActionErrors?: LayoutOnLoadActionErrors[];
|
|
}
|
|
|
|
export interface PageLayoutsRequest {
|
|
layoutId: string;
|
|
pageId: string;
|
|
layout: {
|
|
dsl: DSLWidget;
|
|
};
|
|
}
|
|
|
|
export interface FetchPageResponseData {
|
|
id: string;
|
|
baseId: string;
|
|
name: string;
|
|
slug: string;
|
|
applicationId: string;
|
|
layouts: Array<PageLayout>;
|
|
lastUpdatedTime: number;
|
|
customSlug?: string;
|
|
userPermissions?: string[];
|
|
layoutOnLoadActionErrors?: LayoutOnLoadActionErrors[];
|
|
}
|
|
|
|
export type FetchPublishedPageResponseData = FetchPageResponseData;
|
|
|
|
export interface SavePageResponseData {
|
|
id: string;
|
|
layoutOnLoadActions: PageAction[][];
|
|
dsl: Partial<DSLWidget>;
|
|
messages: string[];
|
|
actionUpdates: Array<{
|
|
executeOnLoad: boolean;
|
|
id: string;
|
|
name: string;
|
|
collectionId?: string;
|
|
}>;
|
|
layoutOnLoadActionErrors?: Array<LayoutOnLoadActionErrors>;
|
|
}
|
|
|
|
export interface CreatePageRequest {
|
|
applicationId: string;
|
|
name: string;
|
|
layouts: Partial<PageLayout>[];
|
|
}
|
|
|
|
export interface UpdatePageRequest {
|
|
pageId: string;
|
|
name?: string;
|
|
isHidden?: boolean;
|
|
customSlug?: string;
|
|
}
|
|
|
|
export interface UpdatePageResponse {
|
|
id: string;
|
|
baseId: string;
|
|
name: string;
|
|
slug: string;
|
|
customSlug?: string;
|
|
applicationId: string;
|
|
layouts: Array<PageLayout>;
|
|
isHidden: boolean;
|
|
lastUpdatedTime: number;
|
|
defaultResources: unknown[];
|
|
}
|
|
|
|
export interface SetPageOrderRequest {
|
|
order: number;
|
|
pageId: string;
|
|
applicationId: string;
|
|
}
|
|
|
|
export type CreatePageResponse = ApiResponse;
|
|
|
|
export interface FetchPageListResponseData {
|
|
pages: Array<{
|
|
id: string;
|
|
baseId: string;
|
|
name: string;
|
|
isDefault: boolean;
|
|
isHidden?: boolean;
|
|
layouts: Array<PageLayout>;
|
|
slug: string;
|
|
userPermissions?: string[];
|
|
description?: string;
|
|
}>;
|
|
workspaceId: string;
|
|
}
|
|
|
|
export interface DeletePageRequest {
|
|
pageId: string;
|
|
}
|
|
|
|
export interface ClonePageRequest {
|
|
pageId: string;
|
|
}
|
|
|
|
export interface UpdateWidgetNameRequest {
|
|
pageId: string;
|
|
layoutId: string;
|
|
newName: string;
|
|
oldName: string;
|
|
}
|
|
|
|
export interface GenerateTemplatePageRequest {
|
|
pageId: string;
|
|
tableName: string;
|
|
datasourceId: string;
|
|
applicationId: string;
|
|
columns?: string[];
|
|
searchColumn?: string;
|
|
mode?: string;
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
pluginSpecificParams?: Record<any, any>;
|
|
}
|
|
|
|
export interface GenerateTemplatePageResponseData {
|
|
id: string;
|
|
name: string;
|
|
applicationId: string;
|
|
layouts: Array<PageLayout>;
|
|
}
|
|
|
|
export type SavePageResponse = ApiResponse<SavePageResponseData>;
|
|
|
|
export type FetchPageListResponse = ApiResponse<FetchPageListResponseData>;
|
|
|
|
export type UpdateWidgetNameResponse = ApiResponse<PageLayout>;
|
|
|
|
export type GenerateTemplatePageRequestResponse =
|
|
ApiResponse<GenerateTemplatePageResponseData>;
|
|
|
|
export type FetchPageResponse = ApiResponse<FetchPageResponseData>;
|
|
|
|
export type FetchPublishedPageResponse =
|
|
ApiResponse<FetchPublishedPageResponseData>;
|
|
|
|
export interface FetchAppAndPagesRequest {
|
|
applicationId?: string | null;
|
|
pageId?: string | null;
|
|
mode: APP_MODE;
|
|
}
|
|
|
|
class PageApi extends Api {
|
|
static url = "v1/pages";
|
|
static pageUpdateCancelTokenSource?: CancelTokenSource = undefined;
|
|
|
|
static getPublishedPageURL = (pageId: string, bustCache?: boolean) => {
|
|
const url = `v1/pages/${pageId}/view`;
|
|
|
|
return !!bustCache ? url + "?v=" + +new Date() : url;
|
|
};
|
|
|
|
static async fetchPage(
|
|
pageRequest: FetchPageRequest,
|
|
): Promise<AxiosPromise<FetchPageResponse>> {
|
|
const params = { migrateDsl: pageRequest.migrateDSL };
|
|
|
|
return Api.get(PageApi.url + "/" + pageRequest.pageId, undefined, {
|
|
params,
|
|
});
|
|
}
|
|
|
|
static savePage(
|
|
request: SavePageRequest,
|
|
): AxiosPromise<SavePageResponse> | undefined {
|
|
if (PageApi.pageUpdateCancelTokenSource) {
|
|
PageApi.pageUpdateCancelTokenSource.cancel();
|
|
}
|
|
|
|
const body = { dsl: request.dsl };
|
|
|
|
PageApi.pageUpdateCancelTokenSource = axios.CancelToken.source();
|
|
const { applicationId, layoutId, pageId } = request;
|
|
|
|
return Api.put(
|
|
`v1/layouts/${layoutId}/pages/${pageId}?applicationId=${applicationId}`,
|
|
body,
|
|
undefined,
|
|
{ cancelToken: PageApi.pageUpdateCancelTokenSource.token },
|
|
);
|
|
}
|
|
|
|
static async saveAllPages(
|
|
applicationId: string,
|
|
pageLayouts: PageLayoutsRequest[],
|
|
) {
|
|
return Api.put(`v1/layouts/application/${applicationId}`, {
|
|
pageLayouts,
|
|
});
|
|
}
|
|
|
|
static async fetchPublishedPage(
|
|
pageRequest: FetchPublishedPageRequest,
|
|
): Promise<AxiosPromise<FetchPublishedPageResponse>> {
|
|
return Api.get(
|
|
PageApi.getPublishedPageURL(pageRequest.pageId, pageRequest.bustCache),
|
|
);
|
|
}
|
|
|
|
static async createPage(
|
|
request: CreatePageRequest,
|
|
): Promise<AxiosPromise<FetchPageResponse>> {
|
|
return Api.post(PageApi.url, request);
|
|
}
|
|
|
|
static async updatePage(
|
|
request: UpdatePageRequest,
|
|
): Promise<AxiosPromise<ApiResponse<UpdatePageResponse>>> {
|
|
const { pageId, ...rest } = request;
|
|
|
|
return Api.put(`${PageApi.url}/${pageId}`, rest);
|
|
}
|
|
|
|
static async generateTemplatePage(
|
|
request: GenerateTemplatePageRequest,
|
|
): Promise<AxiosPromise<ApiResponse>> {
|
|
const { pageId, ...rest } = request;
|
|
|
|
if (pageId) {
|
|
return Api.put(`${PageApi.url}/crud-page/${pageId}`, rest);
|
|
} else {
|
|
return Api.post(`${PageApi.url}/crud-page`, rest);
|
|
}
|
|
}
|
|
|
|
static async deletePage(
|
|
request: DeletePageRequest,
|
|
): Promise<AxiosPromise<ApiResponse>> {
|
|
return Api.delete(`${PageApi.url}/${request.pageId}`);
|
|
}
|
|
|
|
static async clonePage(
|
|
request: ClonePageRequest,
|
|
): Promise<AxiosPromise<FetchPageResponse>> {
|
|
return Api.post(`${PageApi.url}/clone/${request.pageId}`);
|
|
}
|
|
|
|
static async updateWidgetName(
|
|
request: UpdateWidgetNameRequest,
|
|
): Promise<AxiosPromise<UpdateWidgetNameResponse>> {
|
|
return Api.put("v1/layouts/refactor", request);
|
|
}
|
|
|
|
static async setPageOrder(
|
|
request: SetPageOrderRequest,
|
|
): Promise<AxiosPromise<FetchPageListResponse>> {
|
|
const { applicationId, order, pageId } = request;
|
|
|
|
return Api.put(
|
|
`v1/applications/${applicationId}/page/${pageId}/reorder?order=${order}`,
|
|
);
|
|
}
|
|
|
|
static async fetchAppAndPages(
|
|
params: FetchAppAndPagesRequest,
|
|
): Promise<AxiosPromise<FetchApplicationResponse>> {
|
|
return Api.get(PageApi.url, params);
|
|
}
|
|
}
|
|
|
|
export default PageApi;
|