11import { ActionTriggerView } from "@/components/ActionTriggerView"
22import { ActionCard } from "@/components/cards/ActionCard"
33import { Aurora } from "@/components/ui/Aurora"
4- import { HapticButtonLink } from "@/components/ui/HapticButtonLink"
54import { LandingContainer } from "@/components/ui/LandingContainer"
65import { LinkButton } from "@/components/ui/LinkButton"
76import { getPageLocaleAndSlug , type LocaleSlugPageParams } from "@/lib/appRoute"
8- import { extractFunctionDefsFromJson , extractTriggersFromJson , fetchMediaJson } from "@/lib/actionTriggerExtraction "
7+ import { extractFlowTypesFromJson , extractFunctionDefinitionsFromJson , fetchMediaJson } from "@/lib/actionExtraction "
98import { getActionBySlug , getLandingPage } from "@/lib/cms"
10- import { getMediaUrl } from "@/lib/media"
119import { findPageBlock } from "@/lib/pageBlocks"
1210import { createMetadata } from "@/lib/siteConfig"
1311import { getIcon } from "@/components/IconRenderer"
1412import type { Media } from "@/payload-types"
15- import { IconArrowLeft , IconExternalLink } from "@tabler/icons-react"
13+ import { IconArrowLeft } from "@tabler/icons-react"
1614import type { Metadata } from "next"
17- import Image from "next/image"
1815import { notFound } from "next/navigation"
1916
2017export default async function ActionDetailPage ( { params } : { params : LocaleSlugPageParams } ) {
@@ -23,25 +20,27 @@ export default async function ActionDetailPage({ params }: { params: LocaleSlugP
2320 if ( ! action ) notFound ( )
2421 const actionsPage = await getLandingPage ( "actions" , locale )
2522
26- const icon = action . icon as Media | undefined
27- const iconUrl = getMediaUrl ( icon ?. url )
28- const triggers = action . trigger as Media | undefined
29- const functionDefs = action . functiondefinitions as Media | undefined
30- const [ extractedTriggers , extractedFunctionDefs ] = await Promise . all ( [ fetchMediaJson ( triggers ) , fetchMediaJson ( functionDefs ) ] )
31- . then ( ( [ triggerJson , functionDefJson ] ) => [ extractTriggersFromJson ( triggerJson ) , extractFunctionDefsFromJson ( functionDefJson ) ] as const )
32- . catch ( ( ) => [ [ ] , [ ] ] as const )
33- const triggerItems = extractedTriggers . map ( ( item ) => ( {
23+ const module = action . module as Media | undefined
24+ const moduleJson = await fetchMediaJson ( module ) . catch ( ( ) => null )
25+ const extractedFlowTypes = extractFlowTypesFromJson ( moduleJson )
26+ const extractedFunctionDefinitions = extractFunctionDefinitionsFromJson ( moduleJson )
27+ const flowTypeItems = extractedFlowTypes . map ( ( item ) => ( {
3428 item,
3529 icon : getIcon ( item . displayIcon , 32 ) ,
3630 } ) )
37- const functionDefItems = extractedFunctionDefs . map ( ( item ) => ( {
31+ const functionDefinitionItems = extractedFunctionDefinitions . map ( ( item ) => ( {
3832 item,
39- icon : getIcon ( "function" , 32 ) ,
33+ icon : getIcon ( item . displayIcon ?? "function" , 32 ) ,
4034 } ) )
4135 const references = ( action . references ?? [ ] ) . filter ( ( reference ) : reference is Exclude < typeof reference , number > => typeof reference !== "number" )
4236 const tags = ( action . tags ?? [ ] ) . filter ( ( tag ) : tag is string => Boolean ( tag ) )
4337 const actionsBlock = findPageBlock ( actionsPage , "actions" )
4438 const referencesLabel = actionsBlock ?. referencesLabel ?? ( locale === "de" ? "Referenzen" : "References" )
39+ const emptyDefinitionLabels = {
40+ flowTypes : actionsBlock ?. noFlowTypesFoundLabel ?? ( locale === "de" ? "Keine FlowTypes gefunden." : "No flow types found." ) ,
41+ functionDefinitions : actionsBlock ?. noFunctionDefinitionsFoundLabel ?? ( locale === "de" ? "Keine FunctionDefinitions gefunden." : "No function definitions found." ) ,
42+ both : actionsBlock ?. noActionDefinitionsFoundLabel ?? ( locale === "de" ? "Keine FlowTypes oder FunctionDefinitions gefunden." : "No flow types or function definitions found." ) ,
43+ }
4544
4645 return (
4746 < >
@@ -57,9 +56,9 @@ export default async function ActionDetailPage({ params }: { params: LocaleSlugP
5756 < div className = "relative z-10 flex flex-col gap-8" >
5857 < div className = "flex flex-col gap-4 sm:flex-row sm:justify-between" >
5958 < div className = "flex flex-col gap-6 sm:flex-row sm:items-start" >
60- { iconUrl && (
61- < div className = "relative size-20 shrink-0 overflow-hidden rounded-3xl border border-white/10 bg-light" >
62- < Image src = { iconUrl } alt = { icon ?. alt ?? action . title } fill sizes = "80px" className = "object-contain p-2" />
59+ { action . icon && (
60+ < div className = "flex size-20 shrink-0 items-center justify-center overflow-hidden rounded-3xl border border-white/10 bg-light text-white " >
61+ { getIcon ( action . icon , 40 ) }
6362 </ div >
6463 ) }
6564
@@ -76,17 +75,10 @@ export default async function ActionDetailPage({ params }: { params: LocaleSlugP
7675 ) }
7776 </ div >
7877 </ div >
79-
80- { action . documentation ?. label && action . documentation ?. url && (
81- < HapticButtonLink href = { action . documentation . url } variant = "normal" className = "text-sm!" >
82- < IconExternalLink size = { 16 } />
83- { action . documentation . label }
84- </ HapticButtonLink >
85- ) }
8678 </ div >
8779 { action . description && < div className = "max-w-3xl whitespace-pre-line text-sm leading-6 text-secondary" > { action . description } </ div > }
8880
89- < ActionTriggerView locale = { locale } triggers = { triggerItems } functionDefs = { functionDefItems } />
81+ < ActionTriggerView locale = { locale } flowTypes = { flowTypeItems } functionDefinitions = { functionDefinitionItems } emptyLabels = { emptyDefinitionLabels } />
9082
9183 { references . length > 0 && (
9284 < div className = "space-y-3" >
0 commit comments