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
f6ce5527
Commit
f6ce5527
authored
Oct 27, 2021
by
Frédéric Caplette
Committed by
Natalia Tepluhina
Oct 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace writeQuery calls in pipeline_editor app with client mutations
parent
033444cf
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
37 deletions
+63
-37
app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue
...ipts/pipeline_editor/components/commit/commit_section.vue
+5
-5
app/assets/javascripts/pipeline_editor/graphql/mutations/update_app_status.mutation.graphql
...itor/graphql/mutations/update_app_status.mutation.graphql
+3
-0
app/assets/javascripts/pipeline_editor/graphql/queries/client/is_new_ci_config_file.graphql
...itor/graphql/queries/client/is_new_ci_config_file.graphql
+0
-3
app/assets/javascripts/pipeline_editor/graphql/resolvers.js
app/assets/javascripts/pipeline_editor/graphql/resolvers.js
+9
-7
app/assets/javascripts/pipeline_editor/index.js
app/assets/javascripts/pipeline_editor/index.js
+9
-0
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
...ssets/javascripts/pipeline_editor/pipeline_editor_app.vue
+8
-15
app/assets/javascripts/pipeline_editor/pipeline_editor_home.vue
...sets/javascripts/pipeline_editor/pipeline_editor_home.vue
+1
-0
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
.../pipeline_editor/components/commit/commit_section_spec.js
+2
-2
spec/frontend/pipeline_editor/mock_data.js
spec/frontend/pipeline_editor/mock_data.js
+11
-0
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
+15
-5
No files found.
app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue
View file @
f6ce5527
...
...
@@ -11,7 +11,6 @@ import commitCIFile from '../../graphql/mutations/commit_ci_file.mutation.graphq
import
updateCurrentBranchMutation
from
'
../../graphql/mutations/update_current_branch.mutation.graphql
'
;
import
updateLastCommitBranchMutation
from
'
../../graphql/mutations/update_last_commit_branch.mutation.graphql
'
;
import
getCurrentBranch
from
'
../../graphql/queries/client/current_branch.graphql
'
;
import
getIsNewCiConfigFile
from
'
../../graphql/queries/client/is_new_ci_config_file.graphql
'
;
import
getPipelineEtag
from
'
../../graphql/queries/client/pipeline_etag.graphql
'
;
import
CommitForm
from
'
./commit_form.vue
'
;
...
...
@@ -41,18 +40,19 @@ export default {
required
:
false
,
default
:
''
,
},
isNewCiConfigFile
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
data
()
{
return
{
commit
:
{},
isNewCiConfigFile
:
false
,
isSaving
:
false
,
};
},
apollo
:
{
isNewCiConfigFile
:
{
query
:
getIsNewCiConfigFile
,
},
currentBranch
:
{
query
:
getCurrentBranch
,
},
...
...
app/assets/javascripts/pipeline_editor/graphql/mutations/update_app_status.mutation.graphql
0 → 100644
View file @
f6ce5527
mutation
updateAppStatus
(
$appStatus
:
String
)
{
updateAppStatus
(
appStatus
:
$appStatus
)
@client
}
app/assets/javascripts/pipeline_editor/graphql/queries/client/is_new_ci_config_file.graphql
deleted
100644 → 0
View file @
033444cf
query
getIsNewCiConfigFile
{
isNewCiConfigFile
@client
}
app/assets/javascripts/pipeline_editor/graphql/resolvers.js
View file @
f6ce5527
import
produce
from
'
immer
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
getAppStatus
from
'
./queries/client/app_status.graphql
'
;
import
getCurrentBranchQuery
from
'
./queries/client/current_branch.graphql
'
;
import
getLastCommitBranchQuery
from
'
./queries/client/last_commit_branch.query.graphql
'
;
...
...
@@ -31,20 +31,22 @@ export const resolvers = {
__typename
:
'
CiLintContent
'
,
}));
},
updateAppStatus
:
(
_
,
{
appStatus
},
{
cache
})
=>
{
cache
.
writeQuery
({
query
:
getAppStatus
,
data
:
{
appStatus
},
});
},
updateCurrentBranch
:
(
_
,
{
currentBranch
},
{
cache
})
=>
{
cache
.
writeQuery
({
query
:
getCurrentBranchQuery
,
data
:
produce
(
cache
.
readQuery
({
query
:
getCurrentBranchQuery
}),
(
draftData
)
=>
{
draftData
.
currentBranch
=
currentBranch
;
}),
data
:
{
currentBranch
},
});
},
updateLastCommitBranch
:
(
_
,
{
lastCommitBranch
},
{
cache
})
=>
{
cache
.
writeQuery
({
query
:
getLastCommitBranchQuery
,
data
:
produce
(
cache
.
readQuery
({
query
:
getLastCommitBranchQuery
}),
(
draftData
)
=>
{
draftData
.
lastCommitBranch
=
lastCommitBranch
;
}),
data
:
{
lastCommitBranch
},
});
},
},
...
...
app/assets/javascripts/pipeline_editor/index.js
View file @
f6ce5527
...
...
@@ -3,8 +3,10 @@ import Vue from 'vue';
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
{
resetServiceWorkersPublicPath
}
from
'
../lib/utils/webpack
'
;
import
{
EDITOR_APP_STATUS_LOADING
}
from
'
./constants
'
;
import
{
CODE_SNIPPET_SOURCE_SETTINGS
}
from
'
./components/code_snippet_alert/constants
'
;
import
getCurrentBranch
from
'
./graphql/queries/client/current_branch.graphql
'
;
import
getAppStatus
from
'
./graphql/queries/client/app_status.graphql
'
;
import
getLastCommitBranchQuery
from
'
./graphql/queries/client/last_commit_branch.query.graphql
'
;
import
getPipelineEtag
from
'
./graphql/queries/client/pipeline_etag.graphql
'
;
import
{
resolvers
}
from
'
./graphql/resolvers
'
;
...
...
@@ -64,6 +66,13 @@ export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
});
const
{
cache
}
=
apolloProvider
.
clients
.
defaultClient
;
cache
.
writeQuery
({
query
:
getAppStatus
,
data
:
{
appStatus
:
EDITOR_APP_STATUS_LOADING
,
},
});
cache
.
writeQuery
({
query
:
getCurrentBranch
,
data
:
{
...
...
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
View file @
f6ce5527
...
...
@@ -17,11 +17,11 @@ import {
LOAD_FAILURE_UNKNOWN
,
STARTER_TEMPLATE_NAME
,
}
from
'
./constants
'
;
import
updateAppStatus
from
'
./graphql/mutations/update_app_status.mutation.graphql
'
;
import
getBlobContent
from
'
./graphql/queries/blob_content.graphql
'
;
import
getCiConfigData
from
'
./graphql/queries/ci_config.graphql
'
;
import
getAppStatus
from
'
./graphql/queries/client/app_status.graphql
'
;
import
getCurrentBranch
from
'
./graphql/queries/client/current_branch.graphql
'
;
import
getIsNewCiConfigFile
from
'
./graphql/queries/client/is_new_ci_config_file.graphql
'
;
import
getTemplate
from
'
./graphql/queries/get_starter_template.query.graphql
'
;
import
getLatestCommitShaQuery
from
'
./graphql/queries/latest_commit_sha.query.graphql
'
;
import
PipelineEditorHome
from
'
./pipeline_editor_home.vue
'
;
...
...
@@ -44,20 +44,20 @@ export default {
},
data
()
{
return
{
starterTemplateName
:
STARTER_TEMPLATE_NAME
,
ciConfigData
:
{},
currentCiFileContent
:
''
,
failureType
:
null
,
failureReasons
:
[],
initialCiFileContent
:
''
,
isFetchingCommitSha
:
false
,
isNewCiConfigFile
:
false
,
lastCommittedContent
:
''
,
currentCiFileContent
:
''
,
successType
:
null
,
showFailure
:
false
,
showStartScreen
:
false
,
showSuccess
:
false
,
showFailure
:
false
,
starterTemplate
:
''
,
starterTemplateName
:
STARTER_TEMPLATE_NAME
,
successType
:
null
,
};
},
...
...
@@ -179,9 +179,6 @@ export default {
currentBranch
:
{
query
:
getCurrentBranch
,
},
isNewCiConfigFile
:
{
query
:
getIsNewCiConfigFile
,
},
starterTemplate
:
{
query
:
getTemplate
,
variables
()
{
...
...
@@ -261,12 +258,10 @@ export default {
this
.
currentCiFileContent
=
this
.
lastCommittedContent
;
},
setAppStatus
(
appStatus
)
{
this
.
$apollo
.
getClient
().
writeQuery
({
query
:
getAppStatus
,
data
:
{
appStatus
}
});
this
.
$apollo
.
mutate
({
mutation
:
updateAppStatus
,
variables
:
{
appStatus
}
});
},
setNewEmptyCiConfigFile
()
{
this
.
$apollo
.
getClient
()
.
writeQuery
({
query
:
getIsNewCiConfigFile
,
data
:
{
isNewCiConfigFile
:
true
}
});
this
.
isNewCiConfigFile
=
true
;
this
.
showStartScreen
=
false
;
},
showErrorAlert
({
type
,
reasons
=
[]
})
{
...
...
@@ -283,9 +278,7 @@ export default {
this
.
reportSuccess
(
type
);
if
(
this
.
isNewCiConfigFile
)
{
this
.
$apollo
.
getClient
()
.
writeQuery
({
query
:
getIsNewCiConfigFile
,
data
:
{
isNewCiConfigFile
:
false
}
});
this
.
isNewCiConfigFile
=
false
;
}
// Keep track of the latest committed content to know
...
...
app/assets/javascripts/pipeline_editor/pipeline_editor_home.vue
View file @
f6ce5527
...
...
@@ -125,6 +125,7 @@ export default {
:ref=
"$options.commitSectionRef"
:ci-file-content=
"ciFileContent"
:commit-sha=
"commitSha"
:is-new-ci-config-file=
"isNewCiConfigFile"
v-on=
"$listeners"
/>
<pipeline-editor-drawer
/>
...
...
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
View file @
f6ce5527
...
...
@@ -52,6 +52,7 @@ describe('Pipeline Editor | Commit section', () => {
const
defaultProps
=
{
ciFileContent
:
mockCiYml
,
commitSha
:
mockCommitSha
,
isNewCiConfigFile
:
false
,
};
const
createComponent
=
({
props
=
{},
options
=
{},
provide
=
{}
}
=
{})
=>
{
...
...
@@ -72,7 +73,6 @@ describe('Pipeline Editor | Commit section', () => {
data
()
{
return
{
currentBranch
:
mockDefaultBranch
,
isNewCiConfigFile
:
Boolean
(
options
?.
isNewCiConfigfile
),
};
},
mocks
:
{
...
...
@@ -115,7 +115,7 @@ describe('Pipeline Editor | Commit section', () => {
describe
(
'
when the user commits a new file
'
,
()
=>
{
beforeEach
(
async
()
=>
{
createComponent
({
options
:
{
isNewCiConfigf
ile
:
true
}
});
createComponent
({
props
:
{
isNewCiConfigF
ile
:
true
}
});
await
submitCommit
();
});
...
...
spec/frontend/pipeline_editor/mock_data.js
View file @
f6ce5527
...
...
@@ -35,6 +35,17 @@ job_build:
- echo "build"
needs: ["job_test_2"]
`
;
export
const
mockCiTemplateQueryResponse
=
{
data
:
{
project
:
{
ciTemplate
:
{
content
:
mockCiYml
,
},
},
},
};
export
const
mockBlobContentQueryResponse
=
{
data
:
{
project
:
{
repository
:
{
blobs
:
{
nodes
:
[{
rawBlob
:
mockCiYml
}]
}
}
},
...
...
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
View file @
f6ce5527
...
...
@@ -11,17 +11,21 @@ import PipelineEditorMessages from '~/pipeline_editor/components/ui/pipeline_edi
import
{
COMMIT_SUCCESS
,
COMMIT_FAILURE
}
from
'
~/pipeline_editor/constants
'
;
import
getBlobContent
from
'
~/pipeline_editor/graphql/queries/blob_content.graphql
'
;
import
getCiConfigData
from
'
~/pipeline_editor/graphql/queries/ci_config.graphql
'
;
import
getPipelineQuery
from
'
~/pipeline_editor/graphql/queries/client/pipeline.graphql
'
;
import
getTemplate
from
'
~/pipeline_editor/graphql/queries/get_starter_template.query.graphql
'
;
import
getLatestCommitShaQuery
from
'
~/pipeline_editor/graphql/queries/latest_commit_sha.query.graphql
'
;
import
getPipelineQuery
from
'
~/pipeline_editor/graphql/queries/client/pipeline.graphql
'
;
import
PipelineEditorApp
from
'
~/pipeline_editor/pipeline_editor_app.vue
'
;
import
PipelineEditorHome
from
'
~/pipeline_editor/pipeline_editor_home.vue
'
;
import
{
mockCiConfigPath
,
mockCiConfigQueryResponse
,
mockBlobContentQueryResponse
,
mockBlobContentQueryResponseNoCiFile
,
mockCiYml
,
mockCiTemplateQueryResponse
,
mockCommitSha
,
mockCommitShaResults
,
mockDefaultBranch
,
...
...
@@ -79,7 +83,7 @@ describe('Pipeline editor app component', () => {
});
};
const
createComponentWithApollo
=
async
({
pro
ps
=
{},
pro
vide
=
{},
stubs
=
{}
}
=
{})
=>
{
const
createComponentWithApollo
=
async
({
provide
=
{},
stubs
=
{}
}
=
{})
=>
{
const
handlers
=
[
[
getBlobContent
,
mockBlobContentData
],
[
getCiConfigData
,
mockCiConfigData
],
...
...
@@ -87,7 +91,6 @@ describe('Pipeline editor app component', () => {
[
getLatestCommitShaQuery
,
mockLatestCommitShaQuery
],
[
getPipelineQuery
,
mockPipelineQuery
],
];
mockApollo
=
createMockApollo
(
handlers
);
const
options
=
{
...
...
@@ -95,13 +98,15 @@ describe('Pipeline editor app component', () => {
data
()
{
return
{
currentBranch
:
mockDefaultBranch
,
lastCommitBranch
:
''
,
appStatus
:
''
,
};
},
mocks
:
{},
apolloProvider
:
mockApollo
,
};
createComponent
({
pro
ps
,
pro
vide
,
stubs
,
options
});
createComponent
({
provide
,
stubs
,
options
});
return
waitForPromises
();
};
...
...
@@ -199,7 +204,7 @@ describe('Pipeline editor app component', () => {
it
(
'
shows a unkown error message
'
,
async
()
=>
{
const
loadUnknownFailureText
=
'
The CI configuration was not loaded, please try again.
'
;
mockBlobContentData
.
mockRejectedValueOnce
(
new
Error
(
'
My error!
'
)
);
mockBlobContentData
.
mockRejectedValueOnce
();
await
createComponentWithApollo
({
stubs
:
{
PipelineEditorMessages
,
...
...
@@ -344,6 +349,8 @@ describe('Pipeline editor app component', () => {
describe
(
'
when refetching content
'
,
()
=>
{
beforeEach
(()
=>
{
mockBlobContentData
.
mockResolvedValue
(
mockBlobContentQueryResponse
);
mockCiConfigData
.
mockResolvedValue
(
mockCiConfigQueryResponse
);
mockLatestCommitShaQuery
.
mockResolvedValue
(
mockCommitShaResults
);
});
...
...
@@ -379,7 +386,10 @@ describe('Pipeline editor app component', () => {
const
originalLocation
=
window
.
location
.
href
;
beforeEach
(()
=>
{
mockBlobContentData
.
mockResolvedValue
(
mockBlobContentQueryResponse
);
mockCiConfigData
.
mockResolvedValue
(
mockCiConfigQueryResponse
);
mockLatestCommitShaQuery
.
mockResolvedValue
(
mockCommitShaResults
);
mockGetTemplate
.
mockResolvedValue
(
mockCiTemplateQueryResponse
);
setWindowLocation
(
'
?template=Android
'
);
});
...
...
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