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 15 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 @@ -8,8 +8,8 @@ import { datasourcesEditorIdURL } from "ee/RouteBuilder";
import { omit } from "lodash";
import { getQueryParams } from "utils/URLUtils";
import history from "utils/history";
import { useEditorType } from "ee/hooks";
import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks";
import { useParentEntityInfo } from "ee/IDE/hooks/useParentEntityInfo";
import { getIDETypeByUrl } from "ee/entities/IDE/utils";
import type { Plugin } from "entities/Plugin";

interface Props {
Expand All @@ -25,8 +25,8 @@ const DatasourceInfo = ({
plugin,
showEditButton,
}: Props) => {
const editorType = useEditorType(location.pathname);
const { parentEntityId } = useParentEntityInfo(editorType);
const ideType = getIDETypeByUrl(location.pathname);
const { parentEntityId } = useParentEntityInfo(ideType);

// eslint-disable-next-line react-perf/jsx-no-new-function-as-prop
const editDatasource = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import { isEmpty, omit } from "lodash";
import { getQueryParams } from "utils/URLUtils";
import { TableColumns } from "./TableColumns";
import { BOTTOMBAR_HEIGHT } from "./constants";
import { useEditorType } from "ee/hooks";
import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks";
import { useParentEntityInfo } from "ee/IDE/hooks/useParentEntityInfo";
import DatasourceInfo from "./DatasourceInfo";
import { getPlugin } from "ee/selectors/entitiesSelector";
import {
Expand All @@ -34,6 +33,7 @@ import {
} from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { getIDETypeByUrl } from "ee/entities/IDE/utils";

interface Props {
datasourceId: string;
Expand All @@ -58,8 +58,8 @@ const DatasourceTab = (props: Props) => {

const plugin = useSelector((state) => getPlugin(state, pluginId || ""));

const editorType = useEditorType(location.pathname);
const { parentEntityId } = useParentEntityInfo(editorType);
const ideType = getIDETypeByUrl(location.pathname);
const { parentEntityId } = useParentEntityInfo(ideType);

const [selectedTable, setSelectedTable] = useState<string>();

Expand Down
19 changes: 19 additions & 0 deletions app/client/src/ce/IDE/hooks/useParentEntityInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ActionParentEntityType } from "ee/entities/Engine/actionHelpers";
import type { IDEType } from "ee/entities/IDE/constants";
import { useSelector } from "react-redux";
import {
getCurrentApplicationId,
getCurrentBasePageId,
} from "selectors/editorSelectors";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const useParentEntityInfo = (ideType: IDEType) => {
ankitakinger marked this conversation as resolved.
Show resolved Hide resolved
const appId = useSelector(getCurrentApplicationId);
const basePageId = useSelector(getCurrentBasePageId);

return {
editorId: appId || "",
parentEntityId: basePageId || "",
parentEntityType: ActionParentEntityType.PAGE,
};
};
9 changes: 5 additions & 4 deletions app/client/src/ce/actions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
saveActionName,
} from "actions/pluginActionActions";
import { saveJSObjectName } from "actions/jsActionActions";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";

export const createNewQueryBasedOnParentEntity = (
entityId: string,
Expand Down Expand Up @@ -43,12 +44,12 @@ export const createNewJSCollectionBasedOnParentEntity = (
return createNewJSCollection(entityId, from);
};

export const saveActionNameBasedOnParentEntity = (
export const saveActionNameBasedOnIdeType = (
id: string,
name: string,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType: ActionParentEntityTypeInterface = ActionParentEntityType.PAGE,
ideType: IDEType = IDE_TYPE.App,
) => {
return saveActionName({ id, name });
};
Expand All @@ -63,9 +64,9 @@ export const saveJSObjectNameBasedOnParentEntity = (
return saveJSObjectName({ id, name });
};

export const createNewApiActionBasedOnEditorType = (
export const createNewApiActionBasedOnIdeType = (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
editorType: string,
ideType: IDEType,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
editorId: string,
parentEntityId: string,
Expand Down
18 changes: 18 additions & 0 deletions app/client/src/ce/entities/IDE/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,21 @@ export type UseRoutes = Array<{
path: string[];
exact: boolean;
}>;

export enum ActionEntityContextMenuItemsEnum {
RENAME = "Rename",
SHOW_BINDING = "Show Bindings",
CONVERT_QUERY_MODULE_INSTANCE = "Create Module",
COPY = "Copy",
MOVE = "Move",
DELETE = "Delete",
}

export const defaultActionMenuItems = [
ActionEntityContextMenuItemsEnum.RENAME,
ActionEntityContextMenuItemsEnum.DELETE,
ActionEntityContextMenuItemsEnum.SHOW_BINDING,
ActionEntityContextMenuItemsEnum.COPY,
ActionEntityContextMenuItemsEnum.MOVE,
ActionEntityContextMenuItemsEnum.CONVERT_QUERY_MODULE_INSTANCE,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { useSelector } from "react-redux";
import { getPagePermissions } from "selectors/editorSelectors";
import { getHasCreateActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";

export const useCreateActionsPermissions = (ideType: IDEType) => {
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const pagePermissions = useSelector(getPagePermissions);

switch (ideType) {
case IDE_TYPE.App: {
return getHasCreateActionPermission(isFeatureEnabled, pagePermissions);
}
default: {
return true;
}
}
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from "react";
import type { IDEType, EditorState } from "ee/entities/IDE/constants";
import { IDE_TYPE, IDEBasePaths } from "ee/entities/IDE/constants";
import {
defaultActionMenuItems,
IDE_TYPE,
IDEBasePaths,
} from "ee/entities/IDE/constants";
import { matchPath } from "react-router";
import { identifyEntityFromPath } from "navigation/FocusEntity";
import {
Expand All @@ -11,6 +16,9 @@ import { saveActionName } from "actions/pluginActionActions";
import { saveJSObjectName } from "actions/jsActionActions";
import { EditorEntityTab, type EntityItem } from "ee/entities/IDE/constants";
import { getHasManageActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers";
import type { Action } from "entities/Action";
import EntityContextMenu from "pages/Editor/IDE/EditorPane/Query/ListItem/EntityContextMenu";
import { AppQueryContextMenuItems } from "pages/Editor/IDE/EditorPane/Query/ListItem/AppQueryContextMenuItems";

export interface SaveEntityName {
params: {
Expand Down Expand Up @@ -73,3 +81,27 @@ export const getEditableTabPermissions = ({
entity?.userPermissions || [],
);
};

export const getMenuItemsForActionEntityByIdeType = (ideType: IDEType) => {
switch (ideType) {
case IDE_TYPE.App:
return defaultActionMenuItems;
default:
return defaultActionMenuItems;
}
};
ankitakinger marked this conversation as resolved.
Show resolved Hide resolved

export const getActionContextMenuByIdeType = (
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
25 changes: 4 additions & 21 deletions app/client/src/ce/hooks/datasourceEditorHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
GENERATE_NEW_PAGE_BUTTON_TEXT,
createMessage,
} from "ee/constants/messages";
import { ActionParentEntityType } from "ee/entities/Engine/actionHelpers";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import type { AppState } from "ee/reducers";
import { getPlugin } from "ee/selectors/entitiesSelector";
Expand All @@ -18,17 +17,13 @@ import NewActionButton from "pages/Editor/DataSourceEditor/NewActionButton";
import { useShowPageGenerationOnHeader } from "pages/Editor/DataSourceEditor/hooks";
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import {
getCurrentApplicationId,
getCurrentBasePageId,
getPagePermissions,
} from "selectors/editorSelectors";
import { getPagePermissions } from "selectors/editorSelectors";
import { getIsAnvilEnabledInCurrentApplication } from "layoutSystems/anvil/integrations/selectors";
import { isEnabledForPreviewData } from "utils/editorContextUtils";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { EditorNames } from "./";
import { getCurrentApplication } from "ee/selectors/applicationSelectors";
import { openGeneratePageModal } from "pages/Editor/GeneratePage/store/generatePageActions";
import { IDE_TYPE, type IDEType } from "ee/entities/IDE/constants";

export interface HeaderActionProps {
datasource: Datasource | ApiDatasourceForm | undefined;
Expand All @@ -38,7 +33,7 @@ export interface HeaderActionProps {
}

export const useHeaderActions = (
editorType: string,
ideType: IDEType,
{
datasource,
isPluginAuthorized,
Expand Down Expand Up @@ -77,7 +72,7 @@ export const useHeaderActions = (
? false
: !!isPluginAllowedToPreviewData;

if (editorType === EditorNames.APPLICATION) {
if (ideType === IDE_TYPE.App) {
const canCreateDatasourceActions = hasCreateDSActionPermissionInApp({
isEnabled: isFeatureEnabled,
dsPermissions: datasource?.userPermissions ?? [],
Expand Down Expand Up @@ -141,15 +136,3 @@ export const useHeaderActions = (

return {};
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const useParentEntityInfo = (editorType: string) => {
const appId = useSelector(getCurrentApplicationId);
const basePageId = useSelector(getCurrentBasePageId);

return {
editorId: appId || "",
parentEntityId: basePageId || "",
parentEntityType: ActionParentEntityType.PAGE,
};
};
25 changes: 0 additions & 25 deletions app/client/src/ce/hooks/hooks.test.ts

This file was deleted.

35 changes: 0 additions & 35 deletions app/client/src/ce/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
import {
BUILDER_BASE_PATH_DEPRECATED,
BUILDER_VIEWER_PATH_PREFIX,
} from "constants/routes";
import { useEffect, type RefObject } from "react";
import { matchPath } from "react-router";

export const EditorNames = {
APPLICATION: "app",
};

export interface EditorType {
[key: string]: string;
}

export const editorType: EditorType = {
[BUILDER_VIEWER_PATH_PREFIX]: EditorNames.APPLICATION,
[BUILDER_BASE_PATH_DEPRECATED]: EditorNames.APPLICATION,
};

// Utility function to get editor type based on path
// to be used in non react functions
export const getEditorType = (path: string) => {
const basePath = matchPath(path, {
path: [BUILDER_VIEWER_PATH_PREFIX, BUILDER_BASE_PATH_DEPRECATED],
});

return basePath
? editorType[basePath.path]
: editorType[BUILDER_VIEWER_PATH_PREFIX];
};

// custom hook to get editor type based on path
export const useEditorType = (path: string) => {
return getEditorType(path);
};

export function useOutsideClick<T extends HTMLElement>(
ref: RefObject<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ConvertToModuleInstanceCTAProps {
moduleType: MODULE_TYPE;
canDeleteEntity: boolean;
canCreateModuleInstance: boolean;
hideIcon?: boolean;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";
import { QueryEntityItem } from "pages/Editor/IDE/EditorPane/Query/ListItem/QueryEntityItem";
import type { EntityItem } from "ee/entities/IDE/constants";

export const ActionEntityItem = (props: { item: EntityItem }) => {
return <QueryEntityItem {...props} />;
};
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import React from "react";
import type { ActionParentEntityTypeInterface } from "ee/entities/Engine/actionHelpers";
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;
parentEntityType: ActionParentEntityTypeInterface;
}

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

return (
<ExplorerActionEntity
baseId={item.key}
isActive={isActive}
key={item.key}
parentEntityId={parentEntityId}
parentEntityType={parentEntityType}
searchKeyword={""}
step={1}
type={item.type}
Expand Down
Loading
Loading