Commit c56d6c30 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '336052-add-fork-suggestion-component' into 'master'

Add fork suggestion component

See merge request gitlab-org/gitlab!71177
parents f9e40bc5 f65cbc2a
<script>
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
export default {
i18n: {
message: __(
'You can’t edit files directly in this project. Fork this project and submit a merge request with your changes.',
),
fork: __('Fork'),
cancel: __('Cancel'),
},
components: {
GlButton,
},
props: {
forkPath: {
type: String,
required: true,
},
},
};
</script>
<template>
<div
class="gl-display-flex gl-justify-content-end gl-align-items-center gl-bg-gray-10 gl-px-5 gl-py-2 gl-border-1 gl-border-b-solid gl-border-gray-100"
>
<span class="gl-mr-6" data-testid="message">{{ $options.i18n.message }}</span>
<gl-button
class="gl-mr-3"
category="secondary"
variant="confirm"
:href="forkPath"
data-testid="fork"
>
{{ $options.i18n.fork }}
</gl-button>
<gl-button data-testid="cancel" @click="$emit('cancel')">
{{ $options.i18n.cancel }}
</gl-button>
</div>
</template>
......@@ -38770,6 +38770,9 @@ msgstr ""
msgid "You can’t %{tag_start}edit%{tag_end} files directly in this project. Fork this project and submit a merge request with your changes."
msgstr ""
msgid "You can’t edit files directly in this project. Fork this project and submit a merge request with your changes."
msgstr ""
msgid "You could not create a new trigger."
msgstr ""
......
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ForkSuggestion from '~/repository/components/fork_suggestion.vue';
const DEFAULT_PROPS = { forkPath: 'some_file.js/fork' };
describe('ForkSuggestion component', () => {
let wrapper;
const createComponent = () => {
wrapper = shallowMountExtended(ForkSuggestion, {
propsData: { ...DEFAULT_PROPS },
});
};
beforeEach(() => createComponent());
afterEach(() => wrapper.destroy());
const { i18n } = ForkSuggestion;
const findMessage = () => wrapper.findByTestId('message');
const findForkButton = () => wrapper.findByTestId('fork');
const findCancelButton = () => wrapper.findByTestId('cancel');
it('renders a message', () => {
expect(findMessage().text()).toBe(i18n.message);
});
it('renders a Fork button', () => {
const forkButton = findForkButton();
expect(forkButton.text()).toBe(i18n.fork);
expect(forkButton.attributes('href')).toBe(DEFAULT_PROPS.forkPath);
});
it('renders a Cancel button', () => {
expect(findCancelButton().text()).toBe(i18n.cancel);
});
it('emits a cancel event when Cancel button is clicked', () => {
findCancelButton().vm.$emit('click');
expect(wrapper.emitted('cancel')).toEqual([[]]);
});
});
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