2022-09-26 23:22:19 -06:00
|
|
|
<script>
|
2023-05-30 04:53:15 -06:00
|
|
|
import {loadMoreFiles} from '../features/repo-diff.js';
|
|
|
|
import {diffTreeStore} from '../modules/stores.js';
|
2022-09-26 23:22:19 -06:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data: () => {
|
2023-05-30 04:53:15 -06:00
|
|
|
return {store: diffTreeStore()};
|
2022-09-26 23:22:19 -06:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
document.getElementById('show-file-list-btn').addEventListener('click', this.toggleFileList);
|
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
document.getElementById('show-file-list-btn').removeEventListener('click', this.toggleFileList);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleFileList() {
|
2023-05-30 04:53:15 -06:00
|
|
|
this.store.fileListIsVisible = !this.store.fileListIsVisible;
|
2022-09-26 23:22:19 -06:00
|
|
|
},
|
|
|
|
diffTypeToString(pType) {
|
|
|
|
const diffTypes = {
|
|
|
|
1: 'add',
|
|
|
|
2: 'modify',
|
|
|
|
3: 'del',
|
|
|
|
4: 'rename',
|
|
|
|
5: 'copy',
|
|
|
|
};
|
|
|
|
return diffTypes[pType];
|
|
|
|
},
|
|
|
|
diffStatsWidth(adds, dels) {
|
|
|
|
return `${adds / (adds + dels) * 100}%`;
|
|
|
|
},
|
|
|
|
loadMoreData() {
|
2023-05-30 04:53:15 -06:00
|
|
|
loadMoreFiles(this.store.linkLoadMore);
|
2024-03-22 08:06:53 -06:00
|
|
|
},
|
2022-09-26 23:22:19 -06:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2023-09-02 08:59:07 -06:00
|
|
|
<template>
|
2023-09-28 04:00:26 -06:00
|
|
|
<ol class="diff-stats gt-m-0" ref="root" v-if="store.fileListIsVisible">
|
2023-09-02 08:59:07 -06:00
|
|
|
<li v-for="file in store.files" :key="file.NameHash">
|
2024-03-22 13:51:29 -06:00
|
|
|
<div class="gt-font-semibold tw-flex tw-items-center pull-right">
|
2023-09-02 08:59:07 -06:00
|
|
|
<span v-if="file.IsBin" class="gt-ml-1 gt-mr-3">{{ store.binaryFileMessage }}</span>
|
|
|
|
{{ file.IsBin ? '' : file.Addition + file.Deletion }}
|
|
|
|
<span v-if="!file.IsBin" class="diff-stats-bar gt-mx-3" :data-tooltip-content="store.statisticsMessage.replace('%d', (file.Addition + file.Deletion)).replace('%d', file.Addition).replace('%d', file.Deletion)">
|
|
|
|
<div class="diff-stats-add-bar" :style="{ 'width': diffStatsWidth(file.Addition, file.Deletion) }"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<!-- todo finish all file status, now modify, add, delete and rename -->
|
|
|
|
<span :class="['status', diffTypeToString(file.Type)]" :data-tooltip-content="diffTypeToString(file.Type)"> </span>
|
|
|
|
<a class="file gt-mono" :href="'#diff-' + file.NameHash">{{ file.Name }}</a>
|
|
|
|
</li>
|
|
|
|
<li v-if="store.isIncomplete" class="gt-pt-2">
|
2024-03-22 13:51:29 -06:00
|
|
|
<span class="file tw-flex tw-items-center tw-justify-between">{{ store.tooManyFilesMessage }}
|
2023-09-02 08:59:07 -06:00
|
|
|
<a :class="['ui', 'basic', 'tiny', 'button', store.isLoadingNewData ? 'disabled' : '']" @click.stop="loadMoreData">{{ store.showMoreMessage }}</a>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</template>
|