Skip to content
Closed
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
7 changes: 7 additions & 0 deletions app/client/src/actions/ideActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ export const recordAnalyticsForSideBySideNavigation = () => ({
export const resetAnalyticsForSideBySideHover = () => ({
type: ReduxActionTypes.RESET_ANALYTICS_FOR_SIDE_BY_SIDE_HOVER,
});

export const setListViewActiveState = (payload: boolean) => {
return {
type: ReduxActionTypes.SET_IS_LIST_VIEW_ACTIVE,
payload,
};
};
1 change: 1 addition & 0 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ const IDEActionTypes = {
CLOSE_JS_ACTION_TAB_SUCCESS: "CLOSE_JS_ACTION_TAB_SUCCESS",
CLOSE_QUERY_ACTION_TAB: "CLOSE_QUERY_ACTION_TAB",
CLOSE_QUERY_ACTION_TAB_SUCCESS: "CLOSE_QUERY_ACTION_TAB_SUCCESS",
SET_IS_LIST_VIEW_ACTIVE: "SET_IS_LIST_VIEW_ACTIVE",
};

const IDEActionErrorTypes = {
Expand Down
16 changes: 15 additions & 1 deletion app/client/src/ce/pages/Editor/IDE/EditorPane/JS/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
import { useModuleOptions } from "ee/utils/moduleInstanceHelpers";
import { getJSUrl } from "ee/pages/Editor/IDE/EditorPane/JS/utils";
import { JSBlankState } from "pages/Editor/JSEditor/JSBlankState";
import { getIDEViewMode } from "selectors/ideSelectors";
import { EditorViewMode } from "ee/entities/IDE/constants";
import { setListViewActiveState } from "actions/ideActions";

export const useJSAdd = () => {
const pageId = useSelector(getCurrentPageId);
Expand All @@ -24,20 +27,31 @@ export const useJSAdd = () => {
const jsModuleCreationOptions = moduleCreationOptions.filter(
(opt) => opt.focusEntityType === FocusEntity.JS_MODULE_INSTANCE,
);
const ideViewMode = useSelector(getIDEViewMode);

const openAddJS = useCallback(() => {
if (jsModuleCreationOptions.length === 0) {
dispatch(createNewJSCollection(pageId, "ENTITY_EXPLORER"));
} else {
if (currentEntityInfo.entity === FocusEntity.JS_OBJECT_ADD) {
if (ideViewMode === EditorViewMode.SplitScreen) {
dispatch(setListViewActiveState(false));
}

return;
}

const url = getJSUrl(currentEntityInfo, true);

history.push(url);
}
}, [jsModuleCreationOptions, pageId, dispatch, currentEntityInfo]);
}, [
jsModuleCreationOptions,
pageId,
dispatch,
currentEntityInfo,
ideViewMode,
]);

const closeAddJS = useCallback(() => {
const url = getJSUrl(currentEntityInfo, false);
Expand Down
11 changes: 10 additions & 1 deletion app/client/src/ce/pages/Editor/IDE/EditorPane/Query/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,22 @@ import { getPluginEntityIcon } from "pages/Editor/Explorer/ExplorerIcons";
import type { ListItemProps } from "@appsmith/ads";
import { createAddClassName } from "pages/Editor/IDE/EditorPane/utils";
import { QueriesBlankState } from "pages/Editor/QueryEditor/QueriesBlankState";
import { getIDEViewMode } from "selectors/ideSelectors";
import { EditorViewMode } from "ee/entities/IDE/constants";
import { setListViewActiveState } from "actions/ideActions";

export const useQueryAdd = () => {
const location = useLocation();
const dispatch = useDispatch();
const currentEntityInfo = identifyEntityFromPath(location.pathname);
const ideViewMode = useSelector(getIDEViewMode);

const openAddQuery = useCallback(() => {
if (currentEntityInfo.entity === FocusEntity.QUERY_ADD) {
if (ideViewMode === EditorViewMode.SplitScreen) {
dispatch(setListViewActiveState(false));
}

return;
}

Expand All @@ -54,7 +63,7 @@ export const useQueryAdd = () => {

url = getQueryUrl(currentEntityInfo, false);
history.push(url);
}, [currentEntityInfo]);
}, [currentEntityInfo, ideViewMode]);

return { openAddQuery, closeAddQuery };
};
Expand Down
34 changes: 21 additions & 13 deletions app/client/src/pages/Editor/IDE/EditorTabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { useEffect, useState } from "react";
import { shallowEqual, useSelector } from "react-redux";
import React, { useEffect } from "react";
import { shallowEqual, useDispatch, useSelector } from "react-redux";
import { Flex, ScrollArea, ToggleButton } from "@appsmith/ads";
import { getIDEViewMode, getIsSideBySideEnabled } from "selectors/ideSelectors";
import {
getIDEViewMode,
getIsSideBySideEnabled,
getListViewActiveState,
} from "selectors/ideSelectors";
import type { EntityItem } from "ee/entities/IDE/constants";
import {
EditorEntityTab,
Expand All @@ -19,28 +23,30 @@ import { identifyEntityFromPath } from "navigation/FocusEntity";
import { List } from "./List";
import { ScreenModeToggle } from "./ScreenModeToggle";
import { AddTab } from "./AddTab";
import { setListViewActiveState } from "actions/ideActions";

const EditorTabs = () => {
const [showListView, setShowListView] = useState(false);
const isSideBySideEnabled = useSelector(getIsSideBySideEnabled);
const ideViewMode = useSelector(getIDEViewMode);
const { segment, segmentMode } = useCurrentEditorState();
const { closeClickHandler, tabClickHandler } = useIDETabClickHandlers();
const tabsConfig = TabSelectors[segment];
const files = useSelector(tabsConfig.tabsSelector, shallowEqual);
const isListViewActive = useSelector(getListViewActiveState);

const location = useLocation();
const dispatch = useDispatch();
const currentEntity = identifyEntityFromPath(location.pathname);

// Turn off list view while changing segment, files
useEffect(() => {
setShowListView(false);
dispatch(setListViewActiveState(false));
}, [currentEntity.id, currentEntity.entity, files, segmentMode]);

// Show list view if all tabs is closed
useEffect(() => {
if (files.length === 0 && segmentMode !== EditorEntityTabState.Add) {
setShowListView(true);
dispatch(setListViewActiveState(true));
}
}, [files, segmentMode, currentEntity.entity]);

Expand Down Expand Up @@ -75,16 +81,16 @@ const EditorTabs = () => {
const handleHamburgerClick = () => {
if (files.length === 0 && segmentMode !== EditorEntityTabState.Add) return;

setShowListView(!showListView);
dispatch(setListViewActiveState(!isListViewActive));
};

const onTabClick = (tab: EntityItem) => {
setShowListView(false);
dispatch(setListViewActiveState(false));
tabClickHandler(tab);
};

const newTabClickHandler = () => {
setShowListView(false);
dispatch(setListViewActiveState(false));
};

return (
Expand All @@ -94,7 +100,7 @@ const EditorTabs = () => {
<ToggleButton
data-testid="t--list-toggle"
icon="hamburger"
isSelected={showListView}
isSelected={isListViewActive}
onClick={handleHamburgerClick}
size="md"
/>
Expand All @@ -118,13 +124,13 @@ const EditorTabs = () => {
>
<FileTabs
currentEntity={currentEntity}
isListActive={showListView}
isListActive={isListViewActive}
navigateToTab={onTabClick}
onClose={closeClickHandler}
tabs={files}
/>
<AddTab
isListActive={showListView}
isListActive={isListViewActive}
newTabClickCallback={newTabClickHandler}
onClose={closeClickHandler}
/>
Expand All @@ -137,7 +143,9 @@ const EditorTabs = () => {
</Container>

{/* Overflow list */}
{showListView && ideViewMode === EditorViewMode.SplitScreen && <List />}
{isListViewActive && ideViewMode === EditorViewMode.SplitScreen && (
<List />
)}

{/* Announcement modal */}
{ideViewMode === EditorViewMode.SplitScreen && <Announcement />}
Expand Down
10 changes: 10 additions & 0 deletions app/client/src/reducers/uiReducers/ideReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const IDETabsDefaultValue = {
const initialState: IDEState = {
view: EditorViewMode.FullScreen,
tabs: {},
isListViewActive: false,
showCreateModal: false,
ideCanvasSideBySideHover: {
navigated: false,
Expand Down Expand Up @@ -101,10 +102,19 @@ const ideReducer = createImmerReducer(initialState, {
) => {
state.ideCanvasSideBySideHover.widgetTypes.push(action.payload);
},
[ReduxActionTypes.SET_IS_LIST_VIEW_ACTIVE]: (
state: IDEState,
action: {
payload: boolean;
},
) => {
state.isListViewActive = action.payload;
},
});

export interface IDEState {
view: EditorViewMode;
isListViewActive: boolean;
tabs: ParentEntityIDETabs;
showCreateModal: boolean;
ideCanvasSideBySideHover: IDECanvasSideBySideHover;
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/selectors/ideSelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ export const getShowCreateNewModal = (state: AppState) =>

export const getIdeCanvasSideBySideHoverState = (state: AppState) =>
state.ui.ide.ideCanvasSideBySideHover;

export const getListViewActiveState = (state: AppState) =>
state.ui.ide.isListViewActive;