@@ -7,6 +7,7 @@ import { buildReactFlow, type ReactFlowGraph } from '@/utils/stateGraph';
77import { StateGraph , StateGraphNode } from '@/clients/layers/types' ;
88import type { ParsedTerraformPlan } from '@/utils/terraformPlan' ;
99import { augmentStateGraphWithPlan } from '@/utils/terraformPlan' ;
10+ import { twMerge } from 'tailwind-merge' ;
1011
1112export interface LayerStateGraphProps {
1213 variant ?: 'light' | 'dark' ;
@@ -48,11 +49,21 @@ const LayerStateGraph: React.FC<LayerStateGraphProps> = ({
4849 setGraph ( augmentedGraph ) ;
4950 buildReactFlow ( augmentedGraph ) . then ( ( res ) => {
5051 if ( cancelled ) return ;
52+ const withVariant = {
53+ nodes : res . nodes . map ( ( node ) => ( {
54+ ...node ,
55+ data : {
56+ ...node . data ,
57+ variant
58+ }
59+ } ) ) ,
60+ edges : res . edges
61+ } ;
5162 if ( ! plan ) {
52- setRf ( res ) ;
63+ setRf ( withVariant ) ;
5364 return ;
5465 }
55- const nodesWithPlan = res . nodes . map ( ( node ) => {
66+ const nodesWithPlan = withVariant . nodes . map ( ( node ) => {
5667 const exact = plan . byAddr . get ( node . id ) ;
5768 const base = plan . byBase . get ( node . id ) ;
5869 const change = exact ?. action ?? base ?. action ?? null ;
@@ -75,27 +86,31 @@ const LayerStateGraph: React.FC<LayerStateGraphProps> = ({
7586 }
7687 } ;
7788 } ) ;
78- setRf ( { nodes : nodesWithPlan , edges : res . edges } ) ;
89+ setRf ( { nodes : nodesWithPlan , edges : withVariant . edges } ) ;
7990 } ) ;
8091 return ( ) => {
8192 cancelled = true ;
8293 } ;
83- } , [ augmentedGraph , plan ] ) ;
94+ } , [ augmentedGraph , plan , variant ] ) ;
8495
8596 const hasGraphData = ( graph ?. nodes ?. length ?? 0 ) > 0 ;
97+ const infoTextClass =
98+ variant === 'light' ? 'text-slate-500' : 'text-nuances-200' ;
99+ const errorTextClass =
100+ variant === 'light' ? 'text-red-500' : 'text-red-400' ;
86101
87102 if ( layerQuery . isLoading ) {
88103 return (
89104 < div className = "flex items-center justify-center h-full p-4" >
90- < div className = "text-slate-500" > Loading layer...</ div >
105+ < div className = { twMerge ( infoTextClass ) } > Loading layer...</ div >
91106 </ div >
92107 ) ;
93108 }
94109
95110 if ( layerQuery . isError ) {
96111 return (
97112 < div className = "flex items-center justify-center h-full p-4" >
98- < div className = "text-red-500" >
113+ < div className = { twMerge ( errorTextClass ) } >
99114 Error loading layer: { ( layerQuery . error as Error ) . message }
100115 </ div >
101116 </ div >
@@ -105,7 +120,7 @@ const LayerStateGraph: React.FC<LayerStateGraphProps> = ({
105120 if ( ! hasGraphData && ( stateGraphQuery . isLoading || planLoading ) ) {
106121 return (
107122 < div className = "flex items-center justify-center h-full p-4" >
108- < div className = "text-slate-500" > Loading state graph...</ div >
123+ < div className = { twMerge ( infoTextClass ) } > Loading state graph...</ div >
109124 </ div >
110125 ) ;
111126 }
@@ -118,7 +133,7 @@ const LayerStateGraph: React.FC<LayerStateGraphProps> = ({
118133 ) {
119134 return (
120135 < div className = "flex items-center justify-center h-full p-4" >
121- < div className = "text-slate-500" >
136+ < div className = { twMerge ( infoTextClass ) } >
122137 No state graph available for this layer
123138 </ div >
124139 </ div >
@@ -128,7 +143,7 @@ const LayerStateGraph: React.FC<LayerStateGraphProps> = ({
128143 if ( ! hasGraphData || rf . nodes . length === 0 ) {
129144 return (
130145 < div className = "flex items-center justify-center h-full p-4" >
131- < div className = "text-slate-500" >
146+ < div className = { twMerge ( infoTextClass ) } >
132147 No state graph data available for this layer
133148 </ div >
134149 </ div >
0 commit comments