File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
frontend/src/components/history Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 1
- import { History } from "./history_types" ;
1
+ import { History , HistoryItemType } from "./history_types" ;
2
2
import toast from "react-hot-toast" ;
3
3
import classNames from "classnames" ;
4
4
import {
5
5
HoverCard ,
6
6
HoverCardTrigger ,
7
7
HoverCardContent ,
8
8
} from "../ui/hover-card" ;
9
+ import { Badge } from "../ui/badge" ;
9
10
10
11
interface Props {
11
12
history : History ;
@@ -14,17 +15,18 @@ interface Props {
14
15
shouldDisableReverts : boolean ;
15
16
}
16
17
17
- // function displayHistoryItemType(itemType: HistoryItemType) {
18
10000
- // switch (itemType) {
19
- // case "ai_create":
20
- // return "Create";
21
- // case "ai_edit":
22
- // return "Edit";
23
- // default:
24
- // // TODO: Error out since this is exhaustive
25
- // return "Unknown";
26
- // }
27
- // }
18
+ function displayHistoryItemType ( itemType : HistoryItemType ) {
19
+ switch ( itemType ) {
20
+ case "ai_create" :
21
+ return "Create" ;
22
+ case "ai_edit" :
23
+ return "Edit" ;
24
+ default : {
25
+ const exhaustiveCheck : never = itemType ;
26
+ throw new Error ( `Unhandled case: ${ exhaustiveCheck } ` ) ;
27
+ }
28
+ }
29
+ }
28
30
29
31
export default function HistoryDisplay ( {
30
32
history,
@@ -73,7 +75,10 @@ export default function HistoryDisplay({
73
75
< h2 className = "text-sm" > v{ index + 1 } </ h2 >
74
76
</ HoverCardTrigger >
75
77
< HoverCardContent >
76
- { item . type === "ai_edit" ? item . inputs . prompt : "Create" }
78
+ < div >
79
+ { item . type === "ai_edit" ? item . inputs . prompt : "Create" }
80
+ </ div >
81
+ < Badge > { displayHistoryItemType ( item . type ) } </ Badge >
77
82
</ HoverCardContent >
78
83
</ HoverCard >
79
84
</ li >
You can’t perform that action at this time.
0 commit comments