Skip to content

Commit 94b6f80

Browse files
committed
feat: add new localization entries and enhance user subscription links feature
- Added a new translation for "no available hosts found for this user" in English, Persian, and Russian locale files. - Updated the GetUserSubscriptionLinksFeature to display a message when no subscription links are available. - Improved the ViewUserModal to conditionally enable queries based on form state.
1 parent 62eaca3 commit 94b6f80

File tree

5 files changed

+54
-15
lines changed

5 files changed

+54
-15
lines changed

public/locales/en/remnawave.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@
725725
"feature": {
726726
"subscription-links": "Subscription links",
727727
"loading-subscription-links": "Loading subscription links...",
728-
"show-links": "Show links"
728+
"show-links": "Show links",
729+
"no-available-hosts-found-for-this-user": "No available hosts found for this user"
729730
}
730731
}
731732
}

public/locales/fa/remnawave.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@
725725
"feature": {
726726
"loading-subscription-links": "بارگیری پیوندهای اشتراک ...",
727727
"show-links": "نشان دادن پیوندها",
728-
"subscription-links": "پیوندهای اشتراک"
728+
"subscription-links": "پیوندهای اشتراک",
729+
"no-available-hosts-found-for-this-user": "هیچ میزبان موجود برای این کاربر یافت نمی شود"
729730
}
730731
}
731732
}

public/locales/ru/remnawave.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@
725725
"feature": {
726726
"loading-subscription-links": "Загрузка ссылок на подписку ...",
727727
"show-links": "Показать ссылки",
728-
"subscription-links": "Подписные ссылки"
728+
"subscription-links": "Подписные ссылки",
729+
"no-available-hosts-found-for-this-user": "Для этого пользователя не найдено доступных хостов"
729730
}
730731
}
731732
}

src/features/ui/dashboard/users/get-user-subscription-links/get-user-subscription-links.feature.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { ActionIcon, Button, CopyButton, Drawer, Stack, TextInput, Tooltip } from '@mantine/core'
2-
import { PiCheck, PiCopy, PiLinkBreakDuotone } from 'react-icons/pi'
1+
import {
2+
ActionIcon,
3+
Button,
4+
Center,
5+
CopyButton,
6+
Drawer,
7+
Stack,
8+
Text,
9+
TextInput,
10+
Tooltip
11+
} from '@mantine/core'
12+
import { PiCheck, PiCopy, PiEmptyDuotone, PiLinkBreakDuotone } from 'react-icons/pi'
313
import { useDisclosure } from '@mantine/hooks'
414
import { useTranslation } from 'react-i18next'
15+
import { useEffect } from 'react'
516

617
import { useGetSubscriptionInfoByShortUuid } from '@shared/api/hooks'
718
import { LoaderModalShared } from '@shared/ui/loader-modal'
@@ -13,13 +24,36 @@ export function GetUserSubscriptionLinksFeature(props: IProps) {
1324
const { t } = useTranslation()
1425
const [opened, handlers] = useDisclosure(false)
1526

16-
const { data: subscriptionInfo, isLoading } = useGetSubscriptionInfoByShortUuid({
27+
const {
28+
data: subscriptionInfo,
29+
isLoading,
30+
refetch
31+
} = useGetSubscriptionInfoByShortUuid({
1732
route: {
1833
shortUuid
1934
}
2035
})
2136

37+
useEffect(() => {
38+
refetch()
39+
}, [opened])
40+
2241
const renderLinks = () => {
42+
if (!subscriptionInfo?.links.length) {
43+
return (
44+
<Center py="xl">
45+
<Stack align="center" gap="xs">
46+
<PiEmptyDuotone color="var(--mantine-color-gray-5)" size="3rem" />
47+
<Text c="dimmed" size="sm">
48+
{t(
49+
'get-user-subscription-links.feature.no-available-hosts-found-for-this-user'
50+
)}
51+
</Text>
52+
</Stack>
53+
</Center>
54+
)
55+
}
56+
2357
return subscriptionInfo?.links.map((link) => {
2458
const encodedName = link.split('#').at(-1) || 'Host'
2559
const name = decodeURIComponent(encodedName)

src/widgets/dashboard/users/view-user-modal/view-user-modal.widget.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ export const ViewUserModal = () => {
6666

6767
const { data: inbounds } = useGetInbounds()
6868

69+
const form = useForm<IFormValues>({
70+
name: 'edit-user-form',
71+
mode: 'uncontrolled',
72+
validate: zodResolver(
73+
UpdateUserCommand.RequestSchema.omit({ expireAt: true, email: true, telegramId: true })
74+
)
75+
})
76+
77+
const isQueryEnabled = !!selectedUser && !form.isTouched()
78+
6979
const {
7080
data: user,
7181
isLoading: isUserLoading,
@@ -75,18 +85,10 @@ export const ViewUserModal = () => {
7585
uuid: selectedUser ?? ''
7686
},
7787
rQueryParams: {
78-
enabled: !!selectedUser
88+
enabled: isQueryEnabled
7989
}
8090
})
8191

82-
const form = useForm<IFormValues>({
83-
name: 'edit-user-form',
84-
mode: 'uncontrolled',
85-
validate: zodResolver(
86-
UpdateUserCommand.RequestSchema.omit({ expireAt: true, email: true, telegramId: true })
87-
)
88-
})
89-
9092
const {
9193
mutate: updateUser,
9294
isPending: isUpdateUserPending,

0 commit comments

Comments
 (0)