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
a97ea52b
Commit
a97ea52b
authored
Jul 15, 2021
by
Mireya Andres
Committed by
Sarah Groff Hennigh-Palermo
Jul 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sha to CiConfig graphql query
parent
111e48c4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
94 deletions
+33
-94
app/assets/javascripts/pipeline_editor/components/editor/ci_config_merged_preview.vue
...ine_editor/components/editor/ci_config_merged_preview.vue
+15
-53
app/assets/javascripts/pipeline_editor/graphql/queries/ci_config.graphql
...scripts/pipeline_editor/graphql/queries/ci_config.graphql
+2
-2
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
...ssets/javascripts/pipeline_editor/pipeline_editor_app.vue
+5
-0
doc/ci/pipeline_editor/index.md
doc/ci/pipeline_editor/index.md
+0
-3
locale/gitlab.pot
locale/gitlab.pot
+0
-6
spec/frontend/pipeline_editor/components/editor/ci_config_merged_preview_spec.js
...editor/components/editor/ci_config_merged_preview_spec.js
+2
-29
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
+9
-1
No files found.
app/assets/javascripts/pipeline_editor/components/editor/ci_config_merged_preview.vue
View file @
a97ea52b
<
script
>
<
script
>
import
{
Gl
Alert
,
GlLink
,
GlSprintf
,
Gl
Icon
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
uniqueId
}
from
'
lodash
'
;
import
{
uniqueId
}
from
'
lodash
'
;
import
{
helpPagePath
}
from
'
~/helpers/help_page_helper
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
SourceEditor
from
'
~/vue_shared/components/source_editor.vue
'
;
import
SourceEditor
from
'
~/vue_shared/components/source_editor.vue
'
;
import
getCurrentBranch
from
'
../../graphql/queries/client/current_branch.graphql
'
;
export
default
{
export
default
{
i18n
:
{
i18n
:
{
viewOnlyMessage
:
s__
(
'
Pipelines|Merged YAML is view only
'
),
viewOnlyMessage
:
s__
(
'
Pipelines|Merged YAML is view only
'
),
unavailableDefaultTitle
:
s__
(
'
Pipelines|Merged YAML unavailable
'
),
unavailableDefaultText
:
s__
(
'
Pipelines|The merged YAML view is only available for the default branch. %{linkStart}Learn more.%{linkEnd}
'
,
),
},
},
components
:
{
components
:
{
SourceEditor
,
SourceEditor
,
GlAlert
,
GlIcon
,
GlIcon
,
GlLink
,
GlSprintf
,
},
},
inject
:
[
'
ciConfigPath
'
,
'
defaultBranch
'
],
inject
:
[
'
ciConfigPath
'
],
props
:
{
props
:
{
ciConfigData
:
{
ciConfigData
:
{
type
:
Object
,
type
:
Object
,
...
@@ -33,15 +24,6 @@ export default {
...
@@ -33,15 +24,6 @@ export default {
failureType
:
null
,
failureType
:
null
,
};
};
},
},
// This is not the best practice, don't copy me (@samdbeckham)
// This is a temporary workaround to unblock a release.
// See this comment for more information on this approach
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65972#note_626095648
apollo
:
{
currentBranch
:
{
query
:
getCurrentBranch
,
},
},
computed
:
{
computed
:
{
fileGlobalId
()
{
fileGlobalId
()
{
return
`
${
this
.
ciConfigPath
}
-
${
uniqueId
()}
`
;
return
`
${
this
.
ciConfigPath
}
-
${
uniqueId
()}
`
;
...
@@ -49,44 +31,24 @@ export default {
...
@@ -49,44 +31,24 @@ export default {
mergedYaml
()
{
mergedYaml
()
{
return
this
.
ciConfigData
.
mergedYaml
;
return
this
.
ciConfigData
.
mergedYaml
;
},
},
isOnDefaultBranch
()
{
return
this
.
currentBranch
===
this
.
defaultBranch
;
},
expandedConfigHelpPath
()
{
return
helpPagePath
(
'
ci/pipeline_editor/index
'
,
{
anchor
:
'
view-expanded-configuration
'
});
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<div>
<div
v-if=
"isOnDefaultBranch"
>
<div
class=
"gl-display-flex gl-align-items-center"
>
<div
class=
"gl-display-flex gl-align-items-center"
>
<gl-icon
:size=
"16"
name=
"lock"
class=
"gl-text-gray-500 gl-mr-3"
/>
<gl-icon
:size=
"16"
name=
"lock"
class=
"gl-text-gray-500 gl-mr-3"
/>
{{
$options
.
i18n
.
viewOnlyMessage
}}
{{
$options
.
i18n
.
viewOnlyMessage
}}
</div>
</div>
<div
class=
"gl-mt-3 gl-border-solid gl-border-gray-100 gl-border-1"
>
<div
class=
"gl-mt-3 gl-border-solid gl-border-gray-100 gl-border-1"
>
<source-editor
<source-editor
ref=
"editor"
ref=
"editor"
:value=
"mergedYaml"
:value=
"mergedYaml"
:file-name=
"ciConfigPath"
:file-name=
"ciConfigPath"
:file-global-id=
"fileGlobalId"
:file-global-id=
"fileGlobalId"
:editor-options=
"
{ readOnly: true }"
:editor-options=
"
{ readOnly: true }"
v-on="$listeners"
v-on="$listeners"
/>
/>
</div>
</div>
</div>
<gl-alert
v-else
variant=
"info"
:dismissible=
"false"
:title=
"$options.i18n.unavailableDefaultTitle"
>
<gl-sprintf
:message=
"$options.i18n.unavailableDefaultText"
>
<template
#link
="
{ content }">
<gl-link
:href=
"expandedConfigHelpPath"
target=
"_blank"
>
{{
content
}}
</gl-link>
</
template
>
</gl-sprintf>
</gl-alert>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/pipeline_editor/graphql/queries/ci_config.graphql
View file @
a97ea52b
#import "~/pipelines/graphql/fragments/pipeline_stages_connection.fragment.graphql"
#import "~/pipelines/graphql/fragments/pipeline_stages_connection.fragment.graphql"
query
getCiConfigData
(
$projectPath
:
ID
!,
$content
:
String
!)
{
query
getCiConfigData
(
$projectPath
:
ID
!,
$
sha
:
String
,
$
content
:
String
!)
{
ciConfig
(
projectPath
:
$projectPath
,
content
:
$content
)
{
ciConfig
(
projectPath
:
$projectPath
,
sha
:
$sha
,
content
:
$content
)
{
errors
errors
mergedYaml
mergedYaml
status
status
...
...
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
View file @
a97ea52b
...
@@ -20,6 +20,7 @@ import updateCommitShaMutation from './graphql/mutations/update_commit_sha.mutat
...
@@ -20,6 +20,7 @@ import updateCommitShaMutation from './graphql/mutations/update_commit_sha.mutat
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
getAppStatus
from
'
./graphql/queries/client/app_status.graphql
'
;
import
getAppStatus
from
'
./graphql/queries/client/app_status.graphql
'
;
import
getCommitSha
from
'
./graphql/queries/client/commit_sha.graphql
'
;
import
getCurrentBranch
from
'
./graphql/queries/client/current_branch.graphql
'
;
import
getCurrentBranch
from
'
./graphql/queries/client/current_branch.graphql
'
;
import
getIsNewCiConfigFile
from
'
./graphql/queries/client/is_new_ci_config_file.graphql
'
;
import
getIsNewCiConfigFile
from
'
./graphql/queries/client/is_new_ci_config_file.graphql
'
;
import
getTemplate
from
'
./graphql/queries/get_starter_template.query.graphql
'
;
import
getTemplate
from
'
./graphql/queries/get_starter_template.query.graphql
'
;
...
@@ -128,6 +129,7 @@ export default {
...
@@ -128,6 +129,7 @@ export default {
variables
()
{
variables
()
{
return
{
return
{
projectPath
:
this
.
projectFullPath
,
projectPath
:
this
.
projectFullPath
,
sha
:
this
.
commitSha
,
content
:
this
.
currentCiFileContent
,
content
:
this
.
currentCiFileContent
,
};
};
},
},
...
@@ -153,6 +155,9 @@ export default {
...
@@ -153,6 +155,9 @@ export default {
appStatus
:
{
appStatus
:
{
query
:
getAppStatus
,
query
:
getAppStatus
,
},
},
commitSha
:
{
query
:
getCommitSha
,
},
currentBranch
:
{
currentBranch
:
{
query
:
getCurrentBranch
,
query
:
getCurrentBranch
,
},
},
...
...
doc/ci/pipeline_editor/index.md
View file @
a97ea52b
...
@@ -85,9 +85,6 @@ where:
...
@@ -85,9 +85,6 @@ where:
[
extended configuration merged into the job
](
../yaml/index.md#merge-details
)
.
[
extended configuration merged into the job
](
../yaml/index.md#merge-details
)
.
-
YAML anchors are
[
replaced with the linked configuration
](
../yaml/index.md#anchors
)
.
-
YAML anchors are
[
replaced with the linked configuration
](
../yaml/index.md#anchors
)
.
NOTE:
You can only see the expanded view when editing the
[
default branch
](
../../user/project/repository/branches/default.md
)
.
## Commit changes to CI configuration
## Commit changes to CI configuration
The commit form appears at the bottom of each tab in the editor so you can commit
The commit form appears at the bottom of each tab in the editor so you can commit
...
...
locale/gitlab.pot
View file @
a97ea52b
...
@@ -24227,9 +24227,6 @@ msgstr ""
...
@@ -24227,9 +24227,6 @@ msgstr ""
msgid "Pipelines|Merged YAML is view only"
msgid "Pipelines|Merged YAML is view only"
msgstr ""
msgstr ""
msgid "Pipelines|Merged YAML unavailable"
msgstr ""
msgid "Pipelines|More Information"
msgid "Pipelines|More Information"
msgstr ""
msgstr ""
...
@@ -24266,9 +24263,6 @@ msgstr ""
...
@@ -24266,9 +24263,6 @@ msgstr ""
msgid "Pipelines|The GitLab CI configuration could not be updated."
msgid "Pipelines|The GitLab CI configuration could not be updated."
msgstr ""
msgstr ""
msgid "Pipelines|The merged YAML view is only available for the default branch. %{linkStart}Learn more.%{linkEnd}"
msgstr ""
msgid "Pipelines|There are currently no finished pipelines."
msgid "Pipelines|There are currently no finished pipelines."
msgstr ""
msgstr ""
...
...
spec/frontend/pipeline_editor/components/editor/ci_config_merged_preview_spec.js
View file @
a97ea52b
import
{
GlIcon
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
EDITOR_READY_EVENT
}
from
'
~/editor/constants
'
;
import
{
EDITOR_READY_EVENT
}
from
'
~/editor/constants
'
;
import
CiConfigMergedPreview
from
'
~/pipeline_editor/components/editor/ci_config_merged_preview.vue
'
;
import
CiConfigMergedPreview
from
'
~/pipeline_editor/components/editor/ci_config_merged_preview.vue
'
;
import
{
mockLintResponse
,
mockCiConfigPath
}
from
'
../../mock_data
'
;
import
{
mockLintResponse
,
mockCiConfigPath
}
from
'
../../mock_data
'
;
const
DEFAULT_BRANCH
=
'
main
'
;
describe
(
'
Text editor component
'
,
()
=>
{
describe
(
'
Text editor component
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -18,7 +16,7 @@ describe('Text editor component', () => {
...
@@ -18,7 +16,7 @@ describe('Text editor component', () => {
},
},
};
};
const
createComponent
=
({
props
=
{}
,
currentBranch
=
DEFAULT_BRANCH
}
=
{})
=>
{
const
createComponent
=
({
props
=
{}
}
=
{})
=>
{
wrapper
=
shallowMount
(
CiConfigMergedPreview
,
{
wrapper
=
shallowMount
(
CiConfigMergedPreview
,
{
propsData
:
{
propsData
:
{
ciConfigData
:
mockLintResponse
,
ciConfigData
:
mockLintResponse
,
...
@@ -26,45 +24,20 @@ describe('Text editor component', () => {
...
@@ -26,45 +24,20 @@ describe('Text editor component', () => {
},
},
provide
:
{
provide
:
{
ciConfigPath
:
mockCiConfigPath
,
ciConfigPath
:
mockCiConfigPath
,
defaultBranch
:
DEFAULT_BRANCH
,
},
},
stubs
:
{
stubs
:
{
SourceEditor
:
MockSourceEditor
,
SourceEditor
:
MockSourceEditor
,
},
},
data
()
{
return
{
currentBranch
,
};
},
});
});
};
};
const
findIcon
=
()
=>
wrapper
.
findComponent
(
GlIcon
);
const
findIcon
=
()
=>
wrapper
.
findComponent
(
GlIcon
);
const
findAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
const
findEditor
=
()
=>
wrapper
.
findComponent
(
MockSourceEditor
);
const
findEditor
=
()
=>
wrapper
.
findComponent
(
MockSourceEditor
);
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
// This is testing a temporary feature.
// It may be slightly hacky code that doesn't follow best practice.
// See the related MR for more information.
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65972#note_626095644
describe
(
'
on a non-default branch
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
currentBranch
:
'
feature
'
});
});
it
(
'
does not load the editor
'
,
()
=>
{
expect
(
findEditor
().
exists
()).
toBe
(
false
);
});
it
(
'
renders an informational alert
'
,
()
=>
{
expect
(
findAlert
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
when status is valid
'
,
()
=>
{
describe
(
'
when status is valid
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
createComponent
();
...
...
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
View file @
a97ea52b
...
@@ -23,9 +23,10 @@ import {
...
@@ -23,9 +23,10 @@ import {
mockBlobContentQueryResponse
,
mockBlobContentQueryResponse
,
mockBlobContentQueryResponseEmptyCiFile
,
mockBlobContentQueryResponseEmptyCiFile
,
mockBlobContentQueryResponseNoCiFile
,
mockBlobContentQueryResponseNoCiFile
,
mockCiYml
,
mockCommitSha
,
mockDefaultBranch
,
mockDefaultBranch
,
mockProjectFullPath
,
mockProjectFullPath
,
mockCiYml
,
mockNewCommitShaResults
,
mockNewCommitShaResults
,
}
from
'
./mock_data
'
;
}
from
'
./mock_data
'
;
...
@@ -95,10 +96,16 @@ describe('Pipeline editor app component', () => {
...
@@ -95,10 +96,16 @@ describe('Pipeline editor app component', () => {
];
];
const
resolvers
=
{
const
resolvers
=
{
Query
:
{
commitSha
()
{
return
mockCommitSha
;
},
},
Mutation
:
{
Mutation
:
{
updateCommitSha
:
mockUpdateCommitSha
,
updateCommitSha
:
mockUpdateCommitSha
,
},
},
};
};
mockApollo
=
createMockApollo
(
handlers
,
resolvers
);
mockApollo
=
createMockApollo
(
handlers
,
resolvers
);
const
options
=
{
const
options
=
{
...
@@ -170,6 +177,7 @@ describe('Pipeline editor app component', () => {
...
@@ -170,6 +177,7 @@ describe('Pipeline editor app component', () => {
expect
(
mockCiConfigData
).
toHaveBeenCalledWith
({
expect
(
mockCiConfigData
).
toHaveBeenCalledWith
({
content
:
mockCiYml
,
content
:
mockCiYml
,
projectPath
:
mockProjectFullPath
,
projectPath
:
mockProjectFullPath
,
sha
:
mockCommitSha
,
});
});
});
});
});
});
...
...
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