[WEB-438] fix: ai insertion behaviour (#3872)

* fixed ai insertion behaviour

* replaced all ai popover references to have similar behavior

* chore: removed debug statements
This commit is contained in:
M. Palanikannan 2024-03-06 20:38:57 +05:30 committed by GitHub
parent cb5198c883
commit 549f6d0943
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 45 additions and 21 deletions

View file

@ -119,9 +119,7 @@ export const CreateInboxIssueModal: React.FC<Props> = observer((props) => {
const handleAiAssistance = async (response: string) => {
if (!workspaceSlug || !projectId) return;
// setValue("description", {});
setValue("description_html", `${watch("description_html")}<p>${response}</p>`);
editorRef.current?.setEditorValue(`${watch("description_html")}`);
editorRef.current?.setEditorValueAtCursorPosition(response);
};
const handleAutoGenerateDescription = async () => {

View file

@ -180,8 +180,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
const handleAiAssistance = async (response: string) => {
if (!workspaceSlug || !projectId) return;
setValue("description_html", `${watch("description_html")}<p>${response}</p>`);
editorRef.current?.setEditorValue(`${watch("description_html")}`);
editorRef.current?.setEditorValueAtCursorPosition(response);
};
const handleAutoGenerateDescription = async () => {

View file

@ -53,7 +53,7 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
membership: { currentProjectRole },
} = useUser();
const { handleSubmit, setValue, watch, getValues, control, reset } = useForm<IPage>({
const { handleSubmit, getValues, control, reset } = useForm<IPage>({
defaultValues: { name: "", description_html: "" },
});
@ -124,16 +124,13 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
const updatePage = async (formData: IPage) => {
if (!workspaceSlug || !projectId || !pageId) return;
await updateDescriptionAction(formData.description_html);
updateDescriptionAction(formData.description_html);
};
const handleAiAssistance = async (response: string) => {
if (!workspaceSlug || !projectId || !pageId) return;
const newDescription = `${watch("description_html")}<p>${response}</p>`;
setValue("description_html", newDescription);
editorRef.current?.setEditorValue(newDescription);
updateDescriptionAction(newDescription);
editorRef.current?.setEditorValueAtCursorPosition(response);
};
const actionCompleteAlert = ({

View file

@ -35,7 +35,7 @@ export interface IPageStore {
addToFavorites: () => Promise<void>;
removeFromFavorites: () => Promise<void>;
updateName: (name: string) => Promise<void>;
updateDescription: (description: string) => Promise<void>;
updateDescription: (description: string) => void;
// Reactions
disposers: Array<() => void>;
@ -89,7 +89,7 @@ export class PageStore implements IPageStore {
addToFavorites: action,
removeFromFavorites: action,
updateName: action,
updateDescription: action,
updateDescription: action.bound,
setIsSubmitting: action,
cleanup: action,
});
@ -166,7 +166,7 @@ export class PageStore implements IPageStore {
this.name = name;
});
updateDescription = action("updateDescription", async (description_html: string) => {
updateDescription = action("updateDescription", (description_html: string) => {
const { projectId, workspaceSlug } = this.rootStore.app.router;
if (!projectId || !workspaceSlug) return;