Commit 6130a769 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'sse-backstage-branch-web-url' into 'master'

Sse backstage branch web url

See merge request gitlab-org/gitlab!30736
parents 500f70a5 deae3021
......@@ -28,7 +28,8 @@ export default {
},
returnUrl: {
type: String,
required: true,
required: false,
default: '',
},
},
};
......@@ -46,7 +47,7 @@ export default {
}}
</p>
<div class="d-flex justify-content-end">
<gl-button ref="returnToSiteButton" :href="returnUrl">{{
<gl-button v-if="returnUrl" ref="returnToSiteButton" :href="returnUrl">{{
s__('StaticSiteEditor|Return to site')
}}</gl-button>
<gl-button ref="mergeRequestButton" class="ml-2" :href="mergeRequest.url" variant="success">
......@@ -60,7 +61,7 @@ export default {
<ul>
<li>
{{ s__('StaticSiteEditor|You created a new branch:') }}
<span ref="branchLink">{{ branch.label }}</span>
<gl-link ref="branchLink" :href="branch.url">{{ branch.label }}</gl-link>
</li>
<li>
{{ s__('StaticSiteEditor|You created a merge request:') }}
......
......@@ -48,6 +48,7 @@ export default {
<!-- Success view -->
<saved-changes-message
v-if="savedContentMeta"
class="w-75"
:branch="savedContentMeta.branch"
:commit="savedContentMeta.commit"
:merge-request="savedContentMeta.mergeRequest"
......
......@@ -56,8 +56,8 @@ const submitContentChanges = ({ username, projectId, sourcePath, content }) => {
const meta = {};
return createBranch(projectId, branch)
.then(() => {
Object.assign(meta, { branch: { label: branch } });
.then(({ data: { web_url: url } }) => {
Object.assign(meta, { branch: { label: branch, url } });
return commitContent(projectId, mergeRequestTitle, branch, sourcePath, content);
})
......@@ -67,7 +67,7 @@ const submitContentChanges = ({ username, projectId, sourcePath, content }) => {
return createMergeRequest(projectId, mergeRequestTitle, branch);
})
.then(({ data: { iid: label, web_url: url } }) => {
Object.assign(meta, { mergeRequest: { label, url } });
Object.assign(meta, { mergeRequest: { label: label.toString(), url } });
return meta;
});
......
......@@ -46,14 +46,11 @@ describe('~/static_site_editor/components/saved_changes_message.vue', () => {
${'branch'} | ${findBranchLink} | ${props.branch}
${'commit'} | ${findCommitLink} | ${props.commit}
${'merge request'} | ${findMergeRequestLink} | ${props.mergeRequest}
`('renders $desc link', ({ desc, findEl, prop }) => {
`('renders $desc link', ({ findEl, prop }) => {
const el = findEl();
expect(el.exists()).toBe(true);
expect(el.text()).toBe(prop.label);
if (desc !== 'branch') {
expect(el.attributes('href')).toBe(prop.url);
}
expect(el.attributes('href')).toBe(prop.url);
});
});
......@@ -34,6 +34,9 @@ export const savedContentMeta = {
};
export const submitChangesError = 'Could not save changes';
export const commitBranchResponse = {
web_url: '/tree/root-master-patch-88195',
};
export const commitMultipleResponse = {
short_id: 'ed899a2f4b5',
web_url: '/commit/ed899a2f4b5',
......
......@@ -13,6 +13,7 @@ import submitContentChanges from '~/static_site_editor/services/submit_content_c
import {
username,
projectId,
commitBranchResponse,
commitMultipleResponse,
createMergeRequestResponse,
sourcePath,
......@@ -26,7 +27,7 @@ describe('submitContentChanges', () => {
const branch = 'branch-name';
beforeEach(() => {
jest.spyOn(Api, 'createBranch').mockResolvedValue();
jest.spyOn(Api, 'createBranch').mockResolvedValue({ data: commitBranchResponse });
jest.spyOn(Api, 'commitMultiple').mockResolvedValue({ data: commitMultipleResponse });
jest
.spyOn(Api, 'createProjectMergeRequest')
......
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