fix(client): динамический текст и цвет кнопки в confirmDialog

This commit is contained in:
iqubik
2026-04-05 00:09:17 +03:00
parent 4a49121409
commit 60f2a44178
3 changed files with 25 additions and 11 deletions
+10 -3
View File
@@ -36,7 +36,10 @@ export default function SettingsPage() {
const [msg, setMsg] = useState({ open: false, type: 'success' as 'success' | 'error', text: '' });
const [loadingRotate, setLoadingRotate] = useState<boolean>(false);
const [confirmDialog, setConfirmDialog] = useState({ open: false, title: '', onConfirm: () => {} });
const [confirmDialog, setConfirmDialog] = useState({
open: false, title: '', onConfirm: () => {},
confirmText: 'Удалить', confirmColor: 'error' as 'error' | 'primary'
});
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
@@ -215,6 +218,8 @@ export default function SettingsPage() {
setConfirmDialog({
open: true,
title: 'ВНИМАНИЕ: Это немедленно обновит конфиги в подписках.\n\nИнтервал автоматической ротации НЕ будет сброшен.\n\nПродолжить?',
confirmText: 'Сгенерировать',
confirmColor: 'primary',
onConfirm: async () => {
try {
Logger.debug('Starting forced rotation', 'Rotation');
@@ -268,6 +273,8 @@ export default function SettingsPage() {
setConfirmDialog({
open: true,
title: `Обновить подписку "${sub.name}" сейчас?`,
confirmText: 'Обновить',
confirmColor: 'primary',
onConfirm: async () => {
try {
Logger.debug(`Starting manual rotation for subscription: ${sub.id}`, 'Settings');
@@ -597,9 +604,9 @@ export default function SettingsPage() {
confirmDialog.onConfirm();
}}
variant="contained"
color="warning"
color={confirmDialog.confirmColor}
>
Продолжить
{confirmDialog.confirmText}
</Button>
</DialogActions>
</Dialog>
+10 -3
View File
@@ -116,7 +116,10 @@ export default function SubscriptionsPage() {
const [snackbar, setSnackbar] = useState({ open: false, type: 'success' as 'success' | 'error', message: '' });
// Confirmation dialog state
const [confirmDialog, setConfirmDialog] = useState({ open: false, title: '', onConfirm: () => {} });
const [confirmDialog, setConfirmDialog] = useState({
open: false, title: '', onConfirm: () => {},
confirmText: 'Удалить', confirmColor: 'error' as 'error' | 'primary'
});
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
@@ -276,6 +279,8 @@ export default function SubscriptionsPage() {
setConfirmDialog({
open: true,
title: 'Удалить подписку и все соединения?',
confirmText: 'Удалить',
confirmColor: 'error',
onConfirm: async () => {
Logger.debug(`Deleting subscription: ${id}`, 'Subs');
await api.delete(`/subscriptions/${id}`);
@@ -312,6 +317,8 @@ export default function SubscriptionsPage() {
setConfirmDialog({
open: true,
title: `Обновить подписку "${sub.name}" сейчас?`,
confirmText: 'Обновить',
confirmColor: 'primary',
onConfirm: async () => {
try {
Logger.debug(`Starting manual rotation for subscription: ${sub.id}`, 'Subs');
@@ -622,9 +629,9 @@ export default function SubscriptionsPage() {
setConfirmDialog({ ...confirmDialog, open: false });
}}
variant="contained"
color="error"
color={confirmDialog.confirmColor}
>
Удалить
{confirmDialog.confirmText}
</Button>
</DialogActions>
</Dialog>
+5 -5
View File
@@ -380,10 +380,10 @@ describe('SettingsPage', () => {
const rotateButton = await screen.findByText('Сгенерировать сейчас')
fireEvent.click(rotateButton)
const confirmButton = await screen.findByText('Продолжить')
const confirmButton = await screen.findByText('Сгенерировать')
fireEvent.click(confirmButton)
await waitFor(() => {
expect(mockPost).toHaveBeenCalledWith('/rotation/rotate-all')
})
@@ -462,9 +462,9 @@ describe('SettingsPage', () => {
const refreshButton = await screen.findByRole('button', { name: /Обновить подписку вручную/i })
fireEvent.click(refreshButton)
const confirmButton = await screen.findByText('Продолжить')
const confirmButton = await screen.findByText('Обновить')
fireEvent.click(confirmButton)
await waitFor(() => {
expect(mockPost).toHaveBeenCalledWith('/rotation/rotate-one/1')
})