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

chore: Replace entities in entity explorer with new ADS templates #38750

Merged
merged 34 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
49971b1
replacing query list items with the new ADS entity item and entity gr…
ankitakinger Jan 17, 2025
580638b
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 17, 2025
40ba4f9
removing duplicate hook
ankitakinger Jan 17, 2025
4f1382e
updating variabkle
ankitakinger Jan 17, 2025
fce6aef
minor change
ankitakinger Jan 17, 2025
d7b7400
re-structuring folders
ankitakinger Jan 17, 2025
fcf3f36
fixing tests
ankitakinger Jan 17, 2025
3f86ad9
adding classname
ankitakinger Jan 17, 2025
7ad220c
creating hooks for context menu and create action permissions
ankitakinger Jan 20, 2025
625a466
clearing warnings
ankitakinger Jan 20, 2025
e2719d1
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 20, 2025
aa2cff6
updating import
ankitakinger Jan 20, 2025
007bbcb
updating import
ankitakinger Jan 20, 2025
d346aa9
restructuring components to reuse menu items
ankitakinger Jan 20, 2025
dad304b
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 20, 2025
5aa02b8
minor changes
ankitakinger Jan 20, 2025
2764f44
updating disabled state for menu items
ankitakinger Jan 20, 2025
3b79140
removing unused constants
ankitakinger Jan 20, 2025
1580e0f
resolving dependencies
ankitakinger Jan 20, 2025
c818f45
replaced JS entities with new ADS templates in entity explorer
ankitakinger Jan 21, 2025
aec5a5e
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 21, 2025
ae89757
removing hideIcon prop
ankitakinger Jan 21, 2025
67850c7
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 23, 2025
0115c6a
refactoring file and folder structure
ankitakinger Jan 23, 2025
afdd229
type changes
ankitakinger Jan 23, 2025
f0306d5
renaming variables
ankitakinger Jan 23, 2025
216dc51
fixing client build
ankitakinger Jan 23, 2025
4e74792
addressing coderabbitai comments
ankitakinger Jan 23, 2025
d321cf7
handling EE case for js entity deletion
ankitakinger Jan 23, 2025
21ae1aa
updating dependency array
ankitakinger Jan 23, 2025
cb36e5f
removing convert to module for js object
ankitakinger Jan 23, 2025
adb532c
redirecting to page when workflow query is moved to that page
ankitakinger Jan 23, 2025
9e4c0d1
addressing review comments
ankitakinger Jan 24, 2025
bf508e2
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger Jan 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback } from "react";
import { MenuItem } from "@appsmith/ads";
import { useDispatch } from "react-redux";
import { setRenameEntity } from "actions/ideActions";
import { CONTEXT_RENAME, createMessage } from "ee/constants/messages";

interface Props {
disabled?: boolean;
Expand All @@ -24,7 +25,7 @@ export const RenameMenuItem = ({ disabled, entityId }: Props) => {
onSelect={setRename}
startIcon="input-cursor-move"
>
Rename
{createMessage(CONTEXT_RENAME)}
</MenuItem>
);
};
26 changes: 3 additions & 23 deletions app/client/src/ce/pages/Editor/IDE/EditorPane/JS/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
import React from "react";
import ExplorerJSCollectionEntity from "pages/Editor/Explorer/JSActions/JSActionEntity";
import { Flex } from "@appsmith/ads";
import type { EntityItem } from "ee/entities/IDE/constants";
import { JSEntityItem } from "pages/Editor/IDE/EditorPane/JS/EntityItem/JSEntityItem";

export interface JSListItemProps {
item: EntityItem;
isActive: boolean;
parentEntityId: string;
}

export const JSListItem = (props: JSListItemProps) => {
const { isActive, item, parentEntityId } = props;

return (
<Flex data-testid="t--ide-list-item" flexDirection={"column"}>
<ExplorerJSCollectionEntity
baseCollectionId={item.key}
isActive={isActive}
key={item.key}
parentEntityId={parentEntityId}
searchKeyword={""}
step={1}
/>
</Flex>
);
export const JSEntity = (props: { item: EntityItem }) => {
return <JSEntityItem {...props} />;
};
27 changes: 27 additions & 0 deletions app/client/src/ce/pages/Editor/IDE/EditorPane/JS/old/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import ExplorerJSCollectionEntity from "pages/Editor/Explorer/JSActions/JSActionEntity";
import { Flex } from "@appsmith/ads";
import type { EntityItem } from "ee/entities/IDE/constants";

export interface JSListItemProps {
item: EntityItem;
isActive: boolean;
parentEntityId: string;
}

export const JSListItem = (props: JSListItemProps) => {
const { isActive, item, parentEntityId } = props;

return (
<Flex data-testid="t--ide-list-item" flexDirection={"column"}>
<ExplorerJSCollectionEntity
baseCollectionId={item.key}
isActive={isActive}
key={item.key}
parentEntityId={parentEntityId}
searchKeyword={""}
step={1}
/>
</Flex>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import EntityContextMenu from "pages/Editor/IDE/EditorPane/components/EntityContextMenu";
import { AppJSContextMenuItems } from "pages/Editor/IDE/EditorPane/JS/EntityItem/AppJSContextMenuItems";
import type { JSCollection } from "entities/JSCollection";

export const getJSContextMenuByIdeType = (
ideType: IDEType,
jsAction: JSCollection,
) => {
switch (ideType) {
case IDE_TYPE.App: {
return (
<EntityContextMenu
menuContent={<AppJSContextMenuItems jsAction={jsAction} />}
/>
);
}
}
};
ankitakinger marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 3 additions & 21 deletions app/client/src/ce/pages/Editor/IDE/EditorPane/Query/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import React from "react";
import ExplorerActionEntity from "pages/Editor/Explorer/Actions/ActionEntity";
import { QueryEntityItem } from "pages/Editor/IDE/EditorPane/Query/EntityItem/QueryEntityItem";
import type { EntityItem } from "ee/entities/IDE/constants";

export interface QueryListItemProps {
item: EntityItem;
isActive: boolean;
parentEntityId: string;
}

export const QueryListItem = (props: QueryListItemProps) => {
const { isActive, item, parentEntityId } = props;

return (
<ExplorerActionEntity
baseId={item.key}
isActive={isActive}
key={item.key}
parentEntityId={parentEntityId}
searchKeyword={""}
step={1}
type={item.type}
/>
);
export const ActionEntityItem = (props: { item: EntityItem }) => {
return <QueryEntityItem {...props} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import ExplorerActionEntity from "pages/Editor/Explorer/Actions/ActionEntity";
import type { EntityItem } from "ee/entities/IDE/constants";

export interface QueryListItemProps {
item: EntityItem;
isActive: boolean;
parentEntityId: string;
}

export const QueryListItem = (props: QueryListItemProps) => {
const { isActive, item, parentEntityId } = props;

return (
<ExplorerActionEntity
baseId={item.key}
isActive={isActive}
key={item.key}
parentEntityId={parentEntityId}
searchKeyword={""}
step={1}
type={item.type}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import type { Action } from "entities/Action";
import { AppQueryContextMenuItems } from "pages/Editor/IDE/EditorPane/Query/EntityItem/AppQueryContextMenuItems";
import EntityContextMenu from "pages/Editor/IDE/EditorPane/components/EntityContextMenu";

export const getQueryContextMenuByIdeType = (
ideType: IDEType,
action: Action,
) => {
switch (ideType) {
case IDE_TYPE.App: {
return (
<EntityContextMenu
menuContent={<AppQueryContextMenuItems action={action} />}
/>
);
}
}
};
ankitakinger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "ce/pages/Editor/IDE/EditorPane/JS/old/ListItem";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "ce/pages/Editor/IDE/EditorPane/JS/utils/getJSContextMenuByIdeType";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "ce/pages/Editor/IDE/EditorPane/Query/old/ListItem";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "ce/pages/Editor/IDE/EditorPane/Query/utils/getQueryContextMenuByIdeType";
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { usePluginActionContext } from "PluginActionEditor";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useSelector } from "react-redux";
Expand All @@ -11,21 +10,27 @@ import {
import { MODULE_TYPE } from "ee/constants/ModuleConstants";
import ConvertToModuleInstanceCTA from "ee/pages/Editor/EntityEditor/ConvertToModuleInstanceCTA";
import { PluginType } from "entities/Plugin";
import type { Action } from "entities/Action";

const ConvertToModuleCTA = () => {
const { action, plugin } = usePluginActionContext();
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
interface Props {
action: Action;
}

export const ConvertToModule = ({ action }: Props) => {
const pagePermissions = useSelector(getPagePermissions);
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);

const isCreatePermitted = getHasCreateActionPermission(
isFeatureEnabled,
pagePermissions,
);

const isDeletePermitted = getHasDeleteActionPermission(
isFeatureEnabled,
action.userPermissions,
);

if (plugin.type === PluginType.INTERNAL) {
if (action.pluginType === PluginType.INTERNAL) {
// Workflow queries cannot be converted to modules
return null;
}
Expand All @@ -39,5 +44,3 @@ const ConvertToModuleCTA = () => {

return <ConvertToModuleInstanceCTA {...convertToModuleProps} />;
};

export default ConvertToModuleCTA;
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React from "react";
import { MenuSub, MenuSubContent, MenuSubTrigger } from "@appsmith/ads";
import { useDispatch, useSelector } from "react-redux";
import { getPageList } from "ee/selectors/entitiesSelector";
import { usePluginActionContext } from "PluginActionEditor";
import React, { useCallback } from "react";
import { getPageList } from "selectors/editorSelectors";
import { PageMenuItem } from "./PageMenuItem";
import { useCallback } from "react";
import type { Action } from "entities/Action";
import { copyActionRequest } from "actions/pluginActionActions";
import { MenuSub, MenuSubContent, MenuSubTrigger } from "@appsmith/ads";
import { CONTEXT_COPY, createMessage } from "ee/constants/messages";
import { PageMenuItem } from "./PageMenuItem";

interface Props {
action: Action;
disabled?: boolean;
}

export const Copy = ({ disabled }: Props) => {
export const Copy = ({ action, disabled }: Props) => {
const menuPages = useSelector(getPageList);
const { action } = usePluginActionContext();
const dispatch = useDispatch();

const copyActionToPage = useCallback(
Expand All @@ -30,13 +31,14 @@ export const Copy = ({ disabled }: Props) => {

return (
<MenuSub>
<MenuSubTrigger disabled={disabled} startIcon="duplicate">
<MenuSubTrigger startIcon="duplicate">
{createMessage(CONTEXT_COPY)}
</MenuSubTrigger>
<MenuSubContent>
<MenuSubContent style={{ maxHeight: "350px" }} width="220px">
{menuPages.map((page) => {
return (
<PageMenuItem
disabled={disabled}
key={page.basePageId}
onSelect={copyActionToPage}
page={page}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { useHandleDeleteClick } from "PluginActionEditor/hooks";
import React, { useCallback, useState } from "react";
import {
CONFIRM_CONTEXT_DELETE,
CONTEXT_DELETE,
createMessage,
} from "ee/constants/messages";
import { MenuItem } from "@appsmith/ads";
import { useDispatch } from "react-redux";
import { deleteAction } from "actions/pluginActionActions";
import type { Action } from "entities/Action";

interface Props {
action: Action;
disabled?: boolean;
}

export const Delete = ({ disabled }: Props) => {
const { handleDeleteClick } = useHandleDeleteClick();
export const Delete = ({ action, disabled }: Props) => {
const dispatch = useDispatch();
const [confirmDelete, setConfirmDelete] = useState(false);

const handleDeleteClick = useCallback(
({ onSuccess }: { onSuccess?: () => void }) => {
dispatch(
deleteAction({
id: action?.id ?? "",
name: action?.name ?? "",
onSuccess,
}),
);
},
[action.id, action.name, dispatch],
);

const handleSelect = useCallback(
(e?: Event) => {
e?.preventDefault();
confirmDelete ? handleDeleteClick({}) : setConfirmDelete(true);
e?.stopPropagation();
},
[confirmDelete, handleDeleteClick],
);
Expand All @@ -29,7 +46,7 @@ export const Delete = ({ disabled }: Props) => {

return (
<MenuItem
className="t--apiFormDeleteBtn error-menuitem"
className="t--apiFormDeleteBtn single-select error-menuitem"
disabled={disabled}
onSelect={handleSelect}
startIcon="trash"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useDispatch, useSelector } from "react-redux";
import { usePluginActionContext } from "PluginActionEditor";
import { getCurrentPageId } from "selectors/editorSelectors";
import { getPageList } from "ee/selectors/entitiesSelector";
import React, { useCallback, useMemo } from "react";
Expand All @@ -12,14 +11,15 @@ import {
} from "@appsmith/ads";
import { CONTEXT_MOVE, createMessage } from "ee/constants/messages";
import { PageMenuItem } from "./PageMenuItem";
import type { Action } from "entities/Action";

interface Props {
action: Action;
disabled?: boolean;
}

export const Move = ({ disabled }: Props) => {
export const Move = ({ action, disabled }: Props) => {
const dispatch = useDispatch();
const { action } = usePluginActionContext();

const currentPageId = useSelector(getCurrentPageId);
const allPages = useSelector(getPageList);
Expand All @@ -42,14 +42,15 @@ export const Move = ({ disabled }: Props) => {

return (
<MenuSub>
<MenuSubTrigger disabled={disabled} startIcon="swap-horizontal">
<MenuSubTrigger startIcon="swap-horizontal">
{createMessage(CONTEXT_MOVE)}
</MenuSubTrigger>
<MenuSubContent>
<MenuSubContent style={{ maxHeight: "350px" }} width="220px">
{menuPages.length ? (
menuPages.map((page) => {
return (
<PageMenuItem
disabled={disabled}
key={page.basePageId}
onSelect={moveActionToPage}
page={page}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import { MenuItem } from "@appsmith/ads";
export const PageMenuItem = (props: {
page: Page;
onSelect: (id: string) => void;
disabled?: boolean;
}) => {
const handleOnSelect = useCallback(() => {
props.onSelect(props.page.pageId);
}, [props]);

return <MenuItem onSelect={handleOnSelect}>{props.page.pageName}</MenuItem>;
return (
<MenuItem disabled={props.disabled} onSelect={handleOnSelect}>
{props.page.pageName}
</MenuItem>
);
};
Loading
Loading