Skip to content

Commit

Permalink
feat(annotations): annotations UI (#3914)
Browse files Browse the repository at this point in the history
* WIP

WIP

WIP

WIP

WIP

add delete annotation functionality

WIP

lint errors

WIP

* wire up the new span annotation form

* WIP

* WIP

* add a border

* cleanup
  • Loading branch information
mikeldking authored Jul 23, 2024
1 parent 42a6314 commit cd1a48f
Show file tree
Hide file tree
Showing 14 changed files with 1,496 additions and 6 deletions.
1 change: 0 additions & 1 deletion app/src/components/dataset/CreateDatasetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export function CreateDatasetForm(props: CreateDatasetFormProps) {
},
onError: (error) => {
// TODO(datasets): cleanup error handling to show human friendly error

onDatasetCreateError(error);
},
});
Expand Down
4 changes: 2 additions & 2 deletions app/src/contexts/FeatureFlagsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useHotkeys } from "react-hotkeys-hook";

import { Dialog, DialogContainer, Switch, View } from "@arizeai/components";

type FeatureFlag = "__CLEAR__"; // No feature flags right now
type FeatureFlag = "annotations";
export type FeatureFlagsContextType = {
featureFlags: Record<FeatureFlag, boolean>;
setFeatureFlags: (featureFlags: Record<FeatureFlag, boolean>) => void;
Expand All @@ -12,7 +12,7 @@ export type FeatureFlagsContextType = {
export const LOCAL_STORAGE_FEATURE_FLAGS_KEY = "arize-phoenix-feature-flags";

const DEFAULT_FEATURE_FLAGS: Record<FeatureFlag, boolean> = {
__CLEAR__: false,
annotations: false,
};

function getFeatureFlags(): Record<FeatureFlag, boolean> {
Expand Down
54 changes: 54 additions & 0 deletions app/src/pages/trace/AnnotationActionMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from "react";

import { ActionMenu, Flex, Icon, Icons, Item, Text } from "@arizeai/components";

type AnnotationActionMenuProps = {
onDelete: () => void;
isDisabled?: boolean;
};

enum AnnotationAction {
DELETE = "deleteAnnotation",
}

/**
* A generic action menu for annotations that can be extended
*/
export function AnnotationActionMenu(props: AnnotationActionMenuProps) {
const { onDelete, isDisabled = false } = props;
return (
<div
// TODO: add this logic to the ActionMenu component
onClick={(e) => {
// prevent parent anchor link from being followed
e.preventDefault();
e.stopPropagation();
}}
>
<ActionMenu
align="end"
buttonSize="compact"
isDisabled={isDisabled}
onAction={(action) => {
switch (action) {
case AnnotationAction.DELETE:
onDelete();
break;
}
}}
>
<Item key={AnnotationAction.DELETE}>
<Flex
direction="row"
gap="size-75"
justifyContent="start"
alignItems="center"
>
<Icon svg={<Icons.TrashOutline />} />
<Text>Delete</Text>
</Flex>
</Item>
</ActionMenu>
</div>
);
}
38 changes: 38 additions & 0 deletions app/src/pages/trace/EditSpanAnnotationsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { ReactNode, useState } from "react";

import { Button, DialogContainer, Icon, Icons } from "@arizeai/components";

import { EditSpanAnnotationsDialog } from "./EditSpanAnnotationsDialog";

export function EditSpanAnnotationsButton(props: {
spanNodeId: string;
projectId: string;
}) {
const { spanNodeId, projectId } = props;
const [dialog, setDialog] = useState<ReactNode>(null);
return (
<>
<Button
variant="default"
icon={<Icon svg={<Icons.EditOutline />} />}
onClick={() =>
setDialog(
<EditSpanAnnotationsDialog
spanNodeId={spanNodeId}
projectId={projectId}
/>
)
}
>
Annotate
</Button>
<DialogContainer
type="slideOver"
isDismissable
onDismiss={() => setDialog(null)}
>
{dialog}
</DialogContainer>
</>
);
}
Loading

0 comments on commit cd1a48f

Please sign in to comment.