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: Moving action settings from editor form to toolbar (appsmithor…
…g#36894) ## Description Moving action settings from editor form to toolbar to follow the new designs under action redesign project. Fixes [appsmithorg#35512](appsmithorg#35512) [appsmithorg#34670](appsmithorg#34670) [appsmithorg#35535](appsmithorg#35535) ## 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/11384449381> > Commit: 027e2a3 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11384449381&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Thu, 17 Oct 2024 12:40:29 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced new components for managing API and query settings in the Plugin Action Settings. - Added functionality to open plugin action settings directly from the toolbar. - Implemented a settings popover interface for improved user interaction. - Added documentation links for QUERY_SETTINGS to enhance user guidance. - **Improvements** - Simplified rendering logic in the Plugin Action Form for better performance. - Updated form naming conventions for consistency across API and GraphQL editors. - Streamlined configuration settings by replacing `subtitle` with `tooltipText` for clarity. - Enhanced styling in Action Settings for better layout and user experience. - **Bug Fixes** - Corrected the navigation logic to open plugin action settings instead of debugger state. These enhancements aim to improve user experience and streamline plugin action management. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
460d7cc
commit 3960582
Showing
32 changed files
with
374 additions
and
166 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
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
10 changes: 10 additions & 0 deletions
10
src/PluginActionEditor/components/PluginActionSettings/ApiSettings.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,10 @@ | ||
import { API_EDITOR_FORM_NAME } from "ee/constants/forms"; | ||
import { reduxForm } from "redux-form"; | ||
import PluginActionSettingsPopover, { | ||
type SettingsProps, | ||
} from "./SettingsPopover"; | ||
|
||
export default reduxForm<unknown, SettingsProps>({ | ||
form: API_EDITOR_FORM_NAME, | ||
enableReinitialize: true, | ||
})(PluginActionSettingsPopover); |
10 changes: 10 additions & 0 deletions
10
src/PluginActionEditor/components/PluginActionSettings/QuerySettings.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,10 @@ | ||
import { QUERY_EDITOR_FORM_NAME } from "ee/constants/forms"; | ||
import { reduxForm } from "redux-form"; | ||
import PluginActionSettingsPopover, { | ||
type SettingsProps, | ||
} from "./SettingsPopover"; | ||
|
||
export default reduxForm<unknown, SettingsProps>({ | ||
form: QUERY_EDITOR_FORM_NAME, | ||
enableReinitialize: true, | ||
})(PluginActionSettingsPopover); |
142 changes: 142 additions & 0 deletions
142
src/PluginActionEditor/components/PluginActionSettings/SettingsPopover.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,142 @@ | ||
import React, { useCallback, useEffect, useState } from "react"; | ||
import { | ||
Link, | ||
Popover, | ||
PopoverBody, | ||
PopoverContent, | ||
PopoverHeader, | ||
PopoverTrigger, | ||
ToggleButton, | ||
} from "@appsmith/ads"; | ||
import ActionSettings from "pages/Editor/ActionSettings"; | ||
import { usePluginActionContext } from "../../PluginActionContext"; | ||
import styled, { css } from "styled-components"; | ||
import { | ||
API_EDITOR_TAB_TITLES, | ||
createMessage, | ||
LEARN_MORE, | ||
} from "ee/constants/messages"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { | ||
isPluginActionSettingsOpen, | ||
openPluginActionSettings, | ||
} from "../../store"; | ||
import { THEME } from "../../constants/PluginActionConstants"; | ||
import { type DocsLink, openDoc } from "constants/DocumentationLinks"; | ||
|
||
export interface SettingsProps { | ||
formName: string; | ||
docsLink?: DocsLink; | ||
} | ||
|
||
const Variables = css` | ||
--popover-width: 280px; | ||
`; | ||
|
||
/* TODO: Remove this after removing custom width from server side (Ankita) */ | ||
const SettingsWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--ads-v2-spaces-4); | ||
.t--form-control-INPUT_TEXT, | ||
.t--form-control-DROP_DOWN { | ||
> div { | ||
min-width: unset; | ||
width: 100%; | ||
} | ||
} | ||
`; | ||
|
||
const StyledPopoverHeader = styled(PopoverHeader)` | ||
margin-bottom: var(--ads-v2-spaces-5); | ||
`; | ||
|
||
const StyledPopoverContent = styled(PopoverContent)` | ||
${Variables}; | ||
`; | ||
|
||
const LearnMoreLink = styled(Link)` | ||
span { | ||
font-weight: bold; | ||
} | ||
`; | ||
|
||
const PluginActionSettingsPopover = (props: SettingsProps) => { | ||
const { settingsConfig } = usePluginActionContext(); | ||
const openSettings = useSelector(isPluginActionSettingsOpen); | ||
const [isOpen, setIsOpen] = useState(false); | ||
const dispatch = useDispatch(); | ||
|
||
useEffect(() => { | ||
if (openSettings) { | ||
handleOpenChange(true); | ||
} | ||
}, [openSettings]); | ||
|
||
const handleOpenChange = useCallback( | ||
(open: boolean) => { | ||
setIsOpen(open); | ||
|
||
if (openSettings && !open) { | ||
dispatch(openPluginActionSettings(false)); | ||
} | ||
}, | ||
[openSettings], | ||
); | ||
|
||
const handleEscapeKeyDown = () => { | ||
handleOpenChange(false); | ||
}; | ||
|
||
const handleButtonClick = () => { | ||
handleOpenChange(true); | ||
}; | ||
|
||
const handleLearnMoreClick = () => { | ||
openDoc(props.docsLink as DocsLink); | ||
}; | ||
|
||
return ( | ||
<Popover onOpenChange={handleOpenChange} open={isOpen}> | ||
<PopoverTrigger> | ||
<ToggleButton | ||
icon="settings-2-line" | ||
isSelected={isOpen} | ||
onClick={handleButtonClick} | ||
size="md" | ||
/> | ||
</PopoverTrigger> | ||
<StyledPopoverContent | ||
align="end" | ||
onEscapeKeyDown={handleEscapeKeyDown} | ||
size="sm" | ||
> | ||
<StyledPopoverHeader isClosable> | ||
{createMessage(API_EDITOR_TAB_TITLES.SETTINGS)} | ||
</StyledPopoverHeader> | ||
<PopoverBody> | ||
<SettingsWrapper> | ||
<ActionSettings | ||
actionSettingsConfig={settingsConfig} | ||
formName={props.formName} | ||
theme={THEME} | ||
/> | ||
{props.docsLink && ( | ||
<LearnMoreLink | ||
className="t--action-settings-documentation-link" | ||
endIcon="share-box-line" | ||
kind="secondary" | ||
onClick={handleLearnMoreClick} | ||
> | ||
{createMessage(LEARN_MORE)} | ||
</LearnMoreLink> | ||
)} | ||
</SettingsWrapper> | ||
</PopoverBody> | ||
</StyledPopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default PluginActionSettingsPopover; |
30 changes: 30 additions & 0 deletions
30
src/PluginActionEditor/components/PluginActionSettings/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,30 @@ | ||
import React from "react"; | ||
import { UIComponentTypes } from "api/PluginApi"; | ||
import { usePluginActionContext } from "../../PluginActionContext"; | ||
import ApiSettings from "./ApiSettings"; | ||
import QuerySettings from "./QuerySettings"; | ||
import { | ||
API_EDITOR_FORM_NAME, | ||
QUERY_EDITOR_FORM_NAME, | ||
} from "ee/constants/forms"; | ||
import { DocsLink } from "constants/DocumentationLinks"; | ||
|
||
const API_FORM_COMPONENTS = [ | ||
UIComponentTypes.ApiEditorForm, | ||
UIComponentTypes.GraphQLEditorForm, | ||
]; | ||
|
||
const PluginActionSettings = () => { | ||
const { plugin } = usePluginActionContext(); | ||
|
||
return API_FORM_COMPONENTS.includes(plugin.uiComponent) ? ( | ||
<ApiSettings formName={API_EDITOR_FORM_NAME} /> | ||
) : ( | ||
<QuerySettings | ||
docsLink={DocsLink.QUERY_SETTINGS} | ||
formName={QUERY_EDITOR_FORM_NAME} | ||
/> | ||
); | ||
}; | ||
|
||
export default PluginActionSettings; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig"; | ||
|
||
export const THEME = EditorTheme.LIGHT; |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig"; | ||
|
||
export const POST_BODY_FORM_DATA_KEY = "displayFormat"; | ||
export const THEME = EditorTheme.LIGHT; |
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
Oops, something went wrong.