Skip to content

Commit

Permalink
refactor(dashboard): minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bryson-g committed Dec 18, 2024
1 parent 23978fe commit f987030
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { VARIABLE_TYPES } from '@/app/constants'
import { getVariableValue } from '@/app/utils'
import { ThreadVarDef, Variable, WfRunVariableAccessLevel } from 'littlehorse-client/proto'
import { FC } from 'react'
import { OverflowText } from '../../../../components/Overflow'
import { OverflowText } from '../../../../components/OverflowText'

type VariablesProps = {
variableDefs: ThreadVarDef[]
Expand Down
13 changes: 6 additions & 7 deletions dashboard/src/app/[tenantId]/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { FC, useState } from 'react'
import { Button } from '@/components/ui/button'
import { Check, Copy } from 'lucide-react'
Expand All @@ -11,17 +12,15 @@ interface CopyButtonProps {
export const CopyButton: FC<CopyButtonProps> = ({ value, className }) => {
const [copied, setCopied] = useState(false)

const handleCopy = () => {
navigator.clipboard.writeText(value)
setCopied(true)
setTimeout(() => setCopied(false), 1000)
}

return (
<Button
variant="ghost"
size="icon"
onClick={handleCopy}
onClick={() => {
navigator.clipboard.writeText(value)
setCopied(true)
setTimeout(() => setCopied(false), 1000)
}}
className={cn(className)}
>
{copied ? (
Expand Down
8 changes: 8 additions & 0 deletions dashboard/src/app/utils/tryFormatAsJson.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function tryFormatAsJson(text: string): string {
try {
const parsed = JSON.parse(text)
return JSON.stringify(parsed, null, 4)
} catch {
return text
}
}

0 comments on commit f987030

Please sign in to comment.