2018-04-11 12:12:01 -04:00
|
|
|
<script>
|
2018-04-12 04:43:46 -04:00
|
|
|
import fuzzaldrinPlus from 'fuzzaldrin-plus';
|
2018-04-11 12:12:01 -04:00
|
|
|
import FileIcon from '../../../vue_shared/components/file_icon.vue';
|
2018-04-12 07:04:30 -04:00
|
|
|
import ChangedFileIcon from '../changed_file_icon.vue';
|
2018-04-11 12:12:01 -04:00
|
|
|
|
2018-04-12 07:00:07 -04:00
|
|
|
const MAX_PATH_LENGTH = 60;
|
|
|
|
|
2018-04-11 12:12:01 -04:00
|
|
|
export default {
|
|
|
|
components: {
|
2018-04-12 07:04:30 -04:00
|
|
|
ChangedFileIcon,
|
2018-04-11 12:12:01 -04:00
|
|
|
FileIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
file: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-04-12 04:43:46 -04:00
|
|
|
focused: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
searchText: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-04-13 12:03:38 -04:00
|
|
|
index: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-04-12 04:43:46 -04:00
|
|
|
},
|
2018-04-15 04:56:45 -04:00
|
|
|
computed: {
|
|
|
|
pathWithEllipsis() {
|
2018-04-16 09:22:13 -04:00
|
|
|
const path = this.file.path;
|
|
|
|
|
|
|
|
return path.length < MAX_PATH_LENGTH
|
|
|
|
? path
|
|
|
|
: `...${path.substr(path.length - MAX_PATH_LENGTH)}`;
|
2018-04-15 04:56:45 -04:00
|
|
|
},
|
|
|
|
nameSearchTextOccurences() {
|
|
|
|
return fuzzaldrinPlus.match(this.file.name, this.searchText);
|
|
|
|
},
|
|
|
|
pathSearchTextOccurences() {
|
|
|
|
return fuzzaldrinPlus.match(this.pathWithEllipsis, this.searchText);
|
|
|
|
},
|
|
|
|
},
|
2018-04-12 04:43:46 -04:00
|
|
|
methods: {
|
|
|
|
clickRow() {
|
|
|
|
this.$emit('click', this.file);
|
|
|
|
},
|
2018-04-13 12:03:38 -04:00
|
|
|
mouseOverRow() {
|
|
|
|
this.$emit('mouseover', this.index);
|
|
|
|
},
|
2018-04-18 07:23:29 -04:00
|
|
|
mouseMove() {
|
|
|
|
this.$emit('mousemove', this.index);
|
|
|
|
},
|
2018-04-11 12:12:01 -04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-04-19 07:04:49 -04:00
|
|
|
<button
|
|
|
|
type="button"
|
2018-04-11 12:12:01 -04:00
|
|
|
class="diff-changed-file"
|
2018-04-12 04:43:46 -04:00
|
|
|
:class="{
|
|
|
|
'is-focused': focused,
|
|
|
|
}"
|
|
|
|
@click.prevent="clickRow"
|
2018-04-13 12:03:38 -04:00
|
|
|
@mouseover="mouseOverRow"
|
2018-04-18 07:23:29 -04:00
|
|
|
@mousemove="mouseMove"
|
2018-04-11 12:12:01 -04:00
|
|
|
>
|
|
|
|
<file-icon
|
|
|
|
:file-name="file.name"
|
|
|
|
:size="16"
|
|
|
|
css-classes="diff-file-changed-icon append-right-8"
|
|
|
|
/>
|
|
|
|
<span class="diff-changed-file-content append-right-8">
|
2018-04-12 04:43:46 -04:00
|
|
|
<strong
|
|
|
|
class="diff-changed-file-name"
|
|
|
|
>
|
2018-04-15 04:56:45 -04:00
|
|
|
<span
|
|
|
|
v-for="(char, index) in file.name.split('')"
|
|
|
|
:key="index + char"
|
|
|
|
:class="{
|
|
|
|
highlighted: nameSearchTextOccurences.indexOf(index) >= 0,
|
|
|
|
}"
|
|
|
|
v-text="char"
|
|
|
|
>
|
|
|
|
</span>
|
2018-04-11 12:12:01 -04:00
|
|
|
</strong>
|
2018-04-12 04:43:46 -04:00
|
|
|
<span
|
|
|
|
class="diff-changed-file-path prepend-top-5"
|
|
|
|
>
|
2018-04-15 04:56:45 -04:00
|
|
|
<span
|
|
|
|
v-for="(char, index) in pathWithEllipsis.split('')"
|
|
|
|
:key="index + char"
|
|
|
|
:class="{
|
|
|
|
highlighted: pathSearchTextOccurences.indexOf(index) >= 0,
|
|
|
|
}"
|
|
|
|
v-text="char"
|
|
|
|
>
|
|
|
|
</span>
|
2018-04-11 12:12:01 -04:00
|
|
|
</span>
|
|
|
|
</span>
|
2018-04-12 07:04:30 -04:00
|
|
|
<span
|
|
|
|
v-if="file.changed || file.tempFile"
|
|
|
|
class="diff-changed-stats"
|
|
|
|
>
|
|
|
|
<changed-file-icon
|
|
|
|
:file="file"
|
|
|
|
/>
|
|
|
|
</span>
|
2018-04-19 07:04:49 -04:00
|
|
|
</button>
|
2018-04-11 12:12:01 -04:00
|
|
|
</template>
|