Skip to content

Commit

Permalink
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
Browse files Browse the repository at this point in the history
…o create-module-btn-ui-fix
  • Loading branch information
albinAppsmith committed May 6, 2024
2 parents c28f169 + 022d457 commit ad38d66
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/client/src/pages/Editor/Explorer/Entity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
createMessage,
EXPLORER_BETA_ENTITY,
} from "@appsmith/constants/messages";
import classNames from "classnames";

export enum EntityClassNames {
CONTEXT_MENU = "entity-context-menu",
Expand Down Expand Up @@ -361,9 +362,12 @@ export const Entity = forwardRef(
<EntityItem
active={!!props.active}
alwaysShowRightIcon={props.alwaysShowRightIcon}
className={`${props.highlight ? "highlighted" : ""} ${
props.active ? "active" : ""
} t--entity-item`}
className={classNames({
highlighted: props.highlight,
active: props.active,
editable: canEditEntityName,
"t--entity-item": true,
})}
data-guided-tour-id={`explorer-entity-${props.name}`}
data-guided-tour-iid={props.name}
data-testid={`t--entity-item-${props.name}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export const ExplorerJSCollectionEntity = memo(
<Entity
action={navigateToJSCollection}
active={props.isActive}
canEditEntityName={canManageJSAction}
canEditEntityName={
canManageJSAction && !Boolean(jsAction?.isMainJSCollection)
}
className="t--jsaction"
contextMenu={contextMenu}
entityId={jsAction.id}
Expand Down
51 changes: 51 additions & 0 deletions app/client/src/pages/Editor/IDE/EditorPane/JS/JSRender.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,56 @@ describe("IDE Render: JS", () => {
// Close button is rendered
getByRole("button", { name: "Close pane" });
});

it("Prevents edit of main JS object", () => {
const page = PageFactory.build();
const Main_JS = JSObjectFactory.build({
id: "js_id",
name: "Main",
pageId: page.pageId,
});
Main_JS.isMainJSCollection = true;

const Normal_JS = JSObjectFactory.build({
id: "js_id2",
name: "Normal",
pageId: page.pageId,
});

const state = getIDETestState({
pages: [page],
js: [Main_JS, Normal_JS],
tabs: {
[EditorEntityTab.QUERIES]: [],
[EditorEntityTab.JS]: ["js_id"],
},
});

const { getByTestId } = render(
<Route path={BUILDER_PATH}>
<IDE />
</Route>,
{
url: "/app/applicationSlug/pageSlug-page_id/edit/jsObjects/js_id",
initialState: state,
featureFlags: FeatureFlags,
},
);

// Normal JS object should be editable
const normalJsObjectEntity = getByTestId("t--entity-item-Normal");
expect(normalJsObjectEntity.classList.contains("editable")).toBe(true);

// should have `t--context-menu` as a child of the normalJsObjectEntity
expect(
normalJsObjectEntity.querySelector(".t--context-menu"),
).not.toBeNull();

// Main JS object should not be editable
const mainJsObjectEntity = getByTestId("t--entity-item-Main");
expect(mainJsObjectEntity.classList.contains("editable")).toBe(false);
// should not have `t--context-menu` as a child of the mainJsObjectEntity
expect(mainJsObjectEntity.querySelector(".t--context-menu")).toBeNull();
});
});
});

0 comments on commit ad38d66

Please sign in to comment.