11import { MoreHorizontal , Pencil , TrashIcon } from 'lucide-react'
2- import { useState } from 'react'
2+ import React , { useState } from 'react'
33import { toast } from 'sonner'
4-
54import { useFlag , useParams } from 'common'
65import AlertError from 'components/ui/AlertError'
7- import CardButton from 'components/ui/CardButton'
8- import Panel from 'components/ui/Panel'
96import { useDeleteLogDrainMutation } from 'data/log-drains/delete-log-drain-mutation'
107import { LogDrainData , useLogDrainsQuery } from 'data/log-drains/log-drains-query'
118import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'
@@ -21,11 +18,15 @@ import {
2118 TableHead ,
2219 TableHeader ,
2320 TableRow ,
21+ Card ,
22+ cn ,
2423} from 'ui'
2524import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
2625import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
2726import { LOG_DRAIN_TYPES , LogDrainType } from './LogDrains.constants'
2827import { LogDrainsEmpty } from './LogDrainsEmpty'
28+ import { LogDrainsCard } from './LogDrainsCard'
29+ import { VoteLink } from './VoteLink'
2930
3031export function LogDrains ( {
3132 onNewDrainClick,
@@ -81,19 +82,23 @@ export function LogDrains({
8182
8283 if ( ! isLoading && ! hasLogDrains ) {
8384 return (
84- < div className = "grid lg:grid-cols-2 gap-3" >
85- { LOG_DRAIN_TYPES . filter ( ( t ) => t . value !== 'sentry' || sentryEnabled ) . map ( ( src ) => (
86- < CardButton
87- key = { src . value }
88- title = { src . name }
89- description = { src . description }
90- icon = { src . icon }
91- onClick = { ( ) => {
92- onNewDrainClick ( src . value )
93- } }
94- />
95- ) ) }
96- </ div >
85+ < >
86+ < div className = "grid lg:grid-cols-2 gap-4" >
87+ { LOG_DRAIN_TYPES . filter ( ( t ) => t . value !== 'sentry' || sentryEnabled ) . map ( ( src ) => (
88+ < LogDrainsCard
89+ key = { src . value }
90+ title = { src . name }
91+ description = { src . description }
92+ icon = { src . icon }
93+ rightLabel = "Additional $60"
94+ onClick = { ( ) => {
95+ onNewDrainClick ( src . value )
96+ } }
97+ />
98+ ) ) }
99+ </ div >
100+ < VoteLink />
101+ </ >
97102 )
98103 }
99104
@@ -103,63 +108,80 @@ export function LogDrains({
103108
104109 return (
105110 < >
106- < Panel className = "" >
111+ < Card >
107112 < Table >
108113 < TableHeader >
109114 < TableRow >
110115 < TableHead className = "max-w-[200px]" > Name</ TableHead >
111- < TableHead > Description</ TableHead >
112- < TableHead className = "text-right " > Destination</ TableHead >
116+ < TableHead className = "w-96" > Description</ TableHead >
117+ < TableHead className = "w-48 " > Destination</ TableHead >
113118 < TableHead className = "text-right" >
114119 < div className = "sr-only" > Actions</ div >
115120 </ TableHead >
116121 </ TableRow >
117122 </ TableHeader >
118123 < TableBody >
119- { logDrains ?. map ( ( drain ) => (
120- < TableRow key = { drain . id } >
121- < TableCell className = "font-medium truncate max-w-72" title = { drain . name } >
122- { drain . name }
123- </ TableCell >
124- < TableCell
125- className = "text-foreground-light truncate max-w-72"
126- title = { drain . description }
127- >
128- { drain . description }
129- </ TableCell >
130- < TableCell className = "text-right font-mono" > { drain . type } </ TableCell >
131- < TableCell className = "text-right" >
132- < DropdownMenu >
133- < DropdownMenuTrigger asChild >
134- < Button
135- type = "text"
136- className = "px-1 opacity-50 hover:opacity-100 !bg-transparent"
137- icon = { < MoreHorizontal /> }
138- />
139- </ DropdownMenuTrigger >
140- < DropdownMenuContent className = "max-w-[140px]" align = "end" >
141- < DropdownMenuItem
142- onClick = { ( ) => {
143- onUpdateDrainClick ( drain )
144- } }
145- >
146- < Pencil className = "h-4 w-4 mr-2" />
147- Update
148- </ DropdownMenuItem >
149- < DropdownMenuItem
150- onClick = { ( ) => {
151- setSelectedLogDrain ( drain )
152- setIsDeleteModalOpen ( true )
153- } }
154- >
155- < TrashIcon className = "h-4 w-4 mr-2" />
156- Delete
157- </ DropdownMenuItem >
158- </ DropdownMenuContent >
159- </ DropdownMenu >
160- </ TableCell >
161- </ TableRow >
162- ) ) }
124+ { logDrains
125+ ?. slice ( )
126+ . sort ( ( a , b ) => b . id - a . id )
127+ . map ( ( drain ) => (
128+ < TableRow key = { drain . id } >
129+ < TableCell className = "font-medium truncate max-w-72" title = { drain . name } >
130+ { drain . name }
131+ </ TableCell >
132+ < TableCell
133+ className = { cn (
134+ 'truncate max-w-96' ,
135+ drain . description ? 'text-foreground-light' : 'text-foreground-muted'
136+ ) }
137+ title = { drain . description }
138+ >
139+ { drain . description || '-' }
140+ </ TableCell >
141+ < TableCell className = "text-foreground-light" >
142+ < div className = "flex items-center gap-2" >
143+ { React . cloneElement (
144+ LOG_DRAIN_TYPES . find ( ( t ) => t . value === drain . type )
145+ ?. icon as React . ReactElement ,
146+ { width : 16 , height : 16 }
147+ ) }
148+ < span className = "truncate max-w-40" >
149+ { LOG_DRAIN_TYPES . find ( ( t ) => t . value === drain . type ) ?. name }
150+ </ span >
151+ </ div >
152+ </ TableCell >
153+ < TableCell className = "text-right" >
154+ < DropdownMenu >
155+ < DropdownMenuTrigger asChild >
156+ < Button
157+ type = "text"
158+ className = "px-1 opacity-50 hover:opacity-100 !bg-transparent flex-shrink-0"
159+ icon = { < MoreHorizontal /> }
160+ />
161+ </ DropdownMenuTrigger >
162+ < DropdownMenuContent className = "max-w-[140px]" align = "end" >
163+ < DropdownMenuItem
164+ onClick = { ( ) => {
165+ onUpdateDrainClick ( drain )
166+ } }
167+ >
168+ < Pencil className = "h-4 w-4 mr-2" />
169+ Update
170+ </ DropdownMenuItem >
171+ < DropdownMenuItem
172+ onClick = { ( ) => {
173+ setSelectedLogDrain ( drain )
174+ setIsDeleteModalOpen ( true )
175+ } }
176+ >
177+ < TrashIcon className = "h-4 w-4 mr-2" />
178+ Delete
179+ </ DropdownMenuItem >
180+ </ DropdownMenuContent >
181+ </ DropdownMenu >
182+ </ TableCell >
183+ </ TableRow >
184+ ) ) }
163185 </ TableBody >
164186
165187 < ConfirmationModal
@@ -183,7 +205,7 @@ export function LogDrains({
183205 </ div >
184206 </ ConfirmationModal >
185207 </ Table >
186- </ Panel >
208+ </ Card >
187209 </ >
188210 )
189211}
0 commit comments