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
336bbd9d
Commit
336bbd9d
authored
Mar 29, 2021
by
Jacques Erasmus
Committed by
Simon Knox
Mar 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blob content viewer
Added blob content viewer to the app
parent
825552bb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
212 additions
and
0 deletions
+212
-0
app/assets/javascripts/repository/components/blob_content_viewer.vue
...javascripts/repository/components/blob_content_viewer.vue
+93
-0
app/assets/javascripts/repository/queries/blob_info.query.graphql
...ts/javascripts/repository/queries/blob_info.query.graphql
+30
-0
config/known_invalid_graphql_queries.yml
config/known_invalid_graphql_queries.yml
+1
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/repository/components/blob_content_viewer_spec.js
...rontend/repository/components/blob_content_viewer_spec.js
+85
-0
No files found.
app/assets/javascripts/repository/components/blob_content_viewer.vue
0 → 100644
View file @
336bbd9d
<
script
>
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
uniqueId
}
from
'
lodash
'
;
import
BlobContent
from
'
~/blob/components/blob_content.vue
'
;
import
BlobHeader
from
'
~/blob/components/blob_header.vue
'
;
import
createFlash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
blobInfoQuery
from
'
../queries/blob_info.query.graphql
'
;
import
projectPathQuery
from
'
../queries/project_path.query.graphql
'
;
export
default
{
components
:
{
BlobHeader
,
BlobContent
,
GlLoadingIcon
,
},
apollo
:
{
projectPath
:
{
query
:
projectPathQuery
,
},
blobInfo
:
{
query
:
blobInfoQuery
,
variables
()
{
return
{
projectPath
:
this
.
projectPath
,
filePath
:
this
.
path
,
};
},
error
()
{
createFlash
({
message
:
__
(
'
An error occurred while loading the file. Please try again.
'
)
});
},
},
},
provide
()
{
return
{
blobHash
:
uniqueId
(),
};
},
data
()
{
return
{
projectPath
:
''
,
blobInfo
:
{
name
:
''
,
size
:
''
,
rawBlob
:
''
,
type
:
''
,
fileType
:
''
,
tooLarge
:
false
,
path
:
''
,
editBlobPath
:
''
,
ideEditPath
:
''
,
storedExternally
:
false
,
rawPath
:
''
,
externalStorageUrl
:
''
,
replacePath
:
''
,
deletePath
:
''
,
canLock
:
false
,
isLocked
:
false
,
lockLink
:
''
,
canModifyBlob
:
true
,
forkPath
:
''
,
simpleViewer
:
''
,
richViewer
:
''
,
},
};
},
computed
:
{
isLoading
()
{
return
this
.
$apollo
.
queries
.
blobInfo
.
loading
;
},
viewer
()
{
const
{
fileType
,
tooLarge
,
type
}
=
this
.
blobInfo
;
return
{
fileType
,
tooLarge
,
type
};
},
},
};
</
script
>
<
template
>
<div>
<gl-loading-icon
v-if=
"isLoading"
/>
<div
v-if=
"blobInfo && !isLoading"
>
<blob-header
:blob=
"blobInfo"
/>
<blob-content
:blob=
"blobInfo"
:content=
"blobInfo.rawBlob"
:active-viewer=
"viewer"
:loading=
"false"
/>
</div>
</div>
</
template
>
app/assets/javascripts/repository/queries/blob_info.query.graphql
0 → 100644
View file @
336bbd9d
query
getBlobInfo
(
$projectPath
:
ID
!,
$filePath
:
String
!)
{
project
(
fullPath
:
$projectPath
)
{
id
repository
{
blobs
(
path
:
$filePath
)
{
name
size
rawBlob
type
fileType
tooLarge
path
editBlobPath
ideEditPath
storedExternally
rawPath
externalStorageUrl
replacePath
deletePath
canLock
isLocked
lockLink
canModifyBlob
forkPath
simpleViewer
richViewer
}
}
}
}
config/known_invalid_graphql_queries.yml
View file @
336bbd9d
...
...
@@ -4,3 +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/create_api_fuzzing_configuration.mutation.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
locale/gitlab.pot
View file @
336bbd9d
...
...
@@ -3533,6 +3533,9 @@ msgstr ""
msgid "An error occurred while loading the file. Please try again later."
msgstr ""
msgid "An error occurred while loading the file. Please try again."
msgstr ""
msgid "An error occurred while loading the merge request changes."
msgstr ""
...
...
spec/frontend/repository/components/blob_content_viewer_spec.js
0 → 100644
View file @
336bbd9d
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
BlobContent
from
'
~/blob/components/blob_content.vue
'
;
import
BlobHeader
from
'
~/blob/components/blob_header.vue
'
;
import
BlobContentViewer
from
'
~/repository/components/blob_content_viewer.vue
'
;
let
wrapper
;
const
mockData
=
{
name
:
'
some_file.js
'
,
size
:
123
,
rawBlob
:
'
raw content
'
,
type
:
'
text
'
,
fileType
:
'
text
'
,
tooLarge
:
false
,
path
:
'
some_file.js
'
,
editBlobPath
:
'
some_file.js/edit
'
,
ideEditPath
:
'
some_file.js/ide/edit
'
,
storedExternally
:
false
,
rawPath
:
'
some_file.js
'
,
externalStorageUrl
:
'
some_file.js
'
,
replacePath
:
'
some_file.js/replace
'
,
deletePath
:
'
some_file.js/delete
'
,
canLock
:
true
,
isLocked
:
false
,
lockLink
:
'
some_file.js/lock
'
,
canModifyBlob
:
true
,
forkPath
:
'
some_file.js/fork
'
,
simpleViewer
:
{},
richViewer
:
{},
};
function
factory
(
path
,
loading
=
false
)
{
wrapper
=
shallowMount
(
BlobContentViewer
,
{
propsData
:
{
path
,
},
mocks
:
{
$apollo
:
{
queries
:
{
blobInfo
:
{
loading
,
},
},
},
},
});
wrapper
.
setData
({
blobInfo
:
mockData
});
}
describe
(
'
Blob content viewer component
'
,
()
=>
{
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findBlobHeader
=
()
=>
wrapper
.
find
(
BlobHeader
);
const
findBlobContent
=
()
=>
wrapper
.
find
(
BlobContent
);
afterEach
(()
=>
{
wrapper
.
destroy
();
});
beforeEach
(()
=>
{
factory
(
'
some_file.js
'
);
});
it
(
'
renders a GlLoadingIcon component
'
,
()
=>
{
factory
(
'
some_file.js
'
,
true
);
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
});
it
(
'
renders a BlobHeader component
'
,
()
=>
{
expect
(
findBlobHeader
().
exists
()).
toBe
(
true
);
});
it
(
'
renders a BlobContent component
'
,
()
=>
{
expect
(
findBlobContent
().
exists
()).
toBe
(
true
);
expect
(
findBlobContent
().
props
(
'
loading
'
)).
toEqual
(
false
);
expect
(
findBlobContent
().
props
(
'
content
'
)).
toEqual
(
'
raw content
'
);
expect
(
findBlobContent
().
props
(
'
activeViewer
'
)).
toEqual
({
fileType
:
'
text
'
,
tooLarge
:
false
,
type
:
'
text
'
,
});
});
});
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