forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [Plugin Action Editor] Convert to Module (appsmithorg#36305)
## Description CE PR for: https://github.com/appsmithorg/appsmith-ee/pull/5134 ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10845636973> > Commit: 1f40848 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10845636973&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Fri, 13 Sep 2024 08:48:25 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced flexibility for child components in the Plugin Action Editor, allowing single or multiple React nodes. - Introduced a new toolbar with a dropdown menu for additional actions. - Added components for converting actions into modules, including callouts and disablers for better user feedback. - **Bug Fixes** - Improved user experience by providing notifications during the action conversion process. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
9 changed files
with
135 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
app/client/src/ce/pages/Editor/AppPluginActionEditor/AppPluginActionEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/client/src/ce/pages/Editor/AppPluginActionEditor/components/AppPluginActionToolbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
import { PluginActionToolbar } from "PluginActionEditor"; | ||
import { ConvertToModuleCTA } from "./ConvertToModule"; | ||
|
||
const AppPluginActionToolbar = () => { | ||
return <PluginActionToolbar menuContent={<ConvertToModuleCTA />} />; | ||
}; | ||
|
||
export default AppPluginActionToolbar; |
35 changes: 35 additions & 0 deletions
35
...c/ce/pages/Editor/AppPluginActionEditor/components/ConvertToModule/ConvertToModuleCTA.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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"; | ||
import { getPagePermissions } from "selectors/editorSelectors"; | ||
import { | ||
getHasCreateActionPermission, | ||
getHasDeleteActionPermission, | ||
} from "ee/utils/BusinessFeatures/permissionPageHelpers"; | ||
import { MODULE_TYPE } from "ee/constants/ModuleConstants"; | ||
import ConvertToModuleInstanceCTA from "ee/pages/Editor/EntityEditor/ConvertToModuleInstanceCTA"; | ||
|
||
const ConvertToModuleCTA = () => { | ||
const { action } = usePluginActionContext(); | ||
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled); | ||
const pagePermissions = useSelector(getPagePermissions); | ||
const isCreatePermitted = getHasCreateActionPermission( | ||
isFeatureEnabled, | ||
pagePermissions, | ||
); | ||
const isDeletePermitted = getHasDeleteActionPermission( | ||
isFeatureEnabled, | ||
action.userPermissions, | ||
); | ||
const convertToModuleProps = { | ||
canCreateModuleInstance: isCreatePermitted, | ||
canDeleteEntity: isDeletePermitted, | ||
entityId: action.id, | ||
moduleType: MODULE_TYPE.QUERY, | ||
}; | ||
return <ConvertToModuleInstanceCTA {...convertToModuleProps} />; | ||
}; | ||
|
||
export default ConvertToModuleCTA; |
40 changes: 40 additions & 0 deletions
40
.../pages/Editor/AppPluginActionEditor/components/ConvertToModule/ConvertToModuleCallout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { Flex, Icon } from "@appsmith/ads"; | ||
import { useSelector } from "react-redux"; | ||
import { getIsActionConverting } from "ee/selectors/entitiesSelector"; | ||
import { usePluginActionContext } from "PluginActionEditor"; | ||
import { | ||
ENTITY_ICON_SIZE, | ||
EntityIcon, | ||
} from "pages/Editor/Explorer/ExplorerIcons"; | ||
import ConvertEntityNotification from "ee/pages/common/ConvertEntityNotification"; | ||
import { resolveIcon } from "pages/Editor/utils"; | ||
|
||
const ConvertToModuleCallout = () => { | ||
const { action, plugin } = usePluginActionContext(); | ||
const isConverting = useSelector((state) => | ||
getIsActionConverting(state, action.id), | ||
); | ||
|
||
const PluginIcon = resolveIcon({ | ||
iconLocation: plugin.iconLocation || "", | ||
pluginType: plugin.type, | ||
moduleType: action.actionConfiguration?.body?.moduleType, | ||
}) || ( | ||
<EntityIcon | ||
height={`${ENTITY_ICON_SIZE}px`} | ||
width={`${ENTITY_ICON_SIZE}px`} | ||
> | ||
<Icon name="module" /> | ||
</EntityIcon> | ||
); | ||
|
||
if (!isConverting) return null; | ||
return ( | ||
<Flex p="spaces-7" w="100%"> | ||
<ConvertEntityNotification icon={PluginIcon} name={action.name} /> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ConvertToModuleCallout; |
19 changes: 19 additions & 0 deletions
19
...pages/Editor/AppPluginActionEditor/components/ConvertToModule/ConvertToModuleDisabler.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from "react"; | ||
import Disabler from "pages/common/Disabler"; | ||
import { usePluginActionContext } from "PluginActionEditor"; | ||
import { useSelector } from "react-redux"; | ||
import { getIsActionConverting } from "ee/selectors/entitiesSelector"; | ||
|
||
interface Props { | ||
children: React.ReactNode | React.ReactNode[]; | ||
} | ||
|
||
const ConvertToModuleDisabler = (props: Props) => { | ||
const { action } = usePluginActionContext(); | ||
const isConverting = useSelector((state) => | ||
getIsActionConverting(state, action.id), | ||
); | ||
return <Disabler isDisabled={isConverting}>{props.children}</Disabler>; | ||
}; | ||
|
||
export default ConvertToModuleDisabler; |
3 changes: 3 additions & 0 deletions
3
app/client/src/ce/pages/Editor/AppPluginActionEditor/components/ConvertToModule/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as ConvertToModuleCTA } from "./ConvertToModuleCTA"; | ||
export { default as ConvertToModuleDisabler } from "./ConvertToModuleDisabler"; | ||
export { default as ConvertToModuleCallout } from "./ConvertToModuleCallout"; |