gitlab-org--gitlab-foss/app/assets/javascripts/diffs/components/diff_content.vue
Filipa Lacerda 81b9b6f409
Merge branch 'master' into 48960-namespace-diff-module
* master: (29 commits)
  Update the dependencies license list for 11.1.0
  Update .gitignore, .gitlab-ci.yml, and Dockerfile templates for 11.1.0
  This updates only the actual new discussion and not the full tree , which leads to a very costly full rerender
  Resolve "MR Refactor: Improve performance by setting v-once"
  Changed Inline + Parallel Views to v-if instead of v-show
  add basic export to fix timeout problem on import_file_spec.rb
  Add changelog entry for !20465
  Improve render performance of large wiki pages
  Refactor rspec matchers in read_only_spec.rb
  add CHANGELOG.md entry for !20461
  resolve node 6 compatibility issues
  Add missing foreign key in import_export_uploads
  Redesign for mr widget info and pipelines section
  Use proper markdown rendering for previews
  remove extra tick for eks docs
  Make it clear that we need to enable omniauth for SAML and Bitbucket
  Add GPL Commitment language
  Add ExclusiveLease guards for RepositoryCheck::{DispatchWorker,BatchWorker}
  Ability to check if underlying database is read only
  fix spec
  ...
2018-07-09 10:21:18 +01:00

62 lines
1.6 KiB
Vue

<script>
import { mapGetters, mapState } from 'vuex';
import DiffViewer from '~/vue_shared/components/diff_viewer/diff_viewer.vue';
import { diffModes } from '~/ide/constants';
import InlineDiffView from './inline_diff_view.vue';
import ParallelDiffView from './parallel_diff_view.vue';
export default {
components: {
InlineDiffView,
ParallelDiffView,
DiffViewer,
},
props: {
diffFile: {
type: Object,
required: true,
},
},
computed: {
...mapState({
projectPath: state => state.diffs.projectPath,
endpoint: state => state.diffs.endpoint,
}),
...mapGetters('diffs', ['isInlineView', 'isParallelView']),
diffMode() {
const diffModeKey = Object.keys(diffModes).find(key => this.diffFile[`${key}File`]);
return diffModes[diffModeKey] || diffModes.replaced;
},
isTextFile() {
return this.diffFile.text;
},
},
};
</script>
<template>
<div class="diff-content">
<div class="diff-viewer">
<template v-if="isTextFile">
<inline-diff-view
v-if="isInlineView"
:diff-file="diffFile"
:diff-lines="diffFile.highlightedDiffLines || []"
/>
<parallel-diff-view
v-if="isParallelView"
:diff-file="diffFile"
:diff-lines="diffFile.parallelDiffLines || []"
/>
</template>
<diff-viewer
v-else
:diff-mode="diffMode"
:new-path="diffFile.newPath"
:new-sha="diffFile.diffRefs.headSha"
:old-path="diffFile.oldPath"
:old-sha="diffFile.diffRefs.baseSha"
:project-path="projectPath"/>
</div>
</div>
</template>