Commit 7f4cd47e authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '205399-add-tooltip-to-file-tree-state' into 'master'

Add tooltip to file tree

Closes #205399

See merge request gitlab-org/gitlab!27158
parents 31efb009 05209977
...@@ -35,6 +35,6 @@ export default { ...@@ -35,6 +35,6 @@ export default {
<template> <template>
<file-row :file="file" v-bind="$attrs" v-on="$listeners"> <file-row :file="file" v-bind="$attrs" v-on="$listeners">
<file-row-stats v-if="showFileRowStats" :file="file" class="mr-1" /> <file-row-stats v-if="showFileRowStats" :file="file" class="mr-1" />
<changed-file-icon :file="file" :size="16" /> <changed-file-icon :file="file" :size="16" :show-tooltip="true" />
</file-row> </file-row>
</template> </template>
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale';
import { getCommitIconMap } from '~/ide/utils'; import { getCommitIconMap } from '~/ide/utils';
import { __ } from '~/locale';
export default { export default {
components: { components: {
...@@ -49,9 +49,17 @@ export default { ...@@ -49,9 +49,17 @@ export default {
return `${this.changedIcon} float-left d-block`; return `${this.changedIcon} float-left d-block`;
}, },
tooltipTitle() { tooltipTitle() {
if (!this.showTooltip || !this.file.changed) return undefined; if (!this.showTooltip) {
return undefined;
} else if (this.file.deleted) {
return __('Deleted');
} else if (this.file.tempFile) {
return __('Added');
} else if (this.file.changed) {
return __('Modified');
}
return this.file.tempFile ? __('Added') : __('Modified'); return undefined;
}, },
showIcon() { showIcon() {
return ( return (
......
---
title: Add tooltip to modification icon in the file tree
merge_request: 27158
author:
type: other
...@@ -44,12 +44,14 @@ describe('Diff File Row component', () => { ...@@ -44,12 +44,14 @@ describe('Diff File Row component', () => {
level: 4, level: 4,
file: {}, file: {},
hideFileStats: false, hideFileStats: false,
showTooltip: true,
}); });
expect(wrapper.find(ChangedFileIcon).props()).toEqual( expect(wrapper.find(ChangedFileIcon).props()).toEqual(
expect.objectContaining({ expect.objectContaining({
file: {}, file: {},
size: 16, size: 16,
showTooltip: true,
}), }),
); );
}); });
......
...@@ -5,6 +5,7 @@ import Icon from '~/vue_shared/components/icon.vue'; ...@@ -5,6 +5,7 @@ import Icon from '~/vue_shared/components/icon.vue';
const changedFile = () => ({ changed: true }); const changedFile = () => ({ changed: true });
const stagedFile = () => ({ changed: true, staged: true }); const stagedFile = () => ({ changed: true, staged: true });
const newFile = () => ({ changed: true, tempFile: true }); const newFile = () => ({ changed: true, tempFile: true });
const deletedFile = () => ({ changed: false, tempFile: false, staged: false, deleted: true });
const unchangedFile = () => ({ changed: false, tempFile: false, staged: false, deleted: false }); const unchangedFile = () => ({ changed: false, tempFile: false, staged: false, deleted: false });
describe('Changed file icon', () => { describe('Changed file icon', () => {
...@@ -58,6 +59,7 @@ describe('Changed file icon', () => { ...@@ -58,6 +59,7 @@ describe('Changed file icon', () => {
${changedFile()} | ${'file-modified'} | ${'Modified'} | ${'with file changed'} ${changedFile()} | ${'file-modified'} | ${'Modified'} | ${'with file changed'}
${stagedFile()} | ${'file-modified-solid'} | ${'Modified'} | ${'with file staged'} ${stagedFile()} | ${'file-modified-solid'} | ${'Modified'} | ${'with file staged'}
${newFile()} | ${'file-addition'} | ${'Added'} | ${'with file new'} ${newFile()} | ${'file-addition'} | ${'Added'} | ${'with file new'}
${deletedFile()} | ${'file-deletion'} | ${'Deleted'} | ${'with file deleted'}
`('$desc', ({ file, iconName, tooltipText }) => { `('$desc', ({ file, iconName, tooltipText }) => {
beforeEach(() => { beforeEach(() => {
factory({ file }); factory({ file });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment