Redirect to blocked page in epics and project-home pages if the project is blocked

stable
David Barragán Merino 2016-09-20 12:05:10 +02:00
parent c7c929363c
commit ab21b3f92e
1 changed files with 18 additions and 13 deletions

View File

@ -537,8 +537,8 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
responseError: httpResponseError responseError: httpResponseError
} }
$provide.factory("authHttpIntercept", ["$q", "$location", "$tgNavUrls", "lightboxService", "tgErrorHandlingService", $provide.factory("authHttpIntercept", ["$q", "$location", "$tgNavUrls", "lightboxService",
authHttpIntercept]) "tgErrorHandlingService", authHttpIntercept])
$httpProvider.interceptors.push("authHttpIntercept") $httpProvider.interceptors.push("authHttpIntercept")
@ -592,14 +592,13 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
$httpProvider.interceptors.push("versionCheckHttpIntercept") $httpProvider.interceptors.push("versionCheckHttpIntercept")
blockingIntercept = ($q, $routeParams, $location, $navUrls, errorHandlingService) -> blockingIntercept = ($q, errorHandlingService) ->
# API calls can return blocked elements and in that situation the user will be redirected # API calls can return blocked elements and in that situation the user will be redirected
# to the blocked project page # to the blocked project page
# This can happens in two scenarios # This can happens in two scenarios
# - An ok response containing a blocked_code in the data # - An ok response containing a blocked_code in the data
# - An error reponse when updating/creating/deleting including a 451 error code # - An error reponse when updating/creating/deleting including a 451 error code
redirectToBlockedPage = -> redirectToBlockedPage = ->
pslug = $routeParams.pslug
errorHandlingService.block() errorHandlingService.block()
responseOk = (response) -> responseOk = (response) ->
@ -619,7 +618,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
responseError: responseError responseError: responseError
} }
$provide.factory("blockingIntercept", ["$q", "$routeParams", "$location", "$tgNavUrls", "tgErrorHandlingService", blockingIntercept]) $provide.factory("blockingIntercept", ["$q", "tgErrorHandlingService", blockingIntercept])
$httpProvider.interceptors.push("blockingIntercept") $httpProvider.interceptors.push("blockingIntercept")
@ -690,7 +689,8 @@ i18nInit = (lang, $translate) ->
checksley.updateMessages('default', messages) checksley.updateMessages('default', messages)
init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService, loaderService, navigationBarService, errorHandlingService) -> init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService,
loaderService, navigationBarService, errorHandlingService) ->
$log.debug("Initialize application") $log.debug("Initialize application")
$rootscope.$on '$translatePartialLoaderStructureChanged', () -> $rootscope.$on '$translatePartialLoaderStructureChanged', () ->
@ -733,6 +733,10 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
# Analytics # Analytics
$analytics.initialize() $analytics.initialize()
# Initialize error handling service when location change start
$rootscope.$on '$locationChangeStart', (event) ->
errorHandlingService.init()
# On the first page load the loader is painted in `$routeChangeSuccess` # On the first page load the loader is painted in `$routeChangeSuccess`
# because we need to hide the tg-navigation-bar. # because we need to hide the tg-navigation-bar.
# In the other cases the loader is in `$routeChangeSuccess` # In the other cases the loader is in `$routeChangeSuccess`
@ -744,8 +748,6 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
un() un()
$rootscope.$on '$routeChangeSuccess', (event, next) -> $rootscope.$on '$routeChangeSuccess', (event, next) ->
errorHandlingService.init()
if next.loader if next.loader
loaderService.start(true) loaderService.start(true)
@ -768,10 +770,13 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
else else
navigationBarService.enableHeader() navigationBarService.enableHeader()
pluginsWithModule = _.filter(@.taigaContribPlugins, (plugin) -> plugin.module) # Config for infinite scroll
angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 500) angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 500)
# Load modules
pluginsWithModule = _.filter(@.taigaContribPlugins, (plugin) -> plugin.module)
pluginsModules = _.map(pluginsWithModule, (plugin) -> plugin.module)
modules = [ modules = [
# Main Global Modules # Main Global Modules
"taigaBase", "taigaBase",
@ -825,7 +830,7 @@ modules = [
"pascalprecht.translate", "pascalprecht.translate",
"infinite-scroll", "infinite-scroll",
"tgRepeat" "tgRepeat"
].concat(_.map(pluginsWithModule, (plugin) -> plugin.module)) ].concat(pluginsModules)
# Main module definition # Main module definition
module = angular.module("taiga", modules) module = angular.module("taiga", modules)