2
2
import {SvgIcon , type SvgName } from ' ../svg.ts' ;
3
3
import {diffTreeStore } from ' ../modules/stores.ts' ;
4
4
import {ref } from ' vue' ;
5
+ import { type Item , type File , type FileStatus } from ' ./file_tree.ts' ;
5
6
6
- type File = {
7
- Name: string ;
8
- NameHash: string ;
9
- Type: number ;
10
- IsViewed: boolean ;
11
- IsSubmodule: boolean ;
12
- }
13
-
14
- export type Item = {
15
- name: string ;
16
- isFile: boolean ;
17
- file? : File ;
18
- children? : Item [];
19
- };
20
7
21
8
defineProps <{
22
9
item: Item ,
@@ -25,15 +12,15 @@ defineProps<{
25
12
const store = diffTreeStore ();
26
13
const collapsed = ref (false );
27
14
28
- function getIconForDiffType(pType : number ) {
29
- const diffTypes: Record <string , {name: SvgName , classes: Array <string >}> = {
30
- ' 1 ' : {name: ' octicon-diff-added' , classes: [' text' , ' green' ]},
31
- ' 2 ' : {name: ' octicon-diff-modified' , classes: [' text' , ' yellow' ]},
32
- ' 3 ' : {name: ' octicon-diff-removed' , classes: [' text' , ' red' ]},
33
- ' 4 ' : {name: ' octicon-diff-renamed' , classes: [' text' , ' teal' ]},
34
- ' 5 ' : {name: ' octicon-diff-renamed ' , classes: [' text' , ' green' ]}, // there is no octicon for copied, so renamed should be ok
15
+ function getIconForDiffType(pType : FileStatus ) {
16
+ const diffTypes: Record <FileStatus , {name: SvgName , classes: Array <string >}> = {
17
+ ' added ' : {name: ' octicon-diff-added' , classes: [' text' , ' green' ]},
18
+ ' modified ' : {name: ' octicon-diff-modified' , classes: [' text' , ' yellow' ]},
19
+ ' deleted ' : {name: ' octicon-diff-removed' , classes: [' text' , ' red' ]},
20
+ ' renamed ' : {name: ' octicon-diff-renamed' , classes: [' text' , ' teal' ]},
21
+ ' typechange ' : {name: ' octicon-diff-modified ' , classes: [' text' , ' green' ]}, // there is no octicon for copied, so renamed should be ok
35
22
};
36
- return diffTypes [String ( pType ) ];
23
+ return diffTypes [pType ];
37
24
}
38
25
39
26
function fileIcon(file : File ) {
@@ -54,7 +41,7 @@ function fileIcon(file: File) {
54
41
<!-- file -->
55
42
<SvgIcon :name =" fileIcon(item.file)" />
56
43
<span class =" gt-ellipsis tw-flex-1" >{{ item.name }}</span >
57
- <SvgIcon :name =" getIconForDiffType(item.file.Type ).name" :class =" getIconForDiffType(item.file.Type ).classes" />
44
+ <SvgIcon :name =" getIconForDiffType(item.file.Status ).name" :class =" getIconForDiffType(item.file.Status ).classes" />
58
45
</a >
59
46
<div v-else class =" item-directory" :title =" item.name" @click.stop =" collapsed = !collapsed" >
60
47
<!-- directory -->
0 commit comments