Commit 75980735 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '352567-fix-load-it-anyway' into 'master'

Blob refactor: Fix load it anyway link

See merge request gitlab-org/gitlab!80469
parents fb238d7a 2c5e5881
...@@ -42,7 +42,7 @@ export const BLOB_RENDER_ERRORS = { ...@@ -42,7 +42,7 @@ export const BLOB_RENDER_ERRORS = {
id: 'load', id: 'load',
text: __('load it anyway'), text: __('load it anyway'),
conjunction: __('or'), conjunction: __('or'),
href: '#', href: '?expanded=true&viewer=simple',
target: '', target: '',
event: BLOB_RENDER_EVENT_LOAD, event: BLOB_RENDER_EVENT_LOAD,
}, },
......
...@@ -45,6 +45,7 @@ export default { ...@@ -45,6 +45,7 @@ export default {
projectPath: this.projectPath, projectPath: this.projectPath,
filePath: this.path, filePath: this.path,
ref: this.originalBranch || this.ref, ref: this.originalBranch || this.ref,
shouldFetchRawText: Boolean(this.glFeatures.highlightJs),
}; };
}, },
result() { result() {
...@@ -203,7 +204,7 @@ export default { ...@@ -203,7 +204,7 @@ export default {
<template> <template>
<div> <div>
<gl-loading-icon v-if="isLoading" size="sm" /> <gl-loading-icon v-if="isLoading" size="sm" />
<div v-if="blobInfo && !isLoading" class="file-holder gl-overflow-hidden"> <div v-if="blobInfo && !isLoading" class="file-holder">
<blob-header <blob-header
:blob="blobInfo" :blob="blobInfo"
:hide-viewer-switcher="!hasRichViewer || isBinaryFileType || isUsingLfs" :hide-viewer-switcher="!hasRichViewer || isBinaryFileType || isUsingLfs"
......
...@@ -195,6 +195,7 @@ export default { ...@@ -195,6 +195,7 @@ export default {
projectPath: this.projectPath, projectPath: this.projectPath,
filePath: this.path, filePath: this.path,
ref: this.ref, ref: this.ref,
shouldFetchRawText: Boolean(this.glFeatures.highlightJs),
}); });
}, },
apolloQuery(query, variables) { apolloQuery(query, variables) {
......
#import "ee_else_ce/repository/queries/path_locks.fragment.graphql" #import "ee_else_ce/repository/queries/path_locks.fragment.graphql"
query getBlobInfo($projectPath: ID!, $filePath: String!, $ref: String!) { query getBlobInfo(
$projectPath: ID!
$filePath: String!
$ref: String!
$shouldFetchRawText: Boolean!
) {
project(fullPath: $projectPath) { project(fullPath: $projectPath) {
userPermissions { userPermissions {
pushCode pushCode
...@@ -18,7 +23,7 @@ query getBlobInfo($projectPath: ID!, $filePath: String!, $ref: String!) { ...@@ -18,7 +23,7 @@ query getBlobInfo($projectPath: ID!, $filePath: String!, $ref: String!) {
name name
size size
rawSize rawSize
rawTextBlob rawTextBlob @include(if: $shouldFetchRawText)
fileType fileType
language language
path path
......
= render "projects/blob/breadcrumb", blob: blob = render "projects/blob/breadcrumb", blob: blob
- project = @project.present(current_user: current_user) - project = @project.present(current_user: current_user)
- ref = local_assigns[:ref] || @ref - ref = local_assigns[:ref] || @ref
- expanded = params[:expanded].present?
.info-well.d-none.d-sm-block .info-well.d-none.d-sm-block
.well-segment .well-segment
...@@ -13,7 +14,7 @@ ...@@ -13,7 +14,7 @@
#blob-content-holder.blob-content-holder #blob-content-holder.blob-content-holder
- 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) && !expanded
-# Data info will be removed once we migrate this to use GraphQL -# Data info will be removed once we migrate this to use GraphQL
-# Follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/330406 -# Follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/330406
#js-view-blob-app{ data: { blob_path: blob.path, #js-view-blob-app{ data: { blob_path: blob.path,
......
...@@ -361,6 +361,19 @@ describe('Blob content viewer component', () => { ...@@ -361,6 +361,19 @@ describe('Blob content viewer component', () => {
}); });
describe('blob info query', () => { describe('blob info query', () => {
it.each`
highlightJs | shouldFetchRawText
${true} | ${true}
${false} | ${false}
`(
'calls blob info query with shouldFetchRawText: $shouldFetchRawText when highlightJs (feature flag): $highlightJs',
async ({ highlightJs, shouldFetchRawText }) => {
await createComponent({ highlightJs });
expect(mockResolver).toHaveBeenCalledWith(expect.objectContaining({ shouldFetchRawText }));
},
);
it('is called with originalBranch value if the prop has a value', async () => { it('is called with originalBranch value if the prop has a value', async () => {
await createComponent({ inject: { originalBranch: 'some-branch' } }); await createComponent({ inject: { originalBranch: 'some-branch' } });
......
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