## Description Action redesign: Updating the config for SMTP plugin to use sections and zones format Fixes [#35505 ](https://github.com/appsmithorg/appsmith/issues/35505) ## Automation /ok-to-test tags="@tag.All" ### 🔍 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/10704929692> > Commit: f58dfce0a2729442a0e1222762f97cc483e5459b > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10704929692&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 04 Sep 2024 19:46:08 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** - Introduced a comprehensive email sending interface in the SMTP plugin, allowing users to input recipient addresses, subject, body type, and attachments. - Enhanced layout with a new `DOUBLE_COLUMN_ZONE` structure for improved organization of input fields. - **Improvements** - Expanded styling capabilities for the dynamic input text control, allowing for more flexible sizing and better responsiveness in the UI. - Updated existing configurations to streamline the email composition process and improve user experience. - **Bug Fixes** - Adjusted CSS rules to remove minimum height and width constraints for better adaptability of UI components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
161 lines
4.6 KiB
TypeScript
161 lines
4.6 KiB
TypeScript
import React from "react";
|
|
import type { ControlProps } from "./BaseControl";
|
|
import BaseControl from "./BaseControl";
|
|
import type { ControlType } from "constants/PropertyControlConstants";
|
|
import DynamicTextField from "components/editorComponents/form/fields/DynamicTextField";
|
|
import type { AppState } from "ee/reducers";
|
|
import { formValueSelector } from "redux-form";
|
|
import { QUERY_EDITOR_FORM_NAME } from "ee/constants/forms";
|
|
import { connect } from "react-redux";
|
|
import { actionPathFromName } from "components/formControls/utils";
|
|
import {
|
|
EditorModes,
|
|
EditorSize,
|
|
} from "components/editorComponents/CodeEditor/EditorConfig";
|
|
import styled from "styled-components";
|
|
import _ from "lodash";
|
|
|
|
// Enum for the different types of input fields
|
|
export enum INPUT_TEXT_INPUT_TYPES {
|
|
TEXT = "TEXT",
|
|
PASSWORD = "PASSWORD",
|
|
JSON = "JSON",
|
|
TEXT_WITH_BINDING = "TEXT_WITH_BINDING",
|
|
}
|
|
|
|
const StyledDynamicTextField = styled(DynamicTextField)`
|
|
.CodeEditorTarget .CodeMirror.CodeMirror-wrap {
|
|
background-color: var(--ads-v2-color-bg);
|
|
}
|
|
.CodeEditorTarget .CodeMirror.CodeMirror-wrap:hover {
|
|
background-color: var(--ads-v2-color-bg);
|
|
border-color: var(--ads-v2-color-border-emphasis);
|
|
}
|
|
&&& .t--code-editor-wrapper {
|
|
border: none;
|
|
}
|
|
.CodeEditorTarget {
|
|
border-radius: var(--ads-v2-border-radius);
|
|
}
|
|
`;
|
|
|
|
// Functional component for the DYNAMIC_INPUT_TEXT_CONTROL
|
|
export function InputText(props: {
|
|
label: string;
|
|
placeholder?: string;
|
|
isRequired?: boolean;
|
|
name: string;
|
|
actionName: string;
|
|
inputType?: INPUT_TEXT_INPUT_TYPES;
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
customStyles?: any;
|
|
disabled?: boolean;
|
|
showLineNumbers?: boolean;
|
|
}) {
|
|
const { actionName, inputType, name, placeholder } = props;
|
|
const dataTreePath = actionPathFromName(actionName, name);
|
|
let editorProps = {};
|
|
|
|
// Set the editor props to enable JSON editing experience
|
|
if (!!inputType && inputType === INPUT_TEXT_INPUT_TYPES.JSON) {
|
|
editorProps = {
|
|
mode: EditorModes.JSON,
|
|
size: EditorSize.EXTENDED,
|
|
};
|
|
}
|
|
|
|
// Set the editor props to enable JSON editing experience
|
|
if (!!inputType && inputType === INPUT_TEXT_INPUT_TYPES.TEXT_WITH_BINDING) {
|
|
editorProps = {
|
|
mode: EditorModes.TEXT_WITH_BINDING,
|
|
size: EditorSize.EXTENDED,
|
|
};
|
|
}
|
|
|
|
let customStyle = { width: "270px", minHeight: "36px" };
|
|
if (!!props.customStyles && _.isEmpty(props.customStyles) === false) {
|
|
customStyle = { ...props.customStyles };
|
|
if ("width" in props.customStyles) {
|
|
customStyle.width = props.customStyles.width;
|
|
}
|
|
if ("minHeight" in props.customStyles) {
|
|
customStyle.minHeight = props.customStyles.minHeight;
|
|
}
|
|
}
|
|
return (
|
|
<div
|
|
className={`t--${props?.name} uqi-dynamic-input-text`}
|
|
style={customStyle}
|
|
>
|
|
{/* <div style={customStyle}> */}
|
|
<StyledDynamicTextField
|
|
dataTreePath={dataTreePath}
|
|
disabled={props.disabled}
|
|
evaluatedPopUpLabel={props?.label || ""}
|
|
name={name}
|
|
placeholder={placeholder}
|
|
showLightningMenu={false}
|
|
showLineNumbers={props.showLineNumbers}
|
|
{...editorProps}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// This is a custom control that is used for dynamic input text fields in the forms for datsources and queries
|
|
class DynamicInputTextControl extends BaseControl<DynamicInputControlProps> {
|
|
render() {
|
|
const {
|
|
actionName,
|
|
configProperty,
|
|
customStyles,
|
|
disabled,
|
|
inputType,
|
|
label,
|
|
placeholderText,
|
|
showLineNumbers,
|
|
} = this.props;
|
|
|
|
let inputTypeProp = inputType;
|
|
if (!inputType) {
|
|
inputTypeProp = INPUT_TEXT_INPUT_TYPES.TEXT;
|
|
}
|
|
|
|
return (
|
|
<InputText
|
|
actionName={actionName}
|
|
customStyles={customStyles}
|
|
disabled={disabled}
|
|
inputType={inputTypeProp}
|
|
label={label}
|
|
name={configProperty}
|
|
placeholder={placeholderText}
|
|
showLineNumbers={showLineNumbers}
|
|
/>
|
|
);
|
|
}
|
|
|
|
getControlType(): ControlType {
|
|
return "QUERY_DYNAMIC_INPUT_TEXT";
|
|
}
|
|
}
|
|
|
|
export interface DynamicInputControlProps extends ControlProps {
|
|
placeholderText: string;
|
|
actionName: string;
|
|
inputType?: INPUT_TEXT_INPUT_TYPES;
|
|
}
|
|
|
|
const mapStateToProps = (state: AppState, props: DynamicInputControlProps) => {
|
|
const valueSelector = formValueSelector(
|
|
props.formName || QUERY_EDITOR_FORM_NAME,
|
|
);
|
|
const actionName = valueSelector(state, "name");
|
|
return {
|
|
actionName: actionName,
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps)(DynamicInputTextControl);
|