()
| 15 | import { pluginToFiles } from "../../../components/ScriptEditor"; |
| 16 | |
| 17 | export function ViewPlugin() { |
| 18 | const session = useSession() |
| 19 | let { value: plugin } = useFetchedDataBehindGuard(pluginContext); |
| 20 | if (!plugin) { |
| 21 | throw new Error("plugin value was null") |
| 22 | } |
| 23 | |
| 24 | const bannerImage = plugin.images.find(v => v.kind === "Banner") |
| 25 | const showcaseImages = plugin.images.filter(v => v.kind === "Showcase") |
| 26 | |
| 27 | return <Container> |
| 28 | <Paper sx={{ marginTop: 1 }}> |
| 29 | |
| 30 | {bannerImage && <img |
| 31 | alt="plugin uploaded banner" |
| 32 | src={pluginImageUrl(plugin.id, bannerImage.image_id)} |
| 33 | style={{ |
| 34 | width: "100%", |
| 35 | maxHeight: "194px", |
| 36 | objectFit: "cover", |
| 37 | }} |
| 38 | />} |
| 39 | <Box sx={{ padding: 2 }}> |
| 40 | |
| 41 | <Stack direction={"row"} alignItems={"center"} spacing={1}> |
| 42 | <PluginIcon plugin={plugin} /> |
| 43 | <Typography variant="h4">{plugin.name}</Typography> |
| 44 | <Chip label={`${plugin.installed_guilds ?? "?"} Server` + (plugin.installed_guilds !== 1 ? "s" : "")} color="primary" variant="outlined" icon={<TimelineIcon />} /> |
| 45 | </Stack> |
| 46 | |
| 47 | <Stack direction={"row"} alignItems="center" spacing={1} mt={1} mb={1}> |
| 48 | <Avatar alt={plugin.author?.username} sx={{ width: 32, height: 32 }} src={userAvatarUrl(plugin.author!, 64)} /> |
| 49 | <Typography>{plugin.author?.username}</Typography> |
| 50 | {plugin.author?.is_bl_staff ? <Chip label="Staff" size="small" variant="outlined" /> : null} |
| 51 | </Stack> |
| 52 | |
| 53 | <Divider /> |
| 54 | |
| 55 | <Typography mb={2} mt={2}>{plugin.short_description}</Typography> |
| 56 | {plugin.author?.is_bl_staff ? null : <Alert severity="warning">This plugin is from a community member, you should only add plugins from people you trust.</Alert>} |
| 57 | |
| 58 | <AddPluginToServerButton plugin={plugin} /> |
| 59 | |
| 60 | <ReactMarkdown>{plugin.long_description}</ReactMarkdown> |
| 61 | |
| 62 | <Divider /> |
| 63 | |
| 64 | <Box display={"flex"} alignItems={"center"}> |
| 65 | <Typography>{plugin.published_version_updated_at && |
| 66 | <>updated <DisplayRelativeDateTime dt={plugin.published_version_updated_at} /></> |
| 67 | }</Typography> |
| 68 | {session.user?.id === plugin.author_id ? <BlLink to={`/user/plugins/${plugin.id}/`}>Edit</BlLink> : null} |
| 69 | <BlLink to={`/plugins/${plugin.id}/source`}>View source</BlLink> |
| 70 | </Box> |
| 71 | |
| 72 | <Divider /> |
| 73 | {showcaseImages.length > 0 |
| 74 | ? <> |
nothing calls this directly
no test coverage detected