diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 7cff58f7..46568505 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -21,7 +21,7 @@ import { useSettings } from "@api/settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { LazyComponent } from "@utils/misc"; -import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; +import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; import { proxyLazy } from "@utils/proxyLazy"; import { OptionType, Plugin } from "@utils/types"; import { findByCode, findByPropsLazy } from "@webpack"; @@ -84,6 +84,8 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti const canSubmit = () => Object.values(errors).every(e => !e); + const hasSettings = Boolean(pluginSettings && plugin.options); + React.useEffect(() => { (async () => { for (const user of plugin.authors.slice(0, 6)) { @@ -121,33 +123,33 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti } function renderSettings() { - if (!pluginSettings || !plugin.options) { + if (!hasSettings || !plugin.options) { return There are no settings for this plugin.; + } else { + const options = Object.entries(plugin.options).map(([key, setting]) => { + function onChange(newValue: any) { + setTempSettings(s => ({ ...s, [key]: newValue })); + } + + function onError(hasError: boolean) { + setErrors(e => ({ ...e, [key]: hasError })); + } + + const Component = Components[setting.type]; + return ( + + ); + }); + + return {options}; } - - const options = Object.entries(plugin.options).map(([key, setting]) => { - function onChange(newValue: any) { - setTempSettings(s => ({ ...s, [key]: newValue })); - } - - function onError(hasError: boolean) { - setErrors(e => ({ ...e, [key]: hasError })); - } - - const Component = Components[setting.type]; - return ( - - ); - }); - - return {options}; } function renderMoreUsers(_label: string, count: number) { @@ -172,14 +174,16 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti return ( - - {plugin.name} + + {plugin.name} + About {plugin.name} {plugin.description} - + Authors + - + {hasSettings && Cancel @@ -233,7 +238,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti {saveError && Error while saving: {saveError}} - + } ); } diff --git a/src/plugins/viewRaw.tsx b/src/plugins/viewRaw.tsx index c49180b8..fc7a42a0 100644 --- a/src/plugins/viewRaw.tsx +++ b/src/plugins/viewRaw.tsx @@ -21,9 +21,9 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; import { copyWithToast } from "@utils/misc"; -import { closeModal, ModalCloseButton, ModalContent, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin from "@utils/types"; -import { Button, ChannelStore, Forms, Margins, Parser } from "@webpack/common"; +import { Button, ChannelStore, Forms, Margins, Parser, Text } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -89,30 +89,33 @@ function openViewRawModal(msg: Message) { - View Raw + View Raw closeModal(key)} /> - - - copyWithToast(msg.content, "Content copied to clipboard!")}> - Copy Raw Content - + + + {!!msg.content && ( + <> + Content + + + > + )} + + Message Data + + + + + copyWithToast(msgJson, "Message data copied to clipboard!")}> Copy Message JSON + copyWithToast(msg.content, "Content copied to clipboard!")}> + Copy Raw Content + - - {!!msg.content && ( - <> - Content - - - > - )} - - Message Data - - + )); diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx index 0a5fd7d5..2ee2d5d2 100644 --- a/src/webpack/common.tsx +++ b/src/webpack/common.tsx @@ -207,7 +207,7 @@ export type TextProps = React.PropsWithChildren & { className?: string; }; -export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code"; +export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code"; type RC = React.ComponentType>>; interface Menu {