From 74dfe60a34f3c9e295c73bfe20c9a18f47713845 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Fri, 4 Dec 2015 08:28:30 +0100 Subject: [PATCH] lodash 2 -> lodash 4 --- app-loader/app-loader.coffee | 2 +- app/coffee/app.coffee | 2 +- app/coffee/modules/admin/project-values.coffee | 4 ++-- app/coffee/modules/admin/roles.coffee | 2 +- app/coffee/modules/admin/third-parties.coffee | 2 +- app/coffee/modules/base/contrib.coffee | 2 +- app/coffee/modules/base/urls.coffee | 4 ++-- app/coffee/modules/common/history.coffee | 10 ++++++---- app/coffee/modules/common/lightboxes.coffee | 8 ++++---- app/coffee/modules/common/tags.coffee | 2 +- app/coffee/modules/controllerMixins.coffee | 2 +- app/coffee/modules/events.coffee | 2 +- app/coffee/utils.coffee | 15 +++++++++------ bower.json | 6 +++--- e2e/shared/detail.js | 1 + e2e/suites/tasks/task-detail.e2e.js | 2 +- gulpfile.js | 3 +-- run-e2e.js | 2 ++ 18 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app-loader/app-loader.coffee b/app-loader/app-loader.coffee index 310f6df5..333e9860 100644 --- a/app-loader/app-loader.coffee +++ b/app-loader/app-loader.coffee @@ -53,7 +53,7 @@ loadPlugins = (plugins) -> promise = $.getJSON "/conf.json" promise.done (data) -> - window.taigaConfig = _.extend({}, window.taigaConfig, data) + window.taigaConfig = _.assign({}, window.taigaConfig, data) promise.always -> if window.taigaConfig.contribPlugins.length > 0 diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 54ff9b5d..0e8b6f37 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -586,7 +586,7 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na # Taiga Plugins $rootscope.contribPlugins = @.taigaContribPlugins - $rootscope.adminPlugins = _.where(@.taigaContribPlugins, {"type": "admin"}) + $rootscope.adminPlugins = _.filter(@.taigaContribPlugins, {"type": "admin"}) $rootscope.$on "$translateChangeEnd", (e, ctx) -> lang = ctx.language diff --git a/app/coffee/modules/admin/project-values.coffee b/app/coffee/modules/admin/project-values.coffee index 2fb76093..dff5ae07 100644 --- a/app/coffee/modules/admin/project-values.coffee +++ b/app/coffee/modules/admin/project-values.coffee @@ -108,7 +108,7 @@ class ProjectValuesController extends taiga.Controller loadValues: => return @rs[@scope.resource].listValues(@scope.projectId, @scope.type).then (values) => @scope.values = values - @scope.maxValueOrder = _.max(values, "order").order + @scope.maxValueOrder = _.maxBy(values, "order").order return values moveValue: (ctx, itemValue, itemIndex) => @@ -436,7 +436,7 @@ class ProjectCustomAttributesController extends mixOf(taiga.Controller, taiga.Pa loadCustomAttributes: => return @rs.customAttributes[@scope.type].list(@scope.projectId).then (customAttributes) => @scope.customAttributes = customAttributes - @scope.maxOrder = _.max(customAttributes, "order").order + @scope.maxOrder = _.maxBy(customAttributes, "order").order return customAttributes createCustomAttribute: (attrValues) => diff --git a/app/coffee/modules/admin/roles.coffee b/app/coffee/modules/admin/roles.coffee index 59072640..d2689147 100644 --- a/app/coffee/modules/admin/roles.coffee +++ b/app/coffee/modules/admin/roles.coffee @@ -251,7 +251,7 @@ NewRoleDirective = ($tgrepo, $confirm) -> project: $scope.projectId name: target.val() permissions: DEFAULT_PERMISSIONS - order: _.max($scope.roles, (r) -> r.order).order + 1 + order: _.maxBy($scope.roles, (r) -> r.order).order + 1 computable: false } diff --git a/app/coffee/modules/admin/third-parties.coffee b/app/coffee/modules/admin/third-parties.coffee index 484de9b7..ec778ff3 100644 --- a/app/coffee/modules/admin/third-parties.coffee +++ b/app/coffee/modules/admin/third-parties.coffee @@ -103,7 +103,7 @@ WebhookDirective = ($rs, $repo, $confirm, $loading, $translate) -> $rs.webhooklogs.list(webhook.id).then (webhooklogs) => for log in webhooklogs log.validStatus = 200 <= log.status < 300 - log.prettySentHeaders = _.map(_.pairs(log.request_headers), ([header, value]) -> "#{header}: #{value}").join("\n") + log.prettySentHeaders = _.map(_.toPairs(log.request_headers), ([header, value]) -> "#{header}: #{value}").join("\n") log.prettySentData = JSON.stringify(log.request_data) log.prettyDate = moment(log.created).format(prettyDate) diff --git a/app/coffee/modules/base/contrib.coffee b/app/coffee/modules/base/contrib.coffee index 9c66492f..3db5a643 100644 --- a/app/coffee/modules/base/contrib.coffee +++ b/app/coffee/modules/base/contrib.coffee @@ -36,7 +36,7 @@ class ContribController extends taiga.Controller ] constructor: (@rootScope, @scope, @params, @repo, @rs, @confirm) -> - @scope.currentPlugin = _.first(_.where(@rootScope.adminPlugins, {"slug": @params.plugin})) + @scope.currentPlugin = _.head(_.filter(@rootScope.adminPlugins, {"slug": @params.plugin})) @scope.projectSlug = @params.pslug promise = @.loadInitialData() diff --git a/app/coffee/modules/base/urls.coffee b/app/coffee/modules/base/urls.coffee index 44fdfaf6..e275390a 100644 --- a/app/coffee/modules/base/urls.coffee +++ b/app/coffee/modules/base/urls.coffee @@ -48,8 +48,8 @@ class UrlsService extends taiga.Service url = format(@.urls[name], args.slice(1)) return format("%s/%s", [ - _.str.rtrim(@.mainUrl, "/"), - _.str.ltrim(url, "/") + _.trimEnd(@.mainUrl, "/"), + _.trimStart(url, "/") ]) resolveAbsolute: -> diff --git a/app/coffee/modules/common/history.coffee b/app/coffee/modules/common/history.coffee index c650b092..bbc1beb4 100644 --- a/app/coffee/modules/common/history.coffee +++ b/app/coffee/modules/common/history.coffee @@ -370,10 +370,12 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c renderComments = -> comments = $scope.comments or [] totalComments = comments.length - if not showAllComments - comments = _.last(comments, 4) - comments = _.map(comments, (x) -> renderComment(x)) + if not showAllComments + comments = _.takeRight(comments, 4) + + comments = _.map comments, (x) -> renderComment(x) + html = renderHistory(comments, totalComments) $el.find(".comments-list").html(html) @@ -381,7 +383,7 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c changes = $scope.history or [] totalChanges = changes.length if not showAllActivity - changes = _.last(changes, 4) + changes = _.takeRight(changes, 4) changes = _.map(changes, (x) -> renderChange(x)) html = renderHistory(changes, totalChanges) diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index 82f640b0..21851035 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -513,7 +513,7 @@ AssignedToLightboxDirective = (lightboxService, lightboxKeyboardNavigationServic username = normalizeString(username) text = text.toUpperCase() text = normalizeString(text) - return _.contains(username, text) + return _.includes(username, text) render = (selected, text) -> users = _.clone($scope.activeUsers, true) @@ -522,7 +522,7 @@ AssignedToLightboxDirective = (lightboxService, lightboxKeyboardNavigationServic ctx = { selected: selected - users: _.first(users, 5) + users: _.slice(users, 0, 5) showMore: users.length > 5 } @@ -608,7 +608,7 @@ WatchersLightboxDirective = ($repo, lightboxService, lightboxKeyboardNavigationS username = user.full_name_display.toUpperCase() text = text.toUpperCase() - return _.contains(username, text) + return _.includes(username, text) users = _.clone($scope.activeUsers, true) users = _.filter(users, _.partial(_filterUsers, text)) @@ -618,7 +618,7 @@ WatchersLightboxDirective = ($repo, lightboxService, lightboxKeyboardNavigationS render = (users) -> ctx = { selected: false - users: _.first(users, 5) + users: _.head(users, 5) showMore: users.length > 5 } diff --git a/app/coffee/modules/common/tags.coffee b/app/coffee/modules/common/tags.coffee index 0b8c8dfb..c5ea64e4 100644 --- a/app/coffee/modules/common/tags.coffee +++ b/app/coffee/modules/common/tags.coffee @@ -38,7 +38,7 @@ TagsDirective = -> parser = (v) -> return [] if not v - result = _(v.split(",")).map((x) -> _.str.trim(x)) + result = _(v.split(",")).map((x) -> _.trim(x)) return result.value() diff --git a/app/coffee/modules/controllerMixins.coffee b/app/coffee/modules/controllerMixins.coffee index 4bfda2d1..18724b4b 100644 --- a/app/coffee/modules/controllerMixins.coffee +++ b/app/coffee/modules/controllerMixins.coffee @@ -46,7 +46,7 @@ class PageMixin @scope.roles = _.sortBy(roles, "order") computableRoles = _(@scope.project.members).map("role").uniq().value() @scope.computableRoles = _(roles).filter("computable") - .filter((x) -> _.contains(computableRoles, x.id)) + .filter((x) -> _.includes(computableRoles, x.id)) .value() loadUsersAndRoles: -> promise = @q.all([ diff --git a/app/coffee/modules/events.coffee b/app/coffee/modules/events.coffee index aed298b8..ef0bb491 100644 --- a/app/coffee/modules/events.coffee +++ b/app/coffee/modules/events.coffee @@ -59,7 +59,7 @@ class EventsService if not startswith(url, "ws:") and not startswith(url, "wss:") loc = @win.location scheme = if loc.protocol == "https:" then "wss:" else "ws:" - path = _.str.ltrim(url, "/") + path = _.trimStart(url, "/") url = "#{scheme}//#{loc.host}/#{path}" @.ws = new @win.WebSocket(url) diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index 6ced2cc5..443bac59 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -59,16 +59,19 @@ mixOf = (base, mixins...) -> trim = (data, char) -> - return _.str.trim(data, char) + return _.trim(data, char) slugify = (data) -> - return _.str.slugify(data) - + return data.toString().toLowerCase().trim() + .replace(/\s+/g, '-') + .replace(/&/g, '-and-') + .replace(/[^\w\-]+/g, '') + .replace(/\-\-+/g, '-') unslugify = (data) -> if data - return _.str.capitalize(data.replace(/-/g, ' ')) + return _.capitalize(data.replace(/-/g, ' ')) return data @@ -114,7 +117,7 @@ toString = (value) -> joinStr = (str, coll) -> - return _.str.join(str, coll) + return coll.join(str) debounce = (wait, func) -> @@ -126,7 +129,7 @@ debounceLeading = (wait, func) -> startswith = (str1, str2) -> - return _.str.startsWith(str1, str2) + return _.startsWith(str1, str2) truncate = (str, maxLength, suffix="...") -> diff --git a/bower.json b/bower.json index 1846ba06..0ecb935a 100644 --- a/bower.json +++ b/bower.json @@ -47,7 +47,6 @@ "tests" ], "dependencies": { - "lodash": "~2.4.2", "emoticons": "~0.1.7", "jquery-flot": "~0.8.2", "angular": "1.4.7", @@ -83,10 +82,11 @@ "eventemitter2": "~0.4.14", "immutable": "~3.7.6", "bluebird": "~2.10.2", - "intro.js": "~1.1.1" + "intro.js": "~1.1.1", + "lodash": "~4.0.0" }, "resolutions": { - "lodash": "~2.4.2", + "lodash": "~4.0.0", "moment": "~2.10.6", "jquery": "~2.1.1", "angular": "1.4.7" diff --git a/e2e/shared/detail.js b/e2e/shared/detail.js index 5f6dc991..26d87fe4 100644 --- a/e2e/shared/detail.js +++ b/e2e/shared/detail.js @@ -65,6 +65,7 @@ shared.statusTesting = async function(status1 , status2) { await statusHelper.setStatus(1); let selectedStatus = await statusHelper.getSelectedStatus(); + expect(selectedStatus).to.be.equal(status1); // Status 2 diff --git a/e2e/suites/tasks/task-detail.e2e.js b/e2e/suites/tasks/task-detail.e2e.js index f5907c96..26917e1e 100644 --- a/e2e/suites/tasks/task-detail.e2e.js +++ b/e2e/suites/tasks/task-detail.e2e.js @@ -33,7 +33,7 @@ describe('Task detail', function(){ it('description edition', sharedDetail.descriptionTesting); - it('status edition', sharedDetail.statusTesting); + it('status edition', sharedDetail.bind(this, 'Ready', 'In progress')); describe('assigned to edition', sharedDetail.assignedToTesting); diff --git a/gulpfile.js b/gulpfile.js index 8e8056d6..8c50705a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -140,9 +140,8 @@ paths.coffee_order = [ paths.libs = [ paths.vendor + "bluebird/js/browser/bluebird.js", paths.vendor + "jquery/dist/jquery.js", - paths.vendor + "lodash/dist/lodash.js", + paths.vendor + "lodash/lodash.js", paths.vendor + "emoticons/lib/emoticons.js", - paths.vendor + "underscore.string/lib/underscore.string.js", paths.vendor + "messageformat/messageformat.js", paths.vendor + "angular/angular.js", paths.vendor + "angular-route/angular-route.js", diff --git a/run-e2e.js b/run-e2e.js index 33af48d8..e7f005f7 100644 --- a/run-e2e.js +++ b/run-e2e.js @@ -3,6 +3,8 @@ var child_process = require('child_process'); var inquirer = require("inquirer"); var Promise = require('bluebird'); +// npm run e2e -- -s userStories, auth + var suites = [ 'auth', 'public',