mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	- Avoid flash of wrong tree toggle icon on page load by setting icon based on sync state - Avoid "pop-in" of tree on page load by leaving space based on sync state - Use the same border/box-shadow combo used on comment `:target` also for file `:target`. - Refactor `DiffFileTree.vue` to use `toggleElem` instead of hardcoded class name. - Left-align inline comment boxes and make them fit the same amount of markup content on a line as GitHub. - Fix height of `diff-file-list` Fixes: https://github.com/go-gitea/gitea/issues/23593 <img width="1250" alt="Screenshot 2023-03-18 at 00 52 04" src="https://user-images.githubusercontent.com/115237/226071392-6789a644-aead-4756-a77e-aba3642150a0.png"> <img width="1246" alt="Screenshot 2023-03-18 at 00 59 43" src="https://user-images.githubusercontent.com/115237/226071443-8bcba924-458b-48bd-b2f0-0de59cb180ac.png"> <img width="1250" alt="Screenshot 2023-03-18 at 01 27 14" src="https://user-images.githubusercontent.com/115237/226073121-ccb99f9a-d3ac-40b7-9589-43580c4a01c9.png"> <img width="1231" alt="Screenshot 2023-03-19 at 21 44 16" src="https://user-images.githubusercontent.com/115237/226207951-81bcae1b-6b41-4e39-83a7-0f37951df6be.png"> (Yes I'm aware the border-radius in bottom corners is suboptimal, but this would be notorously hard to fix without relying on `overflow: hidden`).
		
			
				
	
	
		
			150 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
<template>
 | 
						|
  <div v-show="show" :title="item.name">
 | 
						|
    <!--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"-->
 | 
						|
    <div class="item" :class="item.isFile ? 'filewrapper gt-p-1 gt-ac' : ''">
 | 
						|
      <!-- Files -->
 | 
						|
      <SvgIcon
 | 
						|
        v-if="item.isFile"
 | 
						|
        name="octicon-file"
 | 
						|
        class="svg-icon file"
 | 
						|
      />
 | 
						|
      <a
 | 
						|
        v-if="item.isFile"
 | 
						|
        class="file gt-ellipsis"
 | 
						|
        :href="item.isFile ? '#diff-' + item.file.NameHash : ''"
 | 
						|
      >{{ item.name }}</a>
 | 
						|
      <SvgIcon
 | 
						|
        v-if="item.isFile"
 | 
						|
        :name="getIconForDiffType(item.file.Type)"
 | 
						|
        :class="['svg-icon', getIconForDiffType(item.file.Type), 'status']"
 | 
						|
      />
 | 
						|
 | 
						|
      <!-- Directories -->
 | 
						|
      <div v-if="!item.isFile" class="directory gt-p-1 gt-ac" @click.stop="handleClick(item.isFile)">
 | 
						|
        <SvgIcon
 | 
						|
          class="svg-icon"
 | 
						|
          :name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"
 | 
						|
        />
 | 
						|
        <SvgIcon
 | 
						|
          class="svg-icon directory"
 | 
						|
          name="octicon-file-directory-fill"
 | 
						|
        />
 | 
						|
        <span class="gt-ellipsis">{{ item.name }}</span>
 | 
						|
      </div>
 | 
						|
      <div v-show="!collapsed">
 | 
						|
        <DiffFileTreeItem v-for="childItem in item.children" :key="childItem.name" :item="childItem" class="list" />
 | 
						|
      </div>
 | 
						|
    </div>
 | 
						|
  </div>
 | 
						|
</template>
 | 
						|
 | 
						|
<script>
 | 
						|
import {SvgIcon} from '../svg.js';
 | 
						|
 | 
						|
export default {
 | 
						|
  components: {SvgIcon},
 | 
						|
  props: {
 | 
						|
    item: {
 | 
						|
      type: Object,
 | 
						|
      required: true
 | 
						|
    },
 | 
						|
    show: {
 | 
						|
      type: Boolean,
 | 
						|
      required: false,
 | 
						|
      default: true
 | 
						|
    }
 | 
						|
  },
 | 
						|
  data: () => ({
 | 
						|
    collapsed: false,
 | 
						|
  }),
 | 
						|
  methods: {
 | 
						|
    handleClick(itemIsFile) {
 | 
						|
      if (itemIsFile) {
 | 
						|
        return;
 | 
						|
      }
 | 
						|
      this.collapsed = !this.collapsed;
 | 
						|
    },
 | 
						|
    getIconForDiffType(pType) {
 | 
						|
      const diffTypes = {
 | 
						|
        1: 'octicon-diff-added',
 | 
						|
        2: 'octicon-diff-modified',
 | 
						|
        3: 'octicon-diff-removed',
 | 
						|
        4: 'octicon-diff-renamed',
 | 
						|
        5: 'octicon-diff-modified', // there is no octicon for copied, so modified should be ok
 | 
						|
      };
 | 
						|
      return diffTypes[pType];
 | 
						|
    },
 | 
						|
  },
 | 
						|
};
 | 
						|
</script>
 | 
						|
 | 
						|
<style scoped>
 | 
						|
.svg-icon.status {
 | 
						|
  float: right;
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.file {
 | 
						|
  color: var(--color-secondary-dark-7);
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.directory {
 | 
						|
  color: var(--color-primary);
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.octicon-diff-modified {
 | 
						|
  color: var(--color-yellow);
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.octicon-diff-added {
 | 
						|
  color: var(--color-green);
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.octicon-diff-removed {
 | 
						|
  color: var(--color-red);
 | 
						|
}
 | 
						|
 | 
						|
.svg-icon.octicon-diff-renamed {
 | 
						|
  color: var(--color-teal);
 | 
						|
}
 | 
						|
 | 
						|
.item.filewrapper {
 | 
						|
  display: grid !important;
 | 
						|
  grid-template-columns: 20px 7fr 1fr;
 | 
						|
  padding-left: 18px !important;
 | 
						|
}
 | 
						|
 | 
						|
.item.filewrapper:hover {
 | 
						|
  color: var(--color-text);
 | 
						|
  background: var(--color-hover);
 | 
						|
  border-radius: 4px;
 | 
						|
}
 | 
						|
 | 
						|
div.directory {
 | 
						|
  display: grid;
 | 
						|
  grid-template-columns: 18px 20px auto;
 | 
						|
  user-select: none;
 | 
						|
  cursor: pointer;
 | 
						|
}
 | 
						|
 | 
						|
div.directory:hover {
 | 
						|
  color: var(--color-text);
 | 
						|
  background: var(--color-hover);
 | 
						|
  border-radius: 4px;
 | 
						|
}
 | 
						|
 | 
						|
div.list {
 | 
						|
  padding-bottom: 0 !important;
 | 
						|
  padding-top: inherit !important;
 | 
						|
}
 | 
						|
 | 
						|
a {
 | 
						|
  text-decoration: none;
 | 
						|
  color: var(--color-text);
 | 
						|
}
 | 
						|
 | 
						|
a:hover {
 | 
						|
  text-decoration: none;
 | 
						|
  color: var(--color-text);
 | 
						|
}
 | 
						|
</style>
 |