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

feat: New tab ui changes #33228

Merged
merged 33 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf1f488
feat: New tab ui changes
albinAppsmith May 7, 2024
d84c5d0
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 9, 2024
79f4185
fix: new query tab ui
albinAppsmith May 9, 2024
12534de
Removed duplicate type definition
albinAppsmith May 9, 2024
bee5670
fix: jest tests
albinAppsmith May 9, 2024
272561a
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 9, 2024
b2fa38b
fix: Add button and maximize button fixes
albinAppsmith May 10, 2024
ef30093
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 10, 2024
ab1e270
fix: cypress failures
albinAppsmith May 10, 2024
ae5654e
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 10, 2024
97feeb5
fix: add button logic change
albinAppsmith May 10, 2024
1012f63
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 10, 2024
e086e0f
fix: add click logic revert
albinAppsmith May 10, 2024
6d63f0d
fix: add and close button behaviour fix
albinAppsmith May 12, 2024
2da706b
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 12, 2024
cd2212b
fix: add and expand button shrink issue
albinAppsmith May 12, 2024
2e3629d
fix: new query tab scroll fix
albinAppsmith May 12, 2024
5ac67bc
fix: jest tests
albinAppsmith May 13, 2024
dd72f03
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 13, 2024
8d0a0ee
fix: cypress failures
albinAppsmith May 13, 2024
c0f210a
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 13, 2024
974b375
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 13, 2024
9540f0c
fix: cypress selector
albinAppsmith May 13, 2024
af6df38
fix: click create option function
albinAppsmith May 13, 2024
36faf74
fix: removed unnecessary function to get
albinAppsmith May 13, 2024
5c0b56d
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 13, 2024
bff3ef1
fix: code refactor
albinAppsmith May 14, 2024
54dda9b
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 14, 2024
6debce9
fix: dependency array for query add
albinAppsmith May 14, 2024
6dff7ef
fix: close issue
albinAppsmith May 14, 2024
6eb7205
fix: cypress refactor
albinAppsmith May 14, 2024
ea658d0
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith May 14, 2024
48223f4
fix: cypress failures
albinAppsmith May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EditorNavigation, {
} from "../../../../support/Pages/EditorNavigation";
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
import FileTabs from "../../../../support/Pages/IDE/FileTabs";
import AddView from "../../../../support/Pages/IDE/AddView";

const agHelper = ObjectsRegistry.AggregateHelper;
const commonLocators = ObjectsRegistry.CommonLocators;
Expand Down Expand Up @@ -66,8 +67,8 @@ describe("IDE add pane interactions", { tags: ["@tag.IDE"] }, () => {
PageLeftPane.switchToAddNew();
// check add pane
PageLeftPane.assertInAddView();
// close add pane
PageLeftPane.closeAddView();
// close add tab
FileTabs.closeTab("new");
// open add pane to add item
PageLeftPane.switchToAddNew();
// add item
Expand Down
14 changes: 14 additions & 0 deletions app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1806,4 +1806,18 @@ export class AggregateHelper {
// }
// return items;
// }, { timeout: 5000 });

public GetChildrenNClick(
selector: string,
childSelector: string,
index = 0,
force = false,
waitTimeInterval = 500,
ctrlKey = false,
) {
return this.ScrollIntoView(selector, index)
.children(childSelector)
.click({ force: force, ctrlKey: ctrlKey })
.wait(waitTimeInterval);
}
}
4 changes: 2 additions & 2 deletions app/client/cypress/support/Pages/EntityExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EditorNavigation, {
PageLeftPane,
PagePaneSegment,
} from "./EditorNavigation";
import AddView from "./IDE/AddView";
import PageList from "./PageList";

type templateActions =
Expand Down Expand Up @@ -247,8 +248,7 @@ export class EntityExplorer {
this.agHelper.ClickOutside(); //to close the evaluated pop-up
PageLeftPane.switchSegment(PagePaneSegment.Queries);
PageLeftPane.switchToAddNew();
let overlayItem = this._visibleTextSpan(dsName);
this.agHelper.GetNClick(overlayItem);
AddView.clickCreateOption(dsName);
}

public CopyPasteWidget(widgetName: string) {
Expand Down
12 changes: 7 additions & 5 deletions app/client/cypress/support/Pages/IDE/AddView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { ObjectsRegistry } from "../../Objects/Registry";

class AddView {
public locators = {
addPane: "[data-testid='t--ide-add-pane']",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The search results indicate that the data-testid='t--ide-add-pane' is used in multiple TypeScript files within the project. This suggests that the data-testid is not unique, which could potentially lead to issues in the test scripts where this identifier is expected to be unique for specific elements.

Files where data-testid='t--ide-add-pane' is found:

  • app/client/src/pages/Editor/IDE/EditorPane/UI/Add.tsx
  • app/client/src/pages/Editor/IDE/EditorPane/Query/Add.tsx
  • app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx

Given this information, it is clear that the data-testid is not uniquely implemented across the project, which contradicts the requirement for uniqueness to avoid test failures.

Analysis chain

Added a new locator for the add pane. Ensure that the data-testid is unique and correctly implemented in the corresponding HTML element to avoid test failures.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the uniqueness and correct implementation of the `data-testid` for the add pane.

# Test: Search for the `data-testid` in the project. Expect: Only one occurrence in the expected HTML element.
rg --type html $'data-testid="t--ide-add-pane"'

Length of output: 48



Script:

#!/bin/bash
# Description: Search for the `data-testid` 't--ide-add-pane' in JavaScript and TypeScript files to verify its implementation and uniqueness.

# Search in JavaScript and TypeScript files
rg --type js --type ts 'data-testid="t--ide-add-pane"'

Length of output: 331

closePaneButton: "[data-testid='t--add-pane-close-icon']",
createOption: "[data-testid='t--create-option']",
createOption: (name: string) =>
".t--datasoucre-create-option-" + name.toLowerCase().replace(/ /g, "_"),
};

constructor() {
Expand All @@ -12,17 +14,17 @@ class AddView {

public assertInAddView() {
ObjectsRegistry.AggregateHelper.AssertElementVisibility(
this.locators.closePaneButton,
this.locators.addPane,
);
}

public closeAddView() {
ObjectsRegistry.AggregateHelper.GetNClick(this.locators.closePaneButton);
}

public getCreateOptions(): Cypress.Chainable {
return cy.get(this.locators.createOption);
public clickCreateOption(name: string) {
ObjectsRegistry.AggregateHelper.GetNClick(this.locators.createOption(name));
}
}

export default AddView;
export default new AddView();
14 changes: 13 additions & 1 deletion app/client/cypress/support/Pages/IDE/FileTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class FileTabs {
container: "[data-testid='t--editor-tabs']",
tabName: (name: string) => `[data-testid='t--ide-tab-${name}']`,
tabs: ".editor-tab",
addItem: "[data-testid='t--ide-split-screen-add-button']",
addItem: "[data-testid='t--ide-tabs-add-button']",
closeTab: "[data-testid='t--tab-close-btn']",
};

assertVisibility() {
Expand Down Expand Up @@ -32,6 +33,17 @@ class FileTabs {
}
});
}

closeTab(name: string) {
const tab = this.locators.tabName(name);
ObjectsRegistry.AggregateHelper.HoverElement(tab);
ObjectsRegistry.AggregateHelper.GetChildrenNClick(
tab,
this.locators.closeTab,
0,
true,
);
}
}

export default new FileTabs();
13 changes: 6 additions & 7 deletions app/client/cypress/support/Pages/IDE/LeftPane.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ObjectsRegistry } from "../../Objects/Registry";
import { PagePaneSegment } from "../EditorNavigation";
import AddView from "./AddView";
import FileTabs from "./FileTabs";
import ListView from "./ListView";

export class LeftPane {
Expand All @@ -15,8 +17,6 @@ export class LeftPane {
activeItemSelector: "",
selector: "",
};

private addView: AddView;
private listView: ListView;

constructor(
Expand All @@ -29,7 +29,6 @@ export class LeftPane {
this.segments = segments;
this.locators.selector = selector;
this.locators.activeItemSelector = activeItemSelector;
this.addView = new AddView();
this.listView = new ListView();
}

Expand Down Expand Up @@ -109,15 +108,15 @@ export class LeftPane {
}

public assertInAddView() {
this.addView.assertInAddView();
AddView.assertInAddView();
}

public closeAddView() {
this.addView.closeAddView();
AddView.closeAddView();
}

public getCreateOptions() {
return this.addView.getCreateOptions();
public clickCreateOption(name: string) {
return AddView.clickCreateOption(name);
}

public assertInListView() {
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2326,9 +2326,9 @@ export const EDITOR_PANE_TEXTS = {
js_add_button: () => "New JS object",
js_blank_object_item: () => "Blank JS object",
widget_add_button: () => "New UI element",
query_create_tab_title: () => "Create new query / API",
query_create_tab_title: () => "Create new query from",
widgets_create_tab_title: () => "Drag & drop UI elements",
js_create_tab_title: () => "Create JS object",
js_create_tab_title: () => "Create JS object from",
queries_create_from_existing: () => "From existing datasource",
queries_create_new: () => "New API",
loading_building_blocks: () => "Loading building blocks",
Expand Down
47 changes: 16 additions & 31 deletions app/client/src/ce/pages/Editor/IDE/EditorPane/JS/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ import { createMessage, EDITOR_PANE_TEXTS } from "@appsmith/constants/messages";
import { JsFileIconV2 } from "pages/Editor/Explorer/ExplorerIcons";
import { SEARCH_ITEM_TYPES } from "components/editorComponents/GlobalSearch/utils";
import type { UseRoutes } from "@appsmith/entities/IDE/constants";
import {
EditorEntityTabState,
EditorViewMode,
} from "@appsmith/entities/IDE/constants";
import { EditorViewMode } from "@appsmith/entities/IDE/constants";
import { getIDEViewMode, getIsSideBySideEnabled } from "selectors/ideSelectors";
import JSEditor from "pages/Editor/JSEditor";
import AddJS from "pages/Editor/IDE/EditorPane/JS/Add";
import { ADD_PATH } from "@appsmith/constants/routes/appRoutes";
import ListJS from "pages/Editor/IDE/EditorPane/JS/List";
import { useCurrentEditorState } from "pages/Editor/IDE/hooks";
import history from "utils/history";
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
import { useModuleOptions } from "@appsmith/utils/moduleInstanceHelpers";
Expand All @@ -26,34 +22,29 @@ export const useJSAdd = () => {
const pageId = useSelector(getCurrentPageId);
const dispatch = useDispatch();
const currentEntityInfo = identifyEntityFromPath(location.pathname);
const { segmentMode } = useCurrentEditorState();
const moduleCreationOptions = useModuleOptions();
const jsModuleCreationOptions = moduleCreationOptions.filter(
(opt) => opt.focusEntityType === FocusEntity.JS_MODULE_INSTANCE,
);

return useCallback(() => {
const openAddJS = useCallback(() => {
if (jsModuleCreationOptions.length === 0) {
if (segmentMode === EditorEntityTabState.Add) {
const url = getJSUrl(currentEntityInfo, false);
history.push(url);
} else {
dispatch(createNewJSCollection(pageId, "ENTITY_EXPLORER"));
}
dispatch(createNewJSCollection(pageId, "ENTITY_EXPLORER"));
} else {
const url = getJSUrl(
currentEntityInfo,
!(segmentMode === EditorEntityTabState.Add),
);
if (currentEntityInfo.entity === FocusEntity.JS_OBJECT_ADD) {
return;
}
const url = getJSUrl(currentEntityInfo, true);
history.push(url);
}
}, [
dispatch,
pageId,
segmentMode,
currentEntityInfo,
jsModuleCreationOptions,
]);
}, [jsModuleCreationOptions, pageId, dispatch, currentEntityInfo]);

const closeAddJS = useCallback(() => {
const url = getJSUrl(currentEntityInfo, false);
history.push(url);
}, [pageId, currentEntityInfo]);

return { openAddJS, closeAddJS };
};

export const useIsJSAddLoading = () => {
Expand Down Expand Up @@ -111,17 +102,11 @@ export const useJSSegmentRoutes = (path: string): UseRoutes => {
];
}
return [
{
exact: true,
key: "AddJS",
component: AddJS,
path: [`${path}${ADD_PATH}`, `${path}/:collectionId${ADD_PATH}`],
},
{
exact: false,
key: "ListJS",
component: ListJS,
path: [path],
path: [path, `${path}${ADD_PATH}`, `${path}/:collectionId${ADD_PATH}`],
},
];
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useMemo } from "react";
import React, { useCallback, useMemo } from "react";
import history from "utils/history";
import { useLocation } from "react-router";
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
Expand Down Expand Up @@ -27,37 +27,39 @@ import {
import { SAAS_EDITOR_API_ID_PATH } from "pages/Editor/SaaSEditor/constants";
import ApiEditor from "pages/Editor/APIEditor";
import type { UseRoutes } from "@appsmith/entities/IDE/constants";
import {
EditorEntityTabState,
EditorViewMode,
} from "@appsmith/entities/IDE/constants";
import { EditorViewMode } from "@appsmith/entities/IDE/constants";
import QueryEditor from "pages/Editor/QueryEditor";
import AddQuery from "pages/Editor/IDE/EditorPane/Query/Add";
import ListQuery from "pages/Editor/IDE/EditorPane/Query/List";
import type { AppState } from "@appsmith/reducers";
import keyBy from "lodash/keyBy";
import { getPluginEntityIcon } from "pages/Editor/Explorer/ExplorerIcons";
import type { ListItemProps } from "design-system";
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";

export const useQueryAdd = () => {
const location = useLocation();
const currentEntityInfo = identifyEntityFromPath(location.pathname);
const { segmentMode } = useCurrentEditorState();

const addButtonClickHandler = useCallback(() => {
let url = "";
if (segmentMode === EditorEntityTabState.Add) {
// Already in add mode, back to the previous active item
url = getQueryUrl(currentEntityInfo, false);
} else {
url = getQueryUrl(currentEntityInfo);
const openAddQuery = useCallback(() => {
if (currentEntityInfo.entity === FocusEntity.QUERY_ADD) {
return;
}
let url = "";
url = getQueryUrl(currentEntityInfo);
history.push(url);
}, [currentEntityInfo, segmentMode, location]);

const closeAddQuery = useCallback(() => {
let url = "";
url = getQueryUrl(currentEntityInfo, false);
history.push(url);
}, [currentEntityInfo, segmentMode]);
}, [currentEntityInfo, segmentMode, location]);

return addButtonClickHandler;
return { openAddQuery, closeAddQuery };
};

export type GroupedAddOperations = Array<{
Expand Down Expand Up @@ -166,17 +168,11 @@ export const useQuerySegmentRoutes = (path: string): UseRoutes => {
];
}
return [
{
key: "AddQuery",
exact: true,
component: AddQuery,
path: [`${path}${ADD_PATH}`, `${path}/:queryId${ADD_PATH}`],
},
{
key: "ListQuery",
exact: false,
component: ListQuery,
path: [path],
path: [path, `${path}${ADD_PATH}`, `${path}/:queryId${ADD_PATH}`],
},
];
};
Expand All @@ -202,17 +198,24 @@ export const useAddQueryListItems = () => {

const getListItems = (data: any[]) => {
return data.map((fileOperation) => {
const title =
fileOperation.entityExplorerTitle ||
fileOperation.dsName ||
fileOperation.title;
const className = createAddClassName(title);
const icon =
fileOperation.icon ||
(fileOperation.pluginId &&
getPluginEntityIcon(pluginGroups[fileOperation.pluginId]));
return {
startIcon: icon,
title:
fileOperation.entityExplorerTitle ||
fileOperation.dsName ||
fileOperation.title,
description: !!fileOperation.isBeta ? "Beta" : "",
wrapperClassName: className,
title,
description: !!fileOperation.isBeta ? (
<Tag isClosable={false}>Beta</Tag>
) : (
""
),
descriptionType: "inline",
onClick: onCreateItemClick.bind(null, fileOperation),
} as ListItemProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("JS Segment", () => {
expect(result.current).toBeDefined();

act(() => {
result.current();
result.current.openAddJS();
});

expect(mockDispatchFn).toBeCalledWith({
Expand All @@ -66,7 +66,7 @@ describe("JS Segment", () => {

// Call the function now from a different page
act(() => {
result.current();
result.current.openAddJS();
});

// Now the creation action should have the new page id
Expand Down