Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(data-warehouse): add buttons to copy table and field names #23919

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions frontend/src/lib/components/DatabaseTableTree/TreeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IconChevronDown, IconEllipsis } from '@posthog/icons'
import { LemonButton, Spinner } from '@posthog/lemon-ui'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { useCallback, useState } from 'react'

import { DatabaseSchemaTable } from '~/queries/schema'
Expand All @@ -13,10 +14,17 @@ export interface TreeRowProps {
selected?: boolean
}

export function TreeRow({ item, selected }: TreeRowProps): JSX.Element {
export function TreeRow({ item }: TreeRowProps): JSX.Element {
return (
<li>
<LemonButton size="xsmall" fullWidth active={selected} icon={item.icon ? <>{item.icon}</> : null}>
<LemonButton
onClick={() => {
void copyToClipboard(item.name, item.name)
}}
size="xsmall"
fullWidth
icon={item.icon ? <>{item.icon}</> : null}
>
<span className="flex-1 flex justify-between">
<span className="truncate">{item.name}</span>
<span className="whitespace-nowrap">{item.type}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { clsx } from 'clsx'
import { BindLogic, useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { DatabaseTableTree, TreeItem } from 'lib/components/DatabaseTableTree/DatabaseTableTree'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { useState } from 'react'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
Expand Down Expand Up @@ -97,6 +98,15 @@ export const DatabaseTableTreeWithItems = ({ inline }: DatabaseTableTreeProps):

const dropdownOverlay = (table: DatabaseSchemaTable): JSX.Element => (
<>
<LemonButton
onClick={() => {
void copyToClipboard(table.name, table.name)
}}
fullWidth
data-attr="schema-list-item-copy"
>
Copy table name
</LemonButton>
<LemonButton
onClick={() => {
selectRow(table)
Expand Down
Loading