Commit d9f72098 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '323210-vue-blob-header-web-ide' into 'master'

Add web ide button to repo blob header

See merge request gitlab-org/gitlab!62752
parents 73a754e9 f5c6f21f
...@@ -126,7 +126,10 @@ export default { ...@@ -126,7 +126,10 @@ export default {
@viewer-changed="switchViewer" @viewer-changed="switchViewer"
> >
<template #actions> <template #actions>
<blob-header-edit :edit-path="blobInfo.editBlobPath" /> <blob-header-edit
:edit-path="blobInfo.editBlobPath"
:web-ide-path="blobInfo.ideEditPath"
/>
</template> </template>
</blob-header> </blob-header>
<blob-content <blob-content
......
...@@ -5,6 +5,7 @@ import { __ } from '~/locale'; ...@@ -5,6 +5,7 @@ import { __ } from '~/locale';
export default { export default {
i18n: { i18n: {
edit: __('Edit'), edit: __('Edit'),
webIde: __('Web IDE'),
}, },
components: { components: {
GlButton, GlButton,
...@@ -14,12 +15,22 @@ export default { ...@@ -14,12 +15,22 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
webIdePath: {
type: String,
required: true,
},
}, },
}; };
</script> </script>
<template> <template>
<gl-button category="primary" variant="confirm" class="gl-mr-3" :href="editPath"> <div>
{{ $options.i18n.edit }} <gl-button class="gl-mr-2" category="primary" variant="confirm" :href="editPath">
</gl-button> {{ $options.i18n.edit }}
</gl-button>
<gl-button class="gl-mr-3" category="primary" variant="confirm" :href="webIdePath">
{{ $options.i18n.webIde }}
</gl-button>
</div>
</template> </template>
...@@ -12,6 +12,7 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) { ...@@ -12,6 +12,7 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) {
fileType fileType
path path
editBlobPath editBlobPath
ideEditPath
storedExternally storedExternally
rawPath rawPath
replacePath replacePath
......
...@@ -162,15 +162,22 @@ describe('Blob content viewer component', () => { ...@@ -162,15 +162,22 @@ describe('Blob content viewer component', () => {
}); });
describe('BlobHeader action slot', () => { describe('BlobHeader action slot', () => {
it('renders BlobHeaderEdit button in simple viewer', async () => { const { ideEditPath, editBlobPath } = simpleMockData;
it('renders BlobHeaderEdit buttons in simple viewer', async () => {
fullFactory({ fullFactory({
mockData: { blobInfo: simpleMockData }, mockData: { blobInfo: simpleMockData },
stubs: { stubs: {
BlobContent: true, BlobContent: true,
}, },
}); });
await nextTick(); await nextTick();
expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit');
expect(findBlobHeaderEdit().props()).toMatchObject({
editPath: editBlobPath,
webIdePath: ideEditPath,
});
}); });
it('renders BlobHeaderEdit button in rich viewer', async () => { it('renders BlobHeaderEdit button in rich viewer', async () => {
...@@ -180,8 +187,13 @@ describe('Blob content viewer component', () => { ...@@ -180,8 +187,13 @@ describe('Blob content viewer component', () => {
BlobContent: true, BlobContent: true,
}, },
}); });
await nextTick(); await nextTick();
expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit');
expect(findBlobHeaderEdit().props()).toMatchObject({
editPath: editBlobPath,
webIdePath: ideEditPath,
});
}); });
}); });
}); });
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import BlobHeaderEdit from '~/repository/components/blob_header_edit.vue';
const DEFAULT_PROPS = {
editPath: 'some_file.js/edit',
webIdePath: 'some_file.js/ide/edit',
};
describe('BlobHeaderEdit component', () => {
let wrapper;
const createComponent = (props = {}) => {
wrapper = shallowMount(BlobHeaderEdit, {
propsData: {
...DEFAULT_PROPS,
...props,
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findButtons = () => wrapper.findAll(GlButton);
const findEditButton = () => findButtons().at(0);
const findWebIdeButton = () => findButtons().at(1);
it('renders component', () => {
createComponent();
const { editPath, webIdePath } = DEFAULT_PROPS;
expect(wrapper.props()).toMatchObject({
editPath,
webIdePath,
});
});
it('renders both buttons', () => {
createComponent();
expect(findButtons()).toHaveLength(2);
});
it('renders the Edit button', () => {
createComponent();
expect(findEditButton().attributes('href')).toBe(DEFAULT_PROPS.editPath);
expect(findEditButton().text()).toBe('Edit');
expect(findEditButton()).not.toBeDisabled();
});
it('renders the Web IDE button', () => {
createComponent();
expect(findWebIdeButton().attributes('href')).toBe(DEFAULT_PROPS.webIdePath);
expect(findWebIdeButton().text()).toBe('Web IDE');
expect(findWebIdeButton()).not.toBeDisabled();
});
});
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