Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate type definitions into dedicated .types.ts files #38546

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/client/.devin/todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- [x] src/reducers/entityReducers/metaReducer/index.ts
- [x] src/reducers/entityReducers/appReducer.ts
- [x] src/reducers/entityReducers/canvasWidgetsStructureReducer.ts
- [x] src/reducers/entityReducers/pluginsReducer.ts
- [x] src/reducers/entityReducers/datasourceReducer.ts
- [x] src/reducers/entityReducers/canvasWidgetsReducer.ts
- [x] src/reducers/entityReducers/autoHeightReducers/canvasLevelsReducer.ts
- [x] src/reducers/entityReducers/autoHeightReducers/autoHeightLayoutTreeReducer.ts
- [x] src/reducers/entityReducers/metaWidgetsReducer.ts
- [x] src/reducers/entityReducers/pageListReducer.tsx
- [x] src/reducers/evaluationReducers/dependencyReducer.ts
- [x] src/reducers/evaluationReducers/loadingEntitiesReducer.ts
- [x] src/reducers/evaluationReducers/formEvaluationReducer.ts
- [x] src/reducers/evaluationReducers/triggerReducer.ts
- [x] src/reducers/evaluationReducers/treeReducer.ts
- [x] src/reducers/uiReducers/gitSyncReducer.ts
- [x] src/reducers/uiReducers/themeReducer.ts
- [x] src/reducers/uiReducers/activeFieldEditorReducer.ts
- [x] src/reducers/uiReducers/actionSelectorReducer.ts
- [x] src/reducers/uiReducers/focusHistoryReducer.ts
- [x] src/reducers/lintingReducers/lintErrorsReducers.ts
- [x] src/api/types.ts
- [x] src/api/PluginApi.ts
- [x] src/api/Api.ts
- [x] src/api/TemplatesApi.ts
- [x] src/api/PageApi.tsx
- [x] src/IDE/Components/Sidebar/SidebarButton/SidebarButton.tsx
- [x] src/IDE/Components/FileTab/FileTab.tsx
Empty file added app/client/circular_deps.json
Empty file.
13 changes: 1 addition & 12 deletions app/client/src/IDE/Components/FileTab/FileTab.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import React from "react";

import clsx from "classnames";

import { Icon } from "@appsmith/ads";
import { sanitizeString } from "utils/URLUtils";

import * as Styled from "./styles";
import { DATA_TEST_ID } from "./constants";

export interface FileTabProps {
isActive: boolean;
title: string;
onClick: () => void;
onClose: (e: React.MouseEvent) => void;
children: React.ReactNode;
onDoubleClick?: () => void;
}
import type { FileTabProps } from "./FileTab.types";

export const FileTab = ({
children,
Expand Down
10 changes: 10 additions & 0 deletions app/client/src/IDE/Components/FileTab/FileTab.types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { MouseEvent, ReactNode } from "react";

export interface FileTabProps {
isActive: boolean;
title: string;
onClick: () => void;
onClose: (e: MouseEvent) => void;
children: ReactNode;
onDoubleClick?: () => void;
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import React, { useCallback } from "react";
import { Flex, Icon, Text, Tooltip } from "@appsmith/ads";
import styled from "styled-components";

import { Condition } from "../../../enums";

const ConditionConfig: Record<Condition, { icon: string; color: string }> = {
[Condition.Warn]: {
icon: "warning",
color: "#ffe283",
},
// TODO add this information for further conditions
// Error: { color: "", icon: "" },
// Success: { color: "", icon: "" },
};

export interface SidebarButtonProps {
title?: string;
testId: string;
selected: boolean;
icon: string;
onClick: (urlSuffix: string) => void;
urlSuffix: string;
tooltip?: string;
condition?: Condition;
}
import { ConditionConfig, type SidebarButtonProps } from "./SidebarButton.types";

const Container = styled(Flex)`
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Condition } from "../../../enums";

export const ConditionConfig: Record<Condition, { icon: string; color: string }> = {
[Condition.Warn]: {
icon: "warning",
color: "#ffe283",
},
// TODO add this information for further conditions
// Error: { color: "", icon: "" },
// Success: { color: "", icon: "" },
};

export interface SidebarButtonProps {
title?: string;
testId: string;
selected: boolean;
icon: string;
onClick: (urlSuffix: string) => void;
urlSuffix: string;
tooltip?: string;
condition?: Condition;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Flex } from "@appsmith/ads";
import { useChangeActionCall } from "./hooks/useChangeActionCall";
import { usePluginActionContext } from "../../PluginActionContext";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "api/PluginApi.types";
import APIEditorForm from "./components/ApiEditor";
import GraphQLEditorForm from "./components/GraphQLEditor";
import UQIEditorForm from "./components/UQIEditor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from "ee/constants/messages";
import { Tag } from "@blueprintjs/core";
import styled from "styled-components";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "api/PluginApi.types";
import log from "loglevel";
import * as Sentry from "@sentry/react";
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer";
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer.types";
import {
checkIfSectionCanRender,
checkIfSectionIsEnabled,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { UIComponentTypes, type Plugin } from "api/PluginApi";
import { UIComponentTypes } from "api/PluginApi.types";
import type { Plugin } from "api/PluginApi.types";
import ApiDatasourceSelector from "./ApiDatasourceSelector";
import QueryDatasourceSelector from "./QueryDatasourceSelector";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { UIComponentTypes } from "api/PluginApi";
import { UIComponentTypes } from "api/PluginApi.types";
import { usePluginActionContext } from "../../PluginActionContext";
import ApiSettings from "./ApiSettings";
import QuerySettings from "./QuerySettings";
Expand Down
8 changes: 3 additions & 5 deletions app/client/src/actions/autoLayoutActions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import type { LayoutSystemTypes } from "layoutSystems/types";
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
import type {
CONVERSION_STATES,
SnapshotDetails,
} from "reducers/uiReducers/layoutConversionReducer";
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer.types";
import { CONVERSION_STATES } from "reducers/uiReducers/layoutConversionReducer.types";
import type { SnapshotDetails } from "reducers/uiReducers/layoutConversionReducer.types";

/**
* Calculate size and position changes owing to minSizes and flex wrap.
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/controlActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ReduxActionType,
} from "ee/constants/ReduxActionConstants";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import type { UpdateWidgetsPayload } from "reducers/entityReducers/canvasWidgetsReducer";
import type { UpdateWidgetsPayload } from "reducers/entityReducers/canvasWidgetsReducer.types";
import type { DynamicPath } from "utils/DynamicBindingUtils";

export const updateWidgetPropertyRequest = (
Expand Down
6 changes: 2 additions & 4 deletions app/client/src/actions/jsPaneActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import type {
SetFunctionPropertyPayload,
} from "ee/api/JSActionAPI";
import type { EventLocation } from "ee/utils/analyticsUtilTypes";
import type {
JSEditorTab,
JSPaneDebuggerState,
} from "reducers/uiReducers/jsPaneReducer";
import { JSEditorTab } from "reducers/uiReducers/jsPaneReducer.types";
import type { JSPaneDebuggerState } from "reducers/uiReducers/jsPaneReducer.types";
import type { JSUpdate } from "../utils/JSPaneUtils";

export const createNewJSCollection = (
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/metaWidgetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
DeleteMetaWidgetsPayload,
ModifyMetaWidgetPayload,
UpdateMetaWidgetPropertyPayload,
} from "reducers/entityReducers/metaWidgetsReducer";
} from "reducers/entityReducers/metaWidgetsReducer.types";

export const modifyMetaWidgets = (payload: ModifyMetaWidgetPayload) => ({
type: ReduxActionTypes.MODIFY_META_WIDGETS,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/pluginActionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
import { ActionExecutionContext } from "entities/Action";
import { batchAction } from "actions/batchActions";
import type { ExecuteErrorPayload } from "constants/AppsmithActionConstants/ActionConstants";
import type { ModalInfo } from "reducers/uiReducers/modalActionReducer";
import type { ModalInfo } from "reducers/uiReducers/modalActionReducer.types";
import type { ApiResponse } from "api/ApiResponses";
import type { JSCollection } from "entities/JSCollection";
import type { ErrorActionPayload } from "sagas/ErrorSagas";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/api/ActionAPI.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type React from "react";
import type { HttpMethod } from "api/Api";
import type { HttpMethod } from "api/Api.types";
import API from "api/Api";
import type { ApiResponse } from "./ApiResponses";
import { DEFAULT_EXECUTE_ACTION_TIMEOUT_MS } from "ee/constants/ApiConstants";
Expand Down
4 changes: 1 addition & 3 deletions app/client/src/api/Api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import type { AxiosInstance, AxiosRequestConfig } from "axios";
import type { AxiosInstance, AxiosRequestConfig } from "./Api.types";
import {
apiRequestInterceptor,
apiFailureResponseInterceptor,
Expand Down Expand Up @@ -139,6 +139,4 @@ class Api {
}
}

export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";

export default Api;
6 changes: 6 additions & 0 deletions app/client/src/api/Api.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { AxiosInstance, AxiosRequestConfig } from "axios";

export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";

// Re-export for backward compatibility
export type { AxiosInstance, AxiosRequestConfig };
Loading
Loading