Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu committed Nov 11, 2024
1 parent cffb595 commit f48efee
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 143 deletions.
7 changes: 7 additions & 0 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2520,3 +2520,10 @@ export const JS_EDITOR_SETTINGS = {
TITLE: () => "Settings",
ON_LOAD_TITLE: () => "Choose the functions to run on page load",
};

export const CUSTOM_WIDGET_BUILDER_TAB_TITLE = {
AI: () => "AI",
HTML: () => "HTML",
STYLE: () => "Style",
JS: () => "Javascript",
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
import type { ContentProps } from "../CodeEditors/types";
import { CustomWidgetBuilderContext } from "../..";
import {
CUSTOM_WIDGET_AI_BOT_MESSAGE_RESPONSE_DEBOUNCE_TIMEOUT,
CUSTOM_WIDGET_AI_BOT_URL,
CUSTOM_WIDGET_AI_CHAT_TYPE,
CUSTOM_WIDGET_AI_INITIALISED_MESSAGE,
Expand All @@ -23,7 +24,12 @@ export const ChatBot = (props: ContentProps) => {

const handleSrcDocUpdates = useCallback(() => {
// Don't send updates back to bot if the last update came from the bot within the last 100ms
if (Date.now() - lastUpdateFromBot.current < 100) return;
if (
Date.now() - lastUpdateFromBot.current <
CUSTOM_WIDGET_AI_BOT_MESSAGE_RESPONSE_DEBOUNCE_TIMEOUT
) {
return;
}

// Send src doc to the chatbot iframe
if (ref.current && ref.current.contentWindow && uncompiledSrcDoc) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useLocalStorageState from "utils/hooks/useLocalStorageState";
import classNames from "classnames";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { CUSTOM_WIDGET_BUILDER_TABS } from "../../../constants";

interface Props {
tabs: Array<{
Expand All @@ -26,7 +27,9 @@ export default function TabLayout(props: Props) {

const [selectedTab, setSelectedTab] = useLocalStorageState<string>(
LOCAL_STORAGE_KEYS,
isDefaultAITab ? "AI" : tabs[0].title,
isDefaultAITab
? CUSTOM_WIDGET_BUILDER_TABS.AI
: CUSTOM_WIDGET_BUILDER_TABS.JS,
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import References from "./References";
import { ChatBot } from "./ChatBot/ChatBot";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
import { CUSTOM_WIDGET_BUILDER_TABS } from "../constants";

export default function Editor() {
const { isReferenceOpen } = useContext(CustomWidgetBuilderContext);
Expand All @@ -21,23 +22,23 @@ export default function Editor() {
const tabs = useMemo(() => {
const defaultTabs = [
{
title: "HTML",
title: CUSTOM_WIDGET_BUILDER_TABS.HTML,
children: (props: ContentProps) => <HTMLEditor {...props} />,
},
{
title: "Style",
title: CUSTOM_WIDGET_BUILDER_TABS.STYLE,
titleControls: <TitleControls />,
children: (props: ContentProps) => <StyleEditor {...props} />,
},
{
title: "Javascript",
title: CUSTOM_WIDGET_BUILDER_TABS.JS,
children: (props: ContentProps) => <JSEditor {...props} />,
},
];

if (isAIEnabled) {
defaultTabs.push({
title: "AI",
title: CUSTOM_WIDGET_BUILDER_TABS.AI,
children: (props: ContentProps) => <ChatBot {...props} />,
});
}
Expand Down
14 changes: 14 additions & 0 deletions app/client/src/pages/Editor/CustomWidgetBuilder/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
createMessage,
CUSTOM_WIDGET_BUILDER_TAB_TITLE,
} from "ee/constants/messages";

export const CUSTOM_WIDGET_BUILDER_EVENTS = {
READY: "READY",
READY_ACK: "READY_ACK",
Expand Down Expand Up @@ -66,3 +71,12 @@ export const CUSTOM_WIDGET_AI_INITIALISED_MESSAGE = "CHAT_INITIALISED";

export const CUSTOM_WIDGET_AI_BOT_URL = (instanceId: string) =>
`https://internal.appsmith.com/app/app-builder-bot/custom-widget-bot-672b2020d37b7d0b29dcfa71?embed=true&chatType=${CUSTOM_WIDGET_AI_CHAT_TYPE}&chatInstance=${instanceId}&url=${encodeURIComponent(window.location.origin)}`;

export const CUSTOM_WIDGET_AI_BOT_MESSAGE_RESPONSE_DEBOUNCE_TIMEOUT = 100;

export const CUSTOM_WIDGET_BUILDER_TABS = {
AI: createMessage(CUSTOM_WIDGET_BUILDER_TAB_TITLE.AI),
HTML: createMessage(CUSTOM_WIDGET_BUILDER_TAB_TITLE.HTML),
STYLE: createMessage(CUSTOM_WIDGET_BUILDER_TAB_TITLE.STYLE),
JS: createMessage(CUSTOM_WIDGET_BUILDER_TAB_TITLE.JS),
};

0 comments on commit f48efee

Please sign in to comment.