fix(client): динамический текст и цвет кнопки в confirmDialog
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user