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
Show 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 {
...
@@ -21,7 +21,7 @@ export default {
GlSprintf
,
GlSprintf
,
},
},
props
:
{
props
:
{
defaul
tBranch
:
{
curren
tBranch
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
...
@@ -40,23 +40,23 @@ export default {
...
@@ -40,23 +40,23 @@ export default {
data
()
{
data
()
{
return
{
return
{
message
:
this
.
defaultMessage
,
message
:
this
.
defaultMessage
,
branch
:
this
.
defaultBranch
,
openMergeRequest
:
false
,
openMergeRequest
:
false
,
targetBranch
:
this
.
currentBranch
,
};
};
},
},
computed
:
{
computed
:
{
is
DefaultBranch
()
{
is
CurrentBranchTarget
()
{
return
this
.
branch
===
this
.
defaul
tBranch
;
return
this
.
targetBranch
===
this
.
curren
tBranch
;
},
},
submitDisabled
()
{
submitDisabled
()
{
return
!
(
this
.
message
&&
this
.
b
ranch
);
return
!
(
this
.
message
&&
this
.
targetB
ranch
);
},
},
},
},
methods
:
{
methods
:
{
onSubmit
()
{
onSubmit
()
{
this
.
$emit
(
'
submit
'
,
{
this
.
$emit
(
'
submit
'
,
{
message
:
this
.
message
,
message
:
this
.
message
,
branch
:
this
.
b
ranch
,
targetBranch
:
this
.
targetB
ranch
,
openMergeRequest
:
this
.
openMergeRequest
,
openMergeRequest
:
this
.
openMergeRequest
,
});
});
},
},
...
@@ -100,12 +100,12 @@ export default {
...
@@ -100,12 +100,12 @@ export default {
>
>
<gl-form-input
<gl-form-input
id=
"target-branch-field"
id=
"target-branch-field"
v-model=
"
b
ranch"
v-model=
"
targetB
ranch"
class=
"gl-font-monospace!"
class=
"gl-font-monospace!"
required
required
/>
/>
<gl-form-checkbox
<gl-form-checkbox
v-if=
"!is
DefaultBranch
"
v-if=
"!is
CurrentBranchTarget
"
v-model=
"openMergeRequest"
v-model=
"openMergeRequest"
data-testid=
"new-mr-checkbox"
data-testid=
"new-mr-checkbox"
class=
"gl-mt-3"
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';
...
@@ -4,6 +4,7 @@ import { __, s__, sprintf } from '~/locale';
import
{
COMMIT_FAILURE
,
COMMIT_SUCCESS
}
from
'
../../constants
'
;
import
{
COMMIT_FAILURE
,
COMMIT_SUCCESS
}
from
'
../../constants
'
;
import
commitCIFile
from
'
../../graphql/mutations/commit_ci_file.mutation.graphql
'
;
import
commitCIFile
from
'
../../graphql/mutations/commit_ci_file.mutation.graphql
'
;
import
getCommitSha
from
'
../../graphql/queries/client/commit_sha.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
'
;
import
CommitForm
from
'
./commit_form.vue
'
;
...
@@ -21,7 +22,7 @@ export default {
...
@@ -21,7 +22,7 @@ export default {
components
:
{
components
:
{
CommitForm
,
CommitForm
,
},
},
inject
:
[
'
projectFullPath
'
,
'
ciConfigPath
'
,
'
defaultBranch
'
,
'
newMergeRequestPath
'
],
inject
:
[
'
projectFullPath
'
,
'
ciConfigPath
'
,
'
newMergeRequestPath
'
],
props
:
{
props
:
{
ciFileContent
:
{
ciFileContent
:
{
type
:
String
,
type
:
String
,
...
@@ -38,6 +39,9 @@ export default {
...
@@ -38,6 +39,9 @@ export default {
commitSha
:
{
commitSha
:
{
query
:
getCommitSha
,
query
:
getCommitSha
,
},
},
currentBranch
:
{
query
:
getCurrentBranch
,
},
},
},
computed
:
{
computed
:
{
defaultCommitMessage
()
{
defaultCommitMessage
()
{
...
@@ -49,13 +53,13 @@ export default {
...
@@ -49,13 +53,13 @@ export default {
const
url
=
mergeUrlParams
(
const
url
=
mergeUrlParams
(
{
{
[
MR_SOURCE_BRANCH
]:
sourceBranch
,
[
MR_SOURCE_BRANCH
]:
sourceBranch
,
[
MR_TARGET_BRANCH
]:
this
.
defaul
tBranch
,
[
MR_TARGET_BRANCH
]:
this
.
curren
tBranch
,
},
},
this
.
newMergeRequestPath
,
this
.
newMergeRequestPath
,
);
);
redirectTo
(
url
);
redirectTo
(
url
);
},
},
async
onCommitSubmit
({
message
,
b
ranch
,
openMergeRequest
})
{
async
onCommitSubmit
({
message
,
targetB
ranch
,
openMergeRequest
})
{
this
.
isSaving
=
true
;
this
.
isSaving
=
true
;
try
{
try
{
...
@@ -67,8 +71,8 @@ export default {
...
@@ -67,8 +71,8 @@ export default {
mutation
:
commitCIFile
,
mutation
:
commitCIFile
,
variables
:
{
variables
:
{
projectPath
:
this
.
projectFullPath
,
projectPath
:
this
.
projectFullPath
,
branch
,
branch
:
targetBranch
,
startBranch
:
this
.
defaul
tBranch
,
startBranch
:
this
.
curren
tBranch
,
message
,
message
,
filePath
:
this
.
ciConfigPath
,
filePath
:
this
.
ciConfigPath
,
content
:
this
.
ciFileContent
,
content
:
this
.
ciFileContent
,
...
@@ -86,7 +90,7 @@ export default {
...
@@ -86,7 +90,7 @@ export default {
if
(
errors
?.
length
)
{
if
(
errors
?.
length
)
{
this
.
$emit
(
'
showError
'
,
{
type
:
COMMIT_FAILURE
,
reasons
:
errors
});
this
.
$emit
(
'
showError
'
,
{
type
:
COMMIT_FAILURE
,
reasons
:
errors
});
}
else
if
(
openMergeRequest
)
{
}
else
if
(
openMergeRequest
)
{
this
.
redirectToNewMergeRequest
(
b
ranch
);
this
.
redirectToNewMergeRequest
(
targetB
ranch
);
}
else
{
}
else
{
this
.
$emit
(
'
commit
'
,
{
type
:
COMMIT_SUCCESS
});
this
.
$emit
(
'
commit
'
,
{
type
:
COMMIT_SUCCESS
});
}
}
...
@@ -105,7 +109,7 @@ export default {
...
@@ -105,7 +109,7 @@ export default {
<
template
>
<
template
>
<commit-form
<commit-form
:
default-branch=
"defaul
tBranch"
:
current-branch=
"curren
tBranch"
:default-message=
"defaultCommitMessage"
:default-message=
"defaultCommitMessage"
:is-saving=
"isSaving"
:is-saving=
"isSaving"
@
cancel=
"onCommitCancel"
@
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') => {
...
@@ -22,6 +22,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
const
{
const
{
// Add to apollo cache as it can be updated by future queries
// Add to apollo cache as it can be updated by future queries
commitSha
,
commitSha
,
initialBranchName
,
// Add to provide/inject API for static values
// Add to provide/inject API for static values
ciConfigPath
,
ciConfigPath
,
defaultBranch
,
defaultBranch
,
...
@@ -42,6 +43,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
...
@@ -42,6 +43,7 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeData
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeData
({
data
:
{
data
:
{
currentBranch
:
initialBranchName
||
defaultBranch
,
commitSha
,
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
...
@@ -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
{
COMMIT_FAILURE
,
COMMIT_SUCCESS
,
DEFAULT_FAILURE
,
LOAD_FAILURE_UNKNOWN
}
from
'
./constants
'
;
import
getBlobContent
from
'
./graphql/queries/blob_content.graphql
'
;
import
getBlobContent
from
'
./graphql/queries/blob_content.graphql
'
;
import
getCiConfigData
from
'
./graphql/queries/ci_config.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
'
;
import
PipelineEditorHome
from
'
./pipeline_editor_home.vue
'
;
export
default
{
export
default
{
...
@@ -23,9 +24,6 @@ export default {
...
@@ -23,9 +24,6 @@ export default {
ciConfigPath
:
{
ciConfigPath
:
{
default
:
''
,
default
:
''
,
},
},
defaultBranch
:
{
default
:
null
,
},
projectFullPath
:
{
projectFullPath
:
{
default
:
''
,
default
:
''
,
},
},
...
@@ -58,7 +56,7 @@ export default {
...
@@ -58,7 +56,7 @@ export default {
return
{
return
{
projectPath
:
this
.
projectFullPath
,
projectPath
:
this
.
projectFullPath
,
path
:
this
.
ciConfigPath
,
path
:
this
.
ciConfigPath
,
ref
:
this
.
defaul
tBranch
,
ref
:
this
.
curren
tBranch
,
};
};
},
},
update
(
data
)
{
update
(
data
)
{
...
@@ -97,6 +95,9 @@ export default {
...
@@ -97,6 +95,9 @@ export default {
this
.
reportFailure
(
LOAD_FAILURE_UNKNOWN
);
this
.
reportFailure
(
LOAD_FAILURE_UNKNOWN
);
},
},
},
},
currentBranch
:
{
query
:
getCurrentBranch
,
},
},
},
computed
:
{
computed
:
{
hasUnsavedChanges
()
{
hasUnsavedChanges
()
{
...
...
app/views/projects/ci/pipeline_editor/show.html.haml
View file @
d69f1899
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
"commit-sha"
=>
@project
.
commit
?
@project
.
commit
.
sha
:
''
,
"commit-sha"
=>
@project
.
commit
?
@project
.
commit
.
sha
:
''
,
"default-branch"
=>
@project
.
default_branch
,
"default-branch"
=>
@project
.
default_branch
,
"empty-state-illustration-path"
=>
image_path
(
'illustrations/empty-state/empty-dag-md.svg'
),
"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'
),
"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
,
"new-merge-request-path"
=>
namespace_project_new_merge_request_path
,
"project-path"
=>
@project
.
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', () => {
...
@@ -12,7 +12,7 @@ describe('Pipeline Editor | Commit Form', () => {
wrapper
=
mountFn
(
CommitForm
,
{
wrapper
=
mountFn
(
CommitForm
,
{
propsData
:
{
propsData
:
{
defaultMessage
:
mockCommitMessage
,
defaultMessage
:
mockCommitMessage
,
defaul
tBranch
:
mockDefaultBranch
,
curren
tBranch
:
mockDefaultBranch
,
...
props
,
...
props
,
},
},
...
@@ -41,7 +41,7 @@ describe('Pipeline Editor | Commit Form', () => {
...
@@ -41,7 +41,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
findCommitTextarea
().
attributes
(
'
value
'
)).
toBe
(
mockCommitMessage
);
expect
(
findCommitTextarea
().
attributes
(
'
value
'
)).
toBe
(
mockCommitMessage
);
});
});
it
(
'
shows
a defaul
t branch
'
,
()
=>
{
it
(
'
shows
curren
t branch
'
,
()
=>
{
expect
(
findBranchInput
().
attributes
(
'
value
'
)).
toBe
(
mockDefaultBranch
);
expect
(
findBranchInput
().
attributes
(
'
value
'
)).
toBe
(
mockDefaultBranch
);
});
});
...
@@ -66,7 +66,7 @@ describe('Pipeline Editor | Commit Form', () => {
...
@@ -66,7 +66,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
{
{
message
:
mockCommitMessage
,
message
:
mockCommitMessage
,
b
ranch
:
mockDefaultBranch
,
targetB
ranch
:
mockDefaultBranch
,
openMergeRequest
:
false
,
openMergeRequest
:
false
,
},
},
]);
]);
...
@@ -101,7 +101,7 @@ describe('Pipeline Editor | Commit Form', () => {
...
@@ -101,7 +101,7 @@ describe('Pipeline Editor | Commit Form', () => {
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
expect
(
wrapper
.
emitted
(
'
submit
'
)[
0
]).
toEqual
([
{
{
message
:
anotherMessage
,
message
:
anotherMessage
,
b
ranch
:
anotherBranch
,
targetB
ranch
:
anotherBranch
,
openMergeRequest
:
true
,
openMergeRequest
:
true
,
},
},
]);
]);
...
...
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
View file @
d69f1899
...
@@ -35,7 +35,6 @@ const mockVariables = {
...
@@ -35,7 +35,6 @@ const mockVariables = {
const
mockProvide
=
{
const
mockProvide
=
{
ciConfigPath
:
mockCiConfigPath
,
ciConfigPath
:
mockCiConfigPath
,
defaultBranch
:
mockDefaultBranch
,
projectFullPath
:
mockProjectFullPath
,
projectFullPath
:
mockProjectFullPath
,
newMergeRequestPath
:
mockNewMergeRequestPath
,
newMergeRequestPath
:
mockNewMergeRequestPath
,
};
};
...
@@ -64,6 +63,7 @@ describe('Pipeline Editor | Commit section', () => {
...
@@ -64,6 +63,7 @@ describe('Pipeline Editor | Commit section', () => {
data
()
{
data
()
{
return
{
return
{
commitSha
:
mockCommitSha
,
commitSha
:
mockCommitSha
,
currentBranch
:
mockDefaultBranch
,
};
};
},
},
mocks
:
{
mocks
:
{
...
@@ -116,7 +116,7 @@ describe('Pipeline Editor | Commit section', () => {
...
@@ -116,7 +116,7 @@ describe('Pipeline Editor | Commit section', () => {
await
submitCommit
();
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
).
toHaveBeenCalledTimes
(
1
);
expect
(
mockMutate
).
toHaveBeenCalledWith
({
expect
(
mockMutate
).
toHaveBeenCalledWith
({
mutation
:
commitCreate
,
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