diff options
author | Phil Hughes <me@iamphill.com> | 2018-11-13 13:42:04 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-11-13 13:42:04 +0000 |
commit | 8e265bc3593ee70cf56579a3e3d8e733e413a8ba (patch) | |
tree | 53fe47b35ab4d79e518b9d21b47850ff762dbbd8 /app/assets | |
parent | 4bda46a1107a5a5007ea211e61ac0ff6f84874d0 (diff) | |
download | gitlab-ce-8e265bc3593ee70cf56579a3e3d8e733e413a8ba.tar.gz |
Fix collapsed files not fully fully expanding
This fixes files that are collapsed by default not expanding
when the expand all button is clicked.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53866
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_file.vue | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index e76c7afd863..93834e72417 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -32,6 +32,7 @@ export default { computed: { ...mapState('diffs', ['currentDiffFileId']), ...mapGetters(['isNotesFetched']), + ...mapGetters('diffs', ['getDiffFileDiscussions']), isCollapsed() { return this.file.collapsed || false; }, @@ -57,12 +58,23 @@ export default { showLoadingIcon() { return this.isLoadingCollapsedDiff || (!this.file.renderIt && !this.isCollapsed); }, + hasDiffLines() { + const { highlightedDiffLines, parallelDiffLines } = this.file; + + return highlightedDiffLines && parallelDiffLines && parallelDiffLines.length > 0; + }, + }, + watch: { + 'file.collapsed': function fileCollapsedWatch(newVal, oldVal) { + if (!newVal && oldVal && !this.hasDiffLines) { + this.handleLoadCollapsedDiff(); + } + }, }, methods: { ...mapActions('diffs', ['loadCollapsedDiff', 'assignDiscussionsToDiff']), handleToggle() { - const { highlightedDiffLines, parallelDiffLines } = this.file; - if (!highlightedDiffLines && parallelDiffLines !== undefined && !parallelDiffLines.length) { + if (!this.hasDiffLines) { this.handleLoadCollapsedDiff(); } else { this.file.collapsed = !this.file.collapsed; @@ -81,7 +93,7 @@ export default { .then(() => { requestIdleCallback( () => { - this.assignDiscussionsToDiff(); + this.assignDiscussionsToDiff(this.getDiffFileDiscussions(this.file)); }, { timeout: 1000 }, ); |