PromucFlow_constructor/app/client/src/IDE/Components/ToolbarSettingsPopover.tsx

65 lines
1.7 KiB
TypeScript
Raw Normal View History

feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
import React, { useCallback } from "react";
import {
Popover,
PopoverBody,
PopoverContent,
PopoverHeader,
PopoverTrigger,
ToggleButton,
} from "@appsmith/ads";
import styled from "styled-components";
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
interface Props {
isOpen: boolean;
handleOpenChange: (isOpen: boolean) => void;
title: string;
children: React.ReactNode;
dataTestId?: string;
disabled?: boolean;
popoverWidth?: string;
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
}
const StyledPopoverHeader = styled(PopoverHeader)`
margin-bottom: var(--ads-v2-spaces-5);
`;
const StyledPopoverContent = styled(PopoverContent)<{ popoverWidth?: string }>`
--popover-width: ${({ popoverWidth }) =>
popoverWidth ? popoverWidth : "280px"};
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
`;
export const ToolbarSettingsPopover = (props: Props) => {
const { handleOpenChange, isOpen, popoverWidth, title } = props;
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
const handleButtonClick = useCallback(() => {
handleOpenChange(true);
}, [handleOpenChange]);
const handleEscapeKeyDown = useCallback(() => {
handleOpenChange(false);
}, [handleOpenChange]);
return (
<Popover onOpenChange={handleOpenChange} open={isOpen}>
<PopoverTrigger>
<ToggleButton
chore: Updating the copy in the action settings pane (#37260) ## Description Updating the copy in the action settings pane Fixes [#37258](https://github.com/appsmithorg/appsmith/issues/37258) ## Automation /ok-to-test tags="@tag.All" ### :mag: 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/11704084082> > Commit: 723332f1a22047bbda149e5d77f9e4ddb0b84d3e > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11704084082&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 06 Nov 2024 15:09:44 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 ## Release Notes - **New Features** - Enhanced testing coverage for promise handling in the Cypress environment, improving validation of asynchronous operations. - **Bug Fixes** - Updated labels in the settings tab of the query editor for clarity. - Improved label consistency across various plugins and settings configurations. - **Documentation** - Updated messaging in the `SettingsPopover` component for better user guidance. - **Chores** - Standardized phrasing in multiple configuration files to enhance user understanding across the application. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-11-06 18:50:52 +00:00
data-testid={props.dataTestId}
disabled={props.disabled}
chore: Updating the settings icon throughout the product (#37330) ## Description Updating the settings icon throughout the product to use the below icon: https://www.figma.com/design/8L9BXMzNTKboGWlHpdXyYP/Appsmith-IDE?node-id=33-3546&t=qpptzxhkWatrFIn1-4 Fixes [#37248](https://github.com/appsmithorg/appsmith/issues/37248) ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: 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/11796204902> > Commit: 0e57343a6c2b7543f37e37940f8447be10ccd9e9 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11796204902&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Tue, 12 Nov 2024 12:12:33 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 - **New Features** - Updated icons for various settings-related components from "settings-2-line" to "settings-v3" to enhance visual representation. - **Bug Fixes** - Improved handling of frame ancestor settings in the AdminSettings configuration, ensuring better management of stored values. - **Documentation** - No changes to the documentation were made in this release. - **Chores** - Updated multiple components to reflect the new icon, maintaining overall functionality without introducing new logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-11-12 12:47:58 +00:00
icon="settings-v3"
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
isSelected={isOpen}
onClick={handleButtonClick}
size="md"
/>
</PopoverTrigger>
<StyledPopoverContent
align="end"
onEscapeKeyDown={handleEscapeKeyDown}
popoverWidth={popoverWidth}
feat: JS Editor Toolbar (#36921) ## Description Adds the redesigned toolbar in the JS editor experience. This change is behind a feature flag. You would notice that there is a lot of repeated code, it is an intentional choice to repeat code instead of refactor and reuse as we essentially want to do a re design and not include any change in logic. All new components are created using the same logic blocks / components and just wrapped with our new design. This makes us debug issues during the transition easy and eventual removal of the old code much easier Fixes #36920 ## Automation /ok-to-test tags="@tag.JS" ### :mag: 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/11402542722> > Commit: e61000b5229a934e4d264849401ca630691b87cb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11402542722&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Fri, 18 Oct 2024 11:41:43 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 ## Release Notes - **New Features** - Introduced a new JavaScript editor settings configuration for enhanced customization. - Added a custom React hook to manage application state effectively. - Launched the `JSEditorToolbar` component, consolidating editing functionalities. - New components for JavaScript function execution and settings management, including `JSFunctionRun` and `JSFunctionSettings`. - Added the `ToolbarSettingsPopover` component for improved settings management in the toolbar. - Enhanced the JavaScript editor with a feature flag for action redesign. - **Bug Fixes** - Improved rendering logic based on feature flags in the context menu and toolbar. - **Tests** - Implemented new test suites for various components to ensure functionality and rendering accuracy. - **Chores** - Cleaned up imports and constants, streamlining the codebase for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-18 12:17:25 +00:00
size="sm"
>
<StyledPopoverHeader isClosable>{title}</StyledPopoverHeader>
<PopoverBody>{props.children}</PopoverBody>
</StyledPopoverContent>
</Popover>
);
};