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
23022a6b
Commit
23022a6b
authored
Aug 26, 2021
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add image blob viewer
Addede a blob viewer for images as part of the refactor
parent
825b82b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
app/assets/javascripts/repository/components/blob_viewers/image_viewer.vue
...ripts/repository/components/blob_viewers/image_viewer.vue
+19
-0
app/assets/javascripts/repository/components/blob_viewers/index.js
...s/javascripts/repository/components/blob_viewers/index.js
+6
-0
spec/frontend/repository/components/blob_viewers/image_viewer_spec.js
...d/repository/components/blob_viewers/image_viewer_spec.js
+25
-0
No files found.
app/assets/javascripts/repository/components/blob_viewers/image_viewer.vue
0 → 100644
View file @
23022a6b
<
script
>
export
default
{
props
:
{
url
:
{
type
:
String
,
required
:
true
,
},
alt
:
{
type
:
String
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<div
class=
"gl-text-center gl-p-7 gl-bg-gray-50"
>
<img
:src=
"url"
:alt=
"alt"
data-testid=
"image"
/>
</div>
</
template
>
app/assets/javascripts/repository/components/blob_viewers/index.js
View file @
23022a6b
...
...
@@ -6,6 +6,8 @@ export const loadViewer = (type) => {
return
()
=>
import
(
/* webpackChunkName: 'blob_text_viewer' */
'
./text_viewer.vue
'
);
case
'
download
'
:
return
()
=>
import
(
/* webpackChunkName: 'blob_download_viewer' */
'
./download_viewer.vue
'
);
case
'
image
'
:
return
()
=>
import
(
/* webpackChunkName: 'blob_image_viewer' */
'
./image_viewer.vue
'
);
default
:
return
null
;
}
...
...
@@ -23,5 +25,9 @@ export const viewerProps = (type, blob) => {
filePath
:
blob
.
rawPath
,
fileSize
:
blob
.
rawSize
,
},
image
:
{
url
:
blob
.
rawPath
,
alt
:
blob
.
name
,
},
}[
type
];
};
spec/frontend/repository/components/blob_viewers/image_viewer_spec.js
0 → 100644
View file @
23022a6b
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ImageViewer
from
'
~/repository/components/blob_viewers/image_viewer.vue
'
;
describe
(
'
Image Viewer
'
,
()
=>
{
let
wrapper
;
const
propsData
=
{
url
:
'
some/image.png
'
,
alt
:
'
image.png
'
,
};
const
createComponent
=
()
=>
{
wrapper
=
shallowMount
(
ImageViewer
,
{
propsData
});
};
const
findImage
=
()
=>
wrapper
.
find
(
'
[data-testid="image"]
'
);
it
(
'
renders a Source Editor component
'
,
()
=>
{
createComponent
();
expect
(
findImage
().
exists
()).
toBe
(
true
);
expect
(
findImage
().
attributes
(
'
src
'
)).
toBe
(
propsData
.
url
);
expect
(
findImage
().
attributes
(
'
alt
'
)).
toBe
(
propsData
.
alt
);
});
});
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