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
7729a0ec
Commit
7729a0ec
authored
Feb 26, 2018
by
Clement Ho
Committed by
Jacob Schatz
Feb 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor wildcard dispatcher imports
parent
8d8fd68a
Changes
15
Hide 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 @
7729a0ec
...
@@ -6,177 +6,80 @@ import GlFieldErrors from './gl_field_errors';
...
@@ -6,177 +6,80 @@ import GlFieldErrors from './gl_field_errors';
import
Shortcuts
from
'
./shortcuts
'
;
import
Shortcuts
from
'
./shortcuts
'
;
import
SearchAutocomplete
from
'
./search_autocomplete
'
;
import
SearchAutocomplete
from
'
./search_autocomplete
'
;
var
Dispatcher
;
function
initSearch
()
{
// Only when search form is present
(
function
()
{
if
(
$
(
'
.search
'
).
length
)
{
Dispatcher
=
(
function
()
{
return
new
SearchAutocomplete
();
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
;
}
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
,
});
});
const
shortcutHandlerPages
=
[
'
projects:activity
'
,
'
projects:artifacts:browse
'
,
'
projects:artifacts:file
'
,
'
projects:blame:show
'
,
'
projects:blob:show
'
,
'
projects:commit:show
'
,
'
projects:commits:show
'
,
'
projects:find_file:show
'
,
'
projects:issues:edit
'
,
'
projects:issues:index
'
,
'
projects:issues:new
'
,
'
projects:issues:show
'
,
'
projects:merge_requests:creations:diffs
'
,
'
projects:merge_requests:creations:new
'
,
'
projects:merge_requests:edit
'
,
'
projects:merge_requests:index
'
,
'
projects:merge_requests:show
'
,
'
projects:network:show
'
,
'
projects:show
'
,
'
projects:tree:show
'
,
'
groups:show
'
,
];
if
(
shortcutHandlerPages
.
indexOf
(
page
)
!==
-
1
)
{
function
initFieldErrors
()
{
shortcut_handler
=
true
;
$
(
'
.gl-show-field-errors
'
).
each
((
i
,
form
)
=>
{
}
new
GlFieldErrors
(
form
);
});
}
switch
(
path
[
0
])
{
function
initPageShortcuts
(
page
)
{
case
'
admin
'
:
const
pagesWithCustomShortcuts
=
[
switch
(
path
[
1
])
{
'
projects:activity
'
,
case
'
broadcast_messages
'
:
'
projects:artifacts:browse
'
,
import
(
'
./pages/admin/broadcast_messages
'
)
'
projects:artifacts:file
'
,
.
then
(
callDefault
)
'
projects:blame:show
'
,
.
catch
(
fail
);
'
projects:blob:show
'
,
break
;
'
projects:commit:show
'
,
case
'
cohorts
'
:
'
projects:commits:show
'
,
import
(
'
./pages/admin/cohorts
'
)
'
projects:find_file:show
'
,
.
then
(
callDefault
)
'
projects:issues:edit
'
,
.
catch
(
fail
);
'
projects:issues:index
'
,
break
;
'
projects:issues:new
'
,
case
'
groups
'
:
'
projects:issues:show
'
,
switch
(
path
[
2
])
{
'
projects:merge_requests:creations:diffs
'
,
case
'
show
'
:
'
projects:merge_requests:creations:new
'
,
import
(
'
./pages/admin/groups/show
'
)
'
projects:merge_requests:edit
'
,
.
then
(
callDefault
)
'
projects:merge_requests:index
'
,
.
catch
(
fail
);
'
projects:merge_requests:show
'
,
break
;
'
projects:network:show
'
,
}
'
projects:show
'
,
break
;
'
projects:tree:show
'
,
case
'
projects
'
:
'
groups:show
'
,
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
)
{
new
Shortcuts
();
}
if
(
document
.
querySelector
(
'
#peek
'
))
{
if
(
pagesWithCustomShortcuts
.
indexOf
(
page
)
===
-
1
)
{
import
(
'
./performance_bar
'
)
new
Shortcuts
();
.
then
(
m
=>
new
m
.
default
({
container
:
'
#peek
'
}))
// eslint-disable-line new-cap
}
.
catch
(
fail
);
}
}
};
Dispatcher
.
prototype
.
initSearch
=
function
()
{
function
initGFMInput
()
{
// Only when search form is present
$
(
'
.js-gfm-input:not(.js-vue-textarea)
'
).
each
((
i
,
el
)
=>
{
if
(
$
(
'
.search
'
).
length
)
{
const
gfm
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
return
new
SearchAutocomplete
();
const
enableGFM
=
convertPermissionToBoolean
(
el
.
dataset
.
supportsAutocomplete
);
}
gfm
.
setup
(
$
(
el
),
{
};
emojis
:
true
,
members
:
enableGFM
,
issues
:
enableGFM
,
milestones
:
enableGFM
,
mergeRequests
:
enableGFM
,
labels
:
enableGFM
,
});
});
}
Dispatcher
.
prototype
.
initFieldErrors
=
function
()
{
function
initPerformanceBar
()
{
$
(
'
.gl-show-field-errors
'
).
each
((
i
,
form
)
=>
{
if
(
document
.
querySelector
(
'
#peek
'
))
{
new
GlFieldErrors
(
form
);
import
(
'
./performance_bar
'
)
});
.
then
(
m
=>
new
m
.
default
({
container
:
'
#peek
'
}))
// eslint-disable-line new-cap
};
.
catch
(()
=>
Flash
(
'
Error loading performance bar module
'
));
}
}
return
Dispatcher
;
export
default
()
=>
{
})
();
initSearch
();
})
();
initFieldErrors
();
export
default
function
initDispatcher
()
{
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
return
new
Dispatcher
();
if
(
page
)
{
}
initPageShortcuts
(
page
);
initGFMInput
();
initPerformanceBar
();
}
};
app/assets/javascripts/pages/admin/abuse_reports/index.js
View file @
7729a0ec
import
AbuseReports
from
'
./abuse_reports
'
;
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 @
7729a0ec
...
@@ -3,7 +3,7 @@ import axios from '~/lib/utils/axios_utils';
...
@@ -3,7 +3,7 @@ import axios from '~/lib/utils/axios_utils';
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
function
initBroadcastMessagesForm
()
{
export
default
()
=>
{
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
onMessageColorInput
()
{
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
onMessageColorInput
()
{
const
previewColor
=
$
(
this
).
val
();
const
previewColor
=
$
(
this
).
val
();
$
(
'
div.broadcast-message-preview
'
).
css
(
'
background-color
'
,
previewColor
);
$
(
'
div.broadcast-message-preview
'
).
css
(
'
background-color
'
,
previewColor
);
...
@@ -32,4 +32,4 @@ export default function initBroadcastMessagesForm() {
...
@@ -32,4 +32,4 @@ export default function initBroadcastMessagesForm() {
.
catch
(()
=>
flash
(
__
(
'
An error occurred while rendering preview broadcast message
'
)));
.
catch
(()
=>
flash
(
__
(
'
An error occurred while rendering preview broadcast message
'
)));
}
}
},
250
));
},
250
));
}
}
;
app/assets/javascripts/pages/admin/broadcast_messages/index.js
View file @
7729a0ec
import
initBroadcastMessagesForm
from
'
./broadcast_message
'
;
import
initBroadcastMessagesForm
from
'
./broadcast_message
'
;
export
default
()
=>
initBroadcastMessagesForm
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initBroadcastMessagesForm
);
app/assets/javascripts/pages/admin/cohorts/index.js
View file @
7729a0ec
import
initUsagePing
from
'
./usage_ping
'
;
import
initUsagePing
from
'
./usage_ping
'
;
export
default
()
=>
initUsagePing
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initUsagePing
);
app/assets/javascripts/pages/admin/groups/show/index.js
View file @
7729a0ec
import
UsersSelect
from
'
../../../../users_select
'
;
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 @
7729a0ec
import
Labels
from
'
../../../../labels
'
;
import
Labels
from
'
../../../../labels
'
;
export
default
()
=>
new
Labels
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Labels
()
);
app/assets/javascripts/pages/admin/labels/new/index.js
View file @
7729a0ec
import
Labels
from
'
../../../../labels
'
;
import
Labels
from
'
../../../../labels
'
;
export
default
()
=>
new
Labels
(
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Labels
()
);
app/assets/javascripts/pages/admin/projects/index.js
View file @
7729a0ec
import
ProjectsList
from
'
../../../projects_list
'
;
import
ProjectsList
from
'
../../../projects_list
'
;
import
NamespaceSelect
from
'
../../../namespace_select
'
;
import
NamespaceSelect
from
'
../../../namespace_select
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
ProjectsList
();
// eslint-disable-line no-new
new
ProjectsList
();
// eslint-disable-line no-new
document
.
querySelectorAll
(
'
.js-namespace-select
'
)
document
.
querySelectorAll
(
'
.js-namespace-select
'
)
.
forEach
(
dropdown
=>
new
NamespaceSelect
({
dropdown
}));
.
forEach
(
dropdown
=>
new
NamespaceSelect
({
dropdown
}));
};
}
)
;
app/assets/javascripts/pages/profiles/index/index.js
View file @
7729a0ec
import
NotificationsForm
from
'
../../../notifications_form
'
;
import
NotificationsForm
from
'
../../../notifications_form
'
;
import
notificationsDropdown
from
'
../../../notifications_dropdown
'
;
import
notificationsDropdown
from
'
../../../notifications_dropdown
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
NotificationsForm
();
// eslint-disable-line no-new
new
NotificationsForm
();
// eslint-disable-line no-new
notificationsDropdown
();
notificationsDropdown
();
};
}
)
;
app/assets/javascripts/pages/projects/compare/index.js
View file @
7729a0ec
import
initCompareAutocomplete
from
'
~/compare_autocomplete
'
;
import
initCompareAutocomplete
from
'
~/compare_autocomplete
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initCompareAutocomplete
);
initCompareAutocomplete
();
};
app/assets/javascripts/pages/projects/index.js
View file @
7729a0ec
import
Project
from
'
./project
'
;
import
Project
from
'
./project
'
;
import
ShortcutsNavigation
from
'
../../shortcuts_navigation
'
;
import
ShortcutsNavigation
from
'
../../shortcuts_navigation
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
Project
();
// eslint-disable-line no-new
new
Project
();
// eslint-disable-line no-new
new
ShortcutsNavigation
();
// eslint-disable-line no-new
new
ShortcutsNavigation
();
// eslint-disable-line no-new
};
}
)
;
app/assets/javascripts/pages/projects/new/index.js
View file @
7729a0ec
...
@@ -2,8 +2,8 @@ import ProjectNew from '../shared/project_new';
...
@@ -2,8 +2,8 @@ import ProjectNew from '../shared/project_new';
import
initProjectVisibilitySelector
from
'
../../../project_visibility
'
;
import
initProjectVisibilitySelector
from
'
../../../project_visibility
'
;
import
initProjectNew
from
'
../../../projects/project_new
'
;
import
initProjectNew
from
'
../../../projects/project_new
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
ProjectNew
();
// eslint-disable-line no-new
new
ProjectNew
();
// eslint-disable-line no-new
initProjectVisibilitySelector
();
initProjectVisibilitySelector
();
initProjectNew
.
bindEvents
();
initProjectNew
.
bindEvents
();
};
}
)
;
app/assets/javascripts/pages/projects/wikis/index.js
View file @
7729a0ec
...
@@ -3,9 +3,9 @@ import ShortcutsWiki from '../../../shortcuts_wiki';
...
@@ -3,9 +3,9 @@ import ShortcutsWiki from '../../../shortcuts_wiki';
import
ZenMode
from
'
../../../zen_mode
'
;
import
ZenMode
from
'
../../../zen_mode
'
;
import
GLForm
from
'
../../../gl_form
'
;
import
GLForm
from
'
../../../gl_form
'
;
export
default
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
Wikis
();
// eslint-disable-line no-new
new
Wikis
();
// eslint-disable-line no-new
new
ShortcutsWiki
();
// eslint-disable-line no-new
new
ShortcutsWiki
();
// eslint-disable-line no-new
new
ZenMode
();
// eslint-disable-line no-new
new
ZenMode
();
// eslint-disable-line no-new
new
GLForm
(
$
(
'
.wiki-form
'
),
true
);
// eslint-disable-line no-new
new
GLForm
(
$
(
'
.wiki-form
'
),
true
);
// eslint-disable-line no-new
};
}
)
;
config/webpack.config.js
View file @
7729a0ec
...
@@ -25,16 +25,10 @@ var NO_COMPRESSION = process.env.NO_COMPRESSION;
...
@@ -25,16 +25,10 @@ var NO_COMPRESSION = process.env.NO_COMPRESSION;
var
autoEntries
=
{};
var
autoEntries
=
{};
var
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
)
});
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
=
'
.
'
)
{
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
if
(
!
dispatcherChunks
.
includes
(
`
${
prefix
}
/
${
chunkPath
}
`
))
{
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
autoEntries
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
autoEntries
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
}
}
}
pageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
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