import {
faClock,
faCloudUploadAlt,
faDownload,
faRecycle,
faTrash,
faUser,
} from "@fortawesome/free-solid-svg-icons";
import {
FontAwesomeIcon,
FontAwesomeIconProps,
} from "@fortawesome/react-fontawesome";
import { isNull, isUndefined } from "lodash";
import React, { FunctionComponent, useMemo } from "react";
import {
OverlayTrigger,
OverlayTriggerProps,
Popover,
Spinner,
SpinnerProps,
} from "react-bootstrap";
enum HistoryAction {
Delete = 0,
Download,
Manual,
Upgrade,
Upload,
Sync,
}
export const HistoryIcon: FunctionComponent<{
action: number;
title?: string;
}> = (props) => {
const { action, title } = props;
let icon = null;
switch (action) {
case HistoryAction.Delete:
icon = faTrash;
break;
case HistoryAction.Download:
icon = faDownload;
break;
case HistoryAction.Manual:
icon = faUser;
break;
case HistoryAction.Sync:
icon = faClock;
break;
case HistoryAction.Upgrade:
icon = faRecycle;
break;
case HistoryAction.Upload:
icon = faCloudUploadAlt;
break;
}
if (icon) {
return ;
} else {
return null;
}
};
interface MessageIconProps extends FontAwesomeIconProps {
messages: string[];
}
export const MessageIcon: FunctionComponent = (props) => {
const { messages, ...iconProps } = props;
const popover = (
{messages.map((m) => (
{m}
))}
);
return (
);
};
export const LoadingIndicator: FunctionComponent<{
animation?: SpinnerProps["animation"];
}> = ({ children, animation: style }) => {
return (
{children}
);
};
interface LanguageTextProps {
text: Language.Info;
className?: string;
long?: boolean;
}
export const LanguageText: FunctionComponent = ({
text,
className,
long,
}) => {
const result = useMemo(() => {
let lang = text.code2;
let hi = ":HI";
let forced = ":Forced";
if (long) {
lang = text.name;
hi = " HI";
forced = " Forced";
}
let res = lang;
if (text.hi) {
res += hi;
} else if (text.forced) {
res += forced;
}
return res;
}, [text, long]);
return (
{result}
);
};
interface TextPopoverProps {
children: React.ReactElement;
text: string | undefined | null;
placement?: OverlayTriggerProps["placement"];
delay?: number;
}
export const TextPopover: FunctionComponent = ({
children,
text,
placement,
delay,
}) => {
if (isNull(text) || isUndefined(text)) {
return children;
}
const popover = (
{text}
);
return (
{children}
);
};
export * from "./async";
export * from "./buttons";
export * from "./ContentHeader";
export * from "./inputs";
export * from "./LanguageSelector";
export * from "./modals";
export * from "./SearchBar";
export * from "./tables";