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: ADS Entity List Tree #38493

Merged
merged 62 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
ce99143
chore: Setup for Entity Item
hetunandu Jan 1, 2025
c28f6a2
chore: Editable State and stories
hetunandu Jan 1, 2025
962253f
chore: Fix list item changes
hetunandu Jan 2, 2025
019dccf
chore: Create new Editable submodule for shared usage
hetunandu Jan 2, 2025
f72e009
chore: Reuse ads editable in tabs
hetunandu Jan 2, 2025
98a50b4
Update tests
hetunandu Jan 2, 2025
b83ae34
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 2, 2025
8ba6531
Merge branch 'feat/ads/entity-item' of https://github.com/appsmithorg…
ankitakinger Jan 2, 2025
87ac4d8
fix: No permission to edit
hetunandu Jan 2, 2025
fd6c715
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 2, 2025
c03b0e1
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 2, 2025
cb6b0ad
updating spacings in list item component
ankitakinger Jan 2, 2025
2c3b12f
Merge branch 'feat/ads/entity-item' of https://github.com/appsmithorg…
ankitakinger Jan 2, 2025
e0c258a
minor change
ankitakinger Jan 2, 2025
9a9db48
css updates
ankitakinger Jan 2, 2025
c38364f
chore: First Draft
hetunandu Jan 3, 2025
58d5329
Merge branch 'feat/ads/entity-item' into feat/ads/entity-tree
hetunandu Jan 3, 2025
09a902e
chore: Fixed padding and styles
hetunandu Jan 3, 2025
0ac9545
chore: Add loading state
hetunandu Jan 3, 2025
4afc917
fix: missing dependency
hetunandu Jan 3, 2025
3679b9f
fix: Test case changes
hetunandu Jan 4, 2025
0bb665e
Merge branch 'release' into feat/ads/entity-item
hetunandu Jan 4, 2025
0978b1c
Merge branch 'release' into feat/ads/entity-item
hetunandu Jan 6, 2025
fa29de4
Merge branch 'feat/ads/entity-item' into feat/ads/entity-tree
hetunandu Jan 6, 2025
699c018
chore: ListItem hook and event improvements
hetunandu Jan 6, 2025
cfd157a
chore: Entity Tree improvements
hetunandu Jan 6, 2025
353e7c4
chore: Entity Tree story improvements
hetunandu Jan 6, 2025
a23a3c9
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 6, 2025
74fe83e
chore: Update types and event handling
hetunandu Jan 6, 2025
d53a243
chore: Use feature flag to show new Entity Item tree
hetunandu Jan 6, 2025
fe2ab7b
chore: Update flag name
hetunandu Jan 6, 2025
ecd2ae3
fix: Update flag name
hetunandu Jan 6, 2025
7fab390
fix: jest test event mocking
hetunandu Jan 7, 2025
001e7a6
fix: Padding with depth is 0
hetunandu Jan 7, 2025
2b41c8a
chore: Rename and correct style application
hetunandu Jan 7, 2025
e161648
fix: Typo
hetunandu Jan 7, 2025
5f34be1
chore: Add more identifiers
hetunandu Jan 7, 2025
74ac8e0
chore: Move Widget Tree inside IDE / UI
hetunandu Jan 8, 2025
3b64e70
chore: Move Widget Tree inside IDE / UI
hetunandu Jan 8, 2025
40a1ae1
Merge remote-tracking branch 'origin/feat/ads/entity-tree' into feat/…
hetunandu Jan 8, 2025
3f68ddf
chore: Housekeeping of List Item and Entity Item
hetunandu Jan 8, 2025
5e37259
Merge branch 'chore/ads-listitem-updates' into feat/ads/entity-tree
hetunandu Jan 8, 2025
027fac7
chore: Some refactors
hetunandu Jan 8, 2025
c5e5b7b
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 8, 2025
064ad76
refactor: Separate UIEntityListTree component logic into hooks and ut…
devin-ai-integration[bot] Jan 8, 2025
e835fc1
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 8, 2025
a25c03e
Revert "refactor: Separate UIEntityListTree component logic into hook…
hetunandu Jan 9, 2025
38705a5
fix: Improve separations
hetunandu Jan 9, 2025
ccaf13e
fix: Null checks
hetunandu Jan 10, 2025
b744321
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 10, 2025
9a8d80f
fix: implement design feedback
hetunandu Jan 10, 2025
034271e
revert type
hetunandu Jan 10, 2025
d566221
fix: Update paths to reduce cycles
hetunandu Jan 10, 2025
b971035
chore: Coderabbit suggestions
hetunandu Jan 10, 2025
5115bb4
add tests
hetunandu Jan 10, 2025
6bafb5e
fix: parent not expanded when children selected
hetunandu Jan 10, 2025
4f80a9a
chore: Padding left design update
hetunandu Jan 10, 2025
560ff97
chore: Test fix
hetunandu Jan 10, 2025
3bc67d9
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 10, 2025
0662ff6
Merge branch 'release' into feat/ads/entity-tree
hetunandu Jan 13, 2025
818289e
Update OldWidgetEntityList.tsx
hetunandu Jan 13, 2025
31e9ae6
Update EntityListTree.styles.ts
hetunandu Jan 13, 2025
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
Prev Previous commit
Next Next commit
fix: Improve separations
  • Loading branch information
hetunandu committed Jan 9, 2025
commit 38705a51dc17d3d3bb5b8238ed4b02c8ae727b39
1 change: 1 addition & 0 deletions app/client/src/IDE/Components/EditableName/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { EditableName } from "./EditableName";
export { RenameMenuItem } from "./RenameMenuItem";
export { useIsRenaming } from "./useIsRenaming";
export { useValidateEntityName } from "./useValidateEntityName";
1 change: 1 addition & 0 deletions app/client/src/IDE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export {
EditableName,
RenameMenuItem,
useIsRenaming,
useValidateEntityName,
} from "./Components/EditableName";

/* ====================================================
Expand Down
3 changes: 0 additions & 3 deletions app/client/src/ce/selectors/entitiesSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,6 @@ export const getExistingActionNames = createSelector(
},
);

export const getEditingEntityName = (state: AppState) =>
state.ui.explorer.entity.editingEntityName;

export const getExistingJSCollectionNames = createSelector(
getJSCollections,
(jsActions) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,27 @@
import React, { useCallback, useState } from "react";
import { EntityListTree, type EntityListTreeItem } from "@appsmith/ads";
import React, { useCallback } from "react";
import { EntityListTree } from "@appsmith/ads";
import { useDispatch, useSelector } from "react-redux";
import {
getEditingEntityName,
selectWidgetsForCurrentPage,
} from "ee/selectors/entitiesSelector";
import type { CanvasStructure } from "reducers/uiReducers/pageCanvasStructureReducer";
import { selectWidgetsForCurrentPage } from "ee/selectors/entitiesSelector";
import { getSelectedWidgets } from "selectors/ui";
import { getEntityExplorerWidgetsToExpand } from "selectors/widgetSelectors";
import { getPagePermissions } from "selectors/editorSelectors";
import { getUpdatingEntity } from "selectors/explorerSelector";
import { getHasManagePagePermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useValidateEntityName } from "IDE";
import { updateWidgetName } from "actions/propertyPaneActions";
import { initExplorerEntityNameEdit } from "actions/explorerActions";
import { useValidateEntityName } from "IDE/Components/EditableName/useValidateEntityName";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import { WidgetContextMenu } from "./WidgetContextMenu";
import { useSwitchToWidget } from "./hooks/useSwitchToWidget";
import { WidgetTypeIcon } from "./WidgetTypeIcon";

const enhanceItemsTree = (
items: CanvasStructure[],
enhancer: (item: CanvasStructure) => EntityListTreeItem,
) => {
return items.map((child): EntityListTreeItem => {
return {
...enhancer(child),
children: child.children
? enhanceItemsTree(child.children, enhancer)
: undefined,
};
});
};
import { useWidgetTreeState } from "./hooks/useWidgetTreeExpandedState";
import { enhanceItemsTree } from "./utils/enhanceTree";
import { useNameEditorState } from "../../hooks/useNameEditorState";

export const UIEntityListTree = () => {
const widgets = useSelector(selectWidgetsForCurrentPage);
const selectedWidgets = useSelector(getSelectedWidgets);
const widgetsToExpand = useSelector(getEntityExplorerWidgetsToExpand);
const [expandedWidgets, setExpandedWidgets] =
useState<string[]>(widgetsToExpand);

const switchToWidget = useSwitchToWidget();

const handleOnClick = useCallback(
(e, widget) => switchToWidget(e, widget),
[switchToWidget],
);

const updatingEntity = useSelector(getUpdatingEntity);
const editingEntity = useSelector(getEditingEntityName);

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const pagePermissions = useSelector(getPagePermissions);
const canManagePages = getHasManagePagePermission(
Expand All @@ -67,28 +37,20 @@ export const UIEntityListTree = () => {
[dispatch],
);

const enterEditMode = useCallback(
(id: string) => {
dispatch(initExplorerEntityNameEdit(id));
},
[dispatch],
);

const exitEditMode = useCallback(() => {
dispatch({
type: ReduxActionTypes.END_EXPLORER_ENTITY_NAME_EDIT,
});
}, [dispatch]);
const { editingEntity, enterEditMode, exitEditMode, updatingEntity } =
useNameEditorState();

const validateName = useValidateEntityName({});

const { expandedWidgets, handleExpand } = useWidgetTreeState();

const items = enhanceItemsTree(widgets?.children || [], (widget) => ({
id: widget.widgetId,
title: widget.widgetName,
startIcon: WidgetTypeIcon(widget.type),
isSelected: selectedWidgets.includes(widget.widgetId),
isExpanded: expandedWidgets.includes(widget.widgetId),
onClick: (e) => handleOnClick(e, widget),
onClick: (e) => switchToWidget(e, widget),
onDoubleClick: () => enterEditMode(widget.widgetId),
rightControl: (
<WidgetContextMenu
Expand All @@ -107,18 +69,5 @@ export const UIEntityListTree = () => {
},
}));

const handleWidgetExpand = useCallback(
(id: string) => {
if (expandedWidgets.includes(id)) {
setExpandedWidgets(
[...expandedWidgets].filter((widgetId) => widgetId !== id),
);
} else {
setExpandedWidgets([...expandedWidgets, id]);
}
},
[expandedWidgets],
);

return <EntityListTree items={items} onItemExpand={handleWidgetExpand} />;
return <EntityListTree items={items} onItemExpand={handleExpand} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useCallback, useState } from "react";
import { useSelector } from "react-redux";
import { getEntityExplorerWidgetsToExpand } from "selectors/widgetSelectors";

export const useWidgetTreeState = () => {
const widgetsToExpand = useSelector(getEntityExplorerWidgetsToExpand);
const [expandedWidgets, setExpandedWidgets] =
useState<string[]>(widgetsToExpand);

const handleExpand = useCallback((id: string) => {
setExpandedWidgets((prev) =>
prev.includes(id)
? prev.filter((widgetId) => widgetId !== id)
: [...prev, id],
);
}, []);
hetunandu marked this conversation as resolved.
Show resolved Hide resolved

return {
expandedWidgets,
handleExpand,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { CanvasStructure } from "reducers/uiReducers/pageCanvasStructureReducer";
import type { EntityListTreeItem } from "@appsmith/ads";

export const enhanceItemsTree = (
items: CanvasStructure[],
enhancer: (item: CanvasStructure) => EntityListTreeItem,
) => {
return items.map((child): EntityListTreeItem => {
return {
...enhancer(child),
children: child.children
? enhanceItemsTree(child.children, enhancer)
: undefined,
};
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import { initExplorerEntityNameEdit } from "actions/explorerActions";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import {
getUpdatingEntity,
getEditingEntityName,
} from "selectors/explorerSelector";

export function useNameEditorState() {
const dispatch = useDispatch();

const editingEntity = useSelector(getEditingEntityName);

const updatingEntity = useSelector(getUpdatingEntity);

const enterEditMode = useCallback(
(id: string) => {
dispatch(initExplorerEntityNameEdit(id));
},
[dispatch],
);

const exitEditMode = useCallback(() => {
dispatch({
type: ReduxActionTypes.END_EXPLORER_ENTITY_NAME_EDIT,
});
}, [dispatch]);

return {
enterEditMode,
exitEditMode,
editingEntity,
updatingEntity,
};
}
2 changes: 2 additions & 0 deletions app/client/src/selectors/explorerSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export const getExplorerActive = (state: AppState) => {
export const getUpdatingEntity = (state: AppState) => {
return state.ui.explorer.entity.updatingEntity;
};
export const getEditingEntityName = (state: AppState) =>
state.ui.explorer.entity.editingEntityName;
Loading