From 357a2024f487f8d3407e1ccf7d0ac572b1ae1933 Mon Sep 17 00:00:00 2001 From: heaven Date: Fri, 1 May 2026 14:42:00 +0300 Subject: [PATCH] =?UTF-8?q?feat(bots):=20M1=20wire=20Direct=20segment=20to?= =?UTF-8?q?=20/bots/=20placeholder=20and=20rename=20label=20to=20=D0=A0?= =?UTF-8?q?=D0=BE=D0=B1=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en.json | 5 ++- public/locales/ru.json | 5 ++- src/app/pages/MobileFriendly.tsx | 5 ++- src/app/pages/Router.tsx | 20 ++++++++++ src/app/pages/client/bots/Bots.tsx | 28 ++++++++++++++ src/app/pages/client/bots/index.ts | 1 + .../client/direct/DirectStreamHeader.tsx | 38 +++++++++---------- src/app/pages/pathUtils.ts | 3 ++ src/app/pages/paths.ts | 2 + 9 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 src/app/pages/client/bots/Bots.tsx create mode 100644 src/app/pages/client/bots/index.ts diff --git a/public/locales/en.json b/public/locales/en.json index e7ee6525..016491f7 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -370,7 +370,7 @@ "start_first_chat": "Start a chat", "segment_dm": "DM", "segment_channels": "Channels", - "segment_bots": "Bots", + "segment_bots": "Robots", "segment_coming_soon": "Coming soon", "self_row_label": "You", "self_row_preview": "Settings & profile", @@ -917,5 +917,8 @@ "invite_body_no_room": "{{inviter}} invited you to a room", "invite_body_no_inviter": "Invited you to {{roomName}}", "invite_body_generic": "New invitation" + }, + "Bots": { + "title": "Robots" } } diff --git a/public/locales/ru.json b/public/locales/ru.json index 1aaff847..15239532 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -370,7 +370,7 @@ "start_first_chat": "Начать чат", "segment_dm": "Личные", "segment_channels": "Каналы", - "segment_bots": "Боты", + "segment_bots": "Роботы", "segment_coming_soon": "Скоро", "self_row_label": "Я", "self_row_preview": "Настройки и профиль", @@ -921,5 +921,8 @@ "invite_body_no_room": "{{inviter}} приглашает вас в комнату", "invite_body_no_inviter": "Приглашение в {{roomName}}", "invite_body_generic": "Новое приглашение" + }, + "Bots": { + "title": "Роботы" } } diff --git a/src/app/pages/MobileFriendly.tsx b/src/app/pages/MobileFriendly.tsx index ca947ac6..5b3997f7 100644 --- a/src/app/pages/MobileFriendly.tsx +++ b/src/app/pages/MobileFriendly.tsx @@ -1,7 +1,7 @@ import { ReactNode } from 'react'; import { useMatch } from 'react-router-dom'; import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize'; -import { DIRECT_PATH, EXPLORE_PATH, HOME_PATH, INBOX_PATH, SPACE_PATH } from './paths'; +import { BOTS_PATH, DIRECT_PATH, EXPLORE_PATH, HOME_PATH, INBOX_PATH, SPACE_PATH } from './paths'; type MobileFriendlyClientNavProps = { children: ReactNode; @@ -13,10 +13,11 @@ export function MobileFriendlyClientNav({ children }: MobileFriendlyClientNavPro const spaceMatch = useMatch({ path: SPACE_PATH, caseSensitive: true, end: true }); const exploreMatch = useMatch({ path: EXPLORE_PATH, caseSensitive: true, end: true }); const inboxMatch = useMatch({ path: INBOX_PATH, caseSensitive: true, end: true }); + const botsMatch = useMatch({ path: BOTS_PATH, caseSensitive: true, end: true }); if ( screenSize === ScreenSize.Mobile && - !(homeMatch || directMatch || spaceMatch || exploreMatch || inboxMatch) + !(homeMatch || directMatch || spaceMatch || exploreMatch || inboxMatch || botsMatch) ) { return null; } diff --git a/src/app/pages/Router.tsx b/src/app/pages/Router.tsx index 045ed0b1..101d6b12 100644 --- a/src/app/pages/Router.tsx +++ b/src/app/pages/Router.tsx @@ -13,6 +13,7 @@ import { import { ClientConfig } from '../hooks/useClientConfig'; import { AuthLayout, Login, Register, ResetPassword } from './auth'; import { + BOTS_PATH, DIRECT_PATH, EXPLORE_PATH, HOME_PATH, @@ -50,6 +51,7 @@ import { getMxIdServer, isUserId } from '../utils/matrix'; import { ClientBindAtoms, ClientLayout, ClientRoot } from './client'; import { HomeRouteRoomProvider } from './client/home'; import { Direct, DirectCreate, DirectRouteRoomProvider } from './client/direct'; +import { Bots } from './client/bots'; import { RouteSpaceProvider, Space, SpaceRouteRoomProvider, SpaceSearch } from './client/space'; import { Explore, FeaturedRooms, PublicRooms } from './client/explore'; import { Notifications, Inbox, Invites } from './client/inbox'; @@ -243,6 +245,24 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) } /> + {/* Bots reuses DirectStreamHeader segments. /bots/* is reserved before SPACE_PATH so deep URLs don't fall to /:spaceIdOrAlias/. Real bot list lands in M2. */} + + + + } + > + + + } + > + {mobile ? null : } />} + + } /> + + + } + title={ + + {t('Bots.title')} + + } + /> + + + ); +} diff --git a/src/app/pages/client/bots/index.ts b/src/app/pages/client/bots/index.ts new file mode 100644 index 00000000..34877baa --- /dev/null +++ b/src/app/pages/client/bots/index.ts @@ -0,0 +1 @@ +export * from './Bots'; diff --git a/src/app/pages/client/direct/DirectStreamHeader.tsx b/src/app/pages/client/direct/DirectStreamHeader.tsx index 137a01e8..10728d43 100644 --- a/src/app/pages/client/direct/DirectStreamHeader.tsx +++ b/src/app/pages/client/direct/DirectStreamHeader.tsx @@ -1,7 +1,10 @@ import React, { forwardRef } from 'react'; import { useTranslation } from 'react-i18next'; +import { useMatch, useNavigate } from 'react-router-dom'; import { Box, Text, Tooltip, TooltipProvider, color, toRem } from 'folds'; import { PageNavHeader } from '../../../components/page'; +import { BOTS_PATH, DIRECT_PATH } from '../../paths'; +import { isNativePlatform } from '../../../utils/capacitor'; type SegmentProps = { active: boolean; @@ -39,12 +42,22 @@ const Segment = forwardRef( export function DirectStreamHeader() { const { t } = useTranslation(); + const navigate = useNavigate(); const comingSoon = t('Direct.segment_coming_soon'); + const directMatch = useMatch({ path: DIRECT_PATH, caseSensitive: true, end: false }); + const botsMatch = useMatch({ path: BOTS_PATH, caseSensitive: true, end: false }); + + const navOpts = { replace: isNativePlatform() }; + return ( - + navigate(DIRECT_PATH, navOpts)} + /> )} - - {comingSoon} - - } - > - {(triggerRef) => ( - } - active={false} - disabled - label={t('Direct.segment_bots')} - /> - )} - + navigate(BOTS_PATH, navOpts)} + /> ); diff --git a/src/app/pages/pathUtils.ts b/src/app/pages/pathUtils.ts index 817d21d1..27136b12 100644 --- a/src/app/pages/pathUtils.ts +++ b/src/app/pages/pathUtils.ts @@ -1,5 +1,6 @@ import { generatePath, Path } from 'react-router-dom'; import { + BOTS_PATH, DIRECT_CREATE_PATH, DIRECT_PATH, DIRECT_ROOM_PATH, @@ -158,3 +159,5 @@ export const getCreatePath = (): string => CREATE_PATH; export const getInboxPath = (): string => INBOX_PATH; export const getInboxNotificationsPath = (): string => INBOX_NOTIFICATIONS_PATH; export const getInboxInvitesPath = (): string => INBOX_INVITES_PATH; + +export const getBotsPath = (): string => BOTS_PATH; diff --git a/src/app/pages/paths.ts b/src/app/pages/paths.ts index 9a7ae8c5..3be9e955 100644 --- a/src/app/pages/paths.ts +++ b/src/app/pages/paths.ts @@ -85,6 +85,8 @@ export const CREATE_PATH = '/create'; export const USER_LINK_HOST = 'vojo.chat'; export const USER_LINK_PATH = '/u/:userIdOrLocalPart'; +export const BOTS_PATH = '/bots/'; + export const _NOTIFICATIONS_PATH = 'notifications/'; export const _INVITES_PATH = 'invites/'; export const INBOX_PATH = '/inbox/';