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