Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d69f1899
Commit
d69f1899
authored
Mar 09, 2021
by
Mireya Andres
Committed by
Sarah Groff Hennigh-Palermo
Mar 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to work on non-default branch in pipeline editor
parent
48e6b011
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
25 deletions
+41
-25
app/assets/javascripts/pipeline_editor/components/commit/commit_form.vue
...scripts/pipeline_editor/components/commit/commit_form.vue
+8
-8
app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue
...ipts/pipeline_editor/components/commit/commit_section.vue
+11
-7
app/assets/javascripts/pipeline_editor/graphql/queries/client/current_branch.graphql
...line_editor/graphql/queries/client/current_branch.graphql
+3
-0
app/assets/javascripts/pipeline_editor/index.js
app/assets/javascripts/pipeline_editor/index.js
+2
-0
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
...ssets/javascripts/pipeline_editor/pipeline_editor_app.vue
+5
-4
app/views/projects/ci/pipeline_editor/show.html.haml
app/views/projects/ci/pipeline_editor/show.html.haml
+1
-0
changelogs/unreleased/pipeline-editor-branch-param.yml
changelogs/unreleased/pipeline-editor-branch-param.yml
+5
-0
spec/frontend/pipeline_editor/components/commit/commit_form_spec.js
...end/pipeline_editor/components/commit/commit_form_spec.js
+4
-4
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
.../pipeline_editor/components/commit/commit_section_spec.js
+2
-2
No files found.
app/assets/javascripts/pipeline_editor/components/commit/commit_form.vue
View file @
d69f1899
...
...
@@ -21,7 +21,7 @@ export default {
GlSprintf
,
},
props
:
{
defaul
tBranch
:
{
curren
tBranch
:
{
type
:
String
,
required
:
false
,
default
:
''
,
...
...
@@ -40,23 +40,23 @@ export default {
data
()
{
return
{
message
:
this
.
defaultMessage
,
branch
:
this
.
defaultBranch
,
openMergeRequest
:
false
,
targetBranch
:
this
.
currentBranch
,
};
},
computed
:
{
is
DefaultBranch
()
{
return
this
.
branch
===
this
.
defaul
tBranch
;
is
CurrentBranchTarget
()
{
return
this
.
targetBranch
===
this
.
curren
tBranch
;
},
submitDisabled
()
{
return
!
(
this
.
message
&&
this
.
b
ranch
);
return
!
(
this
.
message
&&
this
.
targetB
ranch
);
},
},
methods
:
{
onSubmit
()
{
this
.
$emit
(
'
submit
'
,
{
message
:
this
.
message
,
branch
:
this
.
b
ranch
,
targetBranch
:
this
.
targetB
ranch
,
openMergeRequest
:
this
.
openMergeRequest
,
});
},
...
...
@@ -100,12 +100,12 @@ export default {
>
<gl-form-input
id=
"target-branch-field"
v-model=
"
b
ranch"
v-model=
"
targetB
ranch"
class=
"gl-font-monospace!"
required
/>
<gl-form-checkbox
v-if=
"!is
DefaultBranch
"
v-if=
"!is
CurrentBranchTarget
"
v-model=
"openMergeRequest"
data-testid=
"new-mr-checkbox"
class=
"gl-mt-3"
...
...
app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue
View file @
d69f1899
...
...
@@ -4,6 +4,7 @@ import { __, s__, sprintf } from '~/locale';
import
{
COMMIT_FAILURE
,
COMMIT_SUCCESS
}
from
'
../../constants
'
;
import
commitCIFile
from
'
../../graphql/mutations/commit_ci_file.mutation.graphql
'
;
import
getCommitSha
from
'
../../graphql/queries/client/commit_sha.graphql
'
;
import
getCurrentBranch
from
'
../../graphql/queries/client/current_branch.graphql
'
;
import
CommitForm
from
'
./commit_form.vue
'
;
...
...
@@ -21,7 +22,7 @@ export default {
components
:
{
CommitForm
,
},
inject
:
[
'
projectFullPath
'
,
'
ciConfigPath
'
,
'
defaultBranch
'
,
'
newMergeRequestPath
'
],
inject
:
[
'
projectFullPath
'
,
'
ciConfigPath
'
,
'
newMergeRequestPath
'
],
props
:
{
ciFileContent
:
{
type
:
String
,
...
...
@@ -38,6 +39,9 @@ export default {
commitSha
:
{
query
:
getCommitSha
,
},
currentBranch
:
{
query
:
getCurrentBranch
,
},
},
computed
:
{
defaultCommitMessage
()
{
...
...
@@ -49,13 +53,13 @@ export default {
const
url
=
mergeUrlParams
(
{
[
MR_SOURCE_BRANCH
]:
sourceBranch
,
[
MR_TARGET_BRANCH
]:
this
.
defaul
tBranch
,
[
MR_TARGET_BRANCH
]:
this
.
curren
tBranch
,
},
this
.
newMergeRequestPath
,
);
redirectTo
(
url
);
},
async
onCommitSubmit
({
message
,
b
ranch
,
openMergeRequest
})
{
async
onCommitSubmit
({
message
,
targetB
ranch
,
openMergeRequest
})
{
this
.
isSaving
=
true
;
try
{
...
...
@@ -67,8 +71,8 @@ export default {
mutation
:
commitCIFile
,
variables
:
{
projectPath
:
this
.
projectFullPath
,
branch
,
startBranch
:
this
.
defaul
tBranch
,
branch
:
targetBranch
,
startBranch
:
this
.
curren
tBranch
,
message
,
filePath
:
this
.
ciConfigPath
,
content
:
this
.
ciFileContent
,
...
...
@@ -86,7 +90,7 @@ export default {
if
(
errors
?.
length
)
{
this
.
$emit
(
'
showError
'
,
{
type
:
COMMIT_FAILURE
,
reasons
:
errors
});
}
else
if
(
openMergeRequest
)
{
this
.
redirectToNewMergeRequest
(
b
ranch
);
this
.
redirectToNewMergeRequest
(
targetB
ranch
);
}
else
{
this
.
$emit
(
'
commit
'
,
{
type
:
COMMIT_SUCCESS
});
}
...
...
@@ -105,7 +109,7 @@ export default {
<
template
>
<commit-form
:
default-branch=
"defaul
tBranch"
:
current-branch=
"curren
tBranch"
:default-message=
"defaultCommitMessage"
:is-saving=
"isSaving"
@
cancel=
"onCommitCancel"
...
...
app/assets/javascripts/pipeline_editor/graphql/queries/client/current_branch.graphql
0 → 100644
View file @
d69f1899
query
getCurrentBranch
{
currentBranch
@client
}
app/assets/javascripts/pipeline_editor/index.js
View file @
d69f1899
...
...
@@ -22,6 +22,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
const
{
// Add to apollo cache as it can be updated by future queries
commitSha
,
initialBranchName
,
// Add to provide/inject API for static values
ciConfigPath
,
defaultBranch
,
...
...
@@ -42,6 +43,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeData
({
data
:
{
currentBranch
:
initialBranchName
||
defaultBranch
,
commitSha
,
},
});
...
...
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
View file @
d69f1899
...
...
@@ -9,6 +9,7 @@ import PipelineEditorEmptyState from './components/ui/pipeline_editor_empty_stat
import
{
COMMIT_FAILURE
,
COMMIT_SUCCESS
,
DEFAULT_FAILURE
,
LOAD_FAILURE_UNKNOWN
}
from
'
./constants
'
;
import
getBlobContent
from
'
./graphql/queries/blob_content.graphql
'
;
import
getCiConfigData
from
'
./graphql/queries/ci_config.graphql
'
;
import
getCurrentBranch
from
'
./graphql/queries/client/current_branch.graphql
'
;
import
PipelineEditorHome
from
'
./pipeline_editor_home.vue
'
;
export
default
{
...
...
@@ -23,9 +24,6 @@ export default {
ciConfigPath
:
{
default
:
''
,
},
defaultBranch
:
{
default
:
null
,
},
projectFullPath
:
{
default
:
''
,
},
...
...
@@ -58,7 +56,7 @@ export default {
return
{
projectPath
:
this
.
projectFullPath
,
path
:
this
.
ciConfigPath
,
ref
:
this
.
defaul
tBranch
,
ref
:
this
.
curren
tBranch
,
};
},
update
(
data
)
{
...
...
@@ -97,6 +95,9 @@ export default {
this
.
reportFailure
(
LOAD_FAILURE_UNKNOWN
);
},
},
currentBranch
:
{
query
:
getCurrentBranch
,
},
},
computed
:
{
hasUnsavedChanges
()
{
...
...
app/views/projects/ci/pipeline_editor/show.html.haml
View file @
d69f1899
...
...
@@ -4,6 +4,7 @@
"commit-sha"
=>
@project
.
commit
?
@project
.
commit
.
sha
:
''
,
"default-branch"
=>
@project
.
default_branch
,
"empty-state-illustration-path"
=>
image_path
(
'illustrations/empty-state/empty-dag-md.svg'
),
"initial-branch-name"
:
params
[
:branch_name
],
"lint-help-page-path"
=>
help_page_path
(
'ci/lint'
,
anchor:
'validate-basic-logic-and-syntax'
),
"new-merge-request-path"
=>
namespace_project_new_merge_request_path
,
"project-path"
=>
@project
.
path
,
...
...
changelogs/unreleased/pipeline-editor-branch-param.yml
0 → 100644
View file @
d69f1899
---
title
:
Allow users to work on non-default branch in pipeline editor
merge_request
:
55413
author
:
type
:
added
spec/frontend/pipeline_editor/components/commit/commit_form_spec.js
View file @
d69f1899
...
...
@@ -12,7 +12,7 @@ describe('Pipeline Editor | Commit Form', () => {
wrapper
=
mountFn
(
CommitForm
,
{
propsData
:
{
defaultMessage
:
mockCommitMessage
,
defaul
tBranch
:
mockDefaultBranch
,
curren
tBranch
:
mockDefaultBranch
,
...
props
,
},
...
...
@@ -41,7 +41,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
findCommitTextarea
().
attributes
(
'
value
'
)).
toBe
(
mockCommitMessage
);
});
it
(
'
shows
a defaul
t branch
'
,
()
=>
{
it
(
'
shows
curren
t branch
'
,
()
=>
{
expect
(
findBranchInput
().
attributes
(
'
value
'
)).
toBe
(
mockDefaultBranch
);
});
...
...
@@ -66,7 +66,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
{
message
:
mockCommitMessage
,
b
ranch
:
mockDefaultBranch
,
targetB
ranch
:
mockDefaultBranch
,
openMergeRequest
:
false
,
},
]);
...
...
@@ -101,7 +101,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
{
message
:
anotherMessage
,
b
ranch
:
anotherBranch
,
targetB
ranch
:
anotherBranch
,
openMergeRequest
:
true
,
},
]);
...
...
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
View file @
d69f1899
...
...
@@ -35,7 +35,6 @@ const mockVariables = {
const
mockProvide
=
{
ciConfigPath
:
mockCiConfigPath
,
defaultBranch
:
mockDefaultBranch
,
projectFullPath
:
mockProjectFullPath
,
newMergeRequestPath
:
mockNewMergeRequestPath
,
};
...
...
@@ -64,6 +63,7 @@ describe('Pipeline Editor | Commit section', () => {
data
()
{
return
{
commitSha
:
mockCommitSha
,
currentBranch
:
mockDefaultBranch
,
};
},
mocks
:
{
...
...
@@ -116,7 +116,7 @@ describe('Pipeline Editor | Commit section', () => {
await
submitCommit
();
});
it
(
'
calls the mutation with the
defaul
t branch
'
,
()
=>
{
it
(
'
calls the mutation with the
curren
t branch
'
,
()
=>
{
expect
(
mockMutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mockMutate
).
toHaveBeenCalledWith
({
mutation
:
commitCreate
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment