From 4f2ef4913974c540bd259b52e5dc4f1d788c423a Mon Sep 17 00:00:00 2001 From: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:45:10 +0530 Subject: [PATCH 01/12] feat: New ui for overflow tabs --- .../Editor/IDE/EditorPane/Query/hooks.tsx | 3 +- .../IDE/EditorPane/EditorPaneSegments.tsx | 11 +- .../Editor/IDE/EditorTabs/FileTabs.test.tsx | 3 + .../pages/Editor/IDE/EditorTabs/FileTabs.tsx | 16 +- .../Editor/IDE/EditorTabs/FullScreenTabs.tsx | 67 -------- .../Editor/IDE/EditorTabs/SplitScreenTabs.tsx | 79 --------- .../src/pages/Editor/IDE/EditorTabs/index.tsx | 158 ++++++++++++++++++ .../src/pages/Editor/IDE/MainPane/index.tsx | 8 +- app/client/src/pages/Editor/IDE/hooks.ts | 2 +- 9 files changed, 182 insertions(+), 165 deletions(-) delete mode 100644 app/client/src/pages/Editor/IDE/EditorTabs/FullScreenTabs.tsx delete mode 100644 app/client/src/pages/Editor/IDE/EditorTabs/SplitScreenTabs.tsx create mode 100644 app/client/src/pages/Editor/IDE/EditorTabs/index.tsx diff --git a/app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx b/app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx index 90b37aee232..3eedf95b874 100644 --- a/app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx +++ b/app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx @@ -38,6 +38,7 @@ import { Tag, type ListItemProps } from "design-system"; import { useCurrentEditorState } from "pages/Editor/IDE/hooks"; import CurlImportEditor from "pages/Editor/APIEditor/CurlImportEditor"; import { createAddClassName } from "pages/Editor/IDE/EditorPane/utils"; +import { QueriesBlankState } from "pages/Editor/QueryEditor/QueriesBlankState"; export const useQueryAdd = () => { const location = useLocation(); @@ -161,7 +162,7 @@ export const useQuerySegmentRoutes = (path: string): UseRoutes => { }, { key: "QueryEmpty", - component: ListQuery, + component: QueriesBlankState, exact: true, path: [path], }, diff --git a/app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx b/app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx index c2daef1f832..34a89ee61f1 100644 --- a/app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx +++ b/app/client/src/pages/Editor/IDE/EditorPane/EditorPaneSegments.tsx @@ -6,7 +6,7 @@ import QueriesSegment from "./Query"; import WidgetsSegment from "./UI"; import JSSegment from "./JS"; import SegmentedHeader from "./components/SegmentedHeader"; -import EditorTabs from "../EditorTabs/SplitScreenTabs"; +import EditorTabs from "../EditorTabs"; import { jsSegmentRoutes, querySegmentRoutes, @@ -17,19 +17,24 @@ import { BUILDER_PATH, BUILDER_PATH_DEPRECATED, } from "@appsmith/constants/routes/appRoutes"; +import { useSelector } from "react-redux"; +import { getIDEViewMode } from "selectors/ideSelectors"; +import { EditorViewMode } from "@appsmith/entities/IDE/constants"; const EditorPaneSegments = () => { const { path } = useRouteMatch(); + const ideViewMode = useSelector(getIDEViewMode); return ( - + {ideViewMode === EditorViewMode.SplitScreen ? : null} { it("renders tabs correctly", () => { const { getByTestId, getByText } = render( { it("check tab click", () => { const { getByTestId } = render( { it("check for close click", () => { const { getByTestId } = render( void; onClose: (actionId?: string) => void; + currentTab: string; } const FILE_TABS_CONTAINER_ID = "file-tabs-container"; const FileTabs = (props: Props) => { - const { navigateToTab, onClose, tabs } = props; + const { currentTab, navigateToTab, onClose, tabs } = props; const { segment, segmentMode } = useCurrentEditorState(); - const location = useLocation(); - - const currentEntity = identifyEntityFromPath(location.pathname); - useEffect(() => { const activetab = document.querySelector(".editor-tab.active"); if (activetab) { @@ -70,10 +65,7 @@ const FileTabs = (props: Props) => { {tabs.map((tab: EntityItem) => ( navigateToTab(tab)} @@ -92,7 +84,7 @@ const FileTabs = (props: Props) => { {/* New Tab */} {segmentMode === EditorEntityTabState.Add ? ( diff --git a/app/client/src/pages/Editor/IDE/EditorTabs/FullScreenTabs.tsx b/app/client/src/pages/Editor/IDE/EditorTabs/FullScreenTabs.tsx deleted file mode 100644 index f9a3f14c5f0..00000000000 --- a/app/client/src/pages/Editor/IDE/EditorTabs/FullScreenTabs.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useCallback } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { Button, Tooltip } from "design-system"; -import { getIDEViewMode, getIsSideBySideEnabled } from "selectors/ideSelectors"; -import { - EditorEntityTab, - EditorViewMode, -} from "@appsmith/entities/IDE/constants"; -import { setIdeEditorViewMode } from "actions/ideActions"; -import FileTabs from "./FileTabs"; -import Container from "./Container"; -import { useCurrentEditorState, useIDETabClickHandlers } from "../hooks"; -import { TabSelectors } from "./constants"; -import { - MINIMIZE_BUTTON_TOOLTIP, - createMessage, -} from "@appsmith/constants/messages"; -import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil"; -import { AddButton } from "./AddButton"; - -const FullScreenTabs = () => { - const dispatch = useDispatch(); - const isSideBySideEnabled = useSelector(getIsSideBySideEnabled); - const ideViewMode = useSelector(getIDEViewMode); - const { segment } = useCurrentEditorState(); - const { closeClickHandler, tabClickHandler } = useIDETabClickHandlers(); - - const setSplitScreenMode = useCallback(() => { - dispatch(setIdeEditorViewMode(EditorViewMode.SplitScreen)); - AnalyticsUtil.logEvent("EDITOR_MODE_CHANGE", { - to: EditorViewMode.SplitScreen, - }); - }, []); - const tabsConfig = TabSelectors[segment]; - - const files = useSelector(tabsConfig.tabsSelector); - - if (!isSideBySideEnabled) return null; - if (ideViewMode === EditorViewMode.SplitScreen) return null; - if (segment === EditorEntityTab.UI) return null; - return ( - - - {files.length > 0 ? : null} - -