Commit 18599961 authored by Paul Slaughter's avatar Paul Slaughter Committed by Phil Hughes

Extract ide_status_list from ide_status_bar

**Why?**
The ide_status_list will be used and extended in EE.
parent 1e970f62
...@@ -146,7 +146,7 @@ export default { ...@@ -146,7 +146,7 @@ export default {
</div> </div>
<component :is="rightPaneComponent" v-if="currentProjectId" /> <component :is="rightPaneComponent" v-if="currentProjectId" />
</div> </div>
<ide-status-bar :file="activeFile" /> <ide-status-bar />
<new-modal /> <new-modal />
</article> </article>
</template> </template>
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import IdeStatusList from 'ee_else_ce/ide/components/ide_status_list.vue';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import timeAgoMixin from '~/vue_shared/mixins/timeago'; import timeAgoMixin from '~/vue_shared/mixins/timeago';
...@@ -12,18 +13,12 @@ export default { ...@@ -12,18 +13,12 @@ export default {
icon, icon,
userAvatarImage, userAvatarImage,
CiIcon, CiIcon,
IdeStatusList,
}, },
directives: { directives: {
tooltip, tooltip,
}, },
mixins: [timeAgoMixin], mixins: [timeAgoMixin],
props: {
file: {
type: Object,
required: false,
default: null,
},
},
data() { data() {
return { return {
lastCommitFormatedAge: null, lastCommitFormatedAge: null,
...@@ -125,11 +120,6 @@ export default { ...@@ -125,11 +120,6 @@ export default {
>{{ lastCommitFormatedAge }}</time >{{ lastCommitFormatedAge }}</time
> >
</div> </div>
<div v-if="file" class="ide-status-file">{{ file.name }}</div> <ide-status-list class="ml-auto" />
<div v-if="file" class="ide-status-file">{{ file.eol }}</div>
<div v-if="file && !file.binary" class="ide-status-file">
{{ file.editorRow }}:{{ file.editorColumn }}
</div>
<div v-if="file" class="ide-status-file">{{ file.fileLanguage }}</div>
</footer> </footer>
</template> </template>
<script>
import { mapGetters } from 'vuex';
export default {
computed: {
...mapGetters(['activeFile']),
},
};
</script>
<template>
<div class="ide-status-list d-flex">
<template v-if="activeFile">
<div class="ide-status-file">{{ activeFile.name }}</div>
<div class="ide-status-file">{{ activeFile.eol }}</div>
<div v-if="!activeFile.binary" class="ide-status-file">
{{ activeFile.editorRow }}:{{ activeFile.editorColumn }}
</div>
<div class="ide-status-file">{{ activeFile.fileLanguage }}</div>
</template>
<slot></slot>
</div>
</template>
...@@ -396,10 +396,6 @@ $ide-commit-header-height: 48px; ...@@ -396,10 +396,6 @@ $ide-commit-header-height: 48px;
font-size: inherit; font-size: inherit;
} }
> div + div {
padding-left: $gl-padding;
}
svg { svg {
vertical-align: sub; vertical-align: sub;
} }
...@@ -410,13 +406,14 @@ $ide-commit-header-height: 48px; ...@@ -410,13 +406,14 @@ $ide-commit-header-height: 48px;
} }
} }
.ide-status-list {
> div + div {
padding-left: $gl-padding;
}
}
.ide-status-file { .ide-status-file {
text-align: right; text-align: right;
.ide-status-branch + &,
&:first-child {
margin-left: auto;
}
} }
// Not great, but this is to deal with our current output // Not great, but this is to deal with our current output
.multi-file-preview-holder { .multi-file-preview-holder {
......
import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import IdeStatusList from '~/ide/components/ide_status_list';
const TEST_FILE = {
name: 'lorem.md',
eol: 'LF',
editorRow: 3,
editorColumn: 23,
fileLanguage: 'markdown',
};
const localVue = createLocalVue();
localVue.use(Vuex);
describe('ide/components/ide_status_list', () => {
let activeFile;
let store;
let wrapper;
const createComponent = (options = {}) => {
store = new Vuex.Store({
getters: {
activeFile: () => activeFile,
},
});
wrapper = shallowMount(localVue.extend(IdeStatusList), {
localVue,
sync: false,
store,
...options,
});
};
beforeEach(() => {
activeFile = TEST_FILE;
});
afterEach(() => {
wrapper.destroy();
store = null;
wrapper = null;
});
const getEditorPosition = file => `${file.editorRow}:${file.editorColumn}`;
describe('with regular file', () => {
beforeEach(() => {
createComponent();
});
it('shows file name', () => {
expect(wrapper.text()).toContain(TEST_FILE.name);
});
it('shows file eol', () => {
expect(wrapper.text()).toContain(TEST_FILE.name);
});
it('shows file editor position', () => {
expect(wrapper.text()).toContain(getEditorPosition(TEST_FILE));
});
it('shows file language', () => {
expect(wrapper.text()).toContain(TEST_FILE.fileLanguage);
});
});
describe('with binary file', () => {
beforeEach(() => {
activeFile.binary = true;
createComponent();
});
it('does not show file editor position', () => {
expect(wrapper.text()).not.toContain(getEditorPosition(TEST_FILE));
});
});
it('adds slot as child of list', () => {
createComponent({
slots: {
default: ['<div class="js-test">Hello</div>', '<div class="js-test">World</div>'],
},
});
expect(wrapper.find('.ide-status-list').findAll('.js-test').length).toEqual(2);
});
});
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