DeprecatedChartBlock.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { useParams } from 'common'
  2. import { ReactNode } from 'react'
  3. import { ReportBlockContainer } from './ReportBlockContainer'
  4. import { InlineLink } from '@/components/ui/InlineLink'
  5. import { METRICS } from '@/lib/constants/metrics'
  6. interface DeprecatedChartBlockProps {
  7. label: string
  8. attribute: string
  9. actions?: ReactNode
  10. }
  11. export const DeprecatedChartBlock = ({ label, attribute, actions }: DeprecatedChartBlockProps) => {
  12. const { ref } = useParams()
  13. const metric = METRICS.find((x) => x.key === attribute)
  14. const logsName = metric?.category?.label
  15. const getLogsUrl = (logsName?: string) => {
  16. switch (logsName) {
  17. case 'Database API':
  18. return '/logs/postgrest-logs'
  19. case 'All API usage':
  20. return '/logs/explorer'
  21. case 'Realtime':
  22. return '/logs/realtime-logs'
  23. case 'Storage':
  24. return '/logs/storage-logs'
  25. case 'Authentication':
  26. return '/logs/auth-logs'
  27. default:
  28. return ''
  29. }
  30. }
  31. return (
  32. <ReportBlockContainer
  33. draggable
  34. showDragHandle
  35. loading={false}
  36. icon={metric?.category?.icon('text-foreground-muted')}
  37. label={label}
  38. actions={actions}
  39. >
  40. <div className="flex flex-col justify-center flex-1">
  41. <p className="text-xs text-foreground-lightr">
  42. This chart is not longer available, and can be removed from your report
  43. </p>
  44. <p className="text-xs text-foreground-lighter">
  45. You may view the equivalent of this data from the{' '}
  46. <InlineLink href={`/project/${ref}/${getLogsUrl(logsName)}`}>{logsName} Logs</InlineLink>{' '}
  47. instead
  48. </p>
  49. </div>
  50. </ReportBlockContainer>
  51. )
  52. }