From aae10943ebca76d273d2558513fc72e381fe1489 Mon Sep 17 00:00:00 2001 From: Myztiq Date: Tue, 4 Oct 2016 17:06:16 -0700 Subject: [PATCH] We now open the grant access to github in a new window. --- .../chooseOrganizationModalController.js | 7 +++++++ .../grantAccessModalView.jade | 4 ---- client/services/customWindowService.js | 17 +++++++++++++++++ client/services/launchDebugContainerService.js | 15 +++++---------- 4 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 client/services/customWindowService.js diff --git a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js index 1c3816a58..edfee96a9 100644 --- a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js +++ b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js @@ -8,7 +8,9 @@ function ChooseOrganizationModalController( $scope, $state, ahaGuide, + configEnvironment, createNewSandboxForUserService, + customWindowService, errs, eventTracking, featureFlags, @@ -46,6 +48,11 @@ function ChooseOrganizationModalController( }; COMC.grantAccess = function () { + var connectionUrl = 'https://github.com/settings/connections/applications/d42d6634d4070c9d9bf9'; + if (configEnvironment === 'development') { + connectionUrl = 'https://github.com/settings/applications'; + } + customWindowService(connectionUrl); loading.reset('grantAccess'); loading('grantAccess', true); COMC.cancelPollingForWhitelisted(); diff --git a/client/directives/modals/modalChooseOrganization/grantAccessModalView.jade b/client/directives/modals/modalChooseOrganization/grantAccessModalView.jade index c0ff404db..3d0241039 100644 --- a/client/directives/modals/modalChooseOrganization/grantAccessModalView.jade +++ b/client/directives/modals/modalChooseOrganization/grantAccessModalView.jade @@ -23,10 +23,8 @@ //- hide after clicked a.grid-block.align-center.justify-center.shrink.btn.btn-md.green.margin-top-md( data-event-name = "Clicked Grant Access" - href = "https://github.com/settings/connections/applications/d42d6634d4070c9d9bf9" ng-click = "COMC.grantAccess()" ng-if = "!$root.isLoading.grantAccess" - target = "_blank" ) svg.iconnables.margin-right-xxs( ng-if = "!$root.isLoading.grantAccess" @@ -45,9 +43,7 @@ ng-if = "$root.isLoading.grantAccess" ) We’ll update this page once you grant access to an org a.link( - href = "https://github.com/settings/connections/applications/d42d6634d4070c9d9bf9" ng-click = "COMC.grantAccess()" - target = "_blank" ) on GitHub | . button.grid-block.align-center.shrink.btn.btn-md.btn-cancel.gray.margin-top-sm( diff --git a/client/services/customWindowService.js b/client/services/customWindowService.js new file mode 100644 index 000000000..84524e716 --- /dev/null +++ b/client/services/customWindowService.js @@ -0,0 +1,17 @@ +'use strict'; + +require('app') + .factory('customWindowService', customWindowService); + +function customWindowService() { + return function (targetUrl) { + var topBar = window.outerHeight - window.innerHeight; + var padding = 60; + var width = window.innerWidth - padding - padding; + var height = window.innerHeight - padding - padding - 50; + var top = window.screenTop + padding + topBar; + var left = window.screenLeft + padding; + return window.open(targetUrl, 'page', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',titlebar=yes'); + }; +} + diff --git a/client/services/launchDebugContainerService.js b/client/services/launchDebugContainerService.js index f9dbe656e..9eab03a47 100644 --- a/client/services/launchDebugContainerService.js +++ b/client/services/launchDebugContainerService.js @@ -3,22 +3,17 @@ require('app') .factory('launchDebugContainer', launchDebugContainer); -function launchDebugContainer ( +function launchDebugContainer( errs, - createDebugContainer + createDebugContainer, + customWindowService ) { return function (instance, contextVersionId, imageId, rawCommand) { - var topBar = window.outerHeight - window.innerHeight; - var padding = 60; - var width = window.innerWidth - padding - padding; - var height = window.innerHeight - padding - padding - 50; - var top = window.screenTop + padding + topBar; - var left = window.screenLeft + padding; - var newWindow = window.open('/loading', 'page', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left='+left+',top='+top+',titlebar=yes'); + var newWindow = customWindowService('/loading'); return createDebugContainer(instance, contextVersionId, imageId, rawCommand) .then(function (debugContainer) { if (newWindow) { - newWindow.location = '/debug/'+debugContainer.id(); + newWindow.location = '/debug/' + debugContainer.id(); } }) .catch(function (err) {