-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from DataRecce/feature/drc-701-allows-to-show…
…-histogram-and-top-k-in-the-schema-column [Feature] Allows to show histogram and top k in the schema column
- Loading branch information
Showing
4 changed files
with
125 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { useRecceActionContext } from "@/lib/hooks/RecceActionContext"; | ||
import { | ||
Flex, | ||
Box, | ||
Spacer, | ||
Menu, | ||
MenuButton, | ||
IconButton, | ||
Icon, | ||
Portal, | ||
MenuList, | ||
MenuGroup, | ||
MenuItem, | ||
} from "@chakra-ui/react"; | ||
import { VscKebabVertical } from "react-icons/vsc"; | ||
import { supportsHistogramDiff } from "../histogram/HistogramDiffForm"; | ||
|
||
export function ColumnNameCell({ | ||
model, | ||
name, | ||
baseType, | ||
currentType, | ||
}: { | ||
model: string; | ||
name: string; | ||
baseType?: string; | ||
currentType?: string; | ||
}) { | ||
const { runAction } = useRecceActionContext(); | ||
const columnType = currentType || baseType; | ||
|
||
const handleHistogramDiff = () => { | ||
runAction( | ||
"histogram_diff", | ||
{ model, column_name: name, column_type: columnType }, | ||
{ showForm: false } | ||
); | ||
}; | ||
|
||
const handleTopkDiff = () => { | ||
runAction( | ||
"top_k_diff", | ||
{ model, column_name: name, k: 50 }, | ||
{ showForm: false } | ||
); | ||
}; | ||
const addedOrRemoved = !baseType || !currentType; | ||
|
||
return ( | ||
<Flex> | ||
<Box overflow="hidden" textOverflow="ellipsis" whiteSpace="nowrap"> | ||
{name} | ||
</Box> | ||
<Spacer /> | ||
|
||
<Menu> | ||
{({ isOpen }) => ( | ||
<> | ||
<MenuButton | ||
className="row-context-menu" | ||
visibility={isOpen ? "visible" : "hidden"} | ||
width={isOpen ? "auto" : "0px"} | ||
minWidth={isOpen ? "auto" : "0px"} | ||
as={IconButton} | ||
icon={<Icon as={VscKebabVertical} />} | ||
variant="unstyled" | ||
size={"sm"} | ||
/> | ||
|
||
<Portal> | ||
<MenuList lineHeight="20px"> | ||
<MenuGroup title="Diff" m="0" p="4px 12px"> | ||
<MenuItem | ||
fontSize="10pt" | ||
onClick={handleHistogramDiff} | ||
isDisabled={ | ||
addedOrRemoved || | ||
(columnType ? !supportsHistogramDiff(columnType) : true) | ||
} | ||
> | ||
Histogram Diff | ||
</MenuItem> | ||
<MenuItem | ||
fontSize="10pt" | ||
onClick={handleTopkDiff} | ||
isDisabled={addedOrRemoved} | ||
> | ||
Top-k Diff | ||
</MenuItem> | ||
</MenuGroup> | ||
</MenuList> | ||
</Portal> | ||
</> | ||
)} | ||
</Menu> | ||
</Flex> | ||
); | ||
} |
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