fix: Remove collapsed widget tags (#34979)
This commit is contained in:
parent
d39eb588b9
commit
7b5ad60069
|
|
@ -86,12 +86,7 @@ describe(
|
|||
);
|
||||
};
|
||||
|
||||
before(() => {
|
||||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.INPUT_V2);
|
||||
PageLeftPane.switchToAddNew();
|
||||
});
|
||||
|
||||
it("1. All widget tags should be visible but only Suggested tag is open.", () => {
|
||||
it("1. All widget tags should be visible and open by default.", () => {
|
||||
agHelper.AssertElementLength(
|
||||
entityExplorer._widgetTagsList,
|
||||
Object.keys(WIDGET_TAGS).length,
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
|
|||
import { groupWidgetCardsByTags } from "../utils";
|
||||
import UIEntityTagGroup from "./UIEntityTagGroup";
|
||||
import { useUIExplorerItems } from "./hooks";
|
||||
import { useSelector } from "react-redux";
|
||||
import { widgetsExistCurrentPage } from "@appsmith/selectors/entitiesSelector";
|
||||
import { getIsAnvilLayout } from "layoutSystems/anvil/integrations/selectors";
|
||||
|
||||
function UIEntitySidebar({
|
||||
focusSearchInput,
|
||||
|
|
@ -39,8 +36,6 @@ function UIEntitySidebar({
|
|||
const isDragDropBuildingBlocksEnabled = useFeatureFlag(
|
||||
FEATURE_FLAG.release_drag_drop_building_blocks_enabled,
|
||||
);
|
||||
const isAnvil = useSelector(getIsAnvilLayout);
|
||||
const hasWidgets = useSelector(widgetsExistCurrentPage);
|
||||
const hideSuggestedWidgets = useMemo(
|
||||
() =>
|
||||
(isSearching && !areSearchResultsEmpty) ||
|
||||
|
|
@ -151,26 +146,9 @@ function UIEntitySidebar({
|
|||
return null;
|
||||
}
|
||||
|
||||
// Do not expand all the widget tags when the user does not have any
|
||||
// widgets yet.
|
||||
// Only show Suggested or Building Blocks
|
||||
// This behavior should not be used if Anvil layout is active
|
||||
let isInitiallyOpen = false;
|
||||
if (
|
||||
isAnvil ||
|
||||
hasWidgets ||
|
||||
[
|
||||
WIDGET_TAGS.SUGGESTED_WIDGETS as string,
|
||||
WIDGET_TAGS.BUILDING_BLOCKS as string,
|
||||
].includes(tag)
|
||||
) {
|
||||
isInitiallyOpen = true;
|
||||
}
|
||||
|
||||
return (
|
||||
<UIEntityTagGroup
|
||||
cards={cardsForThisTag}
|
||||
isInitiallyOpen={isInitiallyOpen}
|
||||
isLoading={!!entityLoading[tag as WidgetTags]}
|
||||
key={tag}
|
||||
tag={tag}
|
||||
|
|
|
|||
|
|
@ -34,14 +34,12 @@ const LoadingContainer = styled.div`
|
|||
`;
|
||||
|
||||
interface Props {
|
||||
isInitiallyOpen: boolean;
|
||||
tag: string;
|
||||
cards: WidgetCardProps[];
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
const UIEntityTagGroup = (props: Props) => {
|
||||
const [isOpen, setIsOpen] = React.useState(props.isInitiallyOpen);
|
||||
const [showFullItems, setShowFullItems] = React.useState(false);
|
||||
const toggleShowFullItems = () => {
|
||||
setShowFullItems(!showFullItems);
|
||||
|
|
@ -82,9 +80,8 @@ const UIEntityTagGroup = (props: Props) => {
|
|||
className={`pb-2 widget-tag-collapsible widget-tag-collapsible-${props.tag
|
||||
.toLowerCase()
|
||||
.replace(/ /g, "-")}`}
|
||||
isOpen={isOpen}
|
||||
isOpen
|
||||
key={props.tag}
|
||||
onOpenChange={setIsOpen}
|
||||
>
|
||||
<CollapsibleHeader arrowPosition="start">
|
||||
<Text
|
||||
|
|
@ -98,7 +95,6 @@ const UIEntityTagGroup = (props: Props) => {
|
|||
<CollapsibleContent>
|
||||
<div
|
||||
className="grid items-stretch grid-cols-3 gap-x-1 gap-y-1 justify-items-stretch"
|
||||
data-collapsed={!isOpen}
|
||||
data-testid="ui-entity-tag-group"
|
||||
>
|
||||
{props.tag === WIDGET_TAGS.SUGGESTED_WIDGETS
|
||||
|
|
|
|||
|
|
@ -127,21 +127,4 @@ describe("UIEntitySidebar", () => {
|
|||
const { queryByText } = renderUIEntitySidebar(true, true);
|
||||
expect(queryByText(WIDGET_TAGS.SUGGESTED_WIDGETS)).toBeNull();
|
||||
});
|
||||
|
||||
it("6. should have `Building Blocks` section open when no widgets exist", () => {
|
||||
mockUIExplorerItems();
|
||||
const { getAllByTestId, getByText } = renderUIEntitySidebar(true, true);
|
||||
expect(getByText(WIDGET_TAGS.BUILDING_BLOCKS)).not.toBeNull();
|
||||
const groups = getAllByTestId("ui-entity-tag-group");
|
||||
for (const group of groups) {
|
||||
if (
|
||||
group.getElementsByClassName("t--widget-card-draggable-buildingblock")
|
||||
.length
|
||||
) {
|
||||
expect(group.getAttribute("data-collapsed")).toBe("false");
|
||||
} else {
|
||||
expect(group.getAttribute("data-collapsed")).toBe("true");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user