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
7278bc2d
Commit
7278bc2d
authored
Feb 26, 2018
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor wildcard dispatcher imports (EE)
parent
8b0345d7
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
91 additions
and
196 deletions
+91
-196
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+70
-167
app/assets/javascripts/pages/admin/abuse_reports/index.js
app/assets/javascripts/pages/admin/abuse_reports/index.js
+1
-1
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js
...ripts/pages/admin/broadcast_messages/broadcast_message.js
+2
-2
app/assets/javascripts/pages/admin/broadcast_messages/index.js
...ssets/javascripts/pages/admin/broadcast_messages/index.js
+1
-1
app/assets/javascripts/pages/admin/cohorts/index.js
app/assets/javascripts/pages/admin/cohorts/index.js
+1
-1
app/assets/javascripts/pages/admin/groups/show/index.js
app/assets/javascripts/pages/admin/groups/show/index.js
+1
-1
app/assets/javascripts/pages/admin/labels/edit/index.js
app/assets/javascripts/pages/admin/labels/edit/index.js
+1
-1
app/assets/javascripts/pages/admin/labels/new/index.js
app/assets/javascripts/pages/admin/labels/new/index.js
+1
-1
app/assets/javascripts/pages/admin/projects/index.js
app/assets/javascripts/pages/admin/projects/index.js
+2
-2
app/assets/javascripts/pages/profiles/index/index.js
app/assets/javascripts/pages/profiles/index/index.js
+2
-2
app/assets/javascripts/pages/projects/compare/index.js
app/assets/javascripts/pages/projects/compare/index.js
+1
-3
app/assets/javascripts/pages/projects/index.js
app/assets/javascripts/pages/projects/index.js
+2
-2
app/assets/javascripts/pages/projects/new/index.js
app/assets/javascripts/pages/projects/new/index.js
+2
-2
app/assets/javascripts/pages/projects/wikis/index.js
app/assets/javascripts/pages/projects/wikis/index.js
+2
-2
config/webpack.config.js
config/webpack.config.js
+2
-8
No files found.
app/assets/javascripts/dispatcher.js
View file @
7278bc2d
...
...
@@ -6,43 +6,21 @@ import GlFieldErrors from './gl_field_errors';
import
Shortcuts
from
'
./shortcuts
'
;
import
SearchAutocomplete
from
'
./search_autocomplete
'
;
var
Dispatcher
;
(
function
()
{
Dispatcher
=
(
function
()
{
function
Dispatcher
()
{
this
.
initSearch
();
this
.
initFieldErrors
();
this
.
initPageScripts
();
}
Dispatcher
.
prototype
.
initPageScripts
=
function
()
{
var
path
,
shortcut_handler
;
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
if
(
!
page
)
{
return
false
;
function
initSearch
()
{
// Only when search form is present
if
(
$
(
'
.search
'
).
length
)
{
return
new
SearchAutocomplete
();
}
}
const
fail
=
()
=>
Flash
(
'
Error loading dynamic module
'
);
const
callDefault
=
m
=>
m
.
default
();
path
=
page
.
split
(
'
:
'
);
shortcut_handler
=
null
;
$
(
'
.js-gfm-input:not(.js-vue-textarea)
'
).
each
((
i
,
el
)
=>
{
const
gfm
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
const
enableGFM
=
convertPermissionToBoolean
(
el
.
dataset
.
supportsAutocomplete
);
gfm
.
setup
(
$
(
el
),
{
emojis
:
true
,
members
:
enableGFM
,
issues
:
enableGFM
,
milestones
:
enableGFM
,
mergeRequests
:
enableGFM
,
labels
:
enableGFM
,
});
function
initFieldErrors
()
{
$
(
'
.gl-show-field-errors
'
).
each
((
i
,
form
)
=>
{
new
GlFieldErrors
(
form
);
});
}
const
shortcutHandlerPages
=
[
function
initPageShortcuts
(
page
)
{
const
pagesWithCustomShortcuts
=
[
'
projects:activity
'
,
'
projects:artifacts:browse
'
,
'
projects:artifacts:file
'
,
...
...
@@ -66,117 +44,42 @@ var Dispatcher;
'
groups:show
'
,
];
if
(
shortcutHandlerPages
.
indexOf
(
page
)
!==
-
1
)
{
shortcut_handler
=
true
;
}
switch
(
path
[
0
])
{
case
'
admin
'
:
switch
(
path
[
1
])
{
case
'
broadcast_messages
'
:
import
(
'
./pages/admin/broadcast_messages
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
cohorts
'
:
import
(
'
./pages/admin/cohorts
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
groups
'
:
switch
(
path
[
2
])
{
case
'
show
'
:
import
(
'
./pages/admin/groups/show
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
}
break
;
case
'
projects
'
:
import
(
'
./pages/admin/projects
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
labels
'
:
switch
(
path
[
2
])
{
case
'
new
'
:
import
(
'
./pages/admin/labels/new
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
edit
'
:
import
(
'
./pages/admin/labels/edit
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
}
case
'
abuse_reports
'
:
import
(
'
./pages/admin/abuse_reports
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
}
break
;
case
'
profiles
'
:
import
(
'
./pages/profiles/index
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
projects
'
:
import
(
'
./pages/projects
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
shortcut_handler
=
true
;
switch
(
path
[
1
])
{
case
'
compare
'
:
import
(
'
./pages/projects/compare
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
create
'
:
case
'
new
'
:
import
(
'
./pages/projects/new
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
break
;
case
'
wikis
'
:
import
(
'
./pages/projects/wikis
'
)
.
then
(
callDefault
)
.
catch
(
fail
);
shortcut_handler
=
true
;
break
;
}
break
;
}
// If we haven't installed a custom shortcut handler, install the default one
if
(
!
shortcut_handler
)
{
if
(
pagesWithCustomShortcuts
.
indexOf
(
page
)
===
-
1
)
{
new
Shortcuts
();
}
}
function
initGFMInput
()
{
$
(
'
.js-gfm-input:not(.js-vue-textarea)
'
).
each
((
i
,
el
)
=>
{
const
gfm
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
const
enableGFM
=
convertPermissionToBoolean
(
el
.
dataset
.
supportsAutocomplete
);
gfm
.
setup
(
$
(
el
),
{
emojis
:
true
,
members
:
enableGFM
,
issues
:
enableGFM
,
milestones
:
enableGFM
,
mergeRequests
:
enableGFM
,
labels
:
enableGFM
,
});
});
}
function
initPerformanceBar
()
{
if
(
document
.
querySelector
(
'
#peek
'
))
{
import
(
'
./performance_bar
'
)
.
then
(
m
=>
new
m
.
default
({
container
:
'
#peek
'
}))
// eslint-disable-line new-cap
.
catch
(
fail
);
.
catch
(()
=>
Flash
(
'
Error loading performance bar module
'
)
);
}
};
Dispatcher
.
prototype
.
initSearch
=
function
()
{
// Only when search form is present
if
(
$
(
'
.search
'
).
length
)
{
return
new
SearchAutocomplete
();
}
};
Dispatcher
.
prototype
.
initFieldErrors
=
function
()
{
$
(
'
.gl-show-field-errors
'
).
each
((
i
,
form
)
=>
{
new
GlFieldErrors
(
form
);
});
};
}
return
Dispatcher
;
})
();
})
();
export
default
()
=>
{
initSearch
();
initFieldErrors
();
export
default
function
initDispatcher
()
{
return
new
Dispatcher
();
}
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
if
(
page
)
{
initPageShortcuts
(
page
);
initGFMInput
();
initPerformanceBar
();
}
};
app/assets/javascripts/pages/admin/abuse_reports/index.js
View file @
7278bc2d
import
AbuseReports
from
'
./abuse_reports
'
;
export
default
()
=>
new
AbuseReports
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
AbuseReports
()
);
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js
View file @
7278bc2d
...
...
@@ -3,7 +3,7 @@ import axios from '~/lib/utils/axios_utils';
import
flash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
function
initBroadcastMessagesForm
()
{
export
default
()
=>
{
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
onMessageColorInput
()
{
const
previewColor
=
$
(
this
).
val
();
$
(
'
div.broadcast-message-preview
'
).
css
(
'
background-color
'
,
previewColor
);
...
...
@@ -32,4 +32,4 @@ export default function initBroadcastMessagesForm() {
.
catch
(()
=>
flash
(
__
(
'
An error occurred while rendering preview broadcast message
'
)));
}
},
250
));
}
}
;
app/assets/javascripts/pages/admin/broadcast_messages/index.js
View file @
7278bc2d
import
initBroadcastMessagesForm
from
'
./broadcast_message
'
;
export
default
()
=>
initBroadcastMessagesForm
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initBroadcastMessagesForm
);
app/assets/javascripts/pages/admin/cohorts/index.js
View file @
7278bc2d
import
initUsagePing
from
'
./usage_ping
'
;
export
default
()
=>
initUsagePing
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initUsagePing
);
app/assets/javascripts/pages/admin/groups/show/index.js
View file @
7278bc2d
import
UsersSelect
from
'
../../../../users_select
'
;
export
default
()
=>
new
UsersSelect
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
UsersSelect
()
);
app/assets/javascripts/pages/admin/labels/edit/index.js
View file @
7278bc2d
import
Labels
from
'
../../../../labels
'
;
export
default
()
=>
new
Labels
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Labels
()
);
app/assets/javascripts/pages/admin/labels/new/index.js
View file @
7278bc2d
import
Labels
from
'
../../../../labels
'
;
export
default
()
=>
new
Labels
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Labels
()
);
app/assets/javascripts/pages/admin/projects/index.js
View file @
7278bc2d
import
ProjectsList
from
'
../../../projects_list
'
;
import
NamespaceSelect
from
'
../../../namespace_select
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
ProjectsList
();
// eslint-disable-line no-new
document
.
querySelectorAll
(
'
.js-namespace-select
'
)
.
forEach
(
dropdown
=>
new
NamespaceSelect
({
dropdown
}));
};
}
)
;
app/assets/javascripts/pages/profiles/index/index.js
View file @
7278bc2d
import
NotificationsForm
from
'
../../../notifications_form
'
;
import
notificationsDropdown
from
'
../../../notifications_dropdown
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
NotificationsForm
();
// eslint-disable-line no-new
notificationsDropdown
();
};
}
)
;
app/assets/javascripts/pages/projects/compare/index.js
View file @
7278bc2d
import
initCompareAutocomplete
from
'
~/compare_autocomplete
'
;
export
default
()
=>
{
initCompareAutocomplete
();
};
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initCompareAutocomplete
);
app/assets/javascripts/pages/projects/index.js
View file @
7278bc2d
import
Project
from
'
./project
'
;
import
ShortcutsNavigation
from
'
../../shortcuts_navigation
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
Project
();
// eslint-disable-line no-new
new
ShortcutsNavigation
();
// eslint-disable-line no-new
};
}
)
;
app/assets/javascripts/pages/projects/new/index.js
View file @
7278bc2d
...
...
@@ -2,8 +2,8 @@ import ProjectNew from '../shared/project_new';
import
initProjectVisibilitySelector
from
'
../../../project_visibility
'
;
import
initProjectNew
from
'
../../../projects/project_new
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
ProjectNew
();
// eslint-disable-line no-new
initProjectVisibilitySelector
();
initProjectNew
.
bindEvents
();
};
}
)
;
app/assets/javascripts/pages/projects/wikis/index.js
View file @
7278bc2d
...
...
@@ -3,9 +3,9 @@ import ShortcutsWiki from '../../../shortcuts_wiki';
import
ZenMode
from
'
../../../zen_mode
'
;
import
GLForm
from
'
../../../gl_form
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
Wikis
();
// eslint-disable-line no-new
new
ShortcutsWiki
();
// eslint-disable-line no-new
new
ZenMode
();
// eslint-disable-line no-new
new
GLForm
(
$
(
'
.wiki-form
'
),
true
);
// eslint-disable-line no-new
};
}
)
;
config/webpack.config.js
View file @
7278bc2d
...
...
@@ -25,16 +25,10 @@ var NO_COMPRESSION = process.env.NO_COMPRESSION;
var
autoEntries
=
{};
var
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
)
});
// filter out entries currently imported dynamically in dispatcher.js
var
dispatcher
=
fs
.
readFileSync
(
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts/dispatcher.js
'
)).
toString
();
var
dispatcherChunks
=
dispatcher
.
match
(
/
(?!
import
\(
'
)\.\/
pages
\/[^
'
]
+/g
);
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
if
(
!
dispatcherChunks
.
includes
(
`
${
prefix
}
/
${
chunkPath
}
`
))
{
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
autoEntries
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
}
}
pageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
));
...
...
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