summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2016-07-01 03:18:52 +0100
committerLuke Bennett <lukeeeebennettplus@gmail.com>2016-08-14 00:54:18 +0100
commitf5cff060bc74fc0c18a70e111f3ed4fb8a5f2a91 (patch)
tree9bb7af82e40ce56bed68735fa6645a1f67bffd9e
parentcbae07db5e70972bfb320c90640f9a9e12d0351e (diff)
downloadgitlab-ce-f5cff060bc74fc0c18a70e111f3ed4fb8a5f2a91.tar.gz
Started on abuse reports message truncation
-rw-r--r--app/assets/javascripts/abuse_reports.js.coffee26
-rw-r--r--app/assets/javascripts/dispatcher.js3
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee173
-rw-r--r--app/assets/stylesheets/pages/admin.scss8
4 files changed, 209 insertions, 1 deletions
diff --git a/app/assets/javascripts/abuse_reports.js.coffee b/app/assets/javascripts/abuse_reports.js.coffee
new file mode 100644
index 00000000000..de768b12ef9
--- /dev/null
+++ b/app/assets/javascripts/abuse_reports.js.coffee
@@ -0,0 +1,26 @@
+class @AbuseReports
+ MAX_MESSAGE_LENGTH = 300
+ MESSAGE_CELL_SELECTOR = 'table tbody tr td:nth-child(3)'
+
+ constructor: ->
+ $(MESSAGE_CELL_SELECTOR).each @truncateLongMessage
+ $(document).on 'click', "#{MESSAGE_CELL_SELECTOR}", @toggleMessageTruncation
+
+ truncateLongMessage: ->
+ messageCellElement = $(this)
+ reportMessage = messageCellElement.text()
+ if reportMessage.length > MAX_MESSAGE_LENGTH
+ messageCellElement.attr 'data-original-message', reportMessage
+ messageCellElement.attr 'data-message-truncated', 'true'
+ messageCellElement.text "#{reportMessage.substr 0, MAX_MESSAGE_LENGTH}..."
+
+ toggleMessageTruncation: ->
+ messageCellElement = $(this)
+ originalMessage = messageCellElement.attr 'data-original-message'
+ return if not originalMessage
+ if messageCellElement.attr('data-message-truncated') is 'true'
+ messageCellElement.attr 'data-message-truncated', 'false'
+ messageCellElement.text originalMessage
+ else
+ messageCellElement.attr 'data-message-truncated', 'true'
+ messageCellElement.text "#{originalMessage.substr 0, MAX_MESSAGE_LENGTH}..."
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index 3946e861976..0606287f35b 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -192,6 +192,9 @@
case 'edit':
new Labels();
}
+ case 'abuse_reports':
+ new AbuseReports();
+ break;
}
break;
case 'dashboard':
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
new file mode 100644
index 00000000000..7711f66bb91
--- /dev/null
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -0,0 +1,173 @@
+$ ->
+ new Dispatcher()
+
+class Dispatcher
+ constructor: () ->
+ @initSearch()
+ @initPageScripts()
+
+ initPageScripts: ->
+ page = $('body').attr('data-page')
+
+ unless page
+ return false
+
+ path = page.split(':')
+ shortcut_handler = null
+ switch page
+ when 'projects:issues:index'
+ Issuable.init()
+ new IssuableBulkActions()
+ shortcut_handler = new ShortcutsNavigation()
+ when 'projects:issues:show'
+ new Issue()
+ shortcut_handler = new ShortcutsIssuable()
+ new ZenMode()
+ when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
+ new Milestone()
+ when 'dashboard:todos:index'
+ new Todos()
+ when 'projects:milestones:new', 'projects:milestones:edit'
+ new ZenMode()
+ new DueDateSelect()
+ new GLForm($('.milestone-form'))
+ when 'groups:milestones:new'
+ new ZenMode()
+ when 'projects:compare:show'
+ new Diff()
+ when 'projects:issues:new','projects:issues:edit'
+ shortcut_handler = new ShortcutsNavigation()
+ new GLForm($('.issue-form'))
+ new IssuableForm($('.issue-form'))
+ when 'projects:merge_requests:new', 'projects:merge_requests:edit'
+ new Diff()
+ shortcut_handler = new ShortcutsNavigation()
+ new GLForm($('.merge-request-form'))
+ new IssuableForm($('.merge-request-form'))
+ when 'projects:tags:new'
+ new ZenMode()
+ new GLForm($('.tag-form'))
+ when 'projects:releases:edit'
+ new ZenMode()
+ new GLForm($('.release-form'))
+ when 'projects:merge_requests:show'
+ new Diff()
+ shortcut_handler = new ShortcutsIssuable(true)
+ new ZenMode()
+ new MergedButtons()
+ when 'projects:merge_requests:commits', 'projects:merge_requests:builds'
+ new MergedButtons()
+ when "projects:merge_requests:diffs"
+ new Diff()
+ new ZenMode()
+ new MergedButtons()
+ when 'projects:merge_requests:index'
+ shortcut_handler = new ShortcutsNavigation()
+ Issuable.init()
+ when 'dashboard:activity'
+ new Activities()
+ when 'dashboard:projects:starred'
+ new Activities()
+ when 'projects:commit:show'
+ new Commit()
+ new Diff()
+ new ZenMode()
+ shortcut_handler = new ShortcutsNavigation()
+ when 'projects:commits:show', 'projects:activity'
+ shortcut_handler = new ShortcutsNavigation()
+ when 'projects:show'
+ shortcut_handler = new ShortcutsNavigation()
+
+ new NotificationsForm()
+ new TreeView() if $('#tree-slider').length
+ when 'groups:activity'
+ new Activities()
+ when 'groups:show'
+ shortcut_handler = new ShortcutsNavigation()
+ new NotificationsForm()
+ new NotificationsDropdown()
+ when 'groups:group_members:index'
+ new GroupMembers()
+ new UsersSelect()
+ when 'projects:project_members:index'
+ new ProjectMembers()
+ new UsersSelect()
+ when 'groups:new', 'groups:edit', 'admin:groups:edit', 'admin:groups:new'
+ new GroupAvatar()
+ when 'projects:tree:show'
+ shortcut_handler = new ShortcutsNavigation()
+ new TreeView()
+ when 'projects:find_file:show'
+ shortcut_handler = true
+ when 'projects:blob:show', 'projects:blame:show'
+ new LineHighlighter()
+ shortcut_handler = new ShortcutsNavigation()
+ new ShortcutsBlob true
+ when 'projects:labels:new', 'projects:labels:edit'
+ new Labels()
+ when 'projects:labels:index'
+ new LabelManager() if $('.prioritized-labels').length
+ when 'projects:network:show'
+ # Ensure we don't create a particular shortcut handler here. This is
+ # already created, where the network graph is created.
+ shortcut_handler = true
+ when 'projects:forks:new'
+ new ProjectFork()
+ when 'projects:artifacts:browse'
+ new BuildArtifacts()
+ when 'projects:group_links:index'
+ new GroupsSelect()
+ when 'search:show'
+ new Search()
+
+ switch path.first()
+ when 'admin'
+ new Admin()
+ switch path[1]
+ when 'groups'
+ new UsersSelect()
+ when 'projects'
+ new NamespaceSelects()
+ when 'abuse_reports'
+ new AbuseReports()
+ when 'dashboard', 'root'
+ shortcut_handler = new ShortcutsDashboardNavigation()
+ when 'profiles'
+ new NotificationsForm()
+ new NotificationsDropdown()
+ when 'projects'
+ new Project()
+ new ProjectAvatar()
+ switch path[1]
+ when 'compare'
+ new CompareAutocomplete()
+ when 'edit'
+ shortcut_handler = new ShortcutsNavigation()
+ new ProjectNew()
+ when 'new'
+ new ProjectNew()
+ when 'show'
+ new ProjectNew()
+ new ProjectShow()
+ new NotificationsDropdown()
+ when 'wikis'
+ new Wikis()
+ shortcut_handler = new ShortcutsNavigation()
+ new ZenMode()
+ new GLForm($('.wiki-form'))
+ when 'snippets'
+ shortcut_handler = new ShortcutsNavigation()
+ new ZenMode() if path[2] == 'show'
+ when 'labels', 'graphs', 'compare', 'pipelines', 'forks', \
+ 'milestones', 'project_members', 'deploy_keys', 'builds', \
+ 'hooks', 'services', 'protected_branches'
+ shortcut_handler = new ShortcutsNavigation()
+
+ # If we haven't installed a custom shortcut handler, install the default one
+ if not shortcut_handler
+ new Shortcuts()
+
+ initSearch: ->
+
+ # Only when search form is present
+ new SearchAutocomplete() if $('.search').length
diff --git a/app/assets/stylesheets/pages/admin.scss b/app/assets/stylesheets/pages/admin.scss
index 5607239d92d..9220ddd67c0 100644
--- a/app/assets/stylesheets/pages/admin.scss
+++ b/app/assets/stylesheets/pages/admin.scss
@@ -72,7 +72,6 @@
margin-bottom: 20px;
}
-
// Users List
.users-list {
@@ -98,3 +97,10 @@
}
}
}
+
+table.abuse-reports tbody tr td {
+ vertical-align: top;
+ &:nth-child(5) {
+ min-width: 220px;
+ }
+}