2022-09-26 23:22:19 -06:00
|
|
|
<script>
|
|
|
|
import {SvgIcon} from '../svg.js';
|
2023-05-30 04:53:15 -06:00
|
|
|
import {diffTreeStore} from '../modules/stores.js';
|
2022-09-26 23:22:19 -06:00
|
|
|
|
|
|
|
export default {
|
2022-12-23 09:03:11 -07:00
|
|
|
components: {SvgIcon},
|
2022-09-26 23:22:19 -06:00
|
|
|
props: {
|
|
|
|
item: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data: () => ({
|
2023-05-30 04:53:15 -06:00
|
|
|
store: diffTreeStore(),
|
2022-09-26 23:22:19 -06:00
|
|
|
collapsed: false,
|
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
getIconForDiffType(pType) {
|
|
|
|
const diffTypes = {
|
2023-08-18 13:55:56 -06:00
|
|
|
1: {name: 'octicon-diff-added', classes: ['text', 'green']},
|
|
|
|
2: {name: 'octicon-diff-modified', classes: ['text', 'yellow']},
|
|
|
|
3: {name: 'octicon-diff-removed', classes: ['text', 'red']},
|
|
|
|
4: {name: 'octicon-diff-renamed', classes: ['text', 'teal']},
|
|
|
|
5: {name: 'octicon-diff-renamed', classes: ['text', 'green']}, // there is no octicon for copied, so renamed should be ok
|
2022-09-26 23:22:19 -06:00
|
|
|
};
|
|
|
|
return diffTypes[pType];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2023-09-02 08:59:07 -06:00
|
|
|
<template>
|
|
|
|
<!--title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
|
|
|
|
<a
|
|
|
|
v-if="item.isFile" class="item-file"
|
|
|
|
:class="{'selected': store.selectedItem === '#diff-' + item.file.NameHash, 'viewed': item.file.IsViewed}"
|
|
|
|
:title="item.name" :href="'#diff-' + item.file.NameHash"
|
|
|
|
>
|
|
|
|
<!-- file -->
|
|
|
|
<SvgIcon name="octicon-file"/>
|
|
|
|
<span class="gt-ellipsis gt-f1">{{ item.name }}</span>
|
|
|
|
<SvgIcon :name="getIconForDiffType(item.file.Type).name" :class="getIconForDiffType(item.file.Type).classes"/>
|
|
|
|
</a>
|
|
|
|
<div v-else class="item-directory" :title="item.name" @click.stop="collapsed = !collapsed">
|
|
|
|
<!-- directory -->
|
|
|
|
<SvgIcon :name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"/>
|
|
|
|
<SvgIcon class="text primary" name="octicon-file-directory-fill"/>
|
|
|
|
<span class="gt-ellipsis">{{ item.name }}</span>
|
|
|
|
</div>
|
2022-09-26 23:22:19 -06:00
|
|
|
|
2023-09-02 08:59:07 -06:00
|
|
|
<div v-if="item.children?.length" v-show="!collapsed" class="sub-items">
|
|
|
|
<DiffFileTreeItem v-for="childItem in item.children" :key="childItem.name" :item="childItem"/>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-09-26 23:22:19 -06:00
|
|
|
<style scoped>
|
2023-08-18 13:55:56 -06:00
|
|
|
a, a:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
color: var(--color-text);
|
2022-09-26 23:22:19 -06:00
|
|
|
}
|
|
|
|
|
2023-08-18 13:55:56 -06:00
|
|
|
.sub-items {
|
2023-10-21 04:44:58 -06:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: 1px;
|
|
|
|
padding-left: 8px;
|
2022-09-26 23:22:19 -06:00
|
|
|
}
|
|
|
|
|
2023-10-21 04:44:58 -06:00
|
|
|
.sub-items .item-file {
|
|
|
|
padding-left: 24px;
|
2022-09-26 23:22:19 -06:00
|
|
|
}
|
|
|
|
|
2023-08-18 13:55:56 -06:00
|
|
|
.item-file.selected {
|
2023-04-07 12:27:10 -06:00
|
|
|
color: var(--color-text);
|
|
|
|
background: var(--color-active);
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
|
2023-08-18 13:55:56 -06:00
|
|
|
.item-file.viewed {
|
|
|
|
color: var(--color-text-light-3);
|
2022-09-26 23:22:19 -06:00
|
|
|
}
|
|
|
|
|
2023-08-18 13:55:56 -06:00
|
|
|
.item-file,
|
|
|
|
.item-directory {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
gap: 0.25em;
|
2023-10-21 04:44:58 -06:00
|
|
|
padding: 3px 6px;
|
2022-09-26 23:22:19 -06:00
|
|
|
}
|
|
|
|
|
2023-08-18 13:55:56 -06:00
|
|
|
.item-file:hover,
|
|
|
|
.item-directory:hover {
|
2023-03-30 06:06:10 -06:00
|
|
|
color: var(--color-text);
|
2023-08-18 13:55:56 -06:00
|
|
|
background: var(--color-hover);
|
|
|
|
border-radius: 4px;
|
|
|
|
cursor: pointer;
|
2023-06-24 18:46:30 -06:00
|
|
|
}
|
2022-09-26 23:22:19 -06:00
|
|
|
</style>
|