Decor: add copy preset id button (#2737)
Co-authored-by: v <vendicated@riseup.net>
This commit is contained in:
parent
d47be6c017
commit
2382294e8b
1 changed files with 18 additions and 5 deletions
|
@ -8,7 +8,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { openInviteModal } from "@utils/discord";
|
import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes, copyWithToast } from "@utils/misc";
|
||||||
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCodeLazy } from "@webpack";
|
||||||
import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
|
import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
|
||||||
|
@ -45,7 +45,11 @@ interface Section {
|
||||||
authorIds?: string[];
|
authorIds?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function SectionHeader({ section }: { section: Section; }) {
|
interface SectionHeaderProps {
|
||||||
|
section: Section;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SectionHeader({ section }: SectionHeaderProps) {
|
||||||
const hasSubtitle = typeof section.subtitle !== "undefined";
|
const hasSubtitle = typeof section.subtitle !== "undefined";
|
||||||
const hasAuthorIds = typeof section.authorIds !== "undefined";
|
const hasAuthorIds = typeof section.authorIds !== "undefined";
|
||||||
|
|
||||||
|
@ -62,6 +66,7 @@ function SectionHeader({ section }: { section: Section; }) {
|
||||||
})();
|
})();
|
||||||
}, [section.authorIds]);
|
}, [section.authorIds]);
|
||||||
|
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<Flex>
|
<Flex>
|
||||||
<Forms.FormTitle style={{ flexGrow: 1 }}>{section.title}</Forms.FormTitle>
|
<Forms.FormTitle style={{ flexGrow: 1 }}>{section.title}</Forms.FormTitle>
|
||||||
|
@ -74,8 +79,7 @@ function SectionHeader({ section }: { section: Section; }) {
|
||||||
size={16}
|
size={16}
|
||||||
showUserPopout
|
showUserPopout
|
||||||
className={Margins.bottom8}
|
className={Margins.bottom8}
|
||||||
/>
|
/>}
|
||||||
}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
{hasSubtitle &&
|
{hasSubtitle &&
|
||||||
<Forms.FormText type="description" className={Margins.bottom8}>
|
<Forms.FormText type="description" className={Margins.bottom8}>
|
||||||
|
@ -204,7 +208,16 @@ function ChangeDecorationModal(props: ModalProps) {
|
||||||
{activeSelectedDecoration?.alt}
|
{activeSelectedDecoration?.alt}
|
||||||
</Text>
|
</Text>
|
||||||
}
|
}
|
||||||
{activeDecorationHasAuthor && <Text key={`createdBy-${activeSelectedDecoration.authorId}`}>Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}</Text>}
|
{activeDecorationHasAuthor && (
|
||||||
|
<Text key={`createdBy-${activeSelectedDecoration.authorId}`}>
|
||||||
|
Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
{isActiveDecorationPreset && (
|
||||||
|
<Button onClick={() => copyWithToast(activeDecorationPreset.id)}>
|
||||||
|
Copy Preset ID
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
Loading…
Reference in a new issue