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: {
file: {
type: Object,
required: true,
}, },
props: { showTooltip: {
file: { type: Boolean,
type: Object, required: false,
required: true, default: false,
},
}, },
computed: { },
changedIcon() { computed: {
return this.file.tempFile ? 'file-addition' : 'file-modified'; changedIcon() {
}, return this.file.tempFile ? 'file-addition' : 'file-modified';
changedIconClass() {
return `multi-${this.changedIcon}`;
},
}, },
}; changedIconClass() {
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>
<icon <span
:name="changedIcon" v-tooltip
:size="12" :title="tooltipTitle"
:css-classes="`ide-file-changed-icon ${changedIconClass}`" data-container="body"
/> data-placement="right"
class="ide-file-changed-icon"
>
<icon
:name="changedIcon"
:size="12"
: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: {
title: {
type: String,
required: true,
}, },
props: { fileList: {
title: { type: Array,
type: String, required: true,
required: true,
},
fileList: {
type: Array,
required: true,
},
showToggle: {
type: Boolean,
required: false,
default: true,
},
icon: {
type: String,
required: true,
},
action: {
type: String,
required: true,
},
actionBtnText: {
type: String,
required: true,
},
itemActionComponent: {
type: String,
required: true,
},
}, },
computed: { showToggle: {
...mapState([ type: Boolean,
'rightPanelCollapsed', required: false,
]), default: true,
...mapGetters([
'collapseButtonIcon',
]),
}, },
methods: { icon: {
...mapActions([ type: String,
'toggleRightPanelCollapsed', required: true,
'stageAllChanges',
'unstageAllChanges',
]),
actionBtnClicked() {
this[this.action]();
},
}, },
}; action: {
type: String,
required: true,
},
actionBtnText: {
type: String,
required: true,
},
itemActionComponent: {
type: String,
required: true,
},
},
computed: {
...mapState(['rightPanelCollapsed']),
...mapGetters(['collapseButtonIcon', 'collapseButtonTooltip']),
},
methods: {
...mapActions([
'toggleRightPanelCollapsed',
'stageAllChanges',
'unstageAllChanges',
]),
actionBtnClicked() {
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>
...@@ -36,23 +68,46 @@ export default { ...@@ -36,23 +68,46 @@ export default {
<div <div
class="multi-file-commit-list-collapsed text-center" class="multi-file-commit-list-collapsed text-center"
> >
<icon <div
v-once v-tooltip
:name="icon" :title="titleTooltip"
:size="18" data-container="body"
css-classes="append-bottom-15" data-placement="left"
/> class="append-bottom-15"
<icon >
name="file-addition" <icon
:size="18" v-once
:css-classes="addedFilesIconClass + 'append-bottom-10'" :name="icon"
/> :size="18"
/>
</div>
<div
v-tooltip
:title="additionsTooltip"
data-container="body"
data-placement="left"
class="append-bottom-10"
>
<icon
name="file-addition"
:size="18"
:css-classes="addedFilesIconClass"
/>
</div>
{{ addedFilesLength }} {{ addedFilesLength }}
<icon <div
name="file-modified" v-tooltip
:size="18" :title="modifiedTooltip"
:css-classes="modifiedFilesClass + ' prepend-top-10 append-bottom-10'" data-container="body"
/> data-placement="left"
class="prepend-top-10 append-bottom-10"
>
<icon
name="file-modified"
:size="18"
: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