From 7f1e84101469e39922b8f42f422d4f94e0dfe747 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 2 Nov 2016 14:29:57 -0700 Subject: [PATCH 1/3] Prevented invite modal from erroring out on configure page --- client/directives/environment/environmentController.js | 8 ++++++-- client/directives/environment/environmentView.jade | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/directives/environment/environmentController.js b/client/directives/environment/environmentController.js index 7ac4363ec..47a468d2c 100755 --- a/client/directives/environment/environmentController.js +++ b/client/directives/environment/environmentController.js @@ -27,9 +27,10 @@ function EnvironmentController( ) { var EC = this; - EC.showInviteButton = false; EC.isAddingFirstRepo = ahaGuide.isAddingFirstRepo; EC.isInGuide = ahaGuide.isInGuide; + EC.isPersonalAccount = keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount'); + EC.showInviteButton = EC.isPersonalAccount; EC.showCreateTemplate = true; EC.getClassForSubstep = ahaGuide.getClassForSubstep; $scope.$on('ahaGuideEvent', function(event, info) { @@ -56,6 +57,7 @@ function EnvironmentController( var username = keypather.get(res.user, 'attrs.accounts.github.username'); var isOrg = (username !== $state.params.userName); EC.showInviteButton = isOrg && res.members.uninvited.length > 0; + EC.orgMembers = res.members; }); } @@ -78,7 +80,9 @@ function EnvironmentController( templateUrl: 'inviteModalView', inputs: { teamName: $state.params.userName, - unInvitedMembers: null + unInvitedMembers: null, + isPersonalAccount: EC.isPersonalAccount, + orgMembers: EC.orgMembers } }); } diff --git a/client/directives/environment/environmentView.jade b/client/directives/environment/environmentView.jade index 310700725..ad06ef1ab 100755 --- a/client/directives/environment/environmentView.jade +++ b/client/directives/environment/environmentView.jade @@ -84,7 +84,7 @@ ) footer.environment-footer.small.text-center( - ng-if = "EC.showInviteButton || $root.featureFlags.isPersonalAccount" + ng-if = "EC.showInviteButton" ) a.link( ng-click = "EC.triggerModal.inviteTeammate()" From 226ec946250e90a96ae4d409563574d776fbc226 Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Wed, 2 Nov 2016 16:42:45 -0700 Subject: [PATCH 2/3] Re-enable footer for environment view for personal account users --- client/directives/environment/environmentController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/directives/environment/environmentController.js b/client/directives/environment/environmentController.js index 47a468d2c..8828d232f 100755 --- a/client/directives/environment/environmentController.js +++ b/client/directives/environment/environmentController.js @@ -56,7 +56,7 @@ function EnvironmentController( .then(function (res) { var username = keypather.get(res.user, 'attrs.accounts.github.username'); var isOrg = (username !== $state.params.userName); - EC.showInviteButton = isOrg && res.members.uninvited.length > 0; + EC.showInviteButton = isOrg && res.members.uninvited.length > 0 || EC.isPersonalAccount; EC.orgMembers = res.members; }); } From bcbcc2217a770de6b734f9611754f6910a7ec4ba Mon Sep 17 00:00:00 2001 From: Henry Mollman Date: Thu, 3 Nov 2016 14:37:00 -0700 Subject: [PATCH 3/3] Fixed tests --- test/unit/environment/environmentController.unit.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/unit/environment/environmentController.unit.js b/test/unit/environment/environmentController.unit.js index b3c0474e8..c9dc224bc 100644 --- a/test/unit/environment/environmentController.unit.js +++ b/test/unit/environment/environmentController.unit.js @@ -99,7 +99,7 @@ describe('environmentController'.bold.underline.blue, function () { $provide.factory('fetchOrgMembers', function ($q) { ctx.uninvitedUsersArray = [1, 2, 999]; ctx.fetchOrgMembersStub = sinon.stub().returns($q.when({ - uninvited: ctx.uninvitedUsersArray + uninvited: ctx.uninvitedUsersArray, })); return ctx.fetchOrgMembersStub; }); @@ -164,7 +164,7 @@ describe('environmentController'.bold.underline.blue, function () { }); it('should not show the invite button by default', function () { - expect(EC.showInviteButton).to.equal(false); + expect(EC.showInviteButton).to.not.equal(true); }); it('should show the invite button if the user is an org', function () { @@ -174,6 +174,7 @@ describe('environmentController'.bold.underline.blue, function () { it('should not show the user is equal to userName', function () { ctx.state.params.userName = 'thejsj'; + EC.isPersonalAccount = false; $rootScope.$digest(); expect(EC.showInviteButton).to.equal(false); }); @@ -210,6 +211,8 @@ describe('environmentController'.bold.underline.blue, function () { }); it('should invoke the modal with the username and uninvited members', function () { + EC.isPersonalAccount = false; + EC.orgMembers = [1, 2, 999]; EC.triggerModal.inviteTeammate(); $scope.$digest(); sinon.assert.calledOnce(ctx.showModalStub); @@ -219,7 +222,9 @@ describe('environmentController'.bold.underline.blue, function () { templateUrl: 'inviteModalView', inputs: { teamName: ctx.state.params.userName, - unInvitedMembers: null + unInvitedMembers: null, + orgMembers: ctx.uninvitedUsersArray, + isPersonalAccount: false } }); });