Commit 66618af0 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '323210-vue-blob-header-consolidated-edit-button' into 'master'

Add consolidated edit buttons to repo blob header

See merge request gitlab-org/gitlab!62753
parents 54fee676 b685ac52
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
i18n: { i18n: {
...@@ -9,7 +11,9 @@ export default { ...@@ -9,7 +11,9 @@ export default {
}, },
components: { components: {
GlButton, GlButton,
WebIdeLink,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
editPath: { editPath: {
type: String, type: String,
...@@ -24,7 +28,14 @@ export default { ...@@ -24,7 +28,14 @@ export default {
</script> </script>
<template> <template>
<div> <web-ide-link
v-if="glFeatures.consolidatedEditButton"
class="gl-mr-3"
:edit-url="editPath"
:web-ide-url="webIdePath"
:is-blob="true"
/>
<div v-else>
<gl-button class="gl-mr-2" category="primary" variant="confirm" :href="editPath"> <gl-button class="gl-mr-2" category="primary" variant="confirm" :href="editPath">
{{ $options.i18n.edit }} {{ $options.i18n.edit }}
</gl-button> </gl-button>
......
...@@ -39,6 +39,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -39,6 +39,7 @@ class Projects::BlobController < Projects::ApplicationController
before_action do before_action do
push_frontend_feature_flag(:refactor_blob_viewer, @project, default_enabled: :yaml) push_frontend_feature_flag(:refactor_blob_viewer, @project, default_enabled: :yaml)
push_frontend_feature_flag(:consolidated_edit_button, @project, default_enabled: :yaml)
end end
def new def new
......
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import BlobHeaderEdit from '~/repository/components/blob_header_edit.vue'; import BlobHeaderEdit from '~/repository/components/blob_header_edit.vue';
import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
const DEFAULT_PROPS = { const DEFAULT_PROPS = {
editPath: 'some_file.js/edit', editPath: 'some_file.js/edit',
...@@ -10,12 +11,17 @@ const DEFAULT_PROPS = { ...@@ -10,12 +11,17 @@ const DEFAULT_PROPS = {
describe('BlobHeaderEdit component', () => { describe('BlobHeaderEdit component', () => {
let wrapper; let wrapper;
const createComponent = (props = {}) => { const createComponent = (consolidatedEditButton = false, props = {}) => {
wrapper = shallowMount(BlobHeaderEdit, { wrapper = shallowMount(BlobHeaderEdit, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
...props, ...props,
}, },
provide: {
glFeatures: {
consolidatedEditButton,
},
},
}); });
}; };
...@@ -27,6 +33,7 @@ describe('BlobHeaderEdit component', () => { ...@@ -27,6 +33,7 @@ describe('BlobHeaderEdit component', () => {
const findButtons = () => wrapper.findAll(GlButton); const findButtons = () => wrapper.findAll(GlButton);
const findEditButton = () => findButtons().at(0); const findEditButton = () => findButtons().at(0);
const findWebIdeButton = () => findButtons().at(1); const findWebIdeButton = () => findButtons().at(1);
const findWebIdeLink = () => wrapper.find(WebIdeLink);
it('renders component', () => { it('renders component', () => {
createComponent(); createComponent();
...@@ -60,4 +67,16 @@ describe('BlobHeaderEdit component', () => { ...@@ -60,4 +67,16 @@ describe('BlobHeaderEdit component', () => {
expect(findWebIdeButton().text()).toBe('Web IDE'); expect(findWebIdeButton().text()).toBe('Web IDE');
expect(findWebIdeButton()).not.toBeDisabled(); expect(findWebIdeButton()).not.toBeDisabled();
}); });
it('renders WebIdeLink component', () => {
createComponent(true);
const { editPath: editUrl, webIdePath: webIdeUrl } = DEFAULT_PROPS;
expect(findWebIdeLink().props()).toMatchObject({
editUrl,
webIdeUrl,
isBlob: true,
});
});
}); });
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