<commit_before>import { MenuItem, MenuList, useToast } from "@chakra-ui/react"
import React, { forwardRef } from "react"
import { CalculatedColumn } from "react-data-grid"
import { TRow } from "./case-table-types"

interface IProps {
  disableToolTips?: (show: boolean) => void
  column: CalculatedColumn<TRow, unknown>
}

// eslint-disable-next-line react/display-name
export const AttributeMenuList = forwardRef<HTMLDivElement, IProps>(({disableToolTips, column}, ref) => {
  const toast = useToast()

  const handleMenuItemClick = (menuItem: string) => {
    toast({
      title: 'Menu item clicked',
      description: `You clicked on ${menuItem} on ${column.name}`,
      status: 'success',
      duration: 5000,
      isClosable: true,
    })
  }

  return (
    <MenuList ref={ref}>
      <MenuItem onClick={()=>handleMenuItemClick("Rename")}>Rename</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Fit width")}>Fit width to content</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Edit Attribute Properties")}>Edit Attribute Properties...</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Edit Formula")}>Edit Formula...</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Delete Formula")}>Delete Formula (Keeping Values)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Rerandomize")}>Rerandomize</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Sort Ascending")}>Sort Ascending (A→Z, 0→9)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Sort Descending")}>Sort Descending (9→0, Z→A)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Hide Attribute")}>Hide Attribute</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Delete Attribute")}>Delete Attribute</MenuItem>
    </MenuList>
  )
})<commit_msg>Adds ability to delete attribute (#472)<commit_after>import { MenuItem, MenuList, useToast } from "@chakra-ui/react"
import React, { forwardRef } from "react"
import { CalculatedColumn } from "react-data-grid"
import { useDataSetContext } from "../../hooks/use-data-set-context"
import { TRow } from "./case-table-types"

interface IProps {
  disableToolTips?: (show: boolean) => void
  column: CalculatedColumn<TRow, unknown>
}

// eslint-disable-next-line react/display-name
export const AttributeMenuList = forwardRef<HTMLDivElement, IProps>(({disableToolTips, column}, ref) => {
  const toast = useToast()
  const data = useDataSetContext()

  const handleMenuItemClick = (menuItem: string) => {
    toast({
      title: 'Menu item clicked',
      description: `You clicked on ${menuItem} on ${column.name}`,
      status: 'success',
      duration: 5000,
      isClosable: true,
    })
  }
  const handleDeleteAttribute = () => {
    const attrId = data?.attrIDFromName(column.name as string)
    attrId && data?.removeAttribute(attrId)
  }

  return (
    <MenuList ref={ref}>
      <MenuItem onClick={()=>handleMenuItemClick("Rename")}>Rename</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Fit width")}>Fit width to content</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Edit Attribute Properties")}>Edit Attribute Properties...</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Edit Formula")}>Edit Formula...</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Delete Formula")}>Delete Formula (Keeping Values)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Rerandomize")}>Rerandomize</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Sort Ascending")}>Sort Ascending (A→Z, 0→9)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Sort Descending")}>Sort Descending (9→0, Z→A)</MenuItem>
      <MenuItem onClick={()=>handleMenuItemClick("Hide Attribute")}>Hide Attribute</MenuItem>
      <MenuItem onClick={()=>handleDeleteAttribute()}>Delete Attribute</MenuItem>
    </MenuList>
  )
})
{'fraction_non_alphanumeric': 0.16019542298791464, 'fraction_numerical': 0.004885574697865775, 'mean_word_length': 5.059190031152648, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5443618', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1093, 'n_words': 244}