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
2d8966f7
Commit
2d8966f7
authored
Mar 01, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate balsamiq_viewer to dynamic import
parent
52e133d1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
8 deletions
+24
-8
app/assets/javascripts/blob/balsamiq_viewer.js
app/assets/javascripts/blob/balsamiq_viewer.js
+1
-3
app/assets/javascripts/blob/viewer/index.js
app/assets/javascripts/blob/viewer/index.js
+21
-0
app/views/projects/blob/_viewer.html.haml
app/views/projects/blob/_viewer.html.haml
+2
-1
app/views/projects/blob/viewers/_balsamiq.html.haml
app/views/projects/blob/viewers/_balsamiq.html.haml
+0
-3
config/webpack.config.js
config/webpack.config.js
+0
-1
No files found.
app/assets/javascripts/blob/balsamiq_viewer.js
View file @
2d8966f7
...
...
@@ -7,7 +7,7 @@ function onError() {
return
flash
;
}
function
loadBalsamiqFile
()
{
export
default
function
loadBalsamiqFile
()
{
const
viewer
=
document
.
getElementById
(
'
js-balsamiq-viewer
'
);
if
(
!
(
viewer
instanceof
Element
))
return
;
...
...
@@ -17,5 +17,3 @@ function loadBalsamiqFile() {
const
balsamiqViewer
=
new
BalsamiqViewer
(
viewer
);
balsamiqViewer
.
loadFile
(
endpoint
).
catch
(
onError
);
}
$
(
loadBalsamiqFile
);
app/assets/javascripts/blob/viewer/index.js
View file @
2d8966f7
...
...
@@ -5,6 +5,7 @@ import axios from '../../lib/utils/axios_utils';
export
default
class
BlobViewer
{
constructor
()
{
BlobViewer
.
initAuxiliaryViewer
();
BlobViewer
.
initRichViewer
();
this
.
initMainViewers
();
}
...
...
@@ -16,6 +17,26 @@ export default class BlobViewer {
BlobViewer
.
loadViewer
(
auxiliaryViewer
);
}
static
initRichViewer
()
{
const
viewer
=
document
.
querySelector
(
'
.blob-viewer[data-type="rich"]
'
);
if
(
!
viewer
||
!
viewer
.
dataset
.
richType
)
return
;
const
initViewer
=
promise
=>
promise
.
then
(
module
=>
module
.
default
(
viewer
))
.
catch
((
error
)
=>
{
Flash
(
'
Error loading file viewer.
'
);
throw
error
;
});
switch
(
viewer
.
dataset
.
richType
)
{
case
'
balsamiq
'
:
initViewer
(
import
(
/* webpackChunkName: 'balsamiq_viewer' */
'
../balsamiq_viewer
'
));
break
;
default
:
break
;
}
}
initMainViewers
()
{
this
.
$fileHolder
=
$
(
'
.file-holder
'
);
if
(
!
this
.
$fileHolder
.
length
)
return
;
...
...
app/views/projects/blob/_viewer.html.haml
View file @
2d8966f7
-
hidden
=
local_assigns
.
fetch
(
:hidden
,
false
)
-
render_error
=
viewer
.
render_error
-
rich_type
=
viewer
.
type
==
:rich
?
viewer
.
partial_name
:
nil
-
load_async
=
local_assigns
.
fetch
(
:load_async
,
viewer
.
load_async?
&&
render_error
.
nil?
)
-
viewer_url
=
local_assigns
.
fetch
(
:viewer_url
)
{
url_for
(
params
.
merge
(
viewer:
viewer
.
type
,
format: :json
))
}
if
load_async
.blob-viewer
{
data:
{
type:
viewer
.
type
,
url:
viewer_url
},
class:
(
'hidden'
if
hidden
)
}
.blob-viewer
{
data:
{
type:
viewer
.
type
,
rich_type:
rich_type
,
url:
viewer_url
},
class:
(
'hidden'
if
hidden
)
}
-
if
render_error
=
render
'projects/blob/render_error'
,
viewer:
viewer
-
elsif
load_async
...
...
app/views/projects/blob/viewers/_balsamiq.html.haml
View file @
2d8966f7
-
content_for
:page_specific_javascripts
do
=
webpack_bundle_tag
(
'balsamiq_viewer'
)
.file-content.balsamiq-viewer
#js-balsamiq-viewer
{
data:
{
endpoint:
blob_raw_path
}
}
config/webpack.config.js
View file @
2d8966f7
...
...
@@ -43,7 +43,6 @@ function generateEntries() {
autoEntriesCount
=
Object
.
keys
(
autoEntries
).
length
;
const
manualEntries
=
{
balsamiq_viewer
:
'
./blob/balsamiq_viewer.js
'
,
monitoring
:
'
./monitoring/monitoring_bundle.js
'
,
mr_notes
:
'
./mr_notes/index.js
'
,
notebook_viewer
:
'
./blob/notebook_viewer.js
'
,
...
...
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