mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-07 19:12:55 +01:00
e719bf8ead
Backport #27322 by @wxiaoguang Close #26730 1. The `diff-detail-box` was abused, it shouldn't be used for "DiffFileList/DiffFileTree". 2. Fix the sticky position for various screens. ![image](https://github.com/go-gitea/gitea/assets/2114189/558a5c06-c94c-4e5c-8395-d38473dd21c2) ![image](https://github.com/go-gitea/gitea/assets/2114189/3390fb0e-7dc7-457f-bd0c-398fdb6d24c0) ![image](https://github.com/go-gitea/gitea/assets/2114189/d19dd350-aecf-4909-8ef9-73b09d94560e) Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
58 lines
2.2 KiB
Vue
58 lines
2.2 KiB
Vue
<script>
|
|
import {loadMoreFiles} from '../features/repo-diff.js';
|
|
import {diffTreeStore} from '../modules/stores.js';
|
|
|
|
export default {
|
|
data: () => {
|
|
return {store: diffTreeStore()};
|
|
},
|
|
mounted() {
|
|
document.getElementById('show-file-list-btn').addEventListener('click', this.toggleFileList);
|
|
},
|
|
unmounted() {
|
|
document.getElementById('show-file-list-btn').removeEventListener('click', this.toggleFileList);
|
|
},
|
|
methods: {
|
|
toggleFileList() {
|
|
this.store.fileListIsVisible = !this.store.fileListIsVisible;
|
|
},
|
|
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() {
|
|
loadMoreFiles(this.store.linkLoadMore);
|
|
}
|
|
},
|
|
};
|
|
</script>
|
|
<template>
|
|
<ol class="diff-stats gt-m-0" ref="root" v-if="store.fileListIsVisible">
|
|
<li v-for="file in store.files" :key="file.NameHash">
|
|
<div class="gt-font-semibold gt-df gt-ac pull-right">
|
|
<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">
|
|
<span class="file gt-df gt-ac gt-sb">{{ store.tooManyFilesMessage }}
|
|
<a :class="['ui', 'basic', 'tiny', 'button', store.isLoadingNewData ? 'disabled' : '']" @click.stop="loadMoreData">{{ store.showMoreMessage }}</a>
|
|
</span>
|
|
</li>
|
|
</ol>
|
|
</template>
|