diff options
Diffstat (limited to 'app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue')
-rw-r--r-- | app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue b/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue index c24e6523352..452420314ed 100644 --- a/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue +++ b/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue @@ -1,7 +1,6 @@ <script> import { GlLoadingIcon } from '@gitlab/ui'; import { fetchPolicies } from '~/lib/graphql'; -import httpStatusCodes from '~/lib/utils/http_status'; import { s__ } from '~/locale'; import { unwrapStagesWithNeeds } from '~/pipelines/components/unwrapping_utils'; @@ -76,22 +75,40 @@ export default { }; }, update(data) { - return data?.blobContent?.rawData; + return data?.project?.repository?.blobs?.nodes[0]?.rawBlob; }, result({ data }) { - const fileContent = data?.blobContent?.rawData ?? ''; + const nodes = data?.project?.repository?.blobs?.nodes; + if (!nodes) { + this.reportFailure(LOAD_FAILURE_UNKNOWN); + } else { + const rawBlob = nodes[0]?.rawBlob; + const fileContent = rawBlob ?? ''; - this.lastCommittedContent = fileContent; - this.currentCiFileContent = fileContent; + this.lastCommittedContent = fileContent; + this.currentCiFileContent = fileContent; - // make sure to reset the start screen flag during a refetch - // e.g. when switching branches - if (fileContent.length) { - this.showStartScreen = false; + // If rawBlob is defined and returns a string, it means that there is + // a CI config file with empty content. If `rawBlob` is not defined + // at all, it means there was no file found. + const hasCIFile = rawBlob === '' || fileContent.length > 0; + + if (!fileContent.length) { + this.setAppStatus(EDITOR_APP_STATUS_EMPTY); + } + + if (!hasCIFile) { + this.showStartScreen = true; + } else if (fileContent.length) { + // If the file content is > 0, then we make sure to reset the + // start screen flag during a refetch + // e.g. when switching branches + this.showStartScreen = false; + } } }, - error(error) { - this.handleBlobContentError(error); + error() { + this.reportFailure(LOAD_FAILURE_UNKNOWN); }, watchLoading(isLoading) { if (isLoading) { @@ -187,22 +204,6 @@ export default { }, }, methods: { - handleBlobContentError(error = {}) { - const { networkError } = error; - - const { response } = networkError; - // 404 for missing CI file - // 400 for blank projects with no repository - if ( - response?.status === httpStatusCodes.NOT_FOUND || - response?.status === httpStatusCodes.BAD_REQUEST - ) { - this.setAppStatus(EDITOR_APP_STATUS_EMPTY); - this.showStartScreen = true; - } else { - this.reportFailure(LOAD_FAILURE_UNKNOWN); - } - }, hideFailure() { this.showFailure = false; }, |