11import React , { useEffect , useState } from "react"
2- import { Text , Box , HStack , Badge , VStack , Select , Spinner } from "@chakra-ui/react" ;
2+ import { Text , Box , HStack , Badge , VStack , Spinner , Menu , MenuButton , MenuList , MenuItem , Button , Icon } from "@chakra-ui/react" ;
3+ import { BiChevronDown , BiCheck , BiTime , BiBuildings , BiGroup } from "react-icons/bi" ;
34import { getParsedIframeInfo } from "../../helpers/origin"
45import { useSelector } from 'react-redux' ;
56import { RootState } from '../../state/store' ;
67import { dispatch } from '../../state/dispatch' ;
78import { setSelectedAssetId } from '../../state/settings/reducer' ;
9+ import { Notify } from '../common/Notify' ;
10+ import { CodeBlock } from '../common/CodeBlock' ;
811
912export const TeamContext : React . FC = ( ) => {
1013 const tool = getParsedIframeInfo ( ) . tool
@@ -38,38 +41,83 @@ export const TeamContext: React.FC = () => {
3841
3942 { /* Asset Selection Section */ }
4043 < VStack align = "stretch" spacing = { 4 } mb = { 4 } >
41- < Text fontSize = "md" fontWeight = "semibold" color = "minusxBW.800" >
42- Organization Asset Selection
43- </ Text >
44-
45- < Box >
46- < HStack justify = "space-between" align = "center" mb = { 3 } >
47- < Text fontSize = "sm" color = "minusxBW.800" >
48- Select Asset:
49- </ Text >
50- { assetsLoading ? (
44+ < VStack align = "stretch" spacing = { 2 } >
45+ { assetsLoading ? (
46+ < Box textAlign = "center" >
5147 < Spinner size = "sm" color = "minusxGreen.500" />
52- ) : availableAssets . length > 0 ? (
53- < Select
54- value = { selectedAssetId || availableAssets [ 0 ] . slug }
55- onChange = { ( e ) => handleAssetSelection ( e . target . value ) }
48+ </ Box >
49+ ) : availableAssets . length > 0 ? (
50+ < Menu >
51+ < MenuButton
52+ as = { Button }
53+ rightIcon = { < BiChevronDown /> }
5654 size = "sm"
57- maxWidth = "300px"
55+ width = "100%"
56+ bg = "white"
57+ border = "1px solid"
58+ borderColor = "gray.200"
5859 color = "minusxBW.800"
60+ _hover = { {
61+ bg : "gray.50" ,
62+ borderColor : "gray.300"
63+ } }
64+ _active = { {
65+ bg : "gray.100" ,
66+ borderColor : "gray.400"
67+ } }
68+ fontWeight = "normal"
69+ textAlign = "left"
70+ justifyContent = "space-between"
71+ >
72+ { selectedAsset ?. name || availableAssets [ 0 ] ?. name }
73+ </ MenuButton >
74+ < MenuList
75+ bg = "white"
76+ border = "1px solid"
77+ borderColor = "gray.200"
78+ boxShadow = "lg"
79+ borderRadius = "md"
80+ py = { 1 }
81+ width = { "100%" }
5982 >
6083 { availableAssets . map ( ( asset ) => (
61- < option key = { asset . slug } value = { asset . slug } >
62- { asset . name }
63- </ option >
84+ < MenuItem
85+ key = { asset . slug }
86+ onClick = { ( ) => handleAssetSelection ( asset . slug ) }
87+ bg = "white"
88+ _hover = { {
89+ bg : "gray.50"
90+ } }
91+ _focus = { {
92+ bg : "gray.50"
93+ } }
94+ py = { 2 }
95+ px = { 3 }
96+ color = "minusxBW.800"
97+ fontSize = "sm"
98+ display = "flex"
99+ justifyContent = "space-between"
100+ alignItems = "center"
101+ width = { "100%" }
102+ >
103+ < Text > { asset . name } </ Text >
104+ { ( selectedAssetId || availableAssets [ 0 ] . slug ) === asset . slug && (
105+ < Icon
106+ as = { BiCheck }
107+ boxSize = { 4 }
108+ color = "minusxGreen.500"
109+ />
110+ ) }
111+ </ MenuItem >
64112 ) ) }
65- </ Select >
66- ) : (
67- < Text fontSize = "sm" color = "gray.500" >
68- No assets available
69- </ Text >
70- ) }
71- </ HStack >
72- </ Box >
113+ </ MenuList >
114+ </ Menu >
115+ ) : (
116+ < Text fontSize = "sm" color = "gray.500" >
117+ No assets available
118+ </ Text >
119+ ) }
120+ </ VStack >
73121
74122 { /* Selected Asset Details */ }
75123 { selectedAsset && (
@@ -85,38 +133,30 @@ export const TeamContext: React.FC = () => {
85133 { selectedAsset . name }
86134 </ Text >
87135
88- < HStack spacing = { 2 } >
89- < Badge colorScheme = "blue " variant = "subtle" >
136+ < HStack spacing = { 2 } wrap = "wrap" >
137+ < Badge colorScheme = "gray " variant = "subtle" >
90138 { selectedAsset . type }
91139 </ Badge >
92- < Badge colorScheme = "green" variant = "subtle" >
93- { selectedAsset . permission }
140+ < Badge variant = "subtle" colorScheme = "gray" >
141+ < HStack spacing = { 2 } >
142+ < Icon as = { BiGroup } boxSize = { 3 } />
143+ < Text fontSize = "xs" > { selectedAsset . team_slug } </ Text >
144+ </ HStack >
145+ </ Badge >
146+ < Badge variant = "subtle" colorScheme = "gray" >
147+ < HStack spacing = { 2 } >
148+ < Icon as = { BiBuildings } boxSize = { 3 } />
149+ < Text fontSize = "xs" > { selectedAsset . company_slug } </ Text >
150+ </ HStack >
151+ </ Badge >
152+ < Badge variant = "subtle" colorScheme = "gray" >
153+ < HStack spacing = { 2 } >
154+ < Icon as = { BiTime } boxSize = { 3 } />
155+ < Text fontSize = "xs" > { new Date ( selectedAsset . updated_at ) . toLocaleDateString ( ) } </ Text >
156+ </ HStack >
94157 </ Badge >
95158 </ HStack >
96159
97- < VStack align = "stretch" spacing = { 2 } >
98- < HStack justify = "space-between" >
99- < Text fontSize = "sm" fontWeight = "medium" color = "gray.700" > Team:</ Text >
100- < Text fontSize = "sm" color = "gray.600" > { selectedAsset . team_slug } </ Text >
101- </ HStack >
102- < HStack justify = "space-between" >
103- < Text fontSize = "sm" fontWeight = "medium" color = "gray.700" > Company:</ Text >
104- < Text fontSize = "sm" color = "gray.600" > { selectedAsset . company_slug } </ Text >
105- </ HStack >
106- < HStack justify = "space-between" >
107- < Text fontSize = "sm" fontWeight = "medium" color = "gray.700" > Created:</ Text >
108- < Text fontSize = "sm" color = "gray.600" >
109- { new Date ( selectedAsset . created_at ) . toLocaleDateString ( ) }
110- </ Text >
111- </ HStack >
112- < HStack justify = "space-between" >
113- < Text fontSize = "sm" fontWeight = "medium" color = "gray.700" > Updated:</ Text >
114- < Text fontSize = "sm" color = "gray.600" >
115- { new Date ( selectedAsset . updated_at ) . toLocaleDateString ( ) }
116- </ Text >
117- </ HStack >
118- </ VStack >
119-
120160 < AssetContentDisplay asset = { selectedAsset } />
121161 </ VStack >
122162 </ Box >
@@ -204,42 +244,26 @@ const AssetContentDisplay: React.FC<{ asset: any }> = ({ asset }) => {
204244 } else {
205245 // For other types, display full content as JSON
206246 return (
207- < Box
208- bg = "gray.900"
209- p = { 3 }
210- borderRadius = "md"
211- border = "1px solid"
212- borderColor = "gray.300"
213- maxHeight = "400px"
214- overflowY = "auto"
215- >
216- < Text
217- fontSize = "xs"
218- color = "green.300"
219- fontFamily = "mono"
220- whiteSpace = "pre-wrap"
221- lineHeight = "1.4"
222- >
223- { JSON . stringify ( asset . content , null , 2 ) }
224- </ Text >
225- </ Box >
247+ < CodeBlock
248+ code = { JSON . stringify ( asset . content , null , 2 ) }
249+ tool = "json"
250+ language = "json"
251+ />
226252 ) ;
227253 }
228254 } ;
229255
230256 return (
231257 < VStack align = "stretch" spacing = { 2 } >
232- < Box bg = "blue.50" p = { 3 } borderRadius = "md" border = "1px solid" borderColor = "blue.200" >
233- < Text fontSize = "xs" color = "blue.700" fontWeight = "medium" mb = { 1 } >
234- Enhanced Context
235- </ Text >
236- < Text fontSize = "xs" color = "blue.600" lineHeight = "1.4" >
237- This asset's context will be included in AI requests to provide more relevant
238- and accurate responses based on your organization's specific information.
239- </ Text >
240- </ Box >
241-
242258 { renderContent ( ) }
259+
260+ < Notify
261+ title = "Team Context"
262+ notificationType = "info"
263+ >
264+ This asset's context will be included in AI requests to provide more relevant
265+ and accurate responses based on your organization's specific information.
266+ </ Notify >
243267 </ VStack >
244268 ) ;
245269} ;
0 commit comments