Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/client/src/ce/components/GeneratePromptButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

export interface GeneratePromptButtonProps {
existingPrompt: string;
onSubmit: (prompt: string) => void;
}

// Implementation is in ee
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const GeneratePromptButton = (props: GeneratePromptButtonProps) => {
return <div />;
};
14 changes: 14 additions & 0 deletions app/client/src/components/formControls/FormTemplateControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { connect } from "react-redux";
import { get, omit } from "lodash";
import type { AppState } from "ee/reducers";
import type { Action } from "entities/Action";
import { GeneratePromptButton } from "ee/components/GeneratePromptButton";

const StyledButton = styled((props: ButtonProps & { isActive: boolean }) => (
<Button {...omit(props, ["isActive"])} />
Expand Down Expand Up @@ -77,6 +78,9 @@ type FormTemplateProps = FormTemplatePartialProps &
ReduxDispatchProps &
ReduxStateProps;

const SYSTEM_INSTRUCTIONS_FIELD =
"actionConfiguration.formData.aiChatAssistant.input.instructions";

export function FormTemplate(props: FormTemplateProps) {
const { formName, formValues, options, updateFormProperty } = props;

Expand All @@ -90,6 +94,12 @@ export function FormTemplate(props: FormTemplateProps) {
});
};

const existingPrompt = get(formValues, SYSTEM_INSTRUCTIONS_FIELD, "");

const onGeneratedPrompt = (prompt: string) => {
updateFormProperty(formName, SYSTEM_INSTRUCTIONS_FIELD, prompt);
};

const onClick = (option: FormTemplateOption) => {
// Updates the form values with the option value
const { value } = option;
Expand All @@ -113,6 +123,10 @@ export function FormTemplate(props: FormTemplateProps) {
{option.label}
</StyledButton>
))}
<GeneratePromptButton
existingPrompt={existingPrompt}
onSubmit={onGeneratedPrompt}
/>
</Flex>
);
}
Expand Down
1 change: 1 addition & 0 deletions app/client/src/ee/components/GeneratePromptButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GeneratePromptButton } from "ce/components/GeneratePromptButton";
Loading