🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Update localization files with new keys for site selection
Bill Yang4ffd4beaa10e
diff --git a/client/messages/cs.json b/client/messages/cs.jsonindex 2dc618784..e9469099f 100644--- a/client/messages/cs.json+++ b/client/messages/cs.json@@ -92,6 +92,8 @@"D3idYv": "Nastavení","yMG/h7": "Nastavení webu","yBqtD8": "{count} relací (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Žádné weby nenalezeny","FIKvUB": "","Yxwqz8": "Žádný web nevybrán","Gpwv5L": "PDF report stažen",@@ -823,7 +825,6 @@"sEqhTf": "Nepodařilo se načíst data webů. Zkus to prosím později.","r9Y1x6": "Hledej podle domény nebo emailu vlastníka...","QQ3i6V": "Žádné weby neodpovídají tvému hledání",- "v5+mtG": "Žádné weby nenalezeny","JXGHuf": "Vyber prosím organizaci","wSHezm": "Uživatel úspěšně přidán do organizace","vKB00F": "Nepodařilo se přidat uživatele do organizace",diff --git a/client/messages/de.json b/client/messages/de.jsonindex 7188b0c89..73696ca56 100644--- a/client/messages/de.json+++ b/client/messages/de.json@@ -92,6 +92,8 @@"D3idYv": "Einstellungen","yMG/h7": "Website-Einstellungen","yBqtD8": "{count} Sitzungen (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Keine Websites gefunden","FIKvUB": "Website hinzufügen","Yxwqz8": "Keine Website ausgewählt","Gpwv5L": "PDF-Bericht heruntergeladen",@@ -823,7 +825,6 @@"sEqhTf": "Website-Daten konnten nicht geladen werden. Bitte versuchen Sie es später erneut.","r9Y1x6": "Nach Domain oder Inhaber-E-Mail suchen...","QQ3i6V": "Keine Websites entsprechen Ihrer Suche",- "v5+mtG": "Keine Websites gefunden","JXGHuf": "Bitte wählen Sie eine Organisation aus","wSHezm": "Benutzer erfolgreich zur Organisation hinzugefügt","vKB00F": "Benutzer konnte nicht zur Organisation hinzugefügt werden",diff --git a/client/messages/en.json b/client/messages/en.jsonindex ac958be9e..5bd691c81 100644--- a/client/messages/en.json+++ b/client/messages/en.json@@ -92,6 +92,8 @@"D3idYv": "Settings","yMG/h7": "Site Settings","yBqtD8": "{count} sessions (24h)",+ "Ep4Hs9": "Search sites...",+ "v5+mtG": "No sites found","FIKvUB": "Add Site","Yxwqz8": "No site selected","Gpwv5L": "PDF report downloaded",@@ -823,7 +825,6 @@"sEqhTf": "Failed to load sites data. Please try again later.","r9Y1x6": "Search by domain or owner email...","QQ3i6V": "No sites match your search",- "v5+mtG": "No sites found","JXGHuf": "Please select an organization","wSHezm": "User added to organization successfully","vKB00F": "Failed to add user to organization",diff --git a/client/messages/es.json b/client/messages/es.jsonindex 3fa9e4c16..9bac23a76 100644--- a/client/messages/es.json+++ b/client/messages/es.json@@ -92,6 +92,8 @@"D3idYv": "Configuraciones","yMG/h7": "Configuración del sitio","yBqtD8": "{count} sesiones (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "No se encontraron sitios","FIKvUB": "Añadir sitio","Yxwqz8": "Ningún sitio seleccionado","Gpwv5L": "Informe PDF descargado",@@ -823,7 +825,6 @@"sEqhTf": "Error al cargar los datos de sitios. Inténtalo de nuevo más tarde.","r9Y1x6": "Buscar por dominio o correo del propietario...","QQ3i6V": "Ningún sitio coincide con tu búsqueda",- "v5+mtG": "No se encontraron sitios","JXGHuf": "Por favor, selecciona una organización","wSHezm": "Usuario añadido a la organización correctamente","vKB00F": "Error al añadir usuario a la organización",diff --git a/client/messages/fr.json b/client/messages/fr.jsonindex c00f202be..f6a5cd46d 100644--- a/client/messages/fr.json+++ b/client/messages/fr.json@@ -92,6 +92,8 @@"D3idYv": "Paramètres","yMG/h7": "Paramètres du site","yBqtD8": "{count} sessions (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Aucun site trouvé","FIKvUB": "Ajouter un site","Yxwqz8": "Aucun site sélectionné","Gpwv5L": "Rapport PDF téléchargé",@@ -823,7 +825,6 @@"sEqhTf": "Échec du chargement des données de sites. Veuillez réessayer plus tard.","r9Y1x6": "Rechercher par domaine ou e-mail du propriétaire...","QQ3i6V": "Aucun site ne correspond à votre recherche",- "v5+mtG": "Aucun site trouvé","JXGHuf": "Veuillez sélectionner une organisation","wSHezm": "Utilisateur ajouté à l'organisation avec succès","vKB00F": "Échec de l'ajout de l'utilisateur à l'organisation",diff --git a/client/messages/it.json b/client/messages/it.jsonindex cc7dd28f0..234c171d2 100644--- a/client/messages/it.json+++ b/client/messages/it.json@@ -92,6 +92,8 @@"D3idYv": "Impostazioni","yMG/h7": "Impostazioni Sito","yBqtD8": "{count} sessioni (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Nessun sito trovato","FIKvUB": "Aggiungi Sito","Yxwqz8": "Nessun sito selezionato","Gpwv5L": "Report PDF scaricato",@@ -823,7 +825,6 @@"sEqhTf": "Impossibile caricare i dati dei siti. Riprova più tardi.","r9Y1x6": "Cerca per dominio o email proprietario...","QQ3i6V": "Nessun sito corrisponde alla tua ricerca",- "v5+mtG": "Nessun sito trovato","JXGHuf": "Seleziona un'organizzazione","wSHezm": "Utente aggiunto all'organizzazione con successo","vKB00F": "Impossibile aggiungere l'utente all'organizzazione",diff --git a/client/messages/ja.json b/client/messages/ja.jsonindex da70976dd..0515dbdc9 100644--- a/client/messages/ja.json+++ b/client/messages/ja.json@@ -92,6 +92,8 @@"D3idYv": "設定","yMG/h7": "サイト設定","yBqtD8": "{count}セッション (24時間)",+ "Ep4Hs9": "",+ "v5+mtG": "サイトが見つかりません","FIKvUB": "サイトを追加","Yxwqz8": "サイトが選択されていません","Gpwv5L": "PDFレポートをダウンロードしました",@@ -823,7 +825,6 @@"sEqhTf": "サイトデータの読み込みに失敗しました。後でもう一度お試しください。","r9Y1x6": "ドメインまたはオーナーメールで検索...","QQ3i6V": "検索に一致するサイトはありません",- "v5+mtG": "サイトが見つかりません","JXGHuf": "組織を選択してください","wSHezm": "ユーザーを組織に追加しました","vKB00F": "ユーザーの組織への追加に失敗しました",diff --git a/client/messages/ko.json b/client/messages/ko.jsonindex 898b74d72..7582f4359 100644--- a/client/messages/ko.json+++ b/client/messages/ko.json@@ -92,6 +92,8 @@"D3idYv": "설정","yMG/h7": "사이트 설정","yBqtD8": "{count}개 세션 (24시간)",+ "Ep4Hs9": "",+ "v5+mtG": "사이트를 찾을 수 없음","FIKvUB": "사이트 추가","Yxwqz8": "사이트 미선택","Gpwv5L": "PDF 보고서 다운로드 완료",@@ -823,7 +825,6 @@"sEqhTf": "사이트 데이터를 로드하지 못했습니다. 나중에 다시 시도해 주세요.","r9Y1x6": "도메인 또는 소유자 이메일로 검색...","QQ3i6V": "검색과 일치하는 사이트 없음",- "v5+mtG": "사이트를 찾을 수 없음","JXGHuf": "조직을 선택하세요","wSHezm": "사용자가 조직에 성공적으로 추가되었습니다","vKB00F": "조직에 사용자 추가 실패",diff --git a/client/messages/pl.json b/client/messages/pl.jsonindex 24d1800ba..aacd8e7da 100644--- a/client/messages/pl.json+++ b/client/messages/pl.json@@ -92,6 +92,8 @@"D3idYv": "Ustawienia","yMG/h7": "Ustawienia strony","yBqtD8": "{count} sesji (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Nie znaleziono stron","FIKvUB": "Dodaj witrynę","Yxwqz8": "Nie wybrano strony","Gpwv5L": "Pobrano raport PDF",@@ -823,7 +825,6 @@"sEqhTf": "Nie udało się załadować danych stron. Spróbuj ponownie później.","r9Y1x6": "Szukaj po domenie lub e-mailu właściciela...","QQ3i6V": "Żadne strony nie pasują do wyszukiwania",- "v5+mtG": "Nie znaleziono stron","JXGHuf": "Wybierz organizację","wSHezm": "Użytkownik dodany do organizacji pomyślnie","vKB00F": "Nie udało się dodać użytkownika do organizacji",diff --git a/client/messages/pt.json b/client/messages/pt.jsonindex 8b1342be3..2bd18f24d 100644--- a/client/messages/pt.json+++ b/client/messages/pt.json@@ -92,6 +92,8 @@"D3idYv": "Configurações","yMG/h7": "Configurações do Site","yBqtD8": "{count} sessões (24h)",+ "Ep4Hs9": "",+ "v5+mtG": "Nenhum site encontrado","FIKvUB": "Adicionar Site","Yxwqz8": "Nenhum site selecionado","Gpwv5L": "Relatório PDF baixado",@@ -823,7 +825,6 @@"sEqhTf": "Falha ao carregar dados de sites. Por favor, tente novamente mais tarde.","r9Y1x6": "Pesquisar por domínio ou email do proprietário...","QQ3i6V": "Nenhum site corresponde à sua pesquisa",- "v5+mtG": "Nenhum site encontrado","JXGHuf": "Por favor, selecione uma organização","wSHezm": "Usuário adicionado à organização com sucesso","vKB00F": "Falha ao adicionar usuário à organização",diff --git a/client/messages/uk.json b/client/messages/uk.jsonindex b2be44971..df469288e 100644--- a/client/messages/uk.json+++ b/client/messages/uk.json@@ -92,6 +92,8 @@"D3idYv": "Налаштування","yMG/h7": "Налаштування сайту","yBqtD8": "{count} сеансів (24 год)",+ "Ep4Hs9": "",+ "v5+mtG": "Сайтів не знайдено","FIKvUB": "","Yxwqz8": "Сайт не вибрано","Gpwv5L": "Звіт у PDF завантажено",@@ -823,7 +825,6 @@"sEqhTf": "Не вдалося завантажити дані сайтів. Будь ласка, спробуйте пізніше.","r9Y1x6": "Шукати за доменом або email власника...","QQ3i6V": "Жоден сайт не відповідає пошуку",- "v5+mtG": "Сайтів не знайдено","JXGHuf": "Будь ласка, виберіть організацію","wSHezm": "Користувача успішно додано до організації","vKB00F": "Не вдалося додати користувача до організації",diff --git a/client/messages/zh.json b/client/messages/zh.jsonindex d8eeadcc6..80c325dea 100644--- a/client/messages/zh.json+++ b/client/messages/zh.json@@ -92,6 +92,8 @@"D3idYv": "设置","yMG/h7": "网站设置","yBqtD8": "{count} 个会话 (24小时)",+ "Ep4Hs9": "",+ "v5+mtG": "未找到网站","FIKvUB": "添加站点","Yxwqz8": "未选择网站","Gpwv5L": "PDF 报告已下载",@@ -823,7 +825,6 @@"sEqhTf": "加载网站数据失败。请稍后重试。","r9Y1x6": "按域名或所有者电子邮件搜索...","QQ3i6V": "没有与您的搜索匹配的网站",- "v5+mtG": "未找到网站","JXGHuf": "请选择一个组织","wSHezm": "用户已成功添加到组织","vKB00F": "添加用户到组织失败",diff --git a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx b/client/src/app/[site]/components/Sidebar/SiteSelector.tsxindex 56cfa5f52..528fd4380 100644--- a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx+++ b/client/src/app/[site]/components/Sidebar/SiteSelector.tsx@@ -1,10 +1,11 @@-import { ChevronDown, Plus } from "lucide-react";+import { Check, ChevronDown, Plus } from "lucide-react";import { useExtracted } from "next-intl";import { usePathname, useRouter } from "next/navigation";import { useState, Suspense } from "react";import { useGetSite, useGetSitesFromOrg } from "../../../../api/admin/hooks/useSites";import { Favicon } from "../../../../components/Favicon";import { Button } from "../../../../components/ui/button";+import { Command, CommandEmpty, CommandInput, CommandItem, CommandList } from "../../../../components/ui/command";import { Popover, PopoverContent, PopoverTrigger } from "../../../../components/ui/popover";import { authClient } from "../../../../lib/auth";import { useStore } from "../../../../lib/store";@@ -14,6 +15,66 @@ import { AddSite } from "../../../components/AddSite";import { useEmbedablePage } from "../../utils";import { DEMO_HOSTNAME } from "../../../../lib/const";+// Show the search field once the list is long enough to scan slowly.+const SEARCH_THRESHOLD = 10;++type SiteOption = {+ siteId: number;+ name: string;+ domain: string;+ sessions?: number;+};++const rowClass =+ "flex w-full items-center gap-3 rounded-md px-2 py-2 text-left transition-colors cursor-pointer";++function SiteRow({ site, isSelected }: { site: SiteOption; isSelected: boolean }) {+ const t = useExtracted();+ // Sites named after their own domain shouldn't print the same string twice.+ const showDomain = Boolean(site.domain) && site.domain !== site.name;+ const sessionsLabel =+ site.sessions !== undefined ? t("{count} sessions (24h)", { count: formatter(site.sessions) }) : null;++ return (+ <>+ <Favicon domain={site.domain} className="w-5 h-5 rounded shrink-0" />+ <div className="min-w-0 flex-1">+ <div className="flex items-center justify-between gap-2">+ <span className="truncate text-sm text-neutral-900 dark:text-white">{site.name}</span>+ {!showDomain && sessionsLabel && (+ <span className="shrink-0 text-xs tabular-nums text-neutral-500 dark:text-neutral-400">+ {sessionsLabel}+ </span>+ )}+ </div>+ {showDomain && (+ <div className="flex items-center justify-between gap-2">+ <span className="truncate text-xs text-neutral-500 dark:text-neutral-400">{site.domain}</span>+ {sessionsLabel && (+ <span className="shrink-0 text-xs tabular-nums text-neutral-500 dark:text-neutral-400">+ {sessionsLabel}+ </span>+ )}+ </div>+ )}+ </div>+ {isSelected && <Check className="h-4 w-4 shrink-0 text-emerald-500" />}+ </>+ );+}++function SiteSkeletonRow() {+ return (+ <div className="flex items-center gap-3 rounded-md px-2 py-2 animate-pulse">+ <div className="w-5 h-5 bg-neutral-200 dark:bg-neutral-800 rounded shrink-0" />+ <div className="min-w-0 flex-1 space-y-1.5">+ <div className="h-3.5 bg-neutral-200 dark:bg-neutral-800 rounded w-32" />+ <div className="h-3 bg-neutral-200 dark:bg-neutral-800 rounded w-20" />+ </div>+ </div>+ );+}+function SiteSelectorContent({ onSiteSelect }: { onSiteSelect: () => void }) {const t = useExtracted();const { data: activeOrganization } = authClient.useActiveOrganization();@@ -28,118 +89,101 @@ function SiteSelectorContent({ onSiteSelect }: { onSiteSelect: () => void }) {if (embed) return null;- if (typeof window !== "undefined" && globalThis.location.hostname === DEMO_HOSTNAME) {- return (- <PopoverContent align="start" className="w-52 p-2">- <div className="max-h-96 overflow-y-auto">- {[- {- siteId: 81,- domain: "rybbit.com",- },- ].map(site => {- const isSelected = site.siteId === currentSiteId;- return (- <div- key={site.siteId}- onClick={() => {- if (isSelected) {- onSiteSelect(); // Close popover even if same site- return;- }- const pathSegments = pathname.split("/");- pathSegments[1] = site.siteId.toString();- const newPath = pathSegments.join("/");- const queryString = window.location.search;- // Let the layout's useEffect sync the site from the new pathname- router.push(queryString ? `${newPath}${queryString}` : newPath);- onSiteSelect(); // Close popover immediately- }}- className={cn(- "flex items-center justify-between p-2 cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-800/50 transition-colors rounded-md border-b border-neutral-300 dark:border-neutral-800 last:border-b-0",- isSelected && "bg-neutral-50 dark:bg-neutral-800"- )}- >- <div className="flex items-center gap-3 flex-1 min-w-0">- <Favicon domain={site.domain} className="w-4 h-4 shrink-0" />- <div className="text-sm text-neutral-900 dark:text-white truncate">{site.domain}</div>- </div>- </div>- );- })}- </div>- </PopoverContent>- );- }+ const isDemo = typeof window !== "undefined" && globalThis.location.hostname === DEMO_HOSTNAME;- if (!user) {+ if (!isDemo && !user) {return null;}+ const navigateToSite = (siteId: number) => {+ if (siteId === currentSiteId) {+ onSiteSelect(); // Close popover even if same site+ return;+ }+ const pathSegments = pathname.split("/");+ pathSegments[1] = siteId.toString();+ const newPath = pathSegments.join("/");+ const queryString = window.location.search;+ // Let the layout's useEffect sync the site from the new pathname+ router.push(queryString ? `${newPath}${queryString}` : newPath);+ onSiteSelect(); // Close popover immediately+ };++ const siteOptions: SiteOption[] | undefined = isDemo+ ? [{ siteId: 81, name: "rybbit.com", domain: "rybbit.com" }]+ : sites?.sites.map(site => ({+ siteId: site.siteId,+ name: site.name,+ domain: site.domain,+ sessions: site.sessionsLast24Hours,+ }));++ const isLoading = !siteOptions;+ const showSearch = (siteOptions?.length ?? 0) >= SEARCH_THRESHOLD;+return (- <PopoverContent align="start" className="w-80 p-2">- <div className="max-h-96 overflow-y-auto">- {sites?.sites- ? sites.sites.map(site => {+ <PopoverContent align="start" className="w-80 p-0 overflow-hidden">+ {isLoading ? (+ <div className="p-1">+ {Array.from({ length: 3 }).map((_, index) => (+ <SiteSkeletonRow key={`skeleton-${index}`} />+ ))}+ </div>+ ) : showSearch ? (+ <Command defaultValue={String(currentSiteId)} className="bg-transparent">+ <CommandInput autoFocus placeholder={t("Search sites...")} />+ <CommandList className="max-h-80 p-1">+ <CommandEmpty>{t("No sites found")}</CommandEmpty>+ {siteOptions.map(site => {+ const isSelected = site.siteId === currentSiteId;+ return (+ <CommandItem+ key={site.siteId}+ value={String(site.siteId)}+ keywords={[site.name, site.domain]}+ onSelect={() => navigateToSite(site.siteId)}+ className={cn(rowClass, "py-2", isSelected && "bg-neutral-50 dark:bg-neutral-800/40")}+ >+ <SiteRow site={site} isSelected={isSelected} />+ </CommandItem>+ );+ })}+ </CommandList>+ </Command>+ ) : (+ <div className="max-h-80 overflow-y-auto p-1">+ {siteOptions.map(site => {const isSelected = site.siteId === currentSiteId;return (- <div+ <buttonkey={site.siteId}- onClick={() => {- if (isSelected) {- onSiteSelect(); // Close popover even if same site- return;- }- const pathSegments = pathname.split("/");- pathSegments[1] = site.siteId.toString();- const newPath = pathSegments.join("/");- const queryString = window.location.search;- // Let the layout's useEffect sync the site from the new pathname- router.push(queryString ? `${newPath}${queryString}` : newPath);- onSiteSelect(); // Close popover immediately- }}+ type="button"+ onClick={() => navigateToSite(site.siteId)}className={cn(- "flex items-center justify-between p-2 cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-800/50 transition-colors rounded-md border-b border-neutral-100 dark:border-neutral-800 last:border-b-0",- isSelected && "bg-neutral-50 dark:bg-neutral-800"+ rowClass,+ "hover:bg-neutral-100 dark:hover:bg-neutral-800/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-neutral-300 dark:focus-visible:ring-neutral-700",+ isSelected && "bg-neutral-50 dark:bg-neutral-800/40")}>- <div className="flex items-center gap-3 flex-1 min-w-0">- <Favicon domain={site.domain} className="w-4 h-4 shrink-0" />- <div className="text-sm text-neutral-900 dark:text-white truncate">{site.name}</div>- </div>- <div className="flex items-center gap-3">- <div className="text-xs text-neutral-600 dark:text-neutral-300 whitespace-nowrap">- {t("{count} sessions (24h)", { count: formatter(site.sessionsLast24Hours) })}- </div>- </div>- </div>+ <SiteRow site={site} isSelected={isSelected} />+ </button>);- })- : Array.from({ length: 3 }).map((_, index) => (- <div- key={`skeleton-${index}`}- className="flex items-center justify-between p-2 animate-pulse rounded-md border-b border-neutral-300 dark:border-neutral-800 last:border-b-0"- >- <div className="flex items-center gap-3 flex-1">- <div className="w-4 h-4 bg-neutral-200 dark:bg-neutral-700 rounded shrink-0"></div>- <div className="h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-32"></div>- </div>- <div className="h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-20"></div>- </div>- ))}- </div>+ })}+ </div>+ )}- {/* Add Site Section */}- <div className="mt-2">- <AddSite- trigger={- <Button variant="ghost" className="w-full justify-start gap-2">- <Plus className="h-4 w-4" />- {t("Add Site")}- </Button>- }- />- </div>+ {!isDemo && (+ <div className="border-t border-neutral-200 dark:border-neutral-800 p-1">+ <AddSite+ trigger={+ <Button variant="ghost" className="w-full justify-start gap-2">+ <Plus className="h-4 w-4" />+ {t("Add Site")}+ </Button>+ }+ />+ </div>+ )}</PopoverContent>);}@@ -154,10 +198,17 @@ function SiteSelectorWrapper() {<Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>{site ? (- <button className="flex gap-2 items-center border border-neutral-200 dark:border-neutral-800 rounded-lg py-1.5 px-3 justify-start cursor-pointer hover:bg-neutral-150 dark:hover:bg-neutral-800/50 transition-colors h-[36px] w-full">+ <button className="flex gap-2 items-center border border-neutral-200 dark:border-neutral-800 rounded-lg py-1.5 px-3 justify-start cursor-pointer hover:bg-neutral-150 dark:hover:bg-neutral-800/50 data-[state=open]:bg-neutral-150 dark:data-[state=open]:bg-neutral-800/50 transition-colors h-[36px] w-full"><Favicon domain={site.domain} className="w-5 h-5" /><div className="text-neutral-900 dark:text-white truncate text-sm flex-1 text-left">{site.name}</div>- {!embed && <ChevronDown className="w-4 h-4 text-neutral-600 dark:text-neutral-400" />}+ {!embed && (+ <ChevronDown+ className={cn(+ "w-4 h-4 text-neutral-600 dark:text-neutral-400 transition-transform duration-200",+ open && "rotate-180"+ )}+ />+ )}</button>) : (<button className="flex gap-2 border border-neutral-200 dark:border-neutral-800 rounded-lg py-1.5 px-3 justify-start items-center h-[36px] w-full animate-pulse">