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

fix: updated the propertpaneview file to hide the copy and delete ico… #35227

Open
wants to merge 2 commits into
base: release
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { getActions } from "./PropertyPaneView";

describe("getActions", () => {
const mockOnCopy = jest.fn();
const mockOnDelete = jest.fn();
beforeEach(() => {
jest.clearAllMocks();
});

it("should return an empty array when widget type is CONTAINER_WIDGET", () => {
const widgetProperties = { type: "CONTAINER_WIDGET" };
const actions = getActions(widgetProperties, mockOnCopy, mockOnDelete);
expect(actions).toEqual([]);
});

it("should returns actions array when widget type is not CONTAINER_WIDGET", () => {
const widgetProperties = { type: "LIST_WIDGET_V2" };
const actions = getActions(widgetProperties, mockOnCopy, mockOnDelete);
expect(actions).toHaveLength(2);
});
});
75 changes: 42 additions & 33 deletions app/client/src/pages/Editor/PropertyPane/PropertyPaneView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,43 @@ export const excludeList: WidgetType[] = [
"WDS_BUTTON_WIDGET",
"WDS_TABLE_WIDGET",
];
export function getActions(
widgetProperties: any,
onCopy: () => void,
onDelete: () => void
): Array<{
tooltipContent: any;
icon: ReactElement;
}> {
return widgetProperties?.type === "CONTAINER_WIDGET"
? []
: [
{
tooltipContent: "Copy widget",
icon: (
<Button
data-testid="t--copy-widget"
isIconButton
kind="tertiary"
onClick={onCopy}
startIcon="duplicate"
/>
),
},
{
tooltipContent: "Delete widget",
icon: (
<Button
data-testid="t--delete-widget"
isIconButton
kind="tertiary"
onClick={onDelete}
startIcon="delete-bin-line"
/>
),
},
];
}

function PropertyPaneView(
props: {
Expand Down Expand Up @@ -208,39 +245,11 @@ function PropertyPaneView(
/**
* actions shown on the right of title
*/
const actions = useMemo((): Array<{
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tooltipContent: any;
icon: ReactElement;
}> => {
return [
{
tooltipContent: "Copy widget",
icon: (
<Button
data-testid="t--copy-widget"
isIconButton
kind="tertiary"
onClick={onCopy}
startIcon="duplicate"
/>
),
},
{
tooltipContent: "Delete widget",
icon: (
<Button
data-testid="t--delete-widget"
isIconButton
kind="tertiary"
onClick={onDelete}
startIcon="delete-bin-line"
/>
),
},
];
}, [onCopy, onDelete]);
const actions = useMemo(
() => getActions(widgetProperties, onCopy, onDelete),
[onCopy, onDelete, widgetProperties]
);


useEffect(() => {
setSearchText("");
Expand Down