PromucFlow_constructor/app/client/src/components/formControls/RadioButtonControl.tsx

74 lines
1.9 KiB
TypeScript
Raw Normal View History

chore:remove space b/w form and CTA onboarding page (#35985) ## Description Following are the improvements made in this PR: - Remove the unnecessary space b/w form and CTA in Gsheet onboarding step - Made one new RadioButtonControl in form control and replaced the current dropdown by radio buttons. - Move the callout to after the permissions | scope property. - Limit the width of the white section Fixes #30523 output screenshot: ![Screenshot from 2024-09-20 15-14-59](https://github.com/user-attachments/assets/61b397fb-8735-4b36-8036-a781ab3bd936) Desired design: ![image](https://github.com/user-attachments/assets/df65fab5-c543-4af8-9bb5-f72d8cb4d004) > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ *Fixes #`35950` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. <!-- 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 - **New Features** - Introduced a new `RadioButtonControl` component for improved form control options. - Enhanced the `FormControlRegistry` to support radio button controls. - Updated the Google Sheets plugin to use radio buttons for permission settings. - **UI Changes** - Corrected styling syntax in the `FormContainer` for proper rendering. - Reorganized the display order of information banners in the `DatasourceForm` for better clarity. - **Tests** - Added a comprehensive suite of unit tests for the `RadioButtonControl` component to ensure proper functionality and user interaction. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-09 04:27:44 +00:00
import React from "react";
import type { ControlProps } from "./BaseControl";
import BaseControl from "./BaseControl";
import type { ControlType } from "constants/PropertyControlConstants";
import type { WrappedFieldInputProps, WrappedFieldMetaProps } from "redux-form";
import { Field } from "redux-form";
import { Radio, RadioGroup, type SelectOptionProps } from "@appsmith/ads";
import styled from "styled-components";
class RadioButtonControl extends BaseControl<RadioButtonControlProps> {
getControlType(): ControlType {
return "RADIO_BUTTON";
}
render() {
return (
<Field
component={renderComponent}
name={this.props.configProperty}
props={{ ...this.props }}
type="radiobutton"
/>
);
}
}
type renderComponentProps = RadioButtonControlProps & {
input?: WrappedFieldInputProps;
meta?: WrappedFieldMetaProps;
options?: Array<{ label: string; value: string }>;
};
const StyledRadioGroup = styled(RadioGroup)({
display: "flex",
flexDirection: "column",
gap: "16px",
marginTop: "16px",
});
function renderComponent(props: renderComponentProps) {
const onChangeHandler = (value: string) => {
if (typeof props.input?.onChange === "function") {
props.input.onChange(value);
}
};
const options = props.options || [];
fix: gsheets all sheets option enabled behind a feature flag (#37942) ## Description This PR adds back all sheets option which had been removed in PR: https://github.com/appsmithorg/appsmith/pull/36125 Fixes #38002 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Datasource, @tag.Widget" ### :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/12311024852> > Commit: e177b648fd593b8ccc8af88c6d90c3958d7c9752 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12311024852&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource, @tag.Widget` > Spec: > <hr>Fri, 13 Dec 2024 08:27:08 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** - Added new options for Google Sheets permissions, enhancing user selection capabilities. - Introduced a feature flag to control the visibility of new Google Sheets options. - **Bug Fixes** - Improved handling of feature flags in the datasource section rendering, ensuring correct visibility based on flags. - **Documentation** - Updated test specifications for Google Sheets datasource to include new dropdown options. - **Chores** - Enhanced the logic for setting default values in the RadioButtonControl component. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: “sneha122” <“sneha@appsmith.com”> Co-authored-by: Alex Golovanov <alex@appsmith.com>
2024-12-13 08:39:53 +00:00
const selectedValue = props.input?.value;
const defaultValue = !!selectedValue
? selectedValue
: (props.initialValue as string);
chore:remove space b/w form and CTA onboarding page (#35985) ## Description Following are the improvements made in this PR: - Remove the unnecessary space b/w form and CTA in Gsheet onboarding step - Made one new RadioButtonControl in form control and replaced the current dropdown by radio buttons. - Move the callout to after the permissions | scope property. - Limit the width of the white section Fixes #30523 output screenshot: ![Screenshot from 2024-09-20 15-14-59](https://github.com/user-attachments/assets/61b397fb-8735-4b36-8036-a781ab3bd936) Desired design: ![image](https://github.com/user-attachments/assets/df65fab5-c543-4af8-9bb5-f72d8cb4d004) > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ *Fixes #`35950` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. <!-- 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 - **New Features** - Introduced a new `RadioButtonControl` component for improved form control options. - Enhanced the `FormControlRegistry` to support radio button controls. - Updated the Google Sheets plugin to use radio buttons for permission settings. - **UI Changes** - Corrected styling syntax in the `FormContainer` for proper rendering. - Reorganized the display order of information banners in the `DatasourceForm` for better clarity. - **Tests** - Added a comprehensive suite of unit tests for the `RadioButtonControl` component to ensure proper functionality and user interaction. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-09 04:27:44 +00:00
return (
<StyledRadioGroup
data-testid={props.input?.name}
defaultValue={defaultValue}
onChange={onChangeHandler}
>
{options.map((option) => {
return (
<Radio key={option.value} value={option.value}>
{option.label}
</Radio>
);
})}
</StyledRadioGroup>
);
}
export interface RadioButtonControlProps extends ControlProps {
options: SelectOptionProps[];
}
export default RadioButtonControl;