Commit 056933ed authored by Phil Hughes's avatar Phil Hughes

added tooltips to various icons in the sidebars

fixed SVG colors
parent 4a4caa01
<script> <script>
import icon from '~/vue_shared/components/icon.vue'; import tooltip from '~/vue_shared/directives/tooltip';
import icon from '~/vue_shared/components/icon.vue';
import { pluralize } from '~/lib/utils/text_utility';
export default { export default {
components: { components: {
icon, icon,
}, },
directives: {
tooltip,
},
props: { props: {
file: { file: {
type: Object, type: Object,
required: true, required: true,
}, },
showTooltip: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
changedIcon() { changedIcon() {
...@@ -18,14 +28,35 @@ ...@@ -18,14 +28,35 @@
changedIconClass() { changedIconClass() {
return `multi-${this.changedIcon}`; return `multi-${this.changedIcon}`;
}, },
tooltipTitle() {
if (!this.showTooltip) return undefined;
const type = this.file.tempFile ? 'addition' : 'modification';
if (this.file.changed && !this.file.staged) {
return `unstaged ${type}`;
} else if (!this.file.changed && this.file.staged) {
return `staged ${type}`;
} else if (this.file.changed && this.file.staged) {
return `unstaged and staged ${pluralize(type)}`;
}
},
}, },
}; };
</script> </script>
<template> <template>
<span
v-tooltip
:title="tooltipTitle"
data-container="body"
data-placement="right"
class="ide-file-changed-icon"
>
<icon <icon
:name="changedIcon" :name="changedIcon"
:size="12" :size="12"
:css-classes="`ide-file-changed-icon ${changedIconClass}`" :css-classes="changedIconClass"
/> />
</span>
</template> </template>
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
export default { export default {
components: { components: {
Icon, Icon,
}, },
directives: {
tooltip,
},
props: { props: {
noChangesStateSvgPath: { noChangesStateSvgPath: {
type: String, type: String,
...@@ -18,7 +22,7 @@ export default { ...@@ -18,7 +22,7 @@ export default {
}, },
computed: { computed: {
...mapState(['lastCommitMsg', 'rightPanelCollapsed']), ...mapState(['lastCommitMsg', 'rightPanelCollapsed']),
...mapGetters(['collapseButtonIcon']), ...mapGetters(['collapseButtonIcon', 'collapseButtonTooltip']),
statusSvg() { statusSvg() {
return this.lastCommitMsg return this.lastCommitMsg
? this.committedStateSvgPath ? this.committedStateSvgPath
...@@ -42,6 +46,10 @@ export default { ...@@ -42,6 +46,10 @@ export default {
}" }"
> >
<button <button
v-tooltip
:title="collapseButtonTooltip"
data-container="body"
data-placement="left"
type="button" type="button"
class="btn btn-transparent multi-file-commit-panel-collapse-btn" class="btn btn-transparent multi-file-commit-panel-collapse-btn"
:aria-label="__('Toggle sidebar')" :aria-label="__('Toggle sidebar')"
......
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import listItem from './list_item.vue'; import tooltip from '~/vue_shared/directives/tooltip';
import listCollapsed from './list_collapsed.vue'; import listItem from './list_item.vue';
import listCollapsed from './list_collapsed.vue';
export default { export default {
components: { components: {
icon, icon,
listItem, listItem,
listCollapsed, listCollapsed,
}, },
directives: {
tooltip,
},
props: { props: {
title: { title: {
type: String, type: String,
...@@ -42,12 +46,8 @@ ...@@ -42,12 +46,8 @@
}, },
}, },
computed: { computed: {
...mapState([ ...mapState(['rightPanelCollapsed']),
'rightPanelCollapsed', ...mapGetters(['collapseButtonIcon', 'collapseButtonTooltip']),
]),
...mapGetters([
'collapseButtonIcon',
]),
}, },
methods: { methods: {
...mapActions([ ...mapActions([
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
this[this.action](); this[this.action]();
}, },
}, },
}; };
</script> </script>
<template> <template>
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
:name="icon" :name="icon"
:size="18" :size="18"
/> />
{{ title }} {{ title }} changes
<button <button
type="button" type="button"
class="btn btn-blank btn-link ide-staged-action-btn" class="btn btn-blank btn-link ide-staged-action-btn"
...@@ -98,6 +98,10 @@ ...@@ -98,6 +98,10 @@
</div> </div>
<button <button
v-if="showToggle" v-if="showToggle"
v-tooltip
:title="collapseButtonTooltip"
data-container="body"
data-placement="left"
type="button" type="button"
class="btn btn-transparent multi-file-commit-panel-collapse-btn" class="btn btn-transparent multi-file-commit-panel-collapse-btn"
:aria-label="__('Toggle sidebar')" :aria-label="__('Toggle sidebar')"
...@@ -113,6 +117,7 @@ ...@@ -113,6 +117,7 @@
v-if="rightPanelCollapsed" v-if="rightPanelCollapsed"
:files="fileList" :files="fileList"
:icon="icon" :icon="icon"
:title="title"
/> />
<template v-else> <template v-else>
<ul <ul
......
<script> <script>
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import { sprintf, n__ } from '~/locale';
export default { export default {
components: { components: {
icon, icon,
}, },
directives: {
tooltip,
},
props: { props: {
files: { files: {
type: Array, type: Array,
...@@ -14,6 +19,10 @@ export default { ...@@ -14,6 +19,10 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
title: {
type: String,
required: true,
},
}, },
computed: { computed: {
addedFilesLength() { addedFilesLength() {
...@@ -28,6 +37,29 @@ export default { ...@@ -28,6 +37,29 @@ export default {
modifiedFilesClass() { modifiedFilesClass() {
return this.modifiedFilesLength ? 'multi-file-modified' : ''; return this.modifiedFilesLength ? 'multi-file-modified' : '';
}, },
additionsTooltip() {
return sprintf(
n__(
'1 %{type} addition',
'%d %{type} additions',
this.modifiedFilesLength,
),
{ type: this.title.toLowerCase() },
);
},
modifiedTooltip() {
return sprintf(
n__(
'1 %{type} modification',
'%d %{type} modifications',
this.modifiedFilesLength,
),
{ type: this.title.toLowerCase() },
);
},
titleTooltip() {
return `${this.title} changes`;
},
}, },
}; };
</script> </script>
...@@ -35,24 +67,47 @@ export default { ...@@ -35,24 +67,47 @@ export default {
<template> <template>
<div <div
class="multi-file-commit-list-collapsed text-center" class="multi-file-commit-list-collapsed text-center"
>
<div
v-tooltip
:title="titleTooltip"
data-container="body"
data-placement="left"
class="append-bottom-15"
> >
<icon <icon
v-once v-once
:name="icon" :name="icon"
:size="18" :size="18"
css-classes="append-bottom-15"
/> />
</div>
<div
v-tooltip
:title="additionsTooltip"
data-container="body"
data-placement="left"
class="append-bottom-10"
>
<icon <icon
name="file-addition" name="file-addition"
:size="18" :size="18"
:css-classes="addedFilesIconClass + 'append-bottom-10'" :css-classes="addedFilesIconClass"
/> />
</div>
{{ addedFilesLength }} {{ addedFilesLength }}
<div
v-tooltip
:title="modifiedTooltip"
data-container="body"
data-placement="left"
class="prepend-top-10 append-bottom-10"
>
<icon <icon
name="file-modified" name="file-modified"
:size="18" :size="18"
:css-classes="modifiedFilesClass + ' prepend-top-10 append-bottom-10'" :css-classes="modifiedFilesClass"
/> />
</div>
{{ modifiedFilesLength }} {{ modifiedFilesLength }}
</div> </div>
</template> </template>
...@@ -38,6 +38,9 @@ export default { ...@@ -38,6 +38,9 @@ export default {
router.push(`/project${file.url}`); router.push(`/project${file.url}`);
}, },
stageFile() {
alert('a');
},
}, },
}; };
</script> </script>
...@@ -47,7 +50,9 @@ export default { ...@@ -47,7 +50,9 @@ export default {
<button <button
type="button" type="button"
class="multi-file-commit-list-path" class="multi-file-commit-list-path"
@click="openFileInEditor(file)"> @dblclick="stageFile"
@click="openFileInEditor(file)"
>
<span class="multi-file-commit-list-file-path"> <span class="multi-file-commit-list-file-path">
<icon <icon
:name="iconName" :name="iconName"
......
<script> <script>
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
export default { export default {
components: { components: {
Icon, Icon,
}, },
directives: {
tooltip,
},
props: { props: {
path: { path: {
type: String, type: String,
...@@ -24,9 +28,12 @@ export default { ...@@ -24,9 +28,12 @@ export default {
class="multi-file-discard-btn" class="multi-file-discard-btn"
> >
<button <button
v-tooltip
type="button" type="button"
class="btn btn-blank append-right-5" class="btn btn-blank append-right-5"
:aria-label="__('Stage change')" :aria-label="__('Stage changes')"
:title="__('Stage changes')"
data-container="body"
@click.stop="stageChange(path)" @click.stop="stageChange(path)"
> >
<icon <icon
...@@ -35,9 +42,12 @@ export default { ...@@ -35,9 +42,12 @@ export default {
/> />
</button> </button>
<button <button
v-tooltip
type="button" type="button"
class="btn btn-blank" class="btn btn-blank"
:aria-label="__('Discard change')" :aria-label="__('Discard changes')"
:title="__('Discard changes')"
data-container="body"
@click.stop="discardFileChanges(path)" @click.stop="discardFileChanges(path)"
> >
<icon <icon
......
<script> <script>
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
export default { export default {
components: { components: {
Icon, Icon,
}, },
directives: {
tooltip,
},
props: { props: {
path: { path: {
type: String, type: String,
...@@ -24,9 +28,12 @@ export default { ...@@ -24,9 +28,12 @@ export default {
class="multi-file-discard-btn" class="multi-file-discard-btn"
> >
<button <button
v-tooltip
type="button" type="button"
class="btn btn-blank" class="btn btn-blank"
:aria-label="__('Unstage change')" :aria-label="__('Unstage changes')"
:title="__('Unstage changes')"
data-container="body"
@click="unstageChange(path)" @click="unstageChange(path)"
> >
<icon <icon
......
...@@ -103,8 +103,9 @@ export default { ...@@ -103,8 +103,9 @@ export default {
/> />
</span> </span>
<changed-file-icon <changed-file-icon
v-if="file.changed || file.tempFile || file.staged"
:file="file" :file="file"
v-if="file.changed || file.tempFile" :show-tooltip="true"
class="prepend-top-5 pull-right" class="prepend-top-5 pull-right"
/> />
<new-dropdown <new-dropdown
......
...@@ -29,3 +29,7 @@ export const collapseButtonIcon = state => ...@@ -29,3 +29,7 @@ export const collapseButtonIcon = state =>
export const hasChanges = state => export const hasChanges = state =>
!!state.changedFiles.length || !!state.stagedFiles.length; !!state.changedFiles.length || !!state.stagedFiles.length;
// eslint-disable-next-line no-confusing-arrow
export const collapseButtonTooltip = state =>
state.rightPanelCollapsed ? 'Expand sidebar' : 'Collapse sidebar';
...@@ -80,6 +80,12 @@ export default { ...@@ -80,6 +80,12 @@ export default {
Object.assign(state, { Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path), changedFiles: state.changedFiles.filter(f => f.path !== path),
entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], {
staged: true,
changed: false,
}),
}),
}); });
if (stagedFile) { if (stagedFile) {
...@@ -111,6 +117,11 @@ export default { ...@@ -111,6 +117,11 @@ export default {
Object.assign(state, { Object.assign(state, {
stagedFiles: state.stagedFiles.filter(f => f.path !== path), stagedFiles: state.stagedFiles.filter(f => f.path !== path),
entries: Object.assign(state.entries, {
[path]: Object.assign(state.entries[path], {
staged: false,
}),
}),
}); });
}, },
[types.TOGGLE_FILE_CHANGED](state, { file, changed }) { [types.TOGGLE_FILE_CHANGED](state, { file, changed }) {
......
...@@ -13,6 +13,7 @@ export const dataStructure = () => ({ ...@@ -13,6 +13,7 @@ export const dataStructure = () => ({
opened: false, opened: false,
active: false, active: false,
changed: false, changed: false,
staged: false,
lastCommitPath: '', lastCommitPath: '',
lastCommit: { lastCommit: {
id: '', id: '',
......
...@@ -64,6 +64,10 @@ ...@@ -64,6 +64,10 @@
.ide-file-changed-icon { .ide-file-changed-icon {
margin-left: auto; margin-left: auto;
> svg {
display: block;
}
} }
.ide-new-btn { .ide-new-btn {
...@@ -488,6 +492,7 @@ ...@@ -488,6 +492,7 @@
svg { svg {
margin-right: $gl-btn-padding; margin-right: $gl-btn-padding;
color: $theme-gray-700;
} }
} }
...@@ -544,7 +549,8 @@ ...@@ -544,7 +549,8 @@
flex-direction: column; flex-direction: column;
padding: $gl-padding 0; padding: $gl-padding 0;
> svg { svg {
display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
color: $theme-gray-700; color: $theme-gray-700;
......
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