Skip to content

Commit 5a0e1cb

Browse files
feat(studio): log drains entry point from logs (supabase#40095)
* fix: field reference button padding * fix: remove overriding button style on field ref button * fix: tidy up the asChild stuff on side panel trigger element * fix: bunch of type errors on logs sidebar Theres a temp any fix in there dont kill me frontend team :D * feat: add to new logs sidebar too * feat: add to download dropdown menus * chore: alphabetical order on new logs dropdown * chore: add target blank to sheet footer * fix: gap between buttons on old logs toolbar * feat: add a separator on old logs * style: new logs top buttons correct types
1 parent d23f08e commit 5a0e1cb

File tree

12 files changed

+76
-24
lines changed

12 files changed

+76
-24
lines changed

apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ export function LogDrainDestinationSheetForm({
612612
<span>See full pricing breakdown</span>{' '}
613613
<Link
614614
href={`${DOCS_URL}/guides/platform/manage-your-usage/log-drains`}
615+
target="_blank"
615616
className="text-foreground underline underline-offset-2 decoration-foreground-muted hover:decoration-foreground transition-all"
616617
>
617618
here

apps/studio/components/interfaces/Settings/Logs/LogsQueryPanel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ const LogsQueryPanel = ({
206206
hideFooter
207207
triggerElement={
208208
<Button
209-
asChild // ?: we don't want a button inside a button
210209
type="text"
211210
onClick={() => setShowReference(true)}
212211
icon={<BookOpen />}

apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ const PreviewFilterPanel = ({
9494
return (
9595
<div
9696
className={cn(
97-
'flex w-full items-center justify-between',
97+
'flex w-full items-center justify-between overflow-x-scroll no-scrollbar',
9898
condensedLayout ? ' p-3' : '',
9999
className
100100
)}
101101
>
102-
<div className="flex flex-row items-center gap-x-2">
102+
<div className="flex flex-row items-center gap-x-2 mr-2">
103103
<form
104104
id="log-panel-search"
105105
onSubmit={(e) => {

apps/studio/components/interfaces/UnifiedLogs/components/DownloadLogsButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import saveAs from 'file-saver'
22
import { Download } from 'lucide-react'
3+
import Link from 'next/link'
34
import Papa from 'papaparse'
45
import { useEffect, useState } from 'react'
56
import { toast } from 'sonner'
@@ -91,13 +92,18 @@ export const DownloadLogsButton = ({ searchParameters }: DownloadLogsButtonProps
9192
<DropdownMenu>
9293
<DropdownMenuTrigger>
9394
<ButtonTooltip
94-
type="outline"
95+
type="default"
9596
className="w-[26px]"
9697
icon={<Download className="text-foreground" />}
9798
tooltip={{ content: { side: 'bottom', text: 'Download logs' } }}
9899
/>
99100
</DropdownMenuTrigger>
100101
<DropdownMenuContent align="end" className="w-36">
102+
<DropdownMenuItem asChild className="gap-x-2">
103+
<Link href={`/project/${ref}/settings/log-drains`}>
104+
<p>Add a Log Drain</p>
105+
</Link>
106+
</DropdownMenuItem>
101107
<DropdownMenuItem onClick={() => setSelectedFormat('csv')}>
102108
<p>Download as CSV</p>
103109
</DropdownMenuItem>

apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ChevronRight, CircleHelpIcon, Plus } from 'lucide-react'
22
import Link from 'next/link'
33
import { useRouter } from 'next/router'
4-
import { useState } from 'react'
4+
import React, { useState } from 'react'
55

66
import { IS_PLATFORM, useFlag, useParams } from 'common'
77
import {
@@ -32,6 +32,7 @@ import {
3232
} from 'ui-patterns/InnerSideMenu'
3333
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
3434
import { FeaturePreviewSidebarPanel } from '../../ui/FeaturePreviewSidebarPanel'
35+
import { LOG_DRAIN_TYPES } from 'components/interfaces/LogDrains/LogDrains.constants'
3536

3637
const SupaIcon = ({ className }: { className?: string }) => {
3738
return (
@@ -230,7 +231,7 @@ export function LogsSidebarMenuV2() {
230231
})
231232

232233
return (
233-
<div className="pb-12 relative">
234+
<div className="pb-4 relative">
234235
{IS_PLATFORM && !unifiedLogsFlagEnabled && (
235236
<FeaturePreviewSidebarPanel
236237
className="mx-4 mt-4"
@@ -316,14 +317,14 @@ export function LogsSidebarMenuV2() {
316317
<>
317318
<SidebarCollapsible title="Collections" defaultOpen={true}>
318319
{filteredLogs.map((collection) => {
319-
const isItemActive = isActive(collection.url)
320+
const isItemActive = isActive(collection?.url ?? '')
320321
return (
321322
<LogsSidebarItem
322-
key={collection.key}
323+
key={collection?.key ?? ''}
323324
isActive={isItemActive}
324-
href={collection.url}
325+
href={collection?.url ?? ''}
325326
icon={<SupaIcon className="text-foreground-light" />}
326-
label={collection.name}
327+
label={collection?.name ?? ''}
327328
/>
328329
)
329330
})}
@@ -366,9 +367,29 @@ export function LogsSidebarMenuV2() {
366367
/>
367368
)}
368369
{savedQueries.map((query) => (
369-
<SavedQueriesItem item={query} key={query.id} />
370+
<SavedQueriesItem item={query as any} key={query.id} /> // kemal: i know, i know, temp any fix.
370371
))}
371372
</SidebarCollapsible>
373+
374+
<Separator className="my-4" />
375+
376+
<FeaturePreviewSidebarPanel
377+
className="mx-4 mt-4"
378+
title="Capture your logs"
379+
description="Send logs to your preferred observability or storage platform."
380+
illustration={
381+
<div className="flex items-center gap-4">
382+
{LOG_DRAIN_TYPES.map((type) =>
383+
React.cloneElement(type.icon, { height: 20, width: 20 })
384+
)}
385+
</div>
386+
}
387+
actions={
388+
<Button asChild type="default">
389+
<Link href={`/project/${ref}/settings/log-drains`}>Go to Log Drains</Link>
390+
</Button>
391+
}
392+
/>
372393
</div>
373394
)
374395
}

apps/studio/components/ui/DataTable/DataTableToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function DataTableToolbar({ renderActions }: DataTableToolbarProps) {
3737
<TooltipTrigger asChild>
3838
<Button
3939
size="tiny"
40-
type="outline"
40+
type="default"
4141
icon={open ? <PanelLeftClose /> : <PanelLeftOpen />}
4242
onClick={() => setOpen((prev) => !prev)}
4343
className="hidden sm:flex"

apps/studio/components/ui/DataTable/DataTableViewOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function DataTableViewOptions() {
3737
<Popover open={open} onOpenChange={setOpen}>
3838
<PopoverTrigger asChild>
3939
<ButtonTooltip
40-
type="outline"
40+
type="default"
4141
size="tiny"
4242
role="combobox"
4343
aria-expanded={open}

apps/studio/components/ui/DataTable/FilterSideBar.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { DateRangeDisabled } from './DataTable.types'
88
import { DataTableFilterControls } from './DataTableFilters/DataTableFilterControls'
99
import { DataTableResetButton } from './DataTableResetButton'
1010
import { useDataTable } from './providers/DataTableProvider'
11+
import Link from 'next/link'
12+
import { LOG_DRAIN_TYPES } from 'components/interfaces/LogDrains/LogDrains.constants'
13+
import React from 'react'
1114

1215
interface FilterSideBarProps {
1316
dateRangeDisabled?: DateRangeDisabled
@@ -60,6 +63,23 @@ export function FilterSideBar({ dateRangeDisabled }: FilterSideBarProps) {
6063
/>
6164
)}
6265
<DataTableFilterControls dateRangeDisabled={dateRangeDisabled} />
66+
<FeaturePreviewSidebarPanel
67+
className="mx-2 my-4"
68+
title="Capture your logs"
69+
description="Send logs to your preferred observability or storage platform."
70+
illustration={
71+
<div className="flex items-center gap-4">
72+
{LOG_DRAIN_TYPES.map((type) =>
73+
React.cloneElement(type.icon, { height: 20, width: 20 })
74+
)}
75+
</div>
76+
}
77+
actions={
78+
<Button asChild type="default">
79+
<Link href={`/project/${ref}/settings/log-drains`}>Go to Log Drains</Link>
80+
</Button>
81+
}
82+
/>
6383
</div>
6484
</ResizablePanel>
6585
)

apps/studio/components/ui/DataTable/RefreshButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const RefreshButton = ({ isLoading, onRefresh }: RefreshButtonProps) => {
1010
return (
1111
<ButtonTooltip
1212
size="tiny"
13-
type="outline"
13+
type="default"
1414
disabled={isLoading}
1515
onClick={onRefresh}
1616
className="w-[26px]"

apps/studio/components/ui/DownloadResultsButton.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import saveAs from 'file-saver'
2-
import { ChevronDown, Copy, Download } from 'lucide-react'
2+
import { ChevronDown, Copy, Download, Settings } from 'lucide-react'
33
import { markdownTable } from 'markdown-table'
44
import Papa from 'papaparse'
55
import { useMemo } from 'react'
66
import { toast } from 'sonner'
7+
import Link from 'next/link'
8+
import { useParams } from 'common'
79

810
import {
911
Button,
@@ -37,6 +39,7 @@ export const DownloadResultsButton = ({
3739
onCopyAsMarkdown,
3840
onCopyAsJSON,
3941
}: DownloadResultsButtonProps) => {
42+
const { ref } = useParams()
4043
// [Joshen] Ensure JSON values are stringified for CSV and Markdown
4144
const formattedResults = results.map((row) => {
4245
const r = { ...row }
@@ -106,9 +109,11 @@ export const DownloadResultsButton = ({
106109
</Button>
107110
</DropdownMenuTrigger>
108111
<DropdownMenuContent align={align} className="w-44">
109-
<DropdownMenuItem className="gap-x-2" onClick={() => downloadAsCSV()}>
110-
<Download size={14} />
111-
<p>Download CSV</p>
112+
<DropdownMenuItem asChild className="gap-x-2">
113+
<Link href={`/project/${ref}/settings/log-drains`}>
114+
<Settings size={14} />
115+
<p>Add a Log Drain</p>
116+
</Link>
112117
</DropdownMenuItem>
113118
<DropdownMenuItem onClick={copyAsMarkdown} className="gap-x-2">
114119
<Copy size={14} />
@@ -118,6 +123,10 @@ export const DownloadResultsButton = ({
118123
<Copy size={14} />
119124
<p>Copy as JSON</p>
120125
</DropdownMenuItem>
126+
<DropdownMenuItem className="gap-x-2" onClick={() => downloadAsCSV()}>
127+
<Download size={14} />
128+
<p>Download CSV</p>
129+
</DropdownMenuItem>
121130
</DropdownMenuContent>
122131
</DropdownMenu>
123132
)

0 commit comments

Comments
 (0)