Skip to content

Commit 4bb94bd

Browse files
committed
fix(dashboard): restrict non-sudo bulk actions and update flow warning copy
1 parent 0440523 commit 4bb94bd

File tree

10 files changed

+35
-13
lines changed

10 files changed

+35
-13
lines changed

dashboard/public/statics/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@
13421342
"proxySettings.password": "Password",
13431343
"proxySettings.method": "Method",
13441344
"proxySettings.flow": "Flow",
1345+
"proxySettings.flowDeprecated": "Deprecated. This will be removed in future versions. Use inbound.settings.flow",
13451346
"proxySettings.hysteria": "Hysteria",
13461347
"proxySettings.hysteriaAuth": "Hysteria Auth",
13471348
"proxySettings.wireguardPrivateKey": "WireGuard Private key",
@@ -1990,6 +1991,7 @@
19901991
"subtractExpiry": "Subtract from Expiry",
19911992
"addDataLimit": "Add Data Limit",
19921993
"subtractDataLimit": "Subtract Data Limit",
1994+
"subtractDataLimitHint": "If the amount to subtract is greater than a user's current limit, that user will not be counted.",
19931995
"applyToDataLimitDesc": "Select the groups, users, or admins you want to apply data limit to",
19941996
"noLimitSet": "No limit set",
19951997
"dataLimitLabel": "Data Limit (GB)",
@@ -2185,4 +2187,4 @@
21852187
"closeBanner": "Close update notification",
21862188
"needsUpdate": "Needs update"
21872189
}
2188-
}
2190+
}

dashboard/public/statics/locales/fa.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@
12071207
"userDialog.proxySettings.password": "رمز عبور",
12081208
"userDialog.proxySettings.method": "روش رمزنگاری",
12091209
"userDialog.proxySettings.flow": "جریان (Flow)",
1210+
"userDialog.proxySettings.flowDeprecated": "این مورد منسوخ شده است و در نسخه‌های بعدی حذف می‌شود. به‌جای آن از inbound.settings.flow استفاده کنید",
12101211
"userDialog.proxySettings.hysteria": "Hysteria",
12111212
"userDialog.proxySettings.hysteriaAuth": "احراز هویت Hysteria",
12121213
"userDialog.proxySettings.wireguardPrivateKey": "کلید خصوصی وایرگارد",
@@ -1932,6 +1933,7 @@
19321933
"subtractExpiry": "کاهش از انقضا",
19331934
"addDataLimit": "افزودن محدودیت حجم",
19341935
"subtractDataLimit": "کاهش محدودیت حجم",
1936+
"subtractDataLimitHint": "اگر مقدار کسر از محدودیت فعلی یک کاربر بیشتر باشد، آن کاربر در شمارش لحاظ نمی‌شود.",
19351937
"applyToDataLimitDesc": "گروه‌ها، کاربران یا مدیرانی که می‌خواهید محدودیت حجم را اعمال کنید انتخاب کنید",
19361938
"noLimitSet": "محدودیتی تنظیم نشده است",
19371939
"dataLimitLabel": "محدودیت حجم (گیگابایت)",

dashboard/public/statics/locales/ru.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,7 @@
17101710
"proxySettings.password": "Пароль",
17111711
"proxySettings.method": "Метод",
17121712
"proxySettings.flow": "Поток (Flow)",
1713+
"proxySettings.flowDeprecated": "Устарело. Будет удалено в следующих версиях. Используйте вместо этого inbound.settings.flow",
17131714
"proxySettings.hysteria": "Hysteria",
17141715
"proxySettings.hysteriaAuth": "Аутентификация Hysteria",
17151716
"proxySettings.wireguardPrivateKey": "Приватный ключ WireGuard",
@@ -1909,6 +1910,7 @@
19091910
"subtractExpiry": "Вычесть из истечения",
19101911
"addDataLimit": "Добавить лимит данных",
19111912
"subtractDataLimit": "Вычесть лимит данных",
1913+
"subtractDataLimitHint": "Если вычитаемое значение больше текущего лимита пользователя, такой пользователь не будет учитываться.",
19121914
"applyToDataLimitDesc": "Выберите группы, пользователей или администраторов для применения лимита данных",
19131915
"noLimitSet": "Лимит не установлен",
19141916
"dataLimitLabel": "Лимит данных (ГБ)",

dashboard/public/statics/locales/zh.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@
13131313
"userDialog.proxySettings.password": "密码",
13141314
"userDialog.proxySettings.method": "加密方式",
13151315
"userDialog.proxySettings.flow": "流 (Flow)",
1316+
"userDialog.proxySettings.flowDeprecated": "此项已弃用,将在后续版本中移除。请改用 inbound.settings.flow",
13161317
"userDialog.proxySettings.hysteria": "Hysteria",
13171318
"userDialog.proxySettings.hysteriaAuth": "Hysteria 认证",
13181319
"userDialog.proxySettings.wireguardPrivateKey": "WireGuard 私钥",
@@ -2045,6 +2046,7 @@
20452046
"subtractExpiry": "从到期时间减去",
20462047
"addDataLimit": "增加数据限额",
20472048
"subtractDataLimit": "减少数据限额",
2049+
"subtractDataLimitHint": "如果要扣减的数值大于用户当前限额,则该用户不会计入统计。",
20482050
"applyToDataLimitDesc": "选择要应用数据限额的分组、用户或管理员",
20492051
"noLimitSet": "未设置限额",
20502052
"confirmApplyExpireDescriptionAll": "您确定要将到期日期 {{expireDate}} 应用于所有用户、管理员和群组吗?这将更新所有人的到期日期。",

dashboard/src/components/bulk/bulk-flow.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,13 @@ export default function BulkFlow({ operationType }: BulkFlowProps) {
720720
<p className="text-xs text-muted-foreground">
721721
{dataOperation === 'add' ? t('bulk.addDataLimit', { defaultValue: 'Add Data Limit' }) : t('bulk.subtractDataLimit', { defaultValue: 'Subtract Data Limit' })}
722722
</p>
723+
{dataOperation === 'subtract' && (
724+
<p className="text-xs text-amber-600 dark:text-amber-400">
725+
{t('bulk.subtractDataLimitHint', {
726+
defaultValue: "If the amount to subtract is greater than a user's current limit, that user will not be counted.",
727+
})}
728+
</p>
729+
)}
723730
</div>
724731
</div>
725732
)}

dashboard/src/components/dialogs/user-modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,7 @@ function UserModal({ isDialogOpen, onOpenChange, form, editingUser, editingUserI
20242024
</SelectContent>
20252025
</Select>
20262026
</FormControl>
2027+
<p className="text-xs text-amber-600 dark:text-amber-400">{t('userDialog.proxySettings.flowDeprecated')}</p>
20272028
<FormMessage />
20282029
</FormItem>
20292030
)}

dashboard/src/components/layout/nav-user.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Button } from '@/components/ui/button'
55
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
66
import { useSidebar } from '@/components/ui/sidebar'
77
import { type AdminDetails } from '@/service/api'
8-
import { ChevronsUpDown, LogOut, UserRoundKey, UsersIcon, UserCircle, ChartPie, ChartNoAxesColumn } from 'lucide-react'
8+
import { ChevronsUpDown, LogOut, UserRoundKey, UsersIcon, UserCircle, ChartPie, ChartNoAxesColumn, UserRound } from 'lucide-react'
99
import { useTranslation } from 'react-i18next'
1010
import { useNavigate } from 'react-router'
1111
import { formatBytes } from '@/utils/formatByte'
@@ -67,7 +67,7 @@ export function NavUser({
6767
</>
6868
) : (
6969
<>
70-
<UsersIcon className="mr-1 size-3" />
70+
<UserRound className="mr-1 size-3" />
7171
{t('admin')}
7272
</>
7373
)}
@@ -138,7 +138,7 @@ export function NavUser({
138138
</>
139139
) : (
140140
<>
141-
<UsersIcon className="mr-1 size-3" />
141+
<UserRound className="mr-1 size-3" />
142142
{t('admin')}
143143
</>
144144
)}
@@ -172,7 +172,7 @@ export function NavUser({
172172
</>
173173
) : (
174174
<>
175-
<UsersIcon className="size-3" />
175+
<UserRound className="size-3" />
176176
<span>{t('admin')}</span>
177177
</>
178178
)}

dashboard/src/components/layout/route-guard.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ export default function RouteGuard({ children }: { children: React.ReactNode })
1919
const currentPath = location.pathname
2020

2121
// Define allowed routes for non-sudo admins
22-
const allowedRoutes = ['/', '/users', '/settings', '/settings/theme']
23-
const isAllowedRoute = allowedRoutes.some(route => currentPath === route || (route === '/settings' && currentPath.startsWith('/settings/theme')))
22+
const allowedRoutes = ['/', '/users', '/settings', '/settings/theme', '/bulk', '/bulk/create']
23+
const isAllowedRoute = allowedRoutes.some(
24+
route =>
25+
currentPath === route ||
26+
(route === '/settings' && currentPath.startsWith('/settings/theme')),
27+
)
2428

2529
// If current route is allowed, don't redirect
2630
if (isAllowedRoute) {
@@ -59,6 +63,14 @@ export default function RouteGuard({ children }: { children: React.ReactNode })
5963
navigate('/settings/theme', { replace: true })
6064
return
6165
}
66+
67+
const restrictedBulkRoutes = ['/bulk/wireguard', '/bulk/groups', '/bulk/expire', '/bulk/data', '/bulk/proxy']
68+
69+
if (restrictedBulkRoutes.some(route => currentPath.startsWith(route))) {
70+
hasNavigatedRef.current = true
71+
navigate('/bulk', { replace: true })
72+
return
73+
}
6274
} else {
6375
hasNavigatedRef.current = false
6476
}

dashboard/src/components/layout/sidebar.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,6 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
291291
url: '/bulk',
292292
icon: UserPlus,
293293
},
294-
{
295-
title: 'bulk.wireguardPeerIps',
296-
url: '/bulk/wireguard',
297-
icon: Network,
298-
},
299294
],
300295
},
301296
// For non-sudo admins, show only theme settings and keep settings at the end

dashboard/src/pages/_dashboard.bulk.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const sudoTabs = [
1818

1919
const nonSudoTabs = [
2020
{ id: 'create', label: 'bulk.createUsers', icon: UserPlus, url: '/bulk' },
21-
{ id: 'wireguard', label: 'bulk.wireguardPeerIps', icon: Network, url: '/bulk/wireguard' },
2221
]
2322

2423
const BulkPage = () => {

0 commit comments

Comments
 (0)