Commit 77becaeb authored by Savas Vedova's avatar Savas Vedova

Merge branch '241801-improve-i18n-project-form-group' into 'master'

Improve i18n of ProjectFormGroup

See merge request gitlab-org/gitlab!70311
parents 0a177774 90cf135b
...@@ -96,12 +96,23 @@ export default { ...@@ -96,12 +96,23 @@ export default {
} }
}, },
}, },
i18n: {
project: __('Project'),
privateForkSelected: __(
"To protect this issue's confidentiality, a private fork of this project was selected.",
),
noForks: __('No forks are available to you.'),
forkTheProject: __(
`To protect this issue's confidentiality, %{linkStart}fork this project%{linkEnd} and set the fork's visibility to private.`,
),
readMore: __('Read more'),
},
}; };
</script> </script>
<template> <template>
<div class="confidential-merge-request-fork-group form-group"> <div class="confidential-merge-request-fork-group form-group">
<label>{{ __('Project') }}</label> <label>{{ $options.i18n.project }}</label>
<div> <div>
<dropdown <dropdown
v-if="projects.length" v-if="projects.length"
...@@ -111,25 +122,13 @@ export default { ...@@ -111,25 +122,13 @@ export default {
/> />
<p class="text-muted mt-1 mb-0"> <p class="text-muted mt-1 mb-0">
<template v-if="projects.length"> <template v-if="projects.length">
{{ {{ $options.i18n.privateForkSelected }}
__(
"To protect this issue's confidentiality, a private fork of this project was selected.",
)
}}
</template> </template>
<template v-else> <template v-else>
{{ __('No forks are available to you.') }}<br /> {{ $options.i18n.noForks }}<br />
<gl-sprintf <gl-sprintf :message="$options.i18n.forkTheProject">
:message=" <template #link="{ content }">
__( <a :href="newForkPath" target="_blank" class="help-link">{{ content }}</a>
`To protect this issue's confidentiality, %{forkLink} and set the fork's visibility to private.`,
)
"
>
<template #forkLink>
<a :href="newForkPath" target="_blank" class="help-link">{{
__('fork this project')
}}</a>
</template> </template>
</gl-sprintf> </gl-sprintf>
</template> </template>
...@@ -138,7 +137,7 @@ export default { ...@@ -138,7 +137,7 @@ export default {
class="w-auto p-0 d-inline-block text-primary bg-transparent" class="w-auto p-0 d-inline-block text-primary bg-transparent"
target="_blank" target="_blank"
> >
<span class="sr-only">{{ __('Read more') }}</span> <span class="sr-only">{{ $options.i18n.readMore }}</span>
<gl-icon name="question-o" /> <gl-icon name="question-o" />
</gl-link> </gl-link>
</p> </p>
......
...@@ -35307,7 +35307,7 @@ msgstr "" ...@@ -35307,7 +35307,7 @@ msgstr ""
msgid "To preserve performance only %{strong_open}%{display_size} of %{real_size}%{strong_close} files are displayed." msgid "To preserve performance only %{strong_open}%{display_size} of %{real_size}%{strong_close} files are displayed."
msgstr "" msgstr ""
msgid "To protect this issue's confidentiality, %{forkLink} and set the fork's visibility to private." msgid "To protect this issue's confidentiality, %{linkStart}fork this project%{linkEnd} and set the fork's visibility to private."
msgstr "" msgstr ""
msgid "To protect this issue's confidentiality, a private fork of this project was selected." msgid "To protect this issue's confidentiality, a private fork of this project was selected."
...@@ -39911,9 +39911,6 @@ msgstr "" ...@@ -39911,9 +39911,6 @@ msgstr ""
msgid "fork" msgid "fork"
msgstr "" msgstr ""
msgid "fork this project"
msgstr ""
msgid "from" msgid "from"
msgstr "" msgstr ""
......
...@@ -17,11 +17,15 @@ exports[`Confidential merge request project form group component renders empty s ...@@ -17,11 +17,15 @@ exports[`Confidential merge request project form group component renders empty s
No forks are available to you. No forks are available to you.
<br /> <br />
To protect this issue's confidentiality,
<gl-sprintf-stub <a
message="To protect this issue's confidentiality, %{forkLink} and set the fork's visibility to private." class="help-link"
/> href="https://test.com"
target="_blank"
>
fork this project
</a>
and set the fork's visibility to private.
<gl-link-stub <gl-link-stub
class="w-auto p-0 d-inline-block text-primary bg-transparent" class="w-auto p-0 d-inline-block text-primary bg-transparent"
href="/help" href="/help"
...@@ -52,18 +56,16 @@ exports[`Confidential merge request project form group component renders fork dr ...@@ -52,18 +56,16 @@ exports[`Confidential merge request project form group component renders fork dr
</label> </label>
<div> <div>
<!----> <dropdown-stub
projects="[object Object],[object Object]"
selectedproject="[object Object]"
/>
<p <p
class="text-muted mt-1 mb-0" class="text-muted mt-1 mb-0"
> >
No forks are available to you. To protect this issue's confidentiality, a private fork of this project was selected.
<br />
<gl-sprintf-stub
message="To protect this issue's confidentiality, %{forkLink} and set the fork's visibility to private."
/>
<gl-link-stub <gl-link-stub
class="w-auto p-0 d-inline-block text-primary bg-transparent" class="w-auto p-0 d-inline-block text-primary bg-transparent"
......
import { GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import ProjectFormGroup from '~/confidential_merge_request/components/project_form_group.vue'; import ProjectFormGroup from '~/confidential_merge_request/components/project_form_group.vue';
...@@ -21,55 +22,52 @@ const mockData = [ ...@@ -21,55 +22,52 @@ const mockData = [
}, },
}, },
]; ];
let vm; let wrapper;
let mock; let mock;
function factory(projects = mockData) { function factory(projects = mockData) {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onGet(/api\/(.*)\/projects\/gitlab-org%2Fgitlab-ce\/forks/).reply(200, projects); mock.onGet(/api\/(.*)\/projects\/gitlab-org%2Fgitlab-ce\/forks/).reply(200, projects);
vm = shallowMount(ProjectFormGroup, { wrapper = shallowMount(ProjectFormGroup, {
propsData: { propsData: {
namespacePath: 'gitlab-org', namespacePath: 'gitlab-org',
projectPath: 'gitlab-org/gitlab-ce', projectPath: 'gitlab-org/gitlab-ce',
newForkPath: 'https://test.com', newForkPath: 'https://test.com',
helpPagePath: '/help', helpPagePath: '/help',
}, },
stubs: { GlSprintf },
}); });
return axios.waitForAll();
} }
describe('Confidential merge request project form group component', () => { describe('Confidential merge request project form group component', () => {
afterEach(() => { afterEach(() => {
mock.restore(); mock.restore();
vm.destroy(); wrapper.destroy();
}); });
it('renders fork dropdown', () => { it('renders fork dropdown', async () => {
factory(); await factory();
return vm.vm.$nextTick(() => { expect(wrapper.element).toMatchSnapshot();
expect(vm.element).toMatchSnapshot();
});
}); });
it('sets selected project as first fork', () => { it('sets selected project as first fork', async () => {
factory(); await factory();
return vm.vm.$nextTick(() => { expect(wrapper.vm.selectedProject).toEqual({
expect(vm.vm.selectedProject).toEqual({
id: 1, id: 1,
name: 'root / gitlab-ce', name: 'root / gitlab-ce',
pathWithNamespace: 'root/gitlab-ce', pathWithNamespace: 'root/gitlab-ce',
namespaceFullpath: 'root', namespaceFullpath: 'root',
}); });
}); });
});
it('renders empty state when response is empty', () => { it('renders empty state when response is empty', async () => {
factory([]); await factory([]);
return vm.vm.$nextTick(() => { expect(wrapper.element).toMatchSnapshot();
expect(vm.element).toMatchSnapshot();
});
}); });
}); });
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