Skip to content

Commit

Permalink
chore: Move entities/IDE/constants (#39064)
Browse files Browse the repository at this point in the history
## Description

Remove the IDE constants from the entities folder and move it to the
common IDE folder
Create separate buttons exports for sidebar buttons
Update the button usages 

Fixes #39050 

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13191919670>
> Commit: 5055b6e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13191919670&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Fri, 07 Feb 2025 05:19:56 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced new editor state definitions and enhanced sidebar
configurations with conditional messaging for data source availability.

- **Refactor**
- Reorganized internal module structures and consolidated type
definitions to improve maintainability, consistency, and type safety.

- **Tests**
  - Updated test references to align with the new module organization.

These changes streamline the codebase and lay the groundwork for future
improvements while maintaining the existing end-user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ankita Kinger <[email protected]>
  • Loading branch information
hetunandu and ankitakinger authored Feb 7, 2025
1 parent ddc3eae commit ac41ad2
Show file tree
Hide file tree
Showing 111 changed files with 291 additions and 280 deletions.
16 changes: 16 additions & 0 deletions app/client/src/IDE/Interfaces/EditorTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export enum EditorEntityTab {
QUERIES = "queries",
JS = "js",
UI = "ui",
}

export enum EditorEntityTabState {
List = "List",
Edit = "Edit",
Add = "Add",
}

export enum EditorViewMode {
FullScreen = "FullScreen",
SplitScreen = "SplitScreen",
}
8 changes: 8 additions & 0 deletions app/client/src/IDE/Interfaces/UseRoutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { ComponentType } from "react";

export type UseRoutes = Array<{
key: string;
component: ComponentType;
path: string[];
exact: boolean;
}>;
41 changes: 41 additions & 0 deletions app/client/src/IDE/constants/SidebarButtons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { IDESidebarButton } from "@appsmith/ads";
import { EditorState } from "../enums";

const SidebarButtonTitles = {
EDITOR: "Editor",
DATA: "Datasources",
SETTINGS: "Settings",
LIBRARIES: "Libraries",
};

export const EditorButton = (urlSuffix: string): IDESidebarButton => ({
state: EditorState.EDITOR,
icon: "editor-v3",
title: SidebarButtonTitles.EDITOR,
testId: SidebarButtonTitles.EDITOR,
urlSuffix,
});

export const DataButton = (urlSuffix: string): IDESidebarButton => ({
state: EditorState.DATA,
icon: "datasource-v3",
tooltip: SidebarButtonTitles.DATA,
testId: SidebarButtonTitles.DATA,
urlSuffix,
});

export const LibrariesButton = (urlSuffix: string): IDESidebarButton => ({
state: EditorState.LIBRARIES,
icon: "packages-v3",
tooltip: SidebarButtonTitles.LIBRARIES,
testId: SidebarButtonTitles.LIBRARIES,
urlSuffix,
});

export const SettingsButton = (urlSuffix: string): IDESidebarButton => ({
state: EditorState.SETTINGS,
icon: "settings-v3",
tooltip: SidebarButtonTitles.SETTINGS,
testId: SidebarButtonTitles.SETTINGS,
urlSuffix,
});
7 changes: 7 additions & 0 deletions app/client/src/IDE/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ export enum Condition {
// Error = "Error",
// Success = "Success",
}

export enum EditorState {
DATA = "DATA",
EDITOR = "EDITOR",
SETTINGS = "SETTINGS",
LIBRARIES = "LIBRARIES",
}
2 changes: 1 addition & 1 deletion app/client/src/IDE/hooks/useIsInSideBySideEditor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { renderHook, act } from "@testing-library/react-hooks/dom";
import { Provider } from "react-redux";
import { EditorViewMode } from "ee/entities/IDE/constants";
import { EditorViewMode } from "IDE/Interfaces/EditorTypes";
import { useIsInSideBySideEditor } from "./useIsInSideBySideEditor";
import { getIDETestState } from "test/factories/AppIDEFactoryUtils";
import type { AppState } from "ee/reducers";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/actions/ideActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EditorViewMode } from "ee/entities/IDE/constants";
import type { EditorViewMode } from "IDE/Interfaces/EditorTypes";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import type { ParentEntityIDETabs } from "../reducers/uiReducers/ideReducer";

Expand Down
13 changes: 13 additions & 0 deletions app/client/src/ce/IDE/Interfaces/EntityItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { PluginType } from "../../../entities/Plugin";
import type { ReactNode } from "react";

export interface EntityItem {
title: string;
type: PluginType;
key: string;
icon?: ReactNode;
group?: string;
userPermissions?: string[];
}

export interface GenericEntityItem extends Omit<EntityItem, "type"> {}
6 changes: 6 additions & 0 deletions app/client/src/ce/IDE/Interfaces/IDETypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const IDE_TYPE = {
None: "None",
App: "App",
} as const;

export type IDEType = keyof typeof IDE_TYPE;
44 changes: 44 additions & 0 deletions app/client/src/ce/IDE/constants/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
ADD_PATH,
API_EDITOR_ID_ADD_PATH,
API_EDITOR_ID_PATH,
BUILDER_CUSTOM_PATH,
BUILDER_PATH,
BUILDER_PATH_DEPRECATED,
DATA_SOURCES_EDITOR_ID_PATH,
ENTITY_PATH,
INTEGRATION_EDITOR_PATH,
JS_COLLECTION_ID_ADD_PATH,
JS_COLLECTION_ID_PATH,
QUERIES_EDITOR_ID_ADD_PATH,
QUERIES_EDITOR_ID_PATH,
WIDGETS_EDITOR_ID_PATH,
} from "ee/constants/routes/appRoutes";
import {
SAAS_EDITOR_API_ID_ADD_PATH,
SAAS_EDITOR_API_ID_PATH,
SAAS_EDITOR_DATASOURCE_ID_PATH,
} from "pages/Editor/SaaSEditor/constants";

import { IDE_TYPE, type IDEType } from "../Interfaces/IDETypes";

export const EntityPaths: string[] = [
API_EDITOR_ID_ADD_PATH,
API_EDITOR_ID_PATH,
QUERIES_EDITOR_ID_ADD_PATH,
QUERIES_EDITOR_ID_PATH,
DATA_SOURCES_EDITOR_ID_PATH,
INTEGRATION_EDITOR_PATH,
SAAS_EDITOR_DATASOURCE_ID_PATH,
SAAS_EDITOR_API_ID_ADD_PATH,
SAAS_EDITOR_API_ID_PATH,
JS_COLLECTION_ID_PATH,
JS_COLLECTION_ID_ADD_PATH,
WIDGETS_EDITOR_ID_PATH,
WIDGETS_EDITOR_ID_PATH + ADD_PATH,
ENTITY_PATH,
];
export const IDEBasePaths: Readonly<Record<IDEType, string[]>> = {
[IDE_TYPE.None]: [],
[IDE_TYPE.App]: [BUILDER_PATH, BUILDER_PATH_DEPRECATED, BUILDER_CUSTOM_PATH],
};
2 changes: 1 addition & 1 deletion app/client/src/ce/IDE/hooks/useParentEntityInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionParentEntityType } from "ee/entities/Engine/actionHelpers";
import type { IDEType } from "ee/entities/IDE/constants";
import type { IDEType } from "ee/IDE/Interfaces/IDETypes";
import { useSelector } from "react-redux";
import {
getCurrentApplicationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { usePluginActionContext } from "PluginActionEditor/PluginActionContext";
import type { BottomTab } from "components/editorComponents/EntityBottomTabs";
import { getIDEViewMode } from "selectors/ideSelectors";
import { useSelector } from "react-redux";
import { EditorViewMode, IDE_TYPE } from "ee/entities/IDE/constants";
import { EditorViewMode } from "IDE/Interfaces/EditorTypes";
import { IDE_TYPE } from "ee/IDE/Interfaces/IDETypes";
import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/constants";
import {
createMessage,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/actions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
saveActionName,
} from "actions/pluginActionActions";
import { saveJSObjectName } from "actions/jsActionActions";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";

export const createNewQueryBasedOnParentEntity = (
entityId: string,
Expand Down
141 changes: 0 additions & 141 deletions app/client/src/ce/entities/IDE/constants.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useSelector } from "react-redux";
import { getPagePermissions } from "selectors/editorSelectors";
Expand Down
8 changes: 5 additions & 3 deletions app/client/src/ce/entities/IDE/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { IDEType, EditorState } from "ee/entities/IDE/constants";
import { IDE_TYPE, IDEBasePaths } from "ee/entities/IDE/constants";
import type { EditorState } from "IDE/enums";
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";
import { IDEBasePaths } from "ee/IDE/constants/routes";
import { matchPath } from "react-router";
import { identifyEntityFromPath } from "navigation/FocusEntity";
import {
Expand All @@ -9,7 +10,8 @@ import {
} from "ee/constants/routes/appRoutes";
import { saveActionName } from "actions/pluginActionActions";
import { saveJSObjectName } from "actions/jsActionActions";
import { EditorEntityTab, type EntityItem } from "ee/entities/IDE/constants";
import { EditorEntityTab } from "IDE/Interfaces/EditorTypes";
import type { EntityItem } from "ee/IDE/Interfaces/EntityItem";
import { getHasManageActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";

export interface SaveEntityName {
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/hooks/datasourceEditorHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isEnabledForPreviewData } from "utils/editorContextUtils";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { getCurrentApplication } from "ee/selectors/applicationSelectors";
import { openGeneratePageModal } from "pages/Editor/GeneratePage/store/generatePageActions";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";

export interface HeaderActionProps {
datasource: Datasource | ApiDatasourceForm | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FocusStoreHierarchy,
identifyEntityFromPath,
} from "navigation/FocusEntity";
import { EditorState } from "ee/entities/IDE/constants";
import { EditorState } from "IDE/enums";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import {
datasourcesEditorURL,
Expand Down
3 changes: 1 addition & 2 deletions app/client/src/ce/navigation/FocusStrategy/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { IDEType } from "ee/entities/IDE/constants";
import { IDE_TYPE } from "ee/entities/IDE/constants";
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";
import { AppIDEFocusStrategy } from "./AppIDEFocusStrategy";
import { NoIDEFocusStrategy } from "./NoIDEFocusStrategy";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import type { EntityItem } from "ee/entities/IDE/constants";
import type { EntityItem } from "ee/IDE/Interfaces/EntityItem";
import { JSEntityItem } from "pages/Editor/IDE/EditorPane/JS/EntityItem/JSEntityItem";

export const JSEntity = (props: { item: EntityItem }) => {
Expand Down
Loading

0 comments on commit ac41ad2

Please sign in to comment.