BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
91 additions
and
196 deletions
+91
-196
dispatcher.js
app/assets/javascripts/dispatcher.js
+70
-167
index.js
app/assets/javascripts/pages/admin/abuse_reports/index.js
+1
-1
broadcast_message.js
...ripts/pages/admin/broadcast_messages/broadcast_message.js
+2
-2
index.js
...ssets/javascripts/pages/admin/broadcast_messages/index.js
+1
-1
index.js
app/assets/javascripts/pages/admin/cohorts/index.js
+1
-1
index.js
app/assets/javascripts/pages/admin/groups/show/index.js
+1
-1
index.js
app/assets/javascripts/pages/admin/labels/edit/index.js
+1
-1
index.js
app/assets/javascripts/pages/admin/labels/new/index.js
+1
-1
index.js
app/assets/javascripts/pages/admin/projects/index.js
+2
-2
index.js
app/assets/javascripts/pages/profiles/index/index.js
+2
-2
index.js
app/assets/javascripts/pages/projects/compare/index.js
+1
-3
index.js
app/assets/javascripts/pages/projects/index.js
+2
-2
index.js
app/assets/javascripts/pages/projects/new/index.js
+2
-2
index.js
app/assets/javascripts/pages/projects/wikis/index.js
+2
-2
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';
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
;
}
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'
,
];
function
initSearch
()
{
// Only when search form is present
if
(
$
(
'.search'
).
length
)
{
return
new
SearchAutocomplete
();
}
}
if
(
shortcutHandlerPages
.
indexOf
(
page
)
!==
-
1
)
{
shortcut_handler
=
true
;
}
function
initFieldErrors
()
{
$
(
'.gl-show-field-errors'
).
each
((
i
,
form
)
=>
{
new
GlFieldErrors
(
form
);
});
}
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
)
{
new
Shortcuts
();
}
function
initPageShortcuts
(
page
)
{
const
pagesWithCustomShortcuts
=
[
'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
(
document
.
querySelector
(
'#peek'
))
{
import
(
'./performance_bar'
)
.
then
(
m
=>
new
m
.
default
({
container
:
'#peek'
}))
// eslint-disable-line new-cap
.
catch
(
fail
);
}
};
if
(
pagesWithCustomShortcuts
.
indexOf
(
page
)
===
-
1
)
{
new
Shortcuts
();
}
}
Dispatcher
.
prototype
.
initSearch
=
function
()
{
// Only when search form is present
if
(
$
(
'.search'
).
length
)
{
return
new
SearchAutocomplete
();
}
};
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
,
});
});
}
Dispatcher
.
prototype
.
initFieldErrors
=
function
()
{
$
(
'.gl-show-field-errors'
).
each
((
i
,
form
)
=>
{
new
GlFieldErrors
(
form
);
});
};
function
initPerformanceBar
()
{
if
(
document
.
querySelector
(
'#peek'
))
{
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
()
{
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 @
7729a0ec
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';
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 @
7729a0ec
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'
;
export
default
()
=>
initUsagePing
(
);
document
.
addEventListener
(
'DOMContentLoaded'
,
initUsagePing
);
app/assets/javascripts/pages/admin/groups/show/index.js
View file @
7729a0ec
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'
;
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'
;
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
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 @
7729a0ec
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 @
7729a0ec
import
initCompareAutocomplete
from
'~/compare_autocomplete'
;
export
default
()
=>
{
initCompareAutocomplete
();
};
document
.
addEventListener
(
'DOMContentLoaded'
,
initCompareAutocomplete
);
app/assets/javascripts/pages/projects/index.js
View file @
7729a0ec
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 @
7729a0ec
...
...
@@ -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 @
7729a0ec
...
...
@@ -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 @
7729a0ec
...
...
@@ -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
}
`
;
}
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