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
fc38a8de
Commit
fc38a8de
authored
Jul 29, 2021
by
Jacques Erasmus
Committed by
Denys Mishunov
Jul 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blob refactor: Hide copy and view raw buttons when viewing binary files
parent
5912f3de
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
4 deletions
+49
-4
app/assets/javascripts/blob/components/blob_header.vue
app/assets/javascripts/blob/components/blob_header.vue
+6
-0
app/assets/javascripts/blob/components/blob_header_default_actions.vue
...vascripts/blob/components/blob_header_default_actions.vue
+10
-1
app/assets/javascripts/repository/components/blob_content_viewer.vue
...javascripts/repository/components/blob_content_viewer.vue
+1
-0
spec/frontend/blob/components/blob_header_default_actions_spec.js
...ntend/blob/components/blob_header_default_actions_spec.js
+11
-1
spec/frontend/blob/components/blob_header_spec.js
spec/frontend/blob/components/blob_header_spec.js
+10
-2
spec/frontend/repository/components/blob_content_viewer_spec.js
...rontend/repository/components/blob_content_viewer_spec.js
+11
-0
No files found.
app/assets/javascripts/blob/components/blob_header.vue
View file @
fc38a8de
...
...
@@ -25,6 +25,11 @@ export default {
required
:
false
,
default
:
false
,
},
isBinary
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
activeViewerType
:
{
type
:
String
,
required
:
false
,
...
...
@@ -81,6 +86,7 @@ export default {
:raw-path=
"blob.rawPath"
:active-viewer=
"viewer"
:has-render-error=
"hasRenderError"
:is-binary=
"isBinary"
@
copy=
"proxyCopyRequest"
/>
</div>
...
...
app/assets/javascripts/blob/components/blob_header_default_actions.vue
View file @
fc38a8de
...
...
@@ -32,6 +32,11 @@ export default {
required
:
false
,
default
:
false
,
},
isBinary
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
computed
:
{
downloadUrl
()
{
...
...
@@ -43,6 +48,9 @@ export default {
getBlobHashTarget
()
{
return
`[data-blob-hash="
${
this
.
blobHash
}
"]`
;
},
showCopyButton
()
{
return
!
this
.
hasRenderError
&&
!
this
.
isBinary
;
},
},
BTN_COPY_CONTENTS_TITLE
,
BTN_DOWNLOAD_TITLE
,
...
...
@@ -52,7 +60,7 @@ export default {
<
template
>
<gl-button-group
data-qa-selector=
"default_actions_container"
>
<gl-button
v-if=
"
!hasRenderError
"
v-if=
"
showCopyButton
"
v-gl-tooltip
.
hover
:aria-label=
"$options.BTN_COPY_CONTENTS_TITLE"
:title=
"$options.BTN_COPY_CONTENTS_TITLE"
...
...
@@ -65,6 +73,7 @@ export default {
variant=
"default"
/>
<gl-button
v-if=
"!isBinary"
v-gl-tooltip
.
hover
:aria-label=
"$options.BTN_RAW_TITLE"
:title=
"$options.BTN_RAW_TITLE"
...
...
app/assets/javascripts/repository/components/blob_content_viewer.vue
View file @
fc38a8de
...
...
@@ -169,6 +169,7 @@ export default {
<blob-header
:blob=
"blobInfo"
:hide-viewer-switcher=
"!hasRichViewer || isBinary"
:is-binary=
"isBinary"
:active-viewer-type=
"viewer.type"
:has-render-error=
"hasRenderError"
@
viewer-changed=
"switchViewer"
...
...
spec/frontend/blob/components/blob_header_default_actions_spec.js
View file @
fc38a8de
...
...
@@ -39,6 +39,9 @@ describe('Blob Header Default Actions', () => {
});
describe
(
'
renders
'
,
()
=>
{
const
findCopyButton
=
()
=>
wrapper
.
find
(
'
[data-testid="copyContentsButton"]
'
);
const
findViewRawButton
=
()
=>
wrapper
.
find
(
'
[data-testid="viewRawButton"]
'
);
it
(
'
gl-button-group component
'
,
()
=>
{
expect
(
btnGroup
.
exists
()).
toBe
(
true
);
});
...
...
@@ -76,7 +79,14 @@ describe('Blob Header Default Actions', () => {
hasRenderError
:
true
,
});
expect
(
wrapper
.
find
(
'
[data-testid="copyContentsButton"]
'
).
exists
()).
toBe
(
false
);
expect
(
findCopyButton
().
exists
()).
toBe
(
false
);
});
it
(
'
does not render the copy and view raw button if isBinary is set to true
'
,
()
=>
{
createComponent
({
isBinary
:
true
});
expect
(
findCopyButton
().
exists
()).
toBe
(
false
);
expect
(
findViewRawButton
().
exists
()).
toBe
(
false
);
});
});
});
spec/frontend/blob/components/blob_header_spec.js
View file @
fc38a8de
...
...
@@ -29,6 +29,8 @@ describe('Blob Header Default Actions', () => {
});
describe
(
'
rendering
'
,
()
=>
{
const
findDefaultActions
=
()
=>
wrapper
.
find
(
DefaultActions
);
const
slots
=
{
prepend
:
'
Foo Prepend
'
,
actions
:
'
Actions Bar
'
,
...
...
@@ -42,7 +44,7 @@ describe('Blob Header Default Actions', () => {
it
(
'
renders all components
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
find
(
ViewerSwitcher
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
DefaultActions
).
exists
()).
toBe
(
true
);
expect
(
findDefaultActions
(
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
BlobFilepath
).
exists
()).
toBe
(
true
);
});
...
...
@@ -100,7 +102,13 @@ describe('Blob Header Default Actions', () => {
hasRenderError
:
true
,
},
);
expect
(
wrapper
.
find
(
DefaultActions
).
props
(
'
hasRenderError
'
)).
toBe
(
true
);
expect
(
findDefaultActions
().
props
(
'
hasRenderError
'
)).
toBe
(
true
);
});
it
(
'
passes the correct isBinary value to default actions when viewing a binary file
'
,
()
=>
{
createComponent
({},
{},
{
isBinary
:
true
});
expect
(
findDefaultActions
().
props
(
'
isBinary
'
)).
toBe
(
true
);
});
});
...
...
spec/frontend/repository/components/blob_content_viewer_spec.js
View file @
fc38a8de
...
...
@@ -349,6 +349,17 @@ describe('Blob content viewer component', () => {
});
});
it
(
'
passes the correct isBinary value to blob header when viewing a binary file
'
,
async
()
=>
{
fullFactory
({
mockData
:
{
blobInfo
:
richMockData
,
isBinary
:
true
},
stubs
:
{
BlobContent
:
true
,
BlobReplace
:
true
},
});
await
nextTick
();
expect
(
findBlobHeader
().
props
(
'
isBinary
'
)).
toBe
(
true
);
});
describe
(
'
BlobButtonGroup
'
,
()
=>
{
const
{
name
,
path
,
replacePath
,
webPath
}
=
simpleMockData
;
const
{
...
...
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