Commit 7577d713 authored by Phil Hughes's avatar Phil Hughes

Merge branch '4572-open-staged-files-in-editor' into 'master'

Open staged files from Web IDE right sidebar

Closes #4572

See merge request gitlab-org/gitlab-ee!4704
parents 265df23c ee0cd7e1
<script> <script>
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import router from '~/ide/ide_router';
import icon from '../../../vue_shared/components/icon.vue'; import icon from '../../../vue_shared/components/icon.vue';
export default { export default {
...@@ -24,20 +25,27 @@ ...@@ -24,20 +25,27 @@
...mapActions([ ...mapActions([
'discardFileChanges', 'discardFileChanges',
]), ]),
openFileInEditor(file) {
router.push(`/project${file.url}`);
},
}, },
}; };
</script> </script>
<template> <template>
<div class="multi-file-commit-list-item"> <div class="multi-file-commit-list-item">
<icon <button
:name="iconName" type="button"
:size="16" class="multi-file-commit-list-path"
:css-classes="iconClass" @click="openFileInEditor(file)">
/> <span class="multi-file-commit-list-file-path">
<span class="multi-file-commit-list-path"> <icon
{{ file.path }} :name="iconName"
</span> :size="16"
:css-classes="iconClass"
/>{{ file.path }}
</span>
</button>
<button <button
type="button" type="button"
class="btn btn-blank multi-file-discard-btn" class="btn btn-blank multi-file-discard-btn"
......
...@@ -409,25 +409,30 @@ table.table tr td.multi-file-table-name { ...@@ -409,25 +409,30 @@ table.table tr td.multi-file-table-name {
.multi-file-commit-list { .multi-file-commit-list {
flex: 1; flex: 1;
overflow: auto; overflow: auto;
padding: $gl-padding; padding: $gl-padding 0;
min-height: 60px;
} }
.multi-file-commit-list-item { .multi-file-commit-list-item {
display: flex; display: flex;
margin-bottom: $grid-size; padding: 0;
align-items: center; align-items: center;
> svg {
min-width: 16px;
}
.multi-file-discard-btn { .multi-file-discard-btn {
display: none; display: none;
margin-left: auto; margin-left: auto;
color: $gl-link-color; color: $gl-link-color;
padding: 0 2px;
&:focus,
&:hover {
text-decoration: underline;
}
} }
&:hover { &:hover {
background: $white-normal;
.multi-file-discard-btn { .multi-file-discard-btn {
display: block; display: block;
} }
...@@ -460,7 +465,36 @@ table.table tr td.multi-file-table-name { ...@@ -460,7 +465,36 @@ table.table tr td.multi-file-table-name {
} }
.multi-file-commit-list-path { .multi-file-commit-list-path {
padding: $grid-size / 2;
padding-left: $gl-padding;
background: none;
border: 0;
text-align: left;
width: 100%;
min-width: 0;
svg {
min-width: 16px;
vertical-align: middle;
display: inline-block;
}
&:hover,
&:focus {
outline: 0;
}
}
.multi-file-commit-list-file-path {
@include str-truncated(100%); @include str-truncated(100%);
&:hover {
text-decoration: underline;
}
&:active {
text-decoration: none;
}
} }
.multi-file-commit-form { .multi-file-commit-form {
......
---
title: Allow clicking on Staged Files in WebIDE to open them in the Editor
merge_request:
author:
type: other
import Vue from 'vue'; import Vue from 'vue';
import listItem from '~/ide/components/commit_sidebar/list_item.vue'; import listItem from '~/ide/components/commit_sidebar/list_item.vue';
import router from '~/ide/ide_router';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { file } from '../../helpers'; import { file } from '../../helpers';
...@@ -33,6 +34,16 @@ describe('Multi-file editor commit sidebar list item', () => { ...@@ -33,6 +34,16 @@ describe('Multi-file editor commit sidebar list item', () => {
expect(vm.discardFileChanges).toHaveBeenCalled(); expect(vm.discardFileChanges).toHaveBeenCalled();
}); });
it('opens a closed file in the editor when clicking the file path', () => {
spyOn(vm, 'openFileInEditor').and.callThrough();
spyOn(router, 'push');
vm.$el.querySelector('.multi-file-commit-list-path').click();
expect(vm.openFileInEditor).toHaveBeenCalled();
expect(router.push).toHaveBeenCalled();
});
describe('computed', () => { describe('computed', () => {
describe('iconName', () => { describe('iconName', () => {
it('returns modified when not a tempFile', () => { it('returns modified when not a tempFile', () => {
......
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