From 7e7df6907282a8adf588774ea837cc24c02e6250 Mon Sep 17 00:00:00 2001 From: Dinmukhamed Mailibay <47117969+dinmukhamedm@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:25:55 -0700 Subject: [PATCH 1/6] upgrade next-auth to fix dependabot alert (#131) --- frontend/package.json | 2 +- frontend/pnpm-lock.yaml | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 1d81f292..da98e802 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -70,7 +70,7 @@ "jsonwebtoken": "^9.0.2", "lucide-react": "^0.323.0", "next": "14.2.15", - "next-auth": "4.24.5", + "next-auth": "4.24.10", "next-themes": "^0.2.1", "postgres": "^3.4.4", "posthog-js": "^1.174.0", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 8822fbef..95aaf365 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -177,8 +177,8 @@ importers: specifier: 14.2.15 version: 14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-auth: - specifier: 4.24.5 - version: 4.24.5(next@14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: 4.24.10 + version: 4.24.10(next@14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-themes: specifier: ^0.2.1 version: 0.2.1(next@14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -3096,10 +3096,6 @@ packages: convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} - engines: {node: '>= 0.6'} - cookie@0.7.2: resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} @@ -4579,14 +4575,17 @@ packages: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} - next-auth@4.24.5: - resolution: {integrity: sha512-3RafV3XbfIKk6rF6GlLE4/KxjTcuMCifqrmD+98ejFq73SRoj2rmzoca8u764977lH/Q7jo6Xu6yM+Re1Mz/Og==} + next-auth@4.24.10: + resolution: {integrity: sha512-8NGqiRO1GXBcVfV8tbbGcUgQkAGsX4GRzzXXea4lDikAsJtD5KiEY34bfhUOjHLvr6rT6afpcxw2H8EZqOV6aQ==} peerDependencies: - next: ^12.2.5 || ^13 || ^14 + '@auth/core': 0.34.2 + next: ^12.2.5 || ^13 || ^14 || ^15 nodemailer: ^6.6.5 react: ^17.0.2 || ^18 react-dom: ^17.0.2 || ^18 peerDependenciesMeta: + '@auth/core': + optional: true nodemailer: optional: true @@ -9053,8 +9052,6 @@ snapshots: convert-source-map@2.0.0: {} - cookie@0.5.0: {} - cookie@0.7.2: {} core-js@3.38.1: {} @@ -10872,11 +10869,11 @@ snapshots: negotiator@0.6.3: {} - next-auth@4.24.5(next@14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next-auth@4.24.10(next@14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.25.7 '@panva/hkdf': 1.2.1 - cookie: 0.5.0 + cookie: 0.7.2 jose: 4.15.9 next: 14.2.15(@babel/core@7.24.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) oauth: 0.9.15 From c23cd2c45c00d0c4ce80c815b5ec64c3a5237c68 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Choudha <115736674+lucky29-git@users.noreply.github.com> Date: Sat, 2 Nov 2024 02:07:43 +0530 Subject: [PATCH 2/6] Improve responsiveness of project cards (#132) --- frontend/components/projects/projects.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/components/projects/projects.tsx b/frontend/components/projects/projects.tsx index 67e45701..38e10d13 100644 --- a/frontend/components/projects/projects.tsx +++ b/frontend/components/projects/projects.tsx @@ -45,7 +45,7 @@ export default function Projects({ isWorkspaceEnabled }: ProjectsProps) { {[...Array(5).keys()].map((_, index) => (
-
+
@@ -67,7 +67,7 @@ export default function Projects({ isWorkspaceEnabled }: ProjectsProps) {
)} {workspace.projects.length > 0 && ( -
+
{workspace.projects.map((project) => ( ))} From c9461ad3971b0e098e67f3a0df272fca632f20fe Mon Sep 17 00:00:00 2001 From: Chandrashekhar Choudha <115736674+lucky29-git@users.noreply.github.com> Date: Sat, 2 Nov 2024 02:54:47 +0530 Subject: [PATCH 3/6] replaced all Loader to Loader2 (#133) --- frontend/components/dataset/dataset-panel.tsx | 2 +- frontend/components/dataset/dataset-upload.tsx | 4 ++-- frontend/components/dataset/delete-datapoints-dialog.tsx | 4 ++-- frontend/components/dataset/index-dataset-dialog.tsx | 4 ++-- frontend/components/dataset/manual-add-datapoint-dialog.tsx | 4 ++-- frontend/components/dataset/unstructured-file-upload.tsx | 4 ++-- frontend/components/datasets/create-dataset-dialog.tsx | 4 ++-- frontend/components/datasets/datasets.tsx | 2 +- frontend/components/datasets/update-dataset-dialog.tsx | 4 ++-- .../components/evaluations/create-evaluation-dialog.tsx | 4 ++-- frontend/components/event/edit-event-template-dialog.tsx | 4 ++-- frontend/components/events/create-event-template-dialog.tsx | 4 ++-- frontend/components/pipeline/commit-button.tsx | 4 ++-- frontend/components/pipeline/delete-version-button.tsx | 4 ++-- frontend/components/pipeline/deploy-button.tsx | 4 ++-- frontend/components/pipeline/fork-button.tsx | 4 ++-- frontend/components/pipeline/overwrite-workshop-button.tsx | 4 ++-- frontend/components/pipeline/stream-trace.tsx | 4 ++-- frontend/components/pipeline/target-version.tsx | 4 ++-- frontend/components/pipelines/create-pipeline-dialog.tsx | 4 ++-- frontend/components/pipelines/update-pipeline-dialog.tsx | 4 ++-- frontend/components/projects/project-create-dialog.tsx | 4 ++-- frontend/components/projects/workspace-create-dialog.tsx | 4 ++-- frontend/components/settings/delete-project.tsx | 4 ++-- frontend/components/settings/revoke-dialog.tsx | 4 ++-- frontend/components/traces/export-spans-dialog.tsx | 4 ++-- frontend/components/traces/log-export-dialog.tsx | 4 ++-- frontend/components/ui/pipeline-select.tsx | 6 +++--- frontend/components/workspace/workspace-users.tsx | 4 ++-- 29 files changed, 57 insertions(+), 57 deletions(-) diff --git a/frontend/components/dataset/dataset-panel.tsx b/frontend/components/dataset/dataset-panel.tsx index 915fd8d5..c584aa8b 100644 --- a/frontend/components/dataset/dataset-panel.tsx +++ b/frontend/components/dataset/dataset-panel.tsx @@ -1,5 +1,5 @@ import { useProjectContext } from '@/contexts/project-context'; -import { ChevronsRight, Loader, Loader2 } from 'lucide-react'; +import { ChevronsRight, Loader2 } from 'lucide-react'; import { Skeleton } from '../ui/skeleton'; import { Label } from '../ui/label'; import { ScrollArea } from '../ui/scroll-area'; diff --git a/frontend/components/dataset/dataset-upload.tsx b/frontend/components/dataset/dataset-upload.tsx index 9a327adf..0dee0d9d 100644 --- a/frontend/components/dataset/dataset-upload.tsx +++ b/frontend/components/dataset/dataset-upload.tsx @@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { uploadFile } from '@/lib/dataset/utils'; import { useToast } from '@/lib/hooks/use-toast'; -import { Loader } from 'lucide-react'; +import { Loader2 } from 'lucide-react'; interface DatasetUploadProps { datasetId: string; @@ -31,7 +31,7 @@ export default function DatasetUpload({ className="mt-4 w-32" onClick={() => hiddenInput.current?.click()} > - {isLoading && } + {isLoading && } Select file - {isLoading && } + {isLoading && } Delete diff --git a/frontend/components/dataset/index-dataset-dialog.tsx b/frontend/components/dataset/index-dataset-dialog.tsx index ec18fcb5..ead7e304 100644 --- a/frontend/components/dataset/index-dataset-dialog.tsx +++ b/frontend/components/dataset/index-dataset-dialog.tsx @@ -10,7 +10,7 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Loader, NotepadText } from 'lucide-react'; +import { Loader2, NotepadText } from 'lucide-react'; import { useProjectContext } from '@/contexts/project-context'; import { Label } from '@/components/ui/label'; import { Input } from '../ui/input'; @@ -102,7 +102,7 @@ export default function IndexDatasetDialog({ onClick={async () => await indexDataset()} handleEnter > - {isLoading && } + {isLoading && } Index diff --git a/frontend/components/dataset/manual-add-datapoint-dialog.tsx b/frontend/components/dataset/manual-add-datapoint-dialog.tsx index c4b4f11e..6208f6da 100644 --- a/frontend/components/dataset/manual-add-datapoint-dialog.tsx +++ b/frontend/components/dataset/manual-add-datapoint-dialog.tsx @@ -10,7 +10,7 @@ import { DialogTrigger } from '../ui/dialog'; import { Button } from '../ui/button'; -import { Loader } from 'lucide-react'; +import { Loader2 } from 'lucide-react'; import CodeEditor from '../ui/code-editor'; const DEFAULT_DATA = '{\n "data": {},\n "target": {}\n}'; @@ -99,7 +99,7 @@ export default function ManualAddDatapointDialog({ disabled={isLoading} onClick={async () => await addDatapoint()} > - {isLoading && } + {isLoading && } Add datapoint diff --git a/frontend/components/dataset/unstructured-file-upload.tsx b/frontend/components/dataset/unstructured-file-upload.tsx index 4e4bea7f..7760e8c7 100644 --- a/frontend/components/dataset/unstructured-file-upload.tsx +++ b/frontend/components/dataset/unstructured-file-upload.tsx @@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { uploadFile } from '@/lib/dataset/utils'; import { useToast } from '@/lib/hooks/use-toast'; -import { Loader } from 'lucide-react'; +import { Loader2 } from 'lucide-react'; interface UnstructuredFileUploadProps { datasetId: string; @@ -37,7 +37,7 @@ export default function UnstructuredFileUpload({ className="mt-4 w-32" onClick={() => hiddenInput.current?.click()} > - {isLoading && } + {isLoading && } Select file - - - diff --git a/frontend/components/pipeline/delete-version-button.tsx b/frontend/components/pipeline/delete-version-button.tsx index 51a15e35..9ab305ae 100644 --- a/frontend/components/pipeline/delete-version-button.tsx +++ b/frontend/components/pipeline/delete-version-button.tsx @@ -1,6 +1,6 @@ import { useContext, useState } from 'react'; import { ProjectContext } from '@/contexts/project-context'; -import { Loader, MoreVertical, Trash2 } from 'lucide-react'; +import { Loader2, MoreVertical, Trash2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Dialog, @@ -100,7 +100,7 @@ export default function DeletePipelineVersionButton({ disabled={deleteVersionInputText != selectedPipelineVersion.name} onClick={deletePipelineVersion} > - - {isDeploying && } + {isDeploying && } Deploy diff --git a/frontend/components/pipeline/fork-button.tsx b/frontend/components/pipeline/fork-button.tsx index fa6a6fc0..f7a7193b 100644 --- a/frontend/components/pipeline/fork-button.tsx +++ b/frontend/components/pipeline/fork-button.tsx @@ -12,7 +12,7 @@ import { } from '@/components/ui/dialog'; import { Label } from '../ui/label'; import { Input } from '../ui/input'; -import { Loader, GitFork } from 'lucide-react'; +import { Loader2, GitFork } from 'lucide-react'; import { PipelineVersionInfo } from '@/lib/pipeline/types'; import { useRouter } from 'next/navigation'; import { useProjectContext } from '@/contexts/project-context'; @@ -109,7 +109,7 @@ export default function ForkButton({ handleEnter={true} onClick={forkPipelineVersion} > - {isLoading && } + {isLoading && } Fork diff --git a/frontend/components/pipeline/overwrite-workshop-button.tsx b/frontend/components/pipeline/overwrite-workshop-button.tsx index 8868da97..30c01e75 100644 --- a/frontend/components/pipeline/overwrite-workshop-button.tsx +++ b/frontend/components/pipeline/overwrite-workshop-button.tsx @@ -11,7 +11,7 @@ import { DialogTrigger } from '@/components/ui/dialog'; import { Label } from '../ui/label'; -import { Loader, Pencil, ShieldQuestion } from 'lucide-react'; +import { Loader2, Pencil, ShieldQuestion } from 'lucide-react'; import { PipelineVersionInfo } from '@/lib/pipeline/types'; import { useProjectContext } from '@/contexts/project-context'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; @@ -93,7 +93,7 @@ export default function OverwriteWorkshopButton({ Cancel diff --git a/frontend/components/pipeline/stream-trace.tsx b/frontend/components/pipeline/stream-trace.tsx index 39e30cd9..3c6c4cab 100644 --- a/frontend/components/pipeline/stream-trace.tsx +++ b/frontend/components/pipeline/stream-trace.tsx @@ -14,7 +14,7 @@ import { Clock3, Coins, FastForward, - Loader, + Loader2, Play } from 'lucide-react'; import { StreamMessage } from './pipeline-outputs'; @@ -334,7 +334,7 @@ function StreamTraceCard({
{showSpinner && (
- diff --git a/frontend/components/pipeline/target-version.tsx b/frontend/components/pipeline/target-version.tsx index 23384443..c8250630 100644 --- a/frontend/components/pipeline/target-version.tsx +++ b/frontend/components/pipeline/target-version.tsx @@ -11,7 +11,7 @@ import { DialogTrigger } from '@/components/ui/dialog'; import { Label } from '../ui/label'; -import { Loader, Pencil, ShieldQuestion } from 'lucide-react'; +import { Loader2, Pencil, ShieldQuestion } from 'lucide-react'; import { PipelineVersionInfo } from '@/lib/pipeline/types'; import { useProjectContext } from '@/contexts/project-context'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; @@ -93,7 +93,7 @@ export default function SetTargetVersionButton({ Cancel diff --git a/frontend/components/pipelines/create-pipeline-dialog.tsx b/frontend/components/pipelines/create-pipeline-dialog.tsx index aeb97751..63f14603 100644 --- a/frontend/components/pipelines/create-pipeline-dialog.tsx +++ b/frontend/components/pipelines/create-pipeline-dialog.tsx @@ -14,7 +14,7 @@ import { Input } from '@/components/ui/input'; import { useEffect, useState } from 'react'; import { useProjectContext } from '@/contexts/project-context'; import { useRouter } from 'next/navigation'; -import { Loader, Plus } from 'lucide-react'; +import { Loader2, Plus } from 'lucide-react'; import { cn } from '@/lib/utils'; import { TemplateInfo } from '@/lib/pipeline/types'; import { Skeleton } from '../ui/skeleton'; @@ -141,7 +141,7 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { handleEnter={true} disabled={selectedTemplateId === undefined || isLoading} > - - {isCreatingProject && ( - + )} Create diff --git a/frontend/components/projects/workspace-create-dialog.tsx b/frontend/components/projects/workspace-create-dialog.tsx index a84ce4ae..6ca906ef 100644 --- a/frontend/components/projects/workspace-create-dialog.tsx +++ b/frontend/components/projects/workspace-create-dialog.tsx @@ -10,7 +10,7 @@ import { DialogTrigger } from '@/components/ui/dialog'; import { Button } from '../ui/button'; -import { Loader, Plus } from 'lucide-react'; +import { Loader2, Plus } from 'lucide-react'; import { Label } from '../ui/label'; import { Input } from '../ui/input'; @@ -71,7 +71,7 @@ export default function WorkspaceCreateDialog({ disabled={!newWorkspaceName || isCreatingWorkspace} > {isCreatingWorkspace && ( - + )} Create diff --git a/frontend/components/settings/delete-project.tsx b/frontend/components/settings/delete-project.tsx index 168e9484..9c0083a1 100644 --- a/frontend/components/settings/delete-project.tsx +++ b/frontend/components/settings/delete-project.tsx @@ -13,7 +13,7 @@ import { Label } from '../ui/label'; import { Input } from '../ui/input'; import { useState } from 'react'; import { useProjectContext } from '@/contexts/project-context'; -import { Loader, Trash, Trash2 } from 'lucide-react'; +import { Loader2, Trash, Trash2 } from 'lucide-react'; import { cn } from '@/lib/utils'; interface DeleteProjectProps { } @@ -82,7 +82,7 @@ export default function DeleteProject({ }: DeleteProjectProps) { onClick={deleteProject} handleEnter={true} > - - - - void; @@ -148,7 +148,7 @@ export default function PipelineSelect({ className="flex justify-center" disabled={true} > - + ) : ( pipelines!.map((pipeline) => ( @@ -189,7 +189,7 @@ export default function PipelineSelect({ className="flex justify-center" disabled={true} > - + ) : ( diff --git a/frontend/components/workspace/workspace-users.tsx b/frontend/components/workspace/workspace-users.tsx index 6d3abb3a..3bfc4532 100644 --- a/frontend/components/workspace/workspace-users.tsx +++ b/frontend/components/workspace/workspace-users.tsx @@ -9,7 +9,7 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Loader, Plus } from 'lucide-react'; +import { Loader2, Plus } from 'lucide-react'; import { Label } from '../ui/label'; import { Input } from '../ui/input'; import { useCallback, useState } from 'react'; @@ -146,7 +146,7 @@ export default function WorkspaceUsers({ Add {isAddUserLoading && ( - + )} From a3352cd31d951e7fc665c6245e32f7d8b22c8e00 Mon Sep 17 00:00:00 2001 From: skull8888888 Date: Fri, 1 Nov 2024 15:33:27 -0700 Subject: [PATCH 4/6] explicit mapping in labels (#135) * explicit mapping in labels * Update frontend/components/traces/add-label.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- frontend/app/globals.css | 6 +- .../components/evaluator/evaluator-editor.tsx | 2 +- .../components/traces/add-label-popover.tsx | 20 +- frontend/components/traces/add-label.tsx | 171 ++++++++++-------- frontend/components/traces/span-labels.tsx | 4 +- frontend/lib/traces/types.ts | 4 +- 6 files changed, 110 insertions(+), 97 deletions(-) diff --git a/frontend/app/globals.css b/frontend/app/globals.css index 5065b3cf..e06c4e41 100644 --- a/frontend/app/globals.css +++ b/frontend/app/globals.css @@ -48,15 +48,15 @@ --primary-foreground: 16 0% 91%; --secondary: 240 4% 16%; - --secondary-foreground: 0 4% 70%; + --secondary-foreground: 215 16% 65%; --muted: 240 6% 16%; - --muted-foreground: 215 20.2% 65.1%; + --muted-foreground: 215 16% 65%; --accent: 232 9% 17%; --accent-foreground: 210 100% 100%; - --destructive: 0 62.8% 30.6%; + --destructive: 0 60% 50%; --destructive-foreground: 210 40% 98%; --border: 240 6% 18%; diff --git a/frontend/components/evaluator/evaluator-editor.tsx b/frontend/components/evaluator/evaluator-editor.tsx index 0c045d67..5e5867f7 100644 --- a/frontend/components/evaluator/evaluator-editor.tsx +++ b/frontend/components/evaluator/evaluator-editor.tsx @@ -171,7 +171,7 @@ export function EvaluatorEditor({
- {labelClass.valueMap.map((value, index) => ( + {Object.keys(labelClass.valueMap).map((value, index) => (
v === value), + value: labelClass.valueMap[value], source: source, reasoning: reasoning }) @@ -491,15 +479,15 @@ function AddLabelInstance({
- {labelClass.valueMap.map((value, index) => ( + {Object.entries(labelClass.valueMap).map(([key, value], index) => (
{ - addLabel(value, labelClass, LabelSource.MANUAL); + addLabel(key, labelClass, LabelSource.MANUAL); }} className="cursor-pointer hover:bg-secondary-foreground/10 p-1 rounded border px-2" > - {value} + {key}
))} diff --git a/frontend/components/traces/add-label.tsx b/frontend/components/traces/add-label.tsx index 9bcaf629..38df27d3 100644 --- a/frontend/components/traces/add-label.tsx +++ b/frontend/components/traces/add-label.tsx @@ -34,16 +34,15 @@ export function AddLabel({ span, onClose }: AddLabelProps) { name: '', projectId: projectId, createdAt: '', - labelType: LabelType.BOOLEAN, - valueMap: ["false", "true"], + labelType: LabelType.CATEGORICAL, + valueMap: { + "False": 0, + "True": 1 + }, description: null, evaluatorRunnableGraph: null }); - const isLabelValueMapValid = - labelClass.valueMap.length > 0 && - labelClass.valueMap.every((value) => value.length > 0); - const saveLabel = async () => { setIsSaving(true); @@ -76,6 +75,11 @@ export function AddLabel({ span, onClose }: AddLabelProps) { onClose(); }; + const hasDuplicateValues = () => { + const values = Object.values(labelClass.valueMap); + return values.length !== new Set(values).size; + }; + return (
@@ -102,77 +106,98 @@ export function AddLabel({ span, onClose }: AddLabelProps) { onChange={(e) => setLabelClass({ ...labelClass, description: e.target.value }) } - minRows={3} + minRows={1} />
-
- - -
- {selectedType === LabelType.CATEGORICAL && ( -
-
- -
- {labelClass.valueMap.map((value, index) => ( -
- - setLabelClass({ - ...labelClass, - valueMap: labelClass.valueMap.map((value, i) => - i === index ? e.target.value : value - ) - }) - } - /> - +
+
+ + {hasDuplicateValues() && ( +
+ Duplicate numerical values are not allowed
- ))} - + )}
- )} + + + + + + + + + + + {Object.entries(labelClass.valueMap).map(([key, value], i) => ( + + + + + + ))} + +
ValueNumerical
+ + setLabelClass({ + ...labelClass, + valueMap: Object.fromEntries( + Object.entries(labelClass.valueMap).map(([k, v], j) => + j === i ? [e.target.value, v] : [k, v] + ) + ) + }) + } + /> + + { + setLabelClass({ + ...labelClass, + valueMap: Object.fromEntries( + Object.entries(labelClass.valueMap).map(([k, v], j) => + j === i ? [k, parseInt(e.target.value, 10)] : [k, v] + ) + ) + }); + }} + /> + + +
+ +
@@ -214,7 +239,7 @@ export function AddLabel({ span, onClose }: AddLabelProps) { onClick={async () => { await saveLabel(); }} - disabled={!labelClass.name || !isLabelValueMapValid} + disabled={!labelClass.name || Object.keys(labelClass.valueMap).length === 0} > {label.labelSource} - {label.valueMap?.[label.value] ?? ''} + {Object.entries(label.valueMap).find(([k, v]) => v === label.value)?.[0] ?? ''} {label.userEmail} - - - -
-
- +
+ + + + + + + +
+
+ +
+
+ + + + +
- - - -
- -
- { - setExpandedValue(v); - if (mode === 'yaml') { - try { - const parsedYaml = YAML.parse(v); - onChange?.(JSON.stringify(parsedYaml, null, 2)); - } catch (e) { + +
+ { + setExpandedValue(v); + if (mode === 'yaml') { + try { + const parsedYaml = YAML.parse(v); + onChange?.(JSON.stringify(parsedYaml, null, 2)); + } catch (e) { + onChange?.(v); + } + } else { onChange?.(v); } - } else { - onChange?.(v); - } - }} - /> -
-
- - + }} + /> +
+
+ + +
{(!collapsible || !isCollapsed) && ( From a446e9c9ece4f86dfae94df99ac427891b8c3587 Mon Sep 17 00:00:00 2001 From: Dinmukhamed Mailibay <47117969+dinmukhamedm@users.noreply.github.com> Date: Fri, 1 Nov 2024 17:15:26 -0700 Subject: [PATCH 6/6] extract copy to clipboard button to a reusable component (#138) --- .../components/settings/project-api-keys.tsx | 15 +++----- frontend/components/ui/copy-to-clipboard.tsx | 36 +++++++++++++++++++ frontend/components/ui/formatter.tsx | 31 ++++++---------- 3 files changed, 51 insertions(+), 31 deletions(-) create mode 100644 frontend/components/ui/copy-to-clipboard.tsx diff --git a/frontend/components/settings/project-api-keys.tsx b/frontend/components/settings/project-api-keys.tsx index d03ba9f6..4aa6be55 100644 --- a/frontend/components/settings/project-api-keys.tsx +++ b/frontend/components/settings/project-api-keys.tsx @@ -18,6 +18,7 @@ import { useCallback, useState } from 'react'; import { useProjectContext } from '@/contexts/project-context'; import { useToast } from '@/lib/hooks/use-toast'; import RevokeDialog from './revoke-dialog'; +import CopyToClipboardButton from '../ui/copy-to-clipboard'; interface ApiKeysProps { apiKeys: ProjectApiKey[]; @@ -187,19 +188,13 @@ function DisplayKeyDialogContent({

- +
diff --git a/frontend/components/ui/copy-to-clipboard.tsx b/frontend/components/ui/copy-to-clipboard.tsx new file mode 100644 index 00000000..9ff511a1 --- /dev/null +++ b/frontend/components/ui/copy-to-clipboard.tsx @@ -0,0 +1,36 @@ +import { useToast } from "@/lib/hooks/use-toast"; +import { Button } from "./button"; + +interface CopyToClipboardButtonProps { + text: string; + toastPrefix?: string; + className?: string; + children?: React.ReactNode; +} + +export default function CopyToClipboardButton({ + text, + toastPrefix, + className, + children +}: CopyToClipboardButtonProps) { + const { toast } = useToast(); + return ( + + ); +} diff --git a/frontend/components/ui/formatter.tsx b/frontend/components/ui/formatter.tsx index 6b67850f..f3844e5e 100644 --- a/frontend/components/ui/formatter.tsx +++ b/frontend/components/ui/formatter.tsx @@ -11,10 +11,11 @@ import { cn } from '@/lib/utils'; import CodeEditor from './code-editor'; import { Sheet, SheetClose, SheetContent, SheetTrigger } from './sheet'; import { Button } from './button'; -import { Expand, Maximize, Minimize, X, ChevronDown, ChevronUp, Copy } from 'lucide-react'; +import { Maximize, Minimize, X, ChevronDown, ChevronUp, Copy } from 'lucide-react'; import { ScrollArea } from './scroll-area'; import { DialogTitle } from './dialog'; import { useToast } from '@/lib/hooks/use-toast'; +import CopyToClipboardButton from './copy-to-clipboard'; interface OutputFormatterProps { value: string; @@ -63,14 +64,6 @@ export default function Formatter({ return value; }; - const copyToClipboard = () => { - navigator.clipboard.writeText(renderText(value)); - toast({ - description: "Copied to clipboard", - duration: 1000, - }); - }; - return (
- +
- +