-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
229ce5d
commit e9c46a9
Showing
3 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,94 @@ | ||
import React from "react"; | ||
import React, { Suspense } from "react"; | ||
import { graphql, useLazyLoadQuery } from "react-relay"; | ||
|
||
import { Dialog } from "@arizeai/components"; | ||
import { | ||
Button, | ||
Dialog, | ||
Form, | ||
TextArea, | ||
TextField, | ||
View, | ||
} from "@arizeai/components"; | ||
|
||
export function EditSpanAnnotationsDialog() { | ||
import { | ||
EditSpanAnnotationsDialogQuery, | ||
EditSpanAnnotationsDialogQuery$data, | ||
} from "./__generated__/EditSpanAnnotationsDialogQuery.graphql"; | ||
|
||
type EditSpanAnnotationsDialogProps = { | ||
spanNodeId: string; | ||
}; | ||
export function EditSpanAnnotationsDialog( | ||
props: EditSpanAnnotationsDialogProps | ||
) { | ||
return ( | ||
<Dialog title="Span Annotations" size="L"> | ||
Annotations go here | ||
<Suspense> | ||
<EditSpanAnnotations {...props} /> | ||
<Button variant="default">New Annotation</Button> | ||
</Suspense> | ||
</Dialog> | ||
); | ||
} | ||
|
||
type EditSpanAnnotationsProps = EditSpanAnnotationsDialogProps; | ||
function EditSpanAnnotations(props: EditSpanAnnotationsProps) { | ||
const data = useLazyLoadQuery<EditSpanAnnotationsDialogQuery>( | ||
graphql` | ||
query EditSpanAnnotationsDialogQuery($spanId: GlobalID!) { | ||
span: node(id: $spanId) { | ||
id | ||
... on Span { | ||
spanAnnotations { | ||
name | ||
score | ||
label | ||
explanation | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
{ spanId: props.spanNodeId } | ||
); | ||
const annotations = data.span.spanAnnotations || []; | ||
return ( | ||
<div> | ||
<ul> | ||
{annotations.map((annotation, idx) => ( | ||
<li key={idx}> | ||
<View borderEndWidth="thin"> | ||
<SpanAnnotationForm annotation={annotation} /> | ||
</View> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
type Annotation = NonNullable< | ||
EditSpanAnnotationsDialogQuery$data["span"]["spanAnnotations"] | ||
>[number]; | ||
|
||
function SpanAnnotationForm(props: { annotation: Annotation }) { | ||
const { annotation } = props; | ||
return ( | ||
<Form> | ||
<TextField label="Name" value={annotation.name} /> | ||
<TextField | ||
label="Score" | ||
value={(annotation.score as unknown as string) || ""} | ||
/> | ||
<TextField | ||
label="Label" | ||
value={(annotation.score as unknown as string) || ""} | ||
/> | ||
<TextArea label="Explanation" value={annotation.explanation || ""} /> | ||
<div>{annotation.name}</div> | ||
<div>{annotation.score}</div> | ||
<div>{annotation.label}</div> | ||
<div>{annotation.explanation}</div> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters