Skip to content

Commit

Permalink
Merge pull request #366 from duyet/feat/overview
Browse files Browse the repository at this point in the history
chore: CodeDialog format support custom className
  • Loading branch information
duyet authored Sep 25, 2024
2 parents 91592ec + 02106a8 commit e7a27d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
27 changes: 21 additions & 6 deletions components/data-table/cells/code-dialog-format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import {
DialogTrigger,
} from '@/components/ui/dialog'
import { formatQuery } from '@/lib/format-readable'
import { cn } from '@/lib/utils'
import { DialogDescription, DialogTitle } from '@radix-ui/react-dialog'
import { SizeIcon } from '@radix-ui/react-icons'

export interface CodeDialogOptions {
dialog_title?: string
dialog_description?: string
trigger_classname?: string
max_truncate?: number
hide_query_comment?: boolean
json?: boolean
dialog_classname?: string
}

interface CodeDialogFormatProps {
Expand Down Expand Up @@ -54,13 +57,25 @@ export function CodeDialogFormat({ value, options }: CodeDialogFormatProps) {

return (
<Dialog>
<DialogTrigger className="flex flex-row items-center gap-1">
<code className="truncate break-words font-normal" role="shorten-code">
{formatted}
</code>
<SizeIcon className="size-4" role="open-dialog" />
<DialogTrigger asChild>
<div
className={cn(
'flex max-w-fit cursor-pointer flex-row items-center gap-1'
)}
>
<code
className={cn(
'break-words font-normal',
options?.trigger_classname
)}
role="shorten-code"
>
{formatted}
</code>
<SizeIcon className="size-4 flex-none" role="open-dialog" />
</div>
</DialogTrigger>
<DialogContent className="max-w-fit">
<DialogContent className={cn('max-w-fit', options?.dialog_classname)}>
{(options?.dialog_title || options?.dialog_description) && (
<DialogHeader>
<DialogTitle>{options.dialog_title}</DialogTitle>
Expand Down
4 changes: 2 additions & 2 deletions lib/clickhouse-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function applyInterval(
interval === 'toStartOfWeek' ||
interval === 'toStartOfDay'
) {
return `toDate(${interval}(${column})) as ${alias || column}`
return `toDate(${interval}(${column})) AS ${alias || column}`
}

return `${interval}(${column}) as ${alias || column}`
return `${interval}(${column}) AS ${alias || column}`
}

1 comment on commit e7a27d5

@vercel
Copy link

@vercel vercel bot commented on e7a27d5 Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.