Skip to content

Commit

Permalink
Merge branch 'main' into 24.03
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Aug 8, 2024
2 parents 8bb76b8 + cd02ff6 commit 6199b4d
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 58 deletions.
20 changes: 17 additions & 3 deletions react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ const InteractiveLoginPage = React.lazy(
);
const ImportAndRunPage = React.lazy(() => import('./pages/ImportAndRunPage'));

const RedirectToSummary = () => {
useSuspendedBackendaiClient();
const pathName = '/summary';
document.dispatchEvent(
new CustomEvent('move-to-from-react', {
detail: {
path: pathName,
// params: options?.params,
},
}),
);
return <Navigate to="/summary" replace />;
};

const router = createBrowserRouter([
{
path: '/interactive-login',
Expand Down Expand Up @@ -91,17 +105,17 @@ const router = createBrowserRouter([
children: [
{
path: '/',
element: <Navigate to="/summary" replace />,
element: <RedirectToSummary />,
},
{
//for electron dev mode
path: '/build/electron-app/app/index.html',
element: <Navigate to="/summary" replace />,
element: <RedirectToSummary />,
},
{
//for electron prod mode
path: '/app/index.html',
element: <Navigate to="/summary" replace />,
element: <RedirectToSummary />,
},
{
path: '/summary',
Expand Down
69 changes: 42 additions & 27 deletions react/src/components/BatchSessionScheduledTimeSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { useWebComponentInfo } from './DefaultProviders';
import Flex from './Flex';
import { useToggle } from 'ahooks';
import { Typography, Checkbox, theme } from 'antd';
import { GetRef } from 'antd/lib';
import dayjs from 'dayjs';
import React from 'react';
import React, { useRef } from 'react';
import { useTranslation } from 'react-i18next';

interface Props extends DatePickerISOProps {}
Expand All @@ -24,6 +25,8 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
dispatchEvent('change', value);
};

const datePickerRef = useRef<GetRef<typeof DatePickerISO>>(null);

return (
<>
<Typography.Text type="secondary" style={{ fontSize: token.fontSizeSM }}>
Expand All @@ -32,7 +35,7 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
<Flex align="start" gap="sm">
<Checkbox
checked={isChecked}
onClick={(v) => {
onChange={(v) => {
toggleChecked();
const newScheduleTime = v
? dayjs().add(2, 'minutes').toISOString()
Expand All @@ -44,11 +47,13 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
</Checkbox>
<Flex direction="column" align="end">
<DatePickerISO
ref={datePickerRef}
{...datePickerISOProps}
popupStyle={{ position: 'fixed' }}
disabledDate={(date) => {
return date.isBefore(dayjs().startOf('minute'));
return date.isBefore(dayjs().startOf('day'));
}}
localFormat
disabled={!isChecked}
showTime={{
hideDisabledOptions: true,
Expand All @@ -57,8 +62,11 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
onChange={(value) => {
dispatchAndSetScheduleTime(value);
}}
onBlur={() => {
dispatchAndSetScheduleTime(scheduleTime);
onCalendarChange={() => {
datePickerRef.current?.focus();
}}
onPanelChange={() => {
datePickerRef.current?.focus();
}}
status={
isChecked && !scheduleTime
Expand All @@ -67,29 +75,26 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
? 'error'
: undefined
}
needConfirm={false}
showNow={false}
/>
{isChecked && scheduleTime && (
<Typography.Text
type="secondary"
style={{ fontSize: token.fontSizeSM - 2 }}
>
({t('session.launcher.StartAfter')}
<BAIIntervalText
callback={() => {
// Add 2 minutes if the schedule time is in the past
const leftTime = dayjs(scheduleTime).diff(dayjs());
if (leftTime < 0) {
dispatchAndSetScheduleTime(
dayjs(scheduleTime).add(2, 'minutes').toISOString(),
);
}
return dayjs(scheduleTime).fromNow();
}}
delay={1000}
/>
)
</Typography.Text>
)}
{isChecked &&
scheduleTime &&
!dayjs(scheduleTime).isBefore(dayjs()) && (
<Typography.Text
type="secondary"
style={{ fontSize: token.fontSizeSM - 2 }}
>
({t('session.launcher.StartAfter')}
<BAIIntervalText
callback={() => {
return dayjs(scheduleTime).fromNow();
}}
delay={1000}
/>
)
</Typography.Text>
)}
{isChecked && !scheduleTime && (
<Typography.Text
type="warning"
Expand All @@ -98,6 +103,16 @@ const BatchSessionScheduledTimeSetting: React.FC<Props> = ({
{t('session.launcher.StartTimeDoesNotApply')}
</Typography.Text>
)}
{isChecked &&
scheduleTime &&
dayjs(scheduleTime).isBefore(dayjs()) && (
<Typography.Text
type="danger"
style={{ fontSize: token.fontSizeSM - 2 }}
>
{t('session.launcher.StartTimeMustBeInTheFuture')}
</Typography.Text>
)}
</Flex>
</Flex>
</>
Expand Down
14 changes: 7 additions & 7 deletions react/src/components/DatePickerISO.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useControllableValue } from 'ahooks';
import { DatePicker } from 'antd';
import { PickerProps } from 'antd/es/date-picker/generatePicker';
import { GetRef } from 'antd/lib';
import dayjs, { Dayjs } from 'dayjs';
import _ from 'lodash';
import React from 'react';
Expand All @@ -11,19 +12,18 @@ export interface DatePickerISOProps
onChange?: (value: string | undefined) => void;
localFormat?: boolean;
}
const DatePickerISO: React.FC<DatePickerISOProps> = ({
value,
onChange,
localFormat,
...pickerProps
}) => {
const DatePickerISO = React.forwardRef<
GetRef<typeof DatePicker>,
DatePickerISOProps
>(({ value, onChange, localFormat, ...pickerProps }, ref) => {
const [, setControllableValue] = useControllableValue({
value,
onChange,
});

return (
<DatePicker
ref={ref}
value={value ? dayjs(value) : undefined}
onChange={(value) => {
if (_.isArray(value)) {
Expand All @@ -38,6 +38,6 @@ const DatePickerISO: React.FC<DatePickerISOProps> = ({
{...pickerProps}
/>
);
};
});

export default DatePickerISO;
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const LLMPlaygroundPage: React.FC<LLMPlaygroundPageProps> = ({ ...props }) => {
>
<Flex gap={'xs'}>
<Typography.Text type="secondary">
{t('chatui.Sync')}
{t('chatui.SyncInput')}
</Typography.Text>
<Switch
value={isSynchronous}
Expand Down
2 changes: 1 addition & 1 deletion resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Chatsitzung löschen",
"DeleteChattingSessionDescription": "Sie sind dabei, dieses Thema zu löschen. \nEinmal gelöscht, kann es nicht wiederhergestellt werden. \nBitte gehen Sie vorsichtig vor.",
"SelectEndpoint": "Wählen Sie Endpunkt aus",
"Sync": "Synchronisieren"
"SyncInput": "Eingang synchronisieren"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Διαγραφή συνεδρίας συνομιλίας",
"DeleteChattingSessionDescription": "Πρόκειται να διαγράψετε αυτό το θέμα. \nΑφού διαγραφεί, δεν μπορεί να ανακτηθεί. \nΠαρακαλούμε προχωρήστε με προσοχή.",
"SelectEndpoint": "Επιλέξτε Τελικό σημείο",
"Sync": "Συγχρονισμός"
"SyncInput": "Συγχρονισμός εισόδου"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,6 @@
"DeleteChatSession": "",
"DeleteChattingSession": "Delete chatting session",
"DeleteChattingSessionDescription": "You are about to delete this topic. Once deleted, it cannot be recovered. Please proceed with caution.",
"Sync": "Sync"
"SyncInput": "Sync input"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,6 @@
"DeleteChattingSession": "Eliminar sesión de chat",
"DeleteChattingSessionDescription": "Estás a punto de eliminar este tema. \nUna vez eliminado, no se puede recuperar. \nProceda con precaución.",
"SelectEndpoint": "Seleccionar punto final",
"Sync": "Sincronizar"
"SyncInput": "Entrada de sincronización"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,6 @@
"DeleteChattingSessionDescription": "Olet poistamassa tätä aihetta. \nKun se on poistettu, sitä ei voi palauttaa. \nOle hyvä ja jatka varoen.",
"DeleteChatHistory": "Poista keskusteluhistoria",
"SelectModel": "Valitse Malli",
"Sync": "Synkronoi"
"SyncInput": "Synkronoi sisääntulo"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Supprimer la session de discussion",
"DeleteChattingSessionDescription": "Vous êtes sur le point de supprimer ce sujet. \nUne fois supprimé, il ne peut pas être récupéré. \nVeuillez procéder avec prudence.",
"SelectEndpoint": "Sélectionnez le point de terminaison",
"Sync": "Synchroniser"
"SyncInput": "Entrée de synchronisation"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Hapus sesi obrolan",
"DeleteChattingSessionDescription": "Anda akan menghapus topik ini. \nSetelah dihapus, itu tidak dapat dipulihkan. \nSilakan lanjutkan dengan hati-hati.",
"SelectEndpoint": "Pilih Titik Akhir",
"Sync": "Sinkronisasi"
"SyncInput": "Sinkronkan masukan"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Elimina la sessione di chat",
"DeleteChattingSessionDescription": "Stai per eliminare questo argomento. \nUna volta eliminato, non può essere recuperato. \nSi prega di procedere con cautela.",
"SelectEndpoint": "Seleziona punto finale",
"Sync": "Sincronizzazione"
"SyncInput": "Ingresso sincronizzato"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "チャットセッションを削除する",
"DeleteChattingSessionDescription": "このトピックを削除しようとしています。\n一度削除すると復元することはできません。\n慎重に進めてください。",
"SelectEndpoint": "エンドポイントの選択",
"Sync": "同期"
"SyncInput": "同期入力"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,6 @@
"DeleteChattingSession": "채팅 세션 삭제",
"DeleteChattingSessionDescription": "이 주제를 삭제하려고 합니다. \n삭제한 후에는 복구할 수 없습니다. \n주의해서 진행하시기 바랍니다.",
"SelectEndpoint": "엔드포인트 선택",
"Sync": "연동"
"SyncInput": "입력 연동"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,6 @@
"DeleteChattingSession": "Чатлах сессийг устгах",
"DeleteChattingSessionDescription": "Та энэ сэдвийг устгах гэж байна. \nУстгасны дараа сэргээх боломжгүй. \nБолгоомжтой үргэлжлүүлнэ үү.",
"SelectEndpoint": "Төгсгөлийн цэгийг сонгоно уу",
"Sync": "Синк хийх"
"SyncInput": "Синкийн оролт"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Padamkan sesi berbual",
"DeleteChattingSessionDescription": "Anda akan memadamkan topik ini. \nSetelah dipadam, ia tidak boleh dipulihkan. \nSila teruskan dengan berhati-hati.",
"SelectEndpoint": "Pilih Titik Akhir",
"Sync": "Segerakkan"
"SyncInput": "Input penyegerakan"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Usuń sesję czatu",
"DeleteChattingSessionDescription": "Zamierzasz usunąć ten temat. \nRaz usuniętego nie można odzyskać. \nProszę postępować ostrożnie.",
"SelectEndpoint": "Wybierz Punkt końcowy",
"Sync": "Synchronizuj"
"SyncInput": "Synchronizuj wejście"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Excluir sessão de bate-papo",
"DeleteChattingSessionDescription": "Você está prestes a excluir este tópico. \nUma vez excluído, ele não pode ser recuperado. \nPor favor, proceda com cautela.",
"SelectEndpoint": "Selecione o ponto final",
"Sync": "Sincronizar"
"SyncInput": "Entrada de sincronização"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Excluir sessão de bate-papo",
"DeleteChattingSessionDescription": "Você está prestes a excluir este tópico. \nUma vez excluído, ele não pode ser recuperado. \nPor favor, proceda com cautela.",
"SelectEndpoint": "Selecione o ponto final",
"Sync": "Sincronizar"
"SyncInput": "Entrada de sincronização"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Удалить сеанс чата",
"DeleteChattingSessionDescription": "Вы собираетесь удалить эту тему. \nПосле удаления его невозможно восстановить. \nПожалуйста, действуйте осторожно.",
"SelectEndpoint": "Выберите конечную точку",
"Sync": "Синхронизировать"
"SyncInput": "Вход синхронизации"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Sohbet oturumunu sil",
"DeleteChattingSessionDescription": "Bu konuyu silmek üzeresiniz. \nBir kere silindikten sonra geri getirilemez. \nLütfen dikkatli bir şekilde ilerleyin.",
"SelectEndpoint": "Uç Noktayı Seçin",
"Sync": "Senkronizasyon"
"SyncInput": "Senkronizasyon girişi"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "Xóa phiên trò chuyện",
"DeleteChattingSessionDescription": "Bạn sắp xóa chủ đề này. \nMột khi đã xóa, nó không thể được phục hồi. \nHãy tiến hành thận trọng.",
"SelectEndpoint": "Chọn điểm cuối",
"Sync": "Đồng bộ hóa"
"SyncInput": "Đồng bộ hóa đầu vào"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,6 @@
"DeleteChattingSession": "删除聊天会话",
"DeleteChattingSessionDescription": "您即将删除该主题。\n一旦删除,就无法恢复。\n请谨慎行事。",
"SelectEndpoint": "选择端点",
"Sync": "同步"
"SyncInput": "同步输入"
}
}
2 changes: 1 addition & 1 deletion resources/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,6 @@
"DeleteChattingSession": "刪除聊天會話",
"DeleteChattingSessionDescription": "您即將刪除該主題。\n一旦刪除,就無法恢復。\n請謹慎行事。",
"SelectEndpoint": "選擇端點",
"Sync": "同步"
"SyncInput": "同步輸入"
}
}

0 comments on commit 6199b4d

Please sign in to comment.