mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 01:46:18 -05:00
Replacing Semantic Confirm with custom confirm to have themeing and mobile support.
This commit is contained in:
parent
2b0b161dad
commit
c55c8e24c9
6 changed files with 62 additions and 14 deletions
|
|
@ -197,6 +197,11 @@ textarea.otp {
|
|||
color: #DDDDDD !important;
|
||||
}
|
||||
|
||||
/* Mobile-responsive Confirm modal */
|
||||
.ui.modal.themed-confirm {
|
||||
max-width: 95vw;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue