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

feat(annotations): annotations UI #3914

Merged
merged 6 commits into from
Jul 23, 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
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
mikeldking marked this conversation as resolved.
Show resolved Hide resolved
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
Loading