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
82333885
Commit
82333885
authored
Jul 26, 2021
by
Jacques Erasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display correct edit buttons
Display correct edit buttons when viewing binary files
parent
b61000b6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
7 deletions
+49
-7
app/assets/javascripts/repository/components/blob_content_viewer.vue
...javascripts/repository/components/blob_content_viewer.vue
+1
-1
app/assets/javascripts/repository/components/blob_edit.vue
app/assets/javascripts/repository/components/blob_edit.vue
+20
-2
spec/frontend/repository/components/blob_content_viewer_spec.js
...rontend/repository/components/blob_content_viewer_spec.js
+8
-2
spec/frontend/repository/components/blob_edit_spec.js
spec/frontend/repository/components/blob_edit_spec.js
+20
-2
No files found.
app/assets/javascripts/repository/components/blob_content_viewer.vue
View file @
82333885
...
...
@@ -175,7 +175,7 @@ export default {
>
<template
#actions
>
<blob-edit
v-if
=
"!isBinary"
:show-edit-button
=
"!isBinary"
:edit-path=
"blobInfo.editBlobPath"
:web-ide-path=
"blobInfo.ideEditPath"
/>
...
...
app/assets/javascripts/repository/components/blob_edit.vue
View file @
82333885
...
...
@@ -15,6 +15,10 @@ export default {
},
mixins
:
[
glFeatureFlagsMixin
()],
props
:
{
showEditButton
:
{
type
:
Boolean
,
required
:
true
,
},
editPath
:
{
type
:
String
,
required
:
true
,
...
...
@@ -30,17 +34,31 @@ export default {
<
template
>
<web-ide-link
v-if=
"glFeatures.consolidatedEditButton"
:show-edit-button=
"showEditButton"
class=
"gl-mr-3"
:edit-url=
"editPath"
:web-ide-url=
"webIdePath"
:is-blob=
"true"
/>
<div
v-else
>
<gl-button
class=
"gl-mr-2"
category=
"primary"
variant=
"confirm"
:href=
"editPath"
>
<gl-button
v-if=
"showEditButton"
class=
"gl-mr-2"
category=
"primary"
variant=
"confirm"
:href=
"editPath"
data-testid=
"edit"
>
{{
$options
.
i18n
.
edit
}}
</gl-button>
<gl-button
class=
"gl-mr-3"
category=
"primary"
variant=
"confirm"
:href=
"webIdePath"
>
<gl-button
class=
"gl-mr-3"
category=
"primary"
variant=
"confirm"
:href=
"webIdePath"
data-testid=
"web-ide"
>
{{
$options
.
i18n
.
webIde
}}
</gl-button>
</div>
...
...
spec/frontend/repository/components/blob_content_viewer_spec.js
View file @
82333885
...
...
@@ -309,6 +309,7 @@ describe('Blob content viewer component', () => {
expect
(
findBlobEdit
().
props
()).
toMatchObject
({
editPath
:
editBlobPath
,
webIdePath
:
ideEditPath
,
showEditButton
:
true
,
});
});
...
...
@@ -326,10 +327,11 @@ describe('Blob content viewer component', () => {
expect
(
findBlobEdit
().
props
()).
toMatchObject
({
editPath
:
editBlobPath
,
webIdePath
:
ideEditPath
,
showEditButton
:
true
,
});
});
it
(
'
does not render BlobHeaderEdit button when viewing a binary file
'
,
async
()
=>
{
it
(
'
renders BlobHeaderEdit button for binary files
'
,
async
()
=>
{
fullFactory
({
mockData
:
{
blobInfo
:
richMockData
,
isBinary
:
true
},
stubs
:
{
...
...
@@ -340,7 +342,11 @@ describe('Blob content viewer component', () => {
await
nextTick
();
expect
(
findBlobEdit
().
exists
()).
toBe
(
false
);
expect
(
findBlobEdit
().
props
()).
toMatchObject
({
editPath
:
editBlobPath
,
webIdePath
:
ideEditPath
,
showEditButton
:
false
,
});
});
describe
(
'
BlobButtonGroup
'
,
()
=>
{
...
...
spec/frontend/repository/components/blob_edit_spec.js
View file @
82333885
...
...
@@ -6,6 +6,7 @@ import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
const
DEFAULT_PROPS
=
{
editPath
:
'
some_file.js/edit
'
,
webIdePath
:
'
some_file.js/ide/edit
'
,
showEditButton
:
true
,
};
describe
(
'
BlobEdit component
'
,
()
=>
{
...
...
@@ -31,8 +32,8 @@ describe('BlobEdit component', () => {
});
const
findButtons
=
()
=>
wrapper
.
findAll
(
GlButton
);
const
findEditButton
=
()
=>
findButtons
().
at
(
0
);
const
findWebIdeButton
=
()
=>
findButtons
().
at
(
1
);
const
findEditButton
=
()
=>
wrapper
.
find
(
'
[data-testid="edit"]
'
);
const
findWebIdeButton
=
()
=>
wrapper
.
find
(
'
[data-testid="web-ide"]
'
);
const
findWebIdeLink
=
()
=>
wrapper
.
find
(
WebIdeLink
);
it
(
'
renders component
'
,
()
=>
{
...
...
@@ -77,6 +78,23 @@ describe('BlobEdit component', () => {
editUrl
,
webIdeUrl
,
isBlob
:
true
,
showEditButton
:
true
,
});
});
describe
(
'
Without Edit button
'
,
()
=>
{
const
showEditButton
=
false
;
it
(
'
renders WebIdeLink component without an edit button
'
,
()
=>
{
createComponent
(
true
,
{
showEditButton
});
expect
(
findWebIdeLink
().
props
()).
toMatchObject
({
showEditButton
});
});
it
(
'
does not render an Edit button
'
,
()
=>
{
createComponent
(
false
,
{
showEditButton
});
expect
(
findEditButton
().
exists
()).
toBe
(
false
);
});
});
});
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