Commit 93d68e10 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'tor/maintenance/source-target-branch-does-not-exist' into 'master'

Add branch name to missing branch widget text

See merge request gitlab-org/gitlab!78439
parents b3a2a400 c580a27d
<script> <script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective, GlSprintf } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables'; import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
import missingBranchQuery from '../../queries/states/missing_branch.query.graphql'; import missingBranchQuery from '../../queries/states/missing_branch.query.graphql';
import {
MR_WIDGET_MISSING_BRANCH_WHICH,
MR_WIDGET_MISSING_BRANCH_RESTORE,
MR_WIDGET_MISSING_BRANCH_MANUALCLI,
} from '../../i18n';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
export default { export default {
...@@ -13,6 +18,7 @@ export default { ...@@ -13,6 +18,7 @@ export default {
}, },
components: { components: {
GlIcon, GlIcon,
GlSprintf,
statusIcon, statusIcon,
}, },
mixins: [glFeatureFlagMixin(), mergeRequestQueryVariablesMixin], mixins: [glFeatureFlagMixin(), mergeRequestQueryVariablesMixin],
...@@ -45,26 +51,20 @@ export default { ...@@ -45,26 +51,20 @@ export default {
return this.mr.sourceBranchRemoved; return this.mr.sourceBranchRemoved;
}, },
missingBranchName() { type() {
return this.sourceBranchRemoved ? 'source' : 'target'; return this.sourceBranchRemoved ? 'source' : 'target';
}, },
missingBranchNameMessage() { name() {
return sprintf( return this.type === 'source' ? this.mr.sourceBranch : this.mr.targetBranch;
s__('mrWidget| Please restore it or use a different %{missingBranchName} branch'),
{
missingBranchName: this.missingBranchName,
}, },
); warning() {
return sprintf(MR_WIDGET_MISSING_BRANCH_WHICH, { type: this.type, name: this.name });
}, },
message() { restore() {
return sprintf( return sprintf(MR_WIDGET_MISSING_BRANCH_RESTORE, { type: this.type });
s__(
'mrWidget|If the %{missingBranchName} branch exists in your local repository, you can merge this merge request manually using the command line',
),
{
missingBranchName: this.missingBranchName,
}, },
); message() {
return sprintf(MR_WIDGET_MISSING_BRANCH_MANUALCLI, { type: this.type });
}, },
}, },
}; };
...@@ -79,9 +79,14 @@ export default { ...@@ -79,9 +79,14 @@ export default {
'gl-ml-0! gl-text-body!': glFeatures.restructuredMrWidget, 'gl-ml-0! gl-text-body!': glFeatures.restructuredMrWidget,
}" }"
class="bold js-branch-text" class="bold js-branch-text"
data-testid="widget-content"
> >
<span class="capitalize" data-testid="missingBranchName"> {{ missingBranchName }} </span> <gl-sprintf :message="warning">
{{ s__('mrWidget|branch does not exist.') }} {{ missingBranchNameMessage }} <template #code="{ content }">
<code>{{ content }}</code>
</template>
</gl-sprintf>
{{ restore }}
<gl-icon <gl-icon
v-gl-tooltip v-gl-tooltip
:title="message" :title="message"
......
import { __ } from '~/locale'; import { __, s__ } from '~/locale';
export const MR_WIDGET_MISSING_BRANCH_WHICH = s__(
'mrWidget|The %{type} branch %{codeStart}%{name}%{codeEnd} does not exist.',
);
export const MR_WIDGET_MISSING_BRANCH_RESTORE = s__(
'mrWidget|Please restore it or use a different %{type} branch.',
);
export const MR_WIDGET_MISSING_BRANCH_MANUALCLI = s__(
'mrWidget|If the %{type} branch exists in your local repository, you can merge this merge request manually using the command line.',
);
export const SQUASH_BEFORE_MERGE = { export const SQUASH_BEFORE_MERGE = {
tooltipTitle: __('Required in this project.'), tooltipTitle: __('Required in this project.'),
......
...@@ -42646,9 +42646,6 @@ msgstr "" ...@@ -42646,9 +42646,6 @@ msgstr ""
msgid "mrWidgetNothingToMerge|Use merge requests to propose changes to your project and discuss them with your team. To make changes, push a commit or edit this merge request to use a different branch. With %{linkStart}CI/CD%{linkEnd}, automatically test your changes before merging." msgid "mrWidgetNothingToMerge|Use merge requests to propose changes to your project and discuss them with your team. To make changes, push a commit or edit this merge request to use a different branch. With %{linkStart}CI/CD%{linkEnd}, automatically test your changes before merging."
msgstr "" msgstr ""
msgid "mrWidget| Please restore it or use a different %{missingBranchName} branch"
msgstr ""
msgid "mrWidget|%{boldHeaderStart}Looks like there's no pipeline here.%{boldHeaderEnd}" msgid "mrWidget|%{boldHeaderStart}Looks like there's no pipeline here.%{boldHeaderEnd}"
msgstr "" msgstr ""
...@@ -42771,7 +42768,7 @@ msgstr "" ...@@ -42771,7 +42768,7 @@ msgstr ""
msgid "mrWidget|Hide %{widget} details" msgid "mrWidget|Hide %{widget} details"
msgstr "" msgstr ""
msgid "mrWidget|If the %{missingBranchName} branch exists in your local repository, you can merge this merge request manually using the command line" msgid "mrWidget|If the %{type} branch exists in your local repository, you can merge this merge request manually using the command line."
msgstr "" msgstr ""
msgid "mrWidget|If the last pipeline ran in the fork project, it may be inaccurate. Before merge, we advise running a pipeline in this project." msgid "mrWidget|If the last pipeline ran in the fork project, it may be inaccurate. Before merge, we advise running a pipeline in this project."
...@@ -42875,6 +42872,9 @@ msgstr "" ...@@ -42875,6 +42872,9 @@ msgstr ""
msgid "mrWidget|Plain diff" msgid "mrWidget|Plain diff"
msgstr "" msgstr ""
msgid "mrWidget|Please restore it or use a different %{type} branch."
msgstr ""
msgid "mrWidget|Ready to be merged automatically. Ask someone with write access to this repository to merge this request" msgid "mrWidget|Ready to be merged automatically. Ask someone with write access to this repository to merge this request"
msgstr "" msgstr ""
...@@ -42920,6 +42920,9 @@ msgstr "" ...@@ -42920,6 +42920,9 @@ msgstr ""
msgid "mrWidget|Show %{widget} details" msgid "mrWidget|Show %{widget} details"
msgstr "" msgstr ""
msgid "mrWidget|The %{type} branch %{codeStart}%{name}%{codeEnd} does not exist."
msgstr ""
msgid "mrWidget|The changes were merged into" msgid "mrWidget|The changes were merged into"
msgstr "" msgstr ""
...@@ -42965,9 +42968,6 @@ msgstr "" ...@@ -42965,9 +42968,6 @@ msgstr ""
msgid "mrWidget|Your password" msgid "mrWidget|Your password"
msgstr "" msgstr ""
msgid "mrWidget|branch does not exist."
msgstr ""
msgid "mrWidget|into" msgid "mrWidget|into"
msgstr "" msgstr ""
......
...@@ -15,7 +15,7 @@ RSpec.describe 'Merge request > User sees deleted target branch', :js do ...@@ -15,7 +15,7 @@ RSpec.describe 'Merge request > User sees deleted target branch', :js do
end end
it 'shows a message about missing target branch' do it 'shows a message about missing target branch' do
expect(page).to have_content('Target branch does not exist') expect(page).to have_content('The target branch feature does not exist')
end end
it 'does not show link to target branch' do it 'does not show link to target branch' do
......
...@@ -17,7 +17,7 @@ RSpec.describe 'Merge request > User sees MR with deleted source branch', :js do ...@@ -17,7 +17,7 @@ RSpec.describe 'Merge request > User sees MR with deleted source branch', :js do
end end
it 'shows a message about missing source branch' do it 'shows a message about missing source branch' do
expect(page).to have_content('Source branch does not exist.') expect(page).to have_content('The source branch this-branch-does-not-exist does not exist.')
end end
it 'still contains Discussion, Commits and Changes tabs' do it 'still contains Discussion, Commits and Changes tabs' do
...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User sees MR with deleted source branch', :js do ...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User sees MR with deleted source branch', :js do
expect(page).to have_content('Changes') expect(page).to have_content('Changes')
end end
expect(page).to have_content('Source branch does not exist.') expect(page).to have_content('The source branch this-branch-does-not-exist does not exist.')
click_on 'Changes' click_on 'Changes'
wait_for_requests wait_for_requests
......
...@@ -40,7 +40,7 @@ describe('MRWidgetMissingBranch', () => { ...@@ -40,7 +40,7 @@ describe('MRWidgetMissingBranch', () => {
async ({ sourceBranchRemoved, branchName }) => { async ({ sourceBranchRemoved, branchName }) => {
await factory(sourceBranchRemoved, mergeRequestWidgetGraphql); await factory(sourceBranchRemoved, mergeRequestWidgetGraphql);
expect(wrapper.find('[data-testid="missingBranchName"]').text()).toContain(branchName); expect(wrapper.find('[data-testid="widget-content"]').text()).toContain(branchName);
}, },
); );
}); });
......
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