Commit 03bc80ed authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'integrate-blob-info-query' into 'master'

Integrate blob info query

See merge request gitlab-org/gitlab!60337
parents eaa29e66 a5d856c0
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo';
import PipelineTourSuccessModal from '~/blob/pipeline_tour_success_modal.vue'; import PipelineTourSuccessModal from '~/blob/pipeline_tour_success_modal.vue';
import BlobViewer from '~/blob/viewer/index'; import BlobViewer from '~/blob/viewer/index';
import GpgBadges from '~/gpg_badges'; import GpgBadges from '~/gpg_badges';
import createDefaultClient from '~/lib/graphql';
import initBlob from '~/pages/projects/init_blob'; import initBlob from '~/pages/projects/init_blob';
import initWebIdeLink from '~/pages/projects/shared/web_ide_link'; import initWebIdeLink from '~/pages/projects/shared/web_ide_link';
import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue'; import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import BlobContentViewer from '~/repository/components/blob_content_viewer.vue'; import BlobContentViewer from '~/repository/components/blob_content_viewer.vue';
import '~/sourcegraph/load'; import '~/sourcegraph/load';
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
const viewBlobEl = document.querySelector('#js-view-blob-app'); const viewBlobEl = document.querySelector('#js-view-blob-app');
if (viewBlobEl) { if (viewBlobEl) {
const { blobPath } = viewBlobEl.dataset; const { blobPath, projectPath } = viewBlobEl.dataset;
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: viewBlobEl, el: viewBlobEl,
apolloProvider,
render(createElement) { render(createElement) {
return createElement(BlobContentViewer, { return createElement(BlobContentViewer, {
props: { props: {
path: blobPath, path: blobPath,
projectPath,
}, },
}); });
}, },
......
...@@ -6,7 +6,6 @@ import BlobHeader from '~/blob/components/blob_header.vue'; ...@@ -6,7 +6,6 @@ import BlobHeader from '~/blob/components/blob_header.vue';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import blobInfoQuery from '../queries/blob_info.query.graphql'; import blobInfoQuery from '../queries/blob_info.query.graphql';
import projectPathQuery from '../queries/project_path.query.graphql';
export default { export default {
components: { components: {
...@@ -15,10 +14,7 @@ export default { ...@@ -15,10 +14,7 @@ export default {
GlLoadingIcon, GlLoadingIcon,
}, },
apollo: { apollo: {
projectPath: { project: {
query: projectPathQuery,
},
blobInfo: {
query: blobInfoQuery, query: blobInfoQuery,
variables() { variables() {
return { return {
...@@ -41,14 +37,21 @@ export default { ...@@ -41,14 +37,21 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
projectPath: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
projectPath: '', project: {
blobInfo: { repository: {
blobs: {
nodes: [
{
name: '', name: '',
size: '', size: '',
rawBlob: '', rawTextBlob: '',
type: '', type: '',
fileType: '', fileType: '',
tooLarge: false, tooLarge: false,
...@@ -65,17 +68,27 @@ export default { ...@@ -65,17 +68,27 @@ export default {
lockLink: '', lockLink: '',
canModifyBlob: true, canModifyBlob: true,
forkPath: '', forkPath: '',
simpleViewer: '', simpleViewer: {},
richViewer: '', richViewer: {},
},
],
},
},
}, },
}; };
}, },
computed: { computed: {
isLoading() { isLoading() {
return this.$apollo.queries.blobInfo.loading; return this.$apollo.queries.project.loading;
},
blobInfo() {
const nodes = this.project?.repository?.blobs?.nodes;
return nodes[0] || {};
}, },
viewer() { viewer() {
const { fileType, tooLarge, type } = this.blobInfo; const viewer = this.blobInfo.richViewer || this.blobInfo.simpleViewer;
const { fileType, tooLarge, type } = viewer;
return { fileType, tooLarge, type }; return { fileType, tooLarge, type };
}, },
...@@ -90,7 +103,7 @@ export default { ...@@ -90,7 +103,7 @@ export default {
<blob-header :blob="blobInfo" /> <blob-header :blob="blobInfo" />
<blob-content <blob-content
:blob="blobInfo" :blob="blobInfo"
:content="blobInfo.rawBlob" :content="blobInfo.rawTextBlob"
:is-raw-content="true" :is-raw-content="true"
:active-viewer="viewer" :active-viewer="viewer"
:loading="false" :loading="false"
......
...@@ -13,10 +13,14 @@ export default { ...@@ -13,10 +13,14 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
projectPath: {
type: String,
required: true,
},
}, },
}; };
</script> </script>
<template> <template>
<blob-content-viewer :path="path" /> <blob-content-viewer :path="path" :project-path="projectPath" />
</template> </template>
...@@ -11,15 +11,19 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) { ...@@ -11,15 +11,19 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) {
fileType fileType
path path
editBlobPath editBlobPath
ideEditPath
storedExternally storedExternally
rawPath rawPath
externalStorageUrl
replacePath replacePath
canModifyBlob simpleViewer {
forkPath fileType
simpleViewer tooLarge
richViewer type
}
richViewer {
fileType
tooLarge
type
}
} }
} }
} }
......
...@@ -20,6 +20,7 @@ export default function createRouter(base, baseRef) { ...@@ -20,6 +20,7 @@ export default function createRouter(base, baseRef) {
component: BlobPage, component: BlobPage,
props: (route) => ({ props: (route) => ({
path: route.params.path, path: route.params.path,
projectPath: base,
}), }),
}; };
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- if @code_navigation_path - if @code_navigation_path
#js-code-navigation{ data: { code_navigation_path: @code_navigation_path, blob_path: blob.path, definition_path_prefix: project_blob_path(@project, @ref) } } #js-code-navigation{ data: { code_navigation_path: @code_navigation_path, blob_path: blob.path, definition_path_prefix: project_blob_path(@project, @ref) } }
- if Feature.enabled?(:refactor_blob_viewer, @project, default_enabled: :yaml) - if Feature.enabled?(:refactor_blob_viewer, @project, default_enabled: :yaml)
#js-view-blob-app{ data: { blob_path: blob.path } } #js-view-blob-app{ data: { blob_path: blob.path, project_path: @project.full_path } }
.gl-spinner-container .gl-spinner-container
= loading_icon(size: 'md') = loading_icon(size: 'md')
- else - else
......
...@@ -4,5 +4,4 @@ filenames: ...@@ -4,5 +4,4 @@ filenames:
- ee/app/assets/javascripts/security_configuration/api_fuzzing/graphql/api_fuzzing_ci_configuration.query.graphql - ee/app/assets/javascripts/security_configuration/api_fuzzing/graphql/api_fuzzing_ci_configuration.query.graphql
- ee/app/assets/javascripts/security_configuration/api_fuzzing/graphql/create_api_fuzzing_configuration.mutation.graphql - ee/app/assets/javascripts/security_configuration/api_fuzzing/graphql/create_api_fuzzing_configuration.mutation.graphql
- ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql - ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql
- app/assets/javascripts/repository/queries/blob_info.query.graphql
- ee/app/assets/javascripts/security_configuration/graphql/configure_dependency_scanning.mutation.graphql - ee/app/assets/javascripts/security_configuration/graphql/configure_dependency_scanning.mutation.graphql
...@@ -8,7 +8,7 @@ let wrapper; ...@@ -8,7 +8,7 @@ let wrapper;
const mockData = { const mockData = {
name: 'some_file.js', name: 'some_file.js',
size: 123, size: 123,
rawBlob: 'raw content', rawTextBlob: 'raw content',
type: 'text', type: 'text',
fileType: 'text', fileType: 'text',
tooLarge: false, tooLarge: false,
...@@ -25,19 +25,24 @@ const mockData = { ...@@ -25,19 +25,24 @@ const mockData = {
lockLink: 'some_file.js/lock', lockLink: 'some_file.js/lock',
canModifyBlob: true, canModifyBlob: true,
forkPath: 'some_file.js/fork', forkPath: 'some_file.js/fork',
simpleViewer: {}, simpleViewer: {
richViewer: {}, fileType: 'text',
tooLarge: false,
type: 'simple',
},
richViewer: null,
}; };
function factory(path, loading = false) { function factory(path, loading = false) {
wrapper = shallowMount(BlobContentViewer, { wrapper = shallowMount(BlobContentViewer, {
propsData: { propsData: {
path, path,
projectPath: 'some/path',
}, },
mocks: { mocks: {
$apollo: { $apollo: {
queries: { queries: {
blobInfo: { project: {
loading, loading,
}, },
}, },
...@@ -80,7 +85,7 @@ describe('Blob content viewer component', () => { ...@@ -80,7 +85,7 @@ describe('Blob content viewer component', () => {
expect(findBlobContent().props('activeViewer')).toEqual({ expect(findBlobContent().props('activeViewer')).toEqual({
fileType: 'text', fileType: 'text',
tooLarge: false, tooLarge: false,
type: 'text', type: 'simple',
}); });
}); });
}); });
...@@ -11,7 +11,7 @@ describe('Repository blob page component', () => { ...@@ -11,7 +11,7 @@ describe('Repository blob page component', () => {
const path = 'file.js'; const path = 'file.js';
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(BlobPage, { propsData: { path } }); wrapper = shallowMount(BlobPage, { propsData: { path, projectPath: 'some/path' } });
}); });
afterEach(() => { afterEach(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment