From 129dd0ffcc4747b2d6fed6b73c761792ad253fc0 Mon Sep 17 00:00:00 2001 From: GlitchGal Date: Wed, 11 Sep 2024 03:56:17 +0200 Subject: [PATCH] ImageDetailPanel Patch Component (#5245) --- .../Images/ImageDetails/ImageDetailPanel.tsx | 232 +++++++++--------- ui/v2.5/src/docs/en/Manual/UIPluginApi.md | 1 + 2 files changed, 119 insertions(+), 114 deletions(-) diff --git a/ui/v2.5/src/components/Images/ImageDetails/ImageDetailPanel.tsx b/ui/v2.5/src/components/Images/ImageDetails/ImageDetailPanel.tsx index 65cce87de64..a2044fcffe4 100644 --- a/ui/v2.5/src/components/Images/ImageDetails/ImageDetailPanel.tsx +++ b/ui/v2.5/src/components/Images/ImageDetails/ImageDetailPanel.tsx @@ -6,131 +6,135 @@ import { PerformerCard } from "src/components/Performers/PerformerCard"; import { sortPerformers } from "src/core/performers"; import { FormattedMessage, useIntl } from "react-intl"; import { PhotographerLink } from "src/components/Shared/Link"; +import { PatchComponent } from "../../../patch"; interface IImageDetailProps { image: GQL.ImageDataFragment; } -export const ImageDetailPanel: React.FC = (props) => { - const intl = useIntl(); +export const ImageDetailPanel: React.FC = PatchComponent( + "ImageDetailPanel", + (props) => { + const intl = useIntl(); - function renderDetails() { - if (!props.image.details) return; - return ( - <> -
- :{" "} -
-

{props.image.details}

- - ); - } + function renderDetails() { + if (!props.image.details) return; + return ( + <> +
+ :{" "} +
+

{props.image.details}

+ + ); + } - function renderTags() { - if (props.image.tags.length === 0) return; - const tags = props.image.tags.map((tag) => ( - - )); - return ( - <> -
- -
- {tags} - - ); - } + function renderTags() { + if (props.image.tags.length === 0) return; + const tags = props.image.tags.map((tag) => ( + + )); + return ( + <> +
+ +
+ {tags} + + ); + } - function renderPerformers() { - if (props.image.performers.length === 0) return; - const performers = sortPerformers(props.image.performers); - const cards = performers.map((performer) => ( - - )); + function renderPerformers() { + if (props.image.performers.length === 0) return; + const performers = sortPerformers(props.image.performers); + const cards = performers.map((performer) => ( + + )); - return ( - <> -
- -
-
- {cards} -
- - ); - } + return ( + <> +
+ +
+
+ {cards} +
+ + ); + } + + function renderGalleries() { + if (props.image.galleries.length === 0) return; + const galleries = props.image.galleries.map((gallery) => ( + + )); + return ( + <> +
+ +
+ {galleries} + + ); + } + + // filename should use entire row if there is no studio + const imageDetailsWidth = props.image.studio ? "col-9" : "col-12"; - function renderGalleries() { - if (props.image.galleries.length === 0) return; - const galleries = props.image.galleries.map((gallery) => ( - - )); return ( <> -
- -
- {galleries} +
+
+ {renderGalleries()} + { +
+ {" "} + :{" "} + {TextUtils.formatDateTime(intl, props.image.created_at)}{" "} +
+ } + { +
+ :{" "} + {TextUtils.formatDateTime(intl, props.image.updated_at)}{" "} +
+ } + {props.image.code && ( +
+ : {props.image.code}{" "} +
+ )} + {props.image.photographer && ( +
+ :{" "} + +
+ )} +
+
+
+
+ {renderDetails()} + {renderTags()} + {renderPerformers()} +
+
); } - - // filename should use entire row if there is no studio - const imageDetailsWidth = props.image.studio ? "col-9" : "col-12"; - - return ( - <> -
-
- {renderGalleries()} - { -
- {" "} - :{" "} - {TextUtils.formatDateTime(intl, props.image.created_at)}{" "} -
- } - { -
- :{" "} - {TextUtils.formatDateTime(intl, props.image.updated_at)}{" "} -
- } - {props.image.code && ( -
- : {props.image.code}{" "} -
- )} - {props.image.photographer && ( -
- :{" "} - -
- )} -
-
-
-
- {renderDetails()} - {renderTags()} - {renderPerformers()} -
-
- - ); -}; +); diff --git a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md index 1357e86cc28..7d267d1b1e9 100644 --- a/ui/v2.5/src/docs/en/Manual/UIPluginApi.md +++ b/ui/v2.5/src/docs/en/Manual/UIPluginApi.md @@ -151,6 +151,7 @@ Returns `void`. - `GallerySelect` - `GallerySelect.sort` - `Icon` +- `ImageDetailPanel` - `ModalSetting` - `MovieIDSelect` - `MovieSelect`