diff --git a/public/assets/no_data_dark.png b/public/assets/no_data_dark.png new file mode 100644 index 00000000..a3aa3852 Binary files /dev/null and b/public/assets/no_data_dark.png differ diff --git a/public/assets/no_data_light.png b/public/assets/no_data_light.png new file mode 100644 index 00000000..0359a69d Binary files /dev/null and b/public/assets/no_data_light.png differ diff --git a/src/components/Common/HistoryList/index.tsx b/src/components/Common/HistoryList/index.tsx index 91acba96..9f985cd8 100644 --- a/src/components/Common/HistoryList/index.tsx +++ b/src/components/Common/HistoryList/index.tsx @@ -19,6 +19,7 @@ import { useTranslation } from "react-i18next"; import VisibleKey from "../VisibleKey"; import { Chat } from "@/components/Assistant/types"; +import NoDataImage from "../NoDataImage"; dayjs.extend(isSameOrAfter); @@ -158,7 +159,7 @@ const HistoryList: FC = (props) => { ref={listRef} id={id} className={clsx( - "h-full overflow-auto px-3 py-2 text-sm bg-[#F3F4F6] dark:bg-[#1F2937]" + "flex flex-col h-full overflow-auto px-3 py-2 text-sm bg-[#F3F4F6] dark:bg-[#1F2937]" )} >
@@ -197,194 +198,202 @@ const HistoryList: FC = (props) => {
-
- {Object.entries(sortedList).map(([label, list]) => { - return ( -
- {t(label)} + {list.length > 0 ? ( + <> +
+ {Object.entries(sortedList).map(([label, list]) => { + return ( +
+ {t(label)} -
    - {list.map((item) => { - const { _id, _source } = item; +
      + {list.map((item) => { + const { _id, _source } = item; - const isActive = _id === active?._id; - const title = _source?.title ?? _id; + const isActive = _id === active?._id; + const title = _source?.title ?? _id; - return ( -
    • { - if (!isActive) { - setIsEdit(false); - } - - onSelect(item); - }} - > -
      - -
      - {isEdit && isActive ? ( - { - if (event.key !== "Enter") return; - - onRename(item._id, event.currentTarget.value); - - setIsEdit(false); - }} - onBlur={(event) => { - onRename(item._id, event.target.value); - - setIsEdit(false); - }} - /> - ) : ( - {title} - )} - -
      - {isActive && !isEdit && ( - + return ( +
    • { + if (!isActive) { + setIsEdit(false); + } - - {isActive && !isEdit && ( - - { - moreButtonRef.current?.click(); - }} - > - - - + onSelect(item); + }} + > +
      + +
      + {isEdit && isActive ? ( + { + if (event.key !== "Enter") return; + + onRename(item._id, event.currentTarget.value); + + setIsEdit(false); + }} + onBlur={(event) => { + onRename(item._id, event.target.value); + + setIsEdit(false); + }} + /> + ) : ( + {title} )} - { - event.stopPropagation(); - }} - > - {menuItems.map((menuItem) => { - const { - label, - icon: Icon, - shortcut, - iconColor, - onClick, - } = menuItem; +
      + {isActive && !isEdit && ( + + )} - return ( - - ); - })} - - -
      -
      -
    • - ); - })} -
    + { + event.stopPropagation(); + }} + > + {menuItems.map((menuItem) => { + const { + label, + icon: Icon, + shortcut, + iconColor, + onClick, + } = menuItem; + + return ( + + ); + })} + + +
+
+ + ); + })} + +
+ ); + })} +
+ + setIsOpen(false)} + className="relative z-1000" + > +
+ +
+ + {t("history_list.delete_modal.title")} + + + {t("history_list.delete_modal.description", { + replace: [active?._source?.title || active?._id], + })} + +
+ +
+ setIsOpen(false)} + > + + + + + + +
+
- ); - })} - - - setIsOpen(false)} - className="relative z-1000" - > -
- -
- - {t("history_list.delete_modal.title")} - - - {t("history_list.delete_modal.description", { - replace: [active?._source?.title || active?._id], - })} - -
- -
- setIsOpen(false)} - > - - - - - - -
-
+
+ + ) : ( +
+
-
+ )} ); }; diff --git a/src/components/Common/NoDataImage.tsx b/src/components/Common/NoDataImage.tsx new file mode 100644 index 00000000..e0c9d425 --- /dev/null +++ b/src/components/Common/NoDataImage.tsx @@ -0,0 +1,18 @@ +import { useThemeStore } from "@/stores/themeStore"; +import clsx from "clsx"; +import { FC, HTMLAttributes } from "react"; + +const NoDataImage: FC> = (props) => { + const { className } = props; + const isDark = useThemeStore((state) => state.isDark); + + return ( + + ); +}; + +export default NoDataImage;