From adc69ad3909a1ac90b17c23a181ea661471b699b Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 26 Oct 2016 12:00:35 -0700 Subject: [PATCH 01/13] Modified flow to consider personal account user same as organization --- .../accountsSelect/directiveAccountsSelect.js | 8 +--- .../chooseOrganizationModalController.js | 6 ++- .../orgSelectModalView.jade | 17 ++++++++ .../inviteModalController.js | 27 +++++++++--- .../teamManagementForm/inviteModalView.jade | 41 ++++++++++++------- .../teamManagementFormController.js | 8 +++- .../teamManagementFormView.jade | 5 +-- .../settingsModal/settingsModalController.js | 4 +- 8 files changed, 81 insertions(+), 35 deletions(-) diff --git a/client/directives/accountsSelect/directiveAccountsSelect.js b/client/directives/accountsSelect/directiveAccountsSelect.js index 5f0101f74..ac4b1a8b8 100644 --- a/client/directives/accountsSelect/directiveAccountsSelect.js +++ b/client/directives/accountsSelect/directiveAccountsSelect.js @@ -91,13 +91,7 @@ function accountsSelect ( keypather.set($scope, 'popoverAccountMenu.data.currentOrg', currentOrg); keypather.set($scope, 'popoverAccountMenu.data.orgs', $scope.data.orgs); keypather.set($scope, 'popoverAccountMenu.data.user', $scope.data.user); - - // Integrations modal - if ($scope.data.user.oauthName() === $state.params.userName) { - $scope.popoverAccountMenu.data.showIntegrations = false; - } else { - $scope.popoverAccountMenu.data.showIntegrations = true; - } + keypather.set($scope, 'popoverAccountMenu.data.showIntegrations', true); }); $scope.getBadgeCount = function () { diff --git a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js index fe35b6dab..9c040bc2e 100644 --- a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js +++ b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js @@ -137,9 +137,11 @@ function ChooseOrganizationModalController( trackFigureAction: eventTracking.trackFigureAction, trackCreateOrgLink: eventTracking.trackCreateOrgLink, trackPersonalAccount: eventTracking.trackPersonalAccount, - createOrCheckDock: function (selectedOrgName) { + createOrCheckDock: function (selectedOrgName, isPersonalAccount) { var selectedOrg = COMC.getSelectedOrg(selectedOrgName); - if (!selectedOrg) { + if (isPersonalAccount) { + selectedOrg = COMC.user; + } else if (!selectedOrg) { return; } loading('chooseOrg', true); diff --git a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade index 162d2aab4..f2a14b465 100644 --- a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade +++ b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade @@ -24,6 +24,23 @@ xlink:href = "#icons-arrow-down" ) + ol.grid-block.vertical.list + li.grid-block.align-center.list-item.btn.white( + data-event-name = "PA Selected" + ng-click = "COMC.actions.createOrCheckDock(COMC.user.oauthName(), true)" + title = "{{COMC.user.oauthName()}}" + ) + img.grid-content.shrink( + height = "30" + ng-src = "{{COMC.user.gravitar()}}" + width = "30" + ) + span.grid-content.text-left.text-overflow {{COMC.user.oauthName()}} + svg.grid-content.iconnables.icons-arrow-forward.shrink + use( + xlink:href = "#icons-arrow-down" + ) + ol.margin-top-sm.grid-block.vertical.list li.grid-block.align-center.list-item.btn.white( data-event-name = "Clicked to Grant Access View" diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js index fbffd367f..4351767c3 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js @@ -7,6 +7,7 @@ require('app') * @ngInject */ function InviteModalController( + $location, $rootScope, $q, $state, @@ -16,17 +17,24 @@ function InviteModalController( inviteGithubUserToRunnable, loading, + closeSettingsModal, + isPersonalAccount, teamName, - unInvitedMembers, + orgMembers, close ) { var IMC = this; angular.extend(IMC, { - name: 'inviteModal', activeUserId: null, + invitedAll: null, + invitesSent: false, + isPersonalAccount: isPersonalAccount, + orgMembers: orgMembers, + name: 'inviteModal', sendingInviteUserId: null, sending: false, - invitesSent: false + showAlternateInviteModal: null, + teamName: teamName }); // Load uninvited members if they are not passed in @@ -34,13 +42,13 @@ function InviteModalController( $q.when(true) .then(function () { // Empty array is valid input - if (!unInvitedMembers && !Array.isArray(unInvitedMembers)) { + if (!orgMembers.uninvited && !Array.isArray(orgMembers.uninvited)) { return fetchOrgMembers($state.params.userName, true) .then(function (members) { return members.uninvited; }); } - return unInvitedMembers; + return orgMembers.uninvited; }) .then(function (unInvitedMembers) { unInvitedMembers.forEach(function (member) { @@ -52,11 +60,12 @@ function InviteModalController( } }); IMC.unInvitedMembers = unInvitedMembers; + IMC.invitedAll = IMC.orgMembers.all.length === IMC.orgMembers.registered.length + IMC.orgMembers.invited.length; + IMC.showAlternateInviteModal = IMC.isPersonalAccount || IMC.invitedAll || !IMC.unInvitedMembers.length; loading(IMC.name, false); }) .catch(errs.handler); - IMC.sendInvitation = function (user) { IMC.sendingInviteUserId = user.id; IMC.setActiveUserId(null); @@ -85,4 +94,10 @@ function InviteModalController( $rootScope.$emit('updateTeammateInvitations', IMC.invitesSent); close(IMC.invitesSent); }; + + IMC.goToOrgSelect = function () { + $state.go('orgSelect') + close(); + closeSettingsModal(); + } } diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade index 3f44e7a55..cb83a03e6 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade @@ -1,6 +1,6 @@ .modal-backdrop.in .modal-dialog.modal-xs.modal-invite( - ng-if = "$root.featureFlags.isPersonalAccount" + ng-if = "$root.featureFlags.personalAccounts && IMC.showAlternateInviteModal" ) .grid-block.vertical.align-center.justify-center.modal-body svg.iconnables.icons-close( @@ -14,24 +14,37 @@ src = "/build/images/runnabear-add.svg" width = "150" ) - p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md + p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( + ng-if = "IMC.isPersonalAccount" + ) | We only support having teammates with GitHub teams, but it looks like you’re using a personal account. - //- | You’re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable. - //- | You’re amazing! You’ve already invited everyone on your GitHub team to Runnable. + + p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( + ng-if = "!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1" + ) + | You’re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable. + + p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( + ng-if = "!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1" + ) + | You’re amazing! You’ve already invited everyone on your GitHub team to Runnable. + footer.modal-footer button.btn.btn-block.btn-md.white( - ui-sref = "orgSelect" - ui-sref-opts = "{reload: true}" + ng-click = "IMC.goToOrgSelect()" + ng-if = "IMC.isPersonalAccount" ) Switch to a Team - //- a.btn.btn-block.btn-md.white( - //- ng-href = "https://github.com/orgs/{{THISORGNAME}}/people" - //- target = "_blank" - //- ) See Team on GitHub - //- button.btn.btn-block.btn-md.white( - //- ng-click = "IMC.close()" - //- ) Close + a.btn.btn-block.btn-md.white( + ng-href = "https://github.com/orgs/{{IMC.teamName}}/people" + ng-if = "!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1" + target = "_blank" + ) See Team on GitHub + button.btn.btn-block.btn-md.white( + ng-if = "!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1" + ng-click = "IMC.close()" + ) Close .modal-dialog.modal-xs.modal-sheet.modal-invite( - ng-if = "!$root.featureFlags.isPersonalAccount" + ng-if = "!IMC.showAlternateInviteModal" ) header.modal-header Invite Teammate svg.iconnables.icons-close( diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js index 468b2389b..37e0cd994 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js @@ -11,6 +11,7 @@ function TeamManagementFormController( $rootScope, $scope, $state, + currentOrg, errs, fetchOrgMembers, inviteGithubUserToRunnable, @@ -61,14 +62,17 @@ function TeamManagementFormController( }); } - TMMC.openInvitationModal = function () { + TMMC.openInvitationModal = function (closeSettingsModal) { + var isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount') ModalService.showModal({ controller: 'InviteModalController', controllerAs: 'IMC', templateUrl: 'inviteModalView', inputs: { teamName: $state.params.userName, - unInvitedMembers: TMMC.members.uninvited + orgMembers: TMMC.members, + isPersonalAccount: isPersonalAccount, + closeSettingsModal: closeSettingsModal } }) .then(function (modal) { diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade index 26053f7fd..894dc316a 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade @@ -16,8 +16,7 @@ ) .label-col.full-width Teammates a.small.link.float-right( - ng-click = "TMMC.openInvitationModal()" - ng-if = "TMMC.members.uninvited.length > 0 || $root.featureFlags.isPersonalAccount" + ng-click = "TMMC.openInvitationModal(SEMC.close)" ) svg.iconnables.icons-team-invite use( @@ -74,7 +73,7 @@ xlink:href = "#icons-overflow" ) p.small.text-center.padding-xxs( - ng-if = "!$root.featureFlags.isPersonalAccount" + ng-if = "!SEMC.isPersonalAccount" ) a.link( href = "mailto:support@runnable.com" diff --git a/client/directives/modals/settingsModal/settingsModalController.js b/client/directives/modals/settingsModal/settingsModalController.js index 1e72b02e0..666cf89f5 100644 --- a/client/directives/modals/settingsModal/settingsModalController.js +++ b/client/directives/modals/settingsModal/settingsModalController.js @@ -8,16 +8,18 @@ require('app') */ function SettingsModalController( close, + keypather, subTab, tab, currentOrg ) { var SEMC = this; angular.extend(SEMC, { - close: close, + close: close.bind(SEMC), currentTab: tab, subTab: subTab }); SEMC.currentOrg = currentOrg; SEMC.showFooter = true; + SEMC.isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); } From 0f0530e5b70a501edcd2aecd6c002287bf9b9b8f Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 26 Oct 2016 13:08:33 -0700 Subject: [PATCH 02/13] Fixed linting and tests --- .../teamManagementForm/inviteModalController.js | 10 ++++++---- .../teamManagementFormController.js | 2 +- .../settingsModal/inviteModalController.unit.js | 16 +++++++++++++++- .../settingsModalController.unit.js | 1 - 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js index 4351767c3..eb8c72828 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js @@ -96,8 +96,10 @@ function InviteModalController( }; IMC.goToOrgSelect = function () { - $state.go('orgSelect') - close(); - closeSettingsModal(); - } + $state.go('orgSelect'); + setTimeout(function() { + close(); + closeSettingsModal(); + }, 200); + }; } diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js index 37e0cd994..b73fac479 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js @@ -63,7 +63,7 @@ function TeamManagementFormController( } TMMC.openInvitationModal = function (closeSettingsModal) { - var isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount') + var isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); ModalService.showModal({ controller: 'InviteModalController', controllerAs: 'IMC', diff --git a/test/unit/directives/modals/settingsModal/inviteModalController.unit.js b/test/unit/directives/modals/settingsModal/inviteModalController.unit.js index 5560073c6..ad35250e9 100644 --- a/test/unit/directives/modals/settingsModal/inviteModalController.unit.js +++ b/test/unit/directives/modals/settingsModal/inviteModalController.unit.js @@ -15,17 +15,25 @@ var $q; describe('InviteModalController'.bold.underline.blue, function () { var IMC; + var closeSettingsModalStub; var inviteGithubUserToRunnableStub; + var isPersonalAccountMock; var fetchUserStub; var fetchGithubOrgIdStub; var fetchOrgMembersStub; - var user; var errs; + var user; var username = 'purpleBear'; var userId = 777; var userEmail = 'purplebear@codenow.com'; var orgId = 787; var unInvitedMembers; + var orgMembersMock = { + uninvited: undefined, + all: [], + invited: [], + registered: [] + }; var closeStub = sinon.stub(); function setup (initWithoutUninvitedMembers) { @@ -50,7 +58,13 @@ describe('InviteModalController'.bold.underline.blue, function () { fetchOrgMembersStub = sinon.stub().returns($q.when({ uninvited: unInvitedMembers })); return fetchOrgMembersStub; }); + $provide.factory('closeSettingsModal', function () { + closeSettingsModalStub = sinon.stub().returns(true); + return closeSettingsModalStub; + }) $provide.value('teamName', 'hello'); + $provide.value('isPersonalAccount', isPersonalAccountMock); + $provide.value('orgMembers', orgMembersMock); $provide.value('unInvitedMembers', (function () { if (initWithoutUninvitedMembers) { return null; diff --git a/test/unit/directives/modals/settingsModal/settingsModalController.unit.js b/test/unit/directives/modals/settingsModal/settingsModalController.unit.js index 4d82067ae..7e238df3f 100644 --- a/test/unit/directives/modals/settingsModal/settingsModalController.unit.js +++ b/test/unit/directives/modals/settingsModal/settingsModalController.unit.js @@ -38,7 +38,6 @@ describe('SettingsModalController'.bold.underline.blue, function () { }); it('should instantiate the controller correctly', function () { - expect(SEMC.close).to.equal(closeStub); expect(SEMC.currentTab).to.equal(tabName); expect(SEMC.subTab).to.equal(subTabName); }); From b9887efd3ae603ed4069db039100e3ed8f48d27f Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 26 Oct 2016 14:35:42 -0700 Subject: [PATCH 03/13] Merged master, fixed lints, changed forking --- .../modals/ahaModal/ahaModalController.js | 4 +++- client/services/githubService.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/directives/modals/ahaModal/ahaModalController.js b/client/directives/modals/ahaModal/ahaModalController.js index 604547ab0..8d4c0d60d 100644 --- a/client/directives/modals/ahaModal/ahaModalController.js +++ b/client/directives/modals/ahaModal/ahaModalController.js @@ -15,6 +15,7 @@ function AhaModalController( fetchOwnerRepos, fetchStackInfo, github, + keypather, loading, ModalService, @@ -105,7 +106,8 @@ function AhaModalController( loading('startDemo', true); var loadingName = 'startDemo' + stackName.charAt(0).toUpperCase() + stackName.slice(1); loading(loadingName, true); - github.forkRepo('RunnableDemo', repoMapping[stackName], currentOrg.github.oauthName()) + var isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); + github.forkRepo('RunnableDemo', repoMapping[stackName], currentOrg.github.oauthName(), isPersonalAccount) .then(function () { return findRepo(repoMapping[stackName]); }) diff --git a/client/services/githubService.js b/client/services/githubService.js index cbacd26f0..f0d81a463 100644 --- a/client/services/githubService.js +++ b/client/services/githubService.js @@ -32,14 +32,17 @@ function github( }); } return { - forkRepo: function (repoOwner, repoName, targetOrg) { - return makeGhRequest({ + forkRepo: function (repoOwner, repoName, targetOrg, isPersonalAccount) { + var ghRequest = { method: 'post', url: githubAPIUrl + '/repos/' + repoOwner + '/' + repoName + '/forks', - data: { + }; + if (!isPersonalAccount) { + ghRequest.data = { organization: targetOrg - } - }); + }; + } + return makeGhRequest(ghRequest); } }; } From a5b87d3acce5b1a6936773e5c763da90475c3162 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 26 Oct 2016 15:08:33 -0700 Subject: [PATCH 04/13] Design changes --- .../teamManagementForm/teamManagementFormController.js | 10 +++++++++- .../modals/settingsModal/settingsModalView.jade | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js index b73fac479..e7f0aa0a5 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js @@ -26,6 +26,7 @@ function TeamManagementFormController( // Load initial state fetchMembers(); + var isPersonalAccount; var newInviteAddedWatchterUnbind = $rootScope.$on('newInvitedAdded', function (event, user) { TMMC.members.invited.push(user); @@ -37,6 +38,7 @@ function TeamManagementFormController( $scope.$on('$destroy', newInviteAddedWatchterUnbind); function fetchMembers () { + var currentUser; return fetchOrgMembers($state.params.userName, true) .then(function (members) { TMMC.loading = false; @@ -56,14 +58,20 @@ function TeamManagementFormController( } }; }; + isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); + if (isPersonalAccount) { + currentUser = keypather.get(currentOrg, 'github.attrs'); + TMMC.members.registered.push(currentUser); + return; + } TMMC.members.invited.forEach(setEmail('userInvitation.attrs.recipient.email')); TMMC.members.registered.forEach(setEmail('userModel.attrs.accounts.github.emails[0].value')); TMMC.members.uninvited.forEach(setEmail(null)); }); + } TMMC.openInvitationModal = function (closeSettingsModal) { - var isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); ModalService.showModal({ controller: 'InviteModalController', controllerAs: 'IMC', diff --git a/client/directives/modals/settingsModal/settingsModalView.jade b/client/directives/modals/settingsModal/settingsModalView.jade index 85b414f77..af0c4476d 100644 --- a/client/directives/modals/settingsModal/settingsModalView.jade +++ b/client/directives/modals/settingsModal/settingsModalView.jade @@ -3,7 +3,12 @@ header.grid-block.vertical.align-center.modal-header .container-title-wrapper .server-status-card-pop-over.no-touching - .container-title {{SEMC.currentOrg.github.attrs.login}} Settings + .container-title( + ng-if = "!SEMC.isPersonalAccount" + ) {{SEMC.currentOrg.github.attrs.login}} Settings + .container-title( + ng-if = "SEMC.isPersonalAccount" + ) Settings svg.iconnables.icons-close( ng-click = "SEMC.close()" ) From cd2e064fb32b2792b5ed5036174df3f381d578b9 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 26 Oct 2016 16:39:22 -0700 Subject: [PATCH 05/13] Addressed PR comments --- .../alternateInviteModalView.jade | 29 +++++++++++++ .../inviteModalController.js | 13 +++++- .../teamManagementForm/inviteModalView.jade | 43 +------------------ .../settingsModal/settingsModalController.js | 2 +- .../settingsModalController.unit.js | 1 + 5 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade new file mode 100644 index 000000000..ecb5cf371 --- /dev/null +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade @@ -0,0 +1,29 @@ +.grid-block.vertical.align-center.justify-center.modal-body + svg.iconnables.icons-close( + ng-click = "IMC.close()" + ) + use( + xlink:href = "#icons-close" + ) + img.grid-block.shrink.margin-top-md( + height = "150" + src = "/build/images/runnabear-add.svg" + width = "150" + ) + p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( + | {{IMC.getTextForInviteModal()}} + +footer.modal-footer + button.btn.btn-block.btn-md.white( + ng-click = "IMC.goToOrgSelect()" + ng-if = "IMC.isPersonalAccount" + ) Switch to a Team + a.btn.btn-block.btn-md.white( + ng-href = "https://github.com/orgs/{{IMC.teamName}}/people" + ng-if = "!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1" + target = "_blank" + ) See Team on GitHub + button.btn.btn-block.btn-md.white( + ng-if = "!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1" + ng-click = "IMC.close()" + ) Close diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js index eb8c72828..32f41d3cb 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js @@ -7,7 +7,6 @@ require('app') * @ngInject */ function InviteModalController( - $location, $rootScope, $q, $state, @@ -102,4 +101,16 @@ function InviteModalController( closeSettingsModal(); }, 200); }; + + IMC.getTextForInviteModal = function () { + if (IMC.isPersonalAccount) { + return 'We only support having teammates with GitHub teams, but it looks like you\'re using a personal account.'; + } + if (!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1) { + return 'You\'re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable.'; + } + if (!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1) { + return 'You\'re amazing! You\'ve already invited everyone on your GitHub team to Runnable.'; + } + }; } diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade index cb83a03e6..90aae9a3c 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalView.jade @@ -1,48 +1,9 @@ .modal-backdrop.in .modal-dialog.modal-xs.modal-invite( ng-if = "$root.featureFlags.personalAccounts && IMC.showAlternateInviteModal" + ng-include = "'alternateInviteModalView'" ) - .grid-block.vertical.align-center.justify-center.modal-body - svg.iconnables.icons-close( - ng-click = "IMC.close()" - ) - use( - xlink:href = "#icons-close" - ) - img.grid-block.shrink.margin-top-md( - height = "150" - src = "/build/images/runnabear-add.svg" - width = "150" - ) - p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( - ng-if = "IMC.isPersonalAccount" - ) - | We only support having teammates with GitHub teams, but it looks like you’re using a personal account. - - p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( - ng-if = "!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1" - ) - | You’re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable. - - p.grid-block.shrink.p.weight-light.text-center.margin-bottom-md.margin-top-md( - ng-if = "!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1" - ) - | You’re amazing! You’ve already invited everyone on your GitHub team to Runnable. - - footer.modal-footer - button.btn.btn-block.btn-md.white( - ng-click = "IMC.goToOrgSelect()" - ng-if = "IMC.isPersonalAccount" - ) Switch to a Team - a.btn.btn-block.btn-md.white( - ng-href = "https://github.com/orgs/{{IMC.teamName}}/people" - ng-if = "!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1" - target = "_blank" - ) See Team on GitHub - button.btn.btn-block.btn-md.white( - ng-if = "!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1" - ng-click = "IMC.close()" - ) Close + .modal-dialog.modal-xs.modal-sheet.modal-invite( ng-if = "!IMC.showAlternateInviteModal" ) diff --git a/client/directives/modals/settingsModal/settingsModalController.js b/client/directives/modals/settingsModal/settingsModalController.js index 666cf89f5..786fa835c 100644 --- a/client/directives/modals/settingsModal/settingsModalController.js +++ b/client/directives/modals/settingsModal/settingsModalController.js @@ -15,7 +15,7 @@ function SettingsModalController( ) { var SEMC = this; angular.extend(SEMC, { - close: close.bind(SEMC), + close: close, currentTab: tab, subTab: subTab }); diff --git a/test/unit/directives/modals/settingsModal/settingsModalController.unit.js b/test/unit/directives/modals/settingsModal/settingsModalController.unit.js index 7e238df3f..4d82067ae 100644 --- a/test/unit/directives/modals/settingsModal/settingsModalController.unit.js +++ b/test/unit/directives/modals/settingsModal/settingsModalController.unit.js @@ -38,6 +38,7 @@ describe('SettingsModalController'.bold.underline.blue, function () { }); it('should instantiate the controller correctly', function () { + expect(SEMC.close).to.equal(closeStub); expect(SEMC.currentTab).to.equal(tabName); expect(SEMC.subTab).to.equal(subTabName); }); From ea779cb806afbe5c7fd392f6ab2607808413ff31 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 27 Oct 2016 12:04:50 -0700 Subject: [PATCH 06/13] Added unit tests --- .../inviteModalController.unit.js | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/unit/directives/modals/settingsModal/inviteModalController.unit.js b/test/unit/directives/modals/settingsModal/inviteModalController.unit.js index ad35250e9..ada549cdb 100644 --- a/test/unit/directives/modals/settingsModal/inviteModalController.unit.js +++ b/test/unit/directives/modals/settingsModal/inviteModalController.unit.js @@ -188,4 +188,65 @@ describe('InviteModalController'.bold.underline.blue, function () { }); }); + describe('showing the correct invite modal', function () { + beforeEach(function () { + isPersonalAccountMock = false; + orgMembersMock = { + all: [1, 2, 3], + registered: [1, 2], + uninvited: [1], + invited: [] + }; + }); + + it('should not show the alternate invite modal for orgs w/ uninvited members', function () { + setup(); + $scope.$digest(); + expect(IMC.showAlternateInviteModal).to.equal(false); + }); + + it('should show the alternate invite modal for personal accounts', function () { + isPersonalAccountMock = true; + setup(); + $scope.$digest(); + expect(IMC.showAlternateInviteModal).to.equal(true); + }); + + it('should show the alternate invite modal for full orgs', function () { + orgMembersMock.invited = ['new guy']; + setup(); + $scope.$digest(); + expect(IMC.showAlternateInviteModal).to.equal(true); + }); + + it('should show the alternate invite modal for one person orgs', function () { + orgMembersMock.all = ['one guy']; + orgMembersMock.registered = ['one guy']; + orgMembersMock.invited = []; + orgMembersMock.uninvited = []; + setup(); + $scope.$digest(); + expect(IMC.showAlternateInviteModal).to.equal(true); + }); + }); + + describe('invite modal user message', function () { + beforeEach(function () { + setup(); + }); + + it('should select the correct caption for a given scenario', function () { + IMC.isPersonalAccount = true; + var message = IMC.getTextForInviteModal(); + expect(message).to.equal('We only support having teammates with GitHub teams, but it looks like you\'re using a personal account.'); + IMC.isPersonalAccount = false; + IMC.orgMembers.all = [1]; + var message = IMC.getTextForInviteModal(); + expect(message).to.equal('You\'re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable.'); + IMC.orgMembers.all = [1, 2]; + IMC.invitedAll = true; + var message = IMC.getTextForInviteModal(); + expect(message).to.equal('You\'re amazing! You\'ve already invited everyone on your GitHub team to Runnable.'); + }); + }); }); From ae86904de29e3892ea9bbc08160c3f224688629d Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 27 Oct 2016 12:14:21 -0700 Subject: [PATCH 07/13] Cleaning up for uncle bob --- .../chooseOrganizationModalController.js | 13 ++++++++----- .../modalChooseOrganization/orgSelectModalView.jade | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js index 9c040bc2e..f17d6f0aa 100644 --- a/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js +++ b/client/directives/modals/modalChooseOrganization/chooseOrganizationModalController.js @@ -11,6 +11,7 @@ function ChooseOrganizationModalController( ahaGuide, configEnvironment, createNewSandboxForUserService, + currentOrg, customWindowService, errs, eventTracking, @@ -137,11 +138,9 @@ function ChooseOrganizationModalController( trackFigureAction: eventTracking.trackFigureAction, trackCreateOrgLink: eventTracking.trackCreateOrgLink, trackPersonalAccount: eventTracking.trackPersonalAccount, - createOrCheckDock: function (selectedOrgName, isPersonalAccount) { + createOrCheckDock: function (selectedOrgName) { var selectedOrg = COMC.getSelectedOrg(selectedOrgName); - if (isPersonalAccount) { - selectedOrg = COMC.user; - } else if (!selectedOrg) { + if (!selectedOrg) { return; } loading('chooseOrg', true); @@ -185,9 +184,13 @@ function ChooseOrganizationModalController( }); }; COMC.getSelectedOrg = function (selectedOrgName) { - return COMC.allAccounts.models.find(function (org) { + var selectedOrg = COMC.allAccounts.models.find(function (org) { return selectedOrgName.toLowerCase() === org.oauthName().toLowerCase(); }); + if (!selectedOrg) { + selectedOrg = COMC.user; + } + return selectedOrg; }; COMC.isChoosingOrg = ahaGuide.isChoosingOrg; diff --git a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade index f2a14b465..b27b74035 100644 --- a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade +++ b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade @@ -27,7 +27,7 @@ ol.grid-block.vertical.list li.grid-block.align-center.list-item.btn.white( data-event-name = "PA Selected" - ng-click = "COMC.actions.createOrCheckDock(COMC.user.oauthName(), true)" + ng-click = "COMC.actions.createOrCheckDock(COMC.user.oauthName())" title = "{{COMC.user.oauthName()}}" ) img.grid-content.shrink( From 109fcdcbd72694b7228e0773a1010e10ac9541b2 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 27 Oct 2016 15:40:31 -0700 Subject: [PATCH 08/13] Super nifty --- client/config/routes.js | 7 +++++++ .../teamManagementForm/alternateInviteModalView.jade | 2 +- .../forms/teamManagementForm/inviteModalController.js | 9 --------- .../teamManagementForm/teamManagementFormController.js | 5 ++--- .../forms/teamManagementForm/teamManagementFormView.jade | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/client/config/routes.js b/client/config/routes.js index 2d5516b2f..d5316ddc0 100755 --- a/client/config/routes.js +++ b/client/config/routes.js @@ -60,6 +60,13 @@ module.exports = [ ) { keypather.get(ModalService, 'modalLayers[0].modal.controller.close()'); }, + onEnter: function ( + ModalService + ) { + ModalService.modalLayers.forEach(function (openModal) { + openModal.close(); + }); + }, resolve: { grantedOrgs: function (fetchGrantedGithubOrgs) { return fetchGrantedGithubOrgs(); diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade index ecb5cf371..04a5d1890 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/alternateInviteModalView.jade @@ -15,7 +15,7 @@ footer.modal-footer button.btn.btn-block.btn-md.white( - ng-click = "IMC.goToOrgSelect()" + ui-sref = "orgSelect" ng-if = "IMC.isPersonalAccount" ) Switch to a Team a.btn.btn-block.btn-md.white( diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js index 32f41d3cb..8c4c3ca52 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js @@ -16,7 +16,6 @@ function InviteModalController( inviteGithubUserToRunnable, loading, - closeSettingsModal, isPersonalAccount, teamName, orgMembers, @@ -94,14 +93,6 @@ function InviteModalController( close(IMC.invitesSent); }; - IMC.goToOrgSelect = function () { - $state.go('orgSelect'); - setTimeout(function() { - close(); - closeSettingsModal(); - }, 200); - }; - IMC.getTextForInviteModal = function () { if (IMC.isPersonalAccount) { return 'We only support having teammates with GitHub teams, but it looks like you\'re using a personal account.'; diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js index e7f0aa0a5..800f168fe 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js @@ -71,7 +71,7 @@ function TeamManagementFormController( } - TMMC.openInvitationModal = function (closeSettingsModal) { + TMMC.openInvitationModal = function () { ModalService.showModal({ controller: 'InviteModalController', controllerAs: 'IMC', @@ -79,8 +79,7 @@ function TeamManagementFormController( inputs: { teamName: $state.params.userName, orgMembers: TMMC.members, - isPersonalAccount: isPersonalAccount, - closeSettingsModal: closeSettingsModal + isPersonalAccount: isPersonalAccount } }) .then(function (modal) { diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade index 894dc316a..5e4636cbd 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade @@ -16,7 +16,7 @@ ) .label-col.full-width Teammates a.small.link.float-right( - ng-click = "TMMC.openInvitationModal(SEMC.close)" + ng-click = "TMMC.openInvitationModal()" ) svg.iconnables.icons-team-invite use( From 9b629f83e2e3c21c3317ae813b3d688497fc489e Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 27 Oct 2016 15:51:54 -0700 Subject: [PATCH 09/13] Prevent org select from showing personal account when feature flag is disabled --- .../modals/modalChooseOrganization/orgSelectModalView.jade | 1 + 1 file changed, 1 insertion(+) diff --git a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade index b27b74035..d6dfded40 100644 --- a/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade +++ b/client/directives/modals/modalChooseOrganization/orgSelectModalView.jade @@ -26,6 +26,7 @@ ol.grid-block.vertical.list li.grid-block.align-center.list-item.btn.white( + ng-if = "$root.featureFlags.personalAccounts" data-event-name = "PA Selected" ng-click = "COMC.actions.createOrCheckDock(COMC.user.oauthName())" title = "{{COMC.user.oauthName()}}" From f136dbdfc740f54edd7847672e8769d12597680e Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 27 Oct 2016 17:38:05 -0700 Subject: [PATCH 10/13] Updated to master and changed runnabot modal for personal accounts --- .../githubIntegrationController.js | 1 + .../gitHubIntegration/githubIntegrationView.jade | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/directives/components/gitHubIntegration/githubIntegrationController.js b/client/directives/components/gitHubIntegration/githubIntegrationController.js index fc8114367..3c0334605 100644 --- a/client/directives/components/gitHubIntegration/githubIntegrationController.js +++ b/client/directives/components/gitHubIntegration/githubIntegrationController.js @@ -20,6 +20,7 @@ function GithubIntegrationController( var GIC = this; var org = keypather.get(currentOrg, 'github.attrs.login'); GIC.organizationName = org; + GIC.isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); function checkRunnabot() { return isRunnabotPartOfOrg(org) diff --git a/client/directives/components/gitHubIntegration/githubIntegrationView.jade b/client/directives/components/gitHubIntegration/githubIntegrationView.jade index 96bf17e93..2c6233efc 100644 --- a/client/directives/components/gitHubIntegration/githubIntegrationView.jade +++ b/client/directives/components/gitHubIntegration/githubIntegrationView.jade @@ -12,7 +12,7 @@ p.grid-content.shrink.p.text-center.weight-light.margin-top-md.margin-bottom-md( //- if is personal account AND phase 2 implemented p.grid-content.shrink.p.text-center.weight-light.margin-top-md.margin-bottom-md( - ng-if = "$root.featureFlags.isPersonalAccount && $root.featureFlags.personalAccountsPhase2" + ng-if = "GIC.isPersonalAccount && $root.featureFlags.personalAccountsPhase2" ) Now you can get environment br.hidden-xxs | notifications on your pull requests. @@ -33,7 +33,7 @@ a.grid-block.align-center.shrink.btn.btn-md.green( data-event-name = "Clicked Invite Runnabot button" ng-disabled = "!GIC.isAdmin" ng-click = "GIC.pollCheckRunnabot()" - ng-hide = "$root.isLoading.checkRunnabot || GIC.hasRunnabot || $root.featureFlags.isPersonalAccount" + ng-hide = "$root.isLoading.checkRunnabot || GIC.hasRunnabot || GIC.isPersonalAccount" ng-href = "https://github.com/orgs/{{GIC.organizationName}}/invitations/runnabot/edit" target = "_blank" ) @@ -54,7 +54,7 @@ a.grid-block.align-center.shrink.btn.btn-md.green( 'text-red': !GIC.isAdmin\ }" ng-hide = "$root.isLoading.checkRunnabot" - ng-if = "!$root.featureFlags.isPersonalAccount && !$root.featureFlags.personalAccountsPhase2 && !GIC.hasRunnabot" + ng-if = "!GIC.isPersonalAccount && !$root.featureFlags.personalAccountsPhase2 && !GIC.hasRunnabot" ) span( ng-if = "GIC.isAdmin" @@ -71,7 +71,7 @@ a.grid-block.align-center.shrink.btn.btn-md.green( //- button for personal accounts label.grid-block.shrink.align-center.label.well.gray.padding-xs( - ng-hide = "$root.isLoading.checkRunnabot || !$root.featureFlags.isPersonalAccount || !$root.featureFlags.personalAccountsPhase2" + ng-hide = "$root.isLoading.checkRunnabot || !GIC.isPersonalAccount || !$root.featureFlags.personalAccountsPhase2" ng-init = "personalRunnabot = false" ) .grid-content Enable PR Notifications @@ -84,7 +84,7 @@ label.grid-block.shrink.align-center.label.well.gray.padding-xs( //- disclaimer for personal accounts .small.text-gray.text-center.margin-top-xxs( - ng-hide = "$root.isLoading.checkRunnabot || personalRunnabot || !$root.featureFlags.isPersonalAccount || !$root.featureFlags.personalAccountsPhase2" + ng-hide = "$root.isLoading.checkRunnabot || personalRunnabot || !GIC.isPersonalAccount || !$root.featureFlags.personalAccountsPhase2" ) Our GitHub bot will join your repos as a collaborator. //- hiding until praful writes his doc //- br @@ -92,7 +92,7 @@ label.grid-block.shrink.align-center.label.well.gray.padding-xs( //- show after successfully inviting runnabot (for both orgs and personal accounts) .grid-block.align-center.shrink.runnabot-success( - ng-show = "(!$root.featureFlags.isPersonalAccount && GIC.hasRunnabot && !$root.isLoading.checkRunnabot) || $root.featureFlags.isPersonalAccount && personalRunnabot" + ng-show = "(!GIC.isPersonalAccount && GIC.hasRunnabot && !$root.isLoading.checkRunnabot) || $root.featureFlags.isPersonalAccount && personalRunnabot" ) img.grid-content.shrink.img( height = "36" @@ -109,7 +109,7 @@ label.grid-block.shrink.align-center.label.well.gray.padding-xs( p.small.text-gray.text-left Thanks! See you soon on your pull requests. button.btn.btn-md.white( - ng-if = "$root.featureFlags.isPersonalAccount && !$root.featureFlags.personalAccountsPhase2 && !$root.isLoading.checkRunnabot" + ng-if = "$root.featureFlags.personalAccounts && GIC.isPersonalAccount && !$root.isLoading.checkRunnabot" ui-sref = "orgSelect" ui-sref-opts = "{reload: true}" ) Switch to a Team From dcb9d803159e5d3826c49ec2b4fe46057da3534b Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Fri, 28 Oct 2016 11:54:30 -0700 Subject: [PATCH 11/13] Changes to phase 1 --- client/controllers/controllerInstance.js | 2 +- .../gitHubIntegration/githubIntegrationView.jade | 4 ++-- client/services/ahaGuideService.js | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/controllers/controllerInstance.js b/client/controllers/controllerInstance.js index 6e4fee42f..2becb0e41 100644 --- a/client/controllers/controllerInstance.js +++ b/client/controllers/controllerInstance.js @@ -206,7 +206,7 @@ function ControllerInstance( }); }); - if (ahaGuide.isInGuide()) { + if (ahaGuide.isInGuide() && !ahaGuide.isPersonalAccount()) { if (keypather.get(instancesByPod, 'models.length')) { if (instancesByPod.models.some(function (instance) { return instance.attrs.hasAddedBranches || keypather.get(instance, 'children.models.length'); diff --git a/client/directives/components/gitHubIntegration/githubIntegrationView.jade b/client/directives/components/gitHubIntegration/githubIntegrationView.jade index 2c6233efc..d5f3ebd61 100644 --- a/client/directives/components/gitHubIntegration/githubIntegrationView.jade +++ b/client/directives/components/gitHubIntegration/githubIntegrationView.jade @@ -7,7 +7,7 @@ img.shrink.img.img-comment( //- if NOT a personal account p.grid-content.shrink.p.text-center.weight-light.margin-top-md.margin-bottom-md( - ng-if = "!$root.featureFlags.isPersonalAccount" + ng-if = "!GIC.isPersonalAccount" ) {{!$root.featureFlags.ahaBranchUrlStep ? 'Now you can invite our bot to your GitHub org to get notifications on your pull requests:' : 'Invite our bot to your GitHub org to get notifications on your pull requests:'}} //- if is personal account AND phase 2 implemented @@ -19,7 +19,7 @@ p.grid-content.shrink.p.text-center.weight-light.margin-top-md.margin-bottom-md( //- if is personal accounts AND phase 2 is NOT implemented p.grid-content.shrink.p.text-center.weight-light.margin-top-md.margin-bottom-md( - ng-if = "$root.featureFlags.isPersonalAccount && !$root.featureFlags.personalAccountsPhase2" + ng-if = "GIC.isPersonalAccount && !$root.featureFlags.personalAccountsPhase2" ) We only support pull request notifications with GitHub teams, but it looks like you’re using a personal account. //- if checking whether the user is an admin, or checking whether runnabot has been enabled diff --git a/client/services/ahaGuideService.js b/client/services/ahaGuideService.js index e2dc605b2..d434e615c 100644 --- a/client/services/ahaGuideService.js +++ b/client/services/ahaGuideService.js @@ -31,6 +31,10 @@ function ahaGuide( } function refreshHasRunnabot() { if (hasRunnabot) { return true; } + if (keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount') && getCurrentStep() === 4) { + endGuide(); + return; + } return isRunnabotPartOfOrg(keypather.get(currentOrg, 'github.attrs.login')) .then(function (runnabot) { if (runnabot && isInGuide()) { @@ -304,6 +308,10 @@ function ahaGuide( return keypather.get(currentOrg, 'poppa.attrs.metadata.hasConfirmedSetup'); } + function isPersonalAccount () { + return keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); + } + function updateCurrentOrg (updatedOrg) { if (keypather.has(updatedOrg, 'metadata.hasAha') && keypather.has(updatedOrg, 'metadata.hasConfirmedSetup')) { currentOrg.poppa.attrs.metadata = updatedOrg.metadata; @@ -393,6 +401,7 @@ function ahaGuide( hasDemoRepo: hasDemoRepo, hasRunnabot: refreshHasRunnabot, isInGuide: isInGuide, + isPersonalAccount: isPersonalAccount, resetGuide: resetGuide, skipBranchMilestone: skipBranchMilestone, stepList: stepList, From 62afe27d241b980caf3356fcdd03c36c43236aa8 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Fri, 28 Oct 2016 14:59:25 -0700 Subject: [PATCH 12/13] Fixed tests --- test/unit/controllers/controllerInstance.unit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/controllers/controllerInstance.unit.js b/test/unit/controllers/controllerInstance.unit.js index 08cea70b9..1086b0f8a 100644 --- a/test/unit/controllers/controllerInstance.unit.js +++ b/test/unit/controllers/controllerInstance.unit.js @@ -64,6 +64,7 @@ describe('controllerInstance'.bold.underline.blue, function () { isAddingFirstRepo: sinon.stub().returns(false), getCurrentStep: sinon.stub().returns(1), isInGuide: sinon.stub().returns(true), + isPersonalAccount: sinon.stub().returns(false), steps: { ADD_FIRST_BRANCH: 123 } From a6cb640dc04251765440fe2706eb5ef8e70fc14a Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Tue, 1 Nov 2016 14:05:29 -0700 Subject: [PATCH 13/13] PR comment changes --- .../forms/teamManagementForm/inviteModalController.js | 4 ++-- .../teamManagementForm/teamManagementFormController.js | 9 ++++----- .../forms/teamManagementForm/teamManagementFormView.jade | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js index 8c4c3ca52..8fd414e9f 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/inviteModalController.js @@ -97,10 +97,10 @@ function InviteModalController( if (IMC.isPersonalAccount) { return 'We only support having teammates with GitHub teams, but it looks like you\'re using a personal account.'; } - if (!IMC.isPersonalAccount && IMC.orgMembers.all.length === 1) { + if (IMC.orgMembers.all.length === 1) { return 'You\'re the only one in this team. Add teammates to your GitHub team before inviting them to Runnable.'; } - if (!IMC.isPersonalAccount && IMC.invitedAll && IMC.orgMembers.all.length > 1) { + if (IMC.invitedAll && IMC.orgMembers.all.length > 1) { return 'You\'re amazing! You\'ve already invited everyone on your GitHub team to Runnable.'; } }; diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js index 800f168fe..f45bb3d45 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormController.js @@ -21,12 +21,12 @@ function TeamManagementFormController( var TMMC = this; angular.extend(TMMC, { loading: true, - members: null + members: null, + isPersonalAccount: keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount') }); // Load initial state fetchMembers(); - var isPersonalAccount; var newInviteAddedWatchterUnbind = $rootScope.$on('newInvitedAdded', function (event, user) { TMMC.members.invited.push(user); @@ -58,8 +58,7 @@ function TeamManagementFormController( } }; }; - isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); - if (isPersonalAccount) { + if (TMMC.isPersonalAccount) { currentUser = keypather.get(currentOrg, 'github.attrs'); TMMC.members.registered.push(currentUser); return; @@ -79,7 +78,7 @@ function TeamManagementFormController( inputs: { teamName: $state.params.userName, orgMembers: TMMC.members, - isPersonalAccount: isPersonalAccount + isPersonalAccount: TMMC.isPersonalAccount } }) .then(function (modal) { diff --git a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade index 5e4636cbd..7b078f0fe 100644 --- a/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade +++ b/client/directives/modals/settingsModal/forms/teamManagementForm/teamManagementFormView.jade @@ -73,7 +73,7 @@ xlink:href = "#icons-overflow" ) p.small.text-center.padding-xxs( - ng-if = "!SEMC.isPersonalAccount" + ng-if = "!TMMC.isPersonalAccount" ) a.link( href = "mailto:support@runnable.com"