Replacing Semantic Confirm with custom confirm to have themeing and mobile support.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2025-12-25 16:03:09 -07:00
parent 2b0b161dad
commit c55c8e24c9
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 62 additions and 14 deletions

View file

@ -197,6 +197,11 @@ textarea.otp {
color: #DDDDDD !important;
}
/* Mobile-responsive Confirm modal */
.ui.modal.themed-confirm {
max-width: 95vw;
}
.clickable {
cursor: pointer;
}

View file

@ -6,7 +6,6 @@ import {
Button as SButton,
ButtonGroup,
Card,
Confirm,
Container,
Dimmer,
DimmerDimmable,
@ -29,6 +28,7 @@ import {
Breadcrumb,
Button,
Card as ThemedCard,
Confirm,
darkTheme,
Form,
Header,
@ -1298,10 +1298,6 @@ export const BackButton = ({...props}) => {
return <Button icon='arrow left' content='Back' onClick={() => navigate(-1)} {...props}/>;
}
export const ColorToSemanticHexColor = (color) => {
return semanticUIColorMap[color] || null;
}
export const filterToMimetypes = (filter) => {
const zipMimetypes = ['application/zip', 'application/zlib', 'application/x-bzip2', 'application/x-xz', 'application/x-bzip', 'application/x-bzip2', 'application/gzip', 'application/vnd.rar', 'application/x-tar', 'application/x-7z-compressed'];
const softwareMimetypes = [...zipMimetypes, 'application/x-iso9660-image', 'application/x-executable', 'application/x-dosexec'];

View file

@ -411,11 +411,11 @@ describe('FileBrowser', () => {
fireEvent.click(deleteButton);
});
// Confirm deletion in modal
// Confirm deletion in modal - getAllByText because Confirm renders both mobile/desktop versions
await waitFor(() => {
expect(screen.getByText('Delete')).toBeInTheDocument();
expect(screen.getAllByText('Delete').length).toBeGreaterThan(0);
});
const confirmButton = screen.getByText('Delete');
const confirmButton = screen.getAllByText('Delete')[0];
await act(async () => {
fireEvent.click(confirmButton);
});
@ -456,11 +456,11 @@ describe('FileBrowser', () => {
fireEvent.click(deleteButton);
});
// Confirm deletion in modal
// Confirm deletion in modal - getAllByText because Confirm renders both mobile/desktop versions
await waitFor(() => {
expect(screen.getByText('Delete')).toBeInTheDocument();
expect(screen.getAllByText('Delete').length).toBeGreaterThan(0);
});
const confirmButton = screen.getByText('Delete');
const confirmButton = screen.getAllByText('Delete')[0];
await act(async () => {
fireEvent.click(confirmButton);
});

View file

@ -70,7 +70,7 @@ import {
TabPaneProps,
TextAreaProps,
} from "semantic-ui-react";
import {ColorToSemanticHexColor} from "./Common";
import {ColorToSemanticHexColor} from "./Vars";
import _ from "lodash";
import {ThemeContextValue, ThemeName, SavedThemeName} from "../types/theme";
@ -336,6 +336,49 @@ export const Modal: ModalComponent = Object.assign(ModalBase, {
Header: ModalHeader,
});
// ----------------------------------------------------------------------------
// Confirm Component
// ----------------------------------------------------------------------------
export interface ConfirmProps {
open: boolean;
header?: string;
content?: string | React.ReactNode;
confirmButton?: string;
cancelButton?: string;
onConfirm?: () => void;
onCancel?: () => void;
onClose?: () => void;
size?: 'mini' | 'tiny' | 'small' | 'large' | 'fullscreen';
}
export const Confirm: React.FC<ConfirmProps> = ({
open,
header,
content,
confirmButton = 'OK',
cancelButton = 'Cancel',
onConfirm,
onCancel,
onClose,
size = 'tiny',
}) => {
const {i} = useContext(ThemeContext);
return (
<Modal open={open} onClose={onClose} size={size} className="themed-confirm">
{header && <Modal.Header>{header}</Modal.Header>}
<Modal.Content>
{typeof content === 'string' ? <p>{content}</p> : content}
</Modal.Content>
<Modal.Actions>
<Button onClick={onCancel} {...i}>{cancelButton}</Button>
<Button onClick={onConfirm} color="green" {...i}>{confirmButton}</Button>
</Modal.Actions>
</Modal>
);
};
// ----------------------------------------------------------------------------
// Form Compound Component
// ----------------------------------------------------------------------------

View file

@ -90,6 +90,10 @@ export const semanticUIColorMap = {
grey: '#767676',
}
export const ColorToSemanticHexColor = (color) => {
return semanticUIColorMap[color] || null;
}
export const validUrlRegex = /^(http|https):\/\/[^ "]+$/;
export const downloadOrderOptions = [

View file

@ -1,6 +1,6 @@
import React from 'react';
import {Checkbox, Confirm, Container, Dropdown, Form, Icon, Input} from "semantic-ui-react";
import {Button, Header, Loader, Modal, Segment, Table} from "../Theme";
import {Checkbox, Container, Dropdown, Form, Icon, Input} from "semantic-ui-react";
import {Button, Confirm, Header, Loader, Modal, Segment, Table} from "../Theme";
import {APIButton, HotspotToggle, ThrottleToggle, Toggle,} from "../Common";
import {useDockerized} from "../../hooks/customHooks";
import {Media} from "../../contexts/contexts";