Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions client/directives/environment/environmentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -55,7 +56,8 @@ 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;
});
}

Expand All @@ -78,7 +80,9 @@ function EnvironmentController(
templateUrl: 'inviteModalView',
inputs: {
teamName: $state.params.userName,
unInvitedMembers: null
unInvitedMembers: null,
isPersonalAccount: EC.isPersonalAccount,
orgMembers: EC.orgMembers
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion client/directives/environment/environmentView.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
Expand Down
11 changes: 8 additions & 3 deletions test/unit/environment/environmentController.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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 () {
Expand All @@ -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);
});
Expand Down Expand Up @@ -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);
Expand All @@ -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
}
});
});
Expand Down