Skip to content

Commit

Permalink
Merge pull request #1865 from CodeNow/add-personal-accounts
Browse files Browse the repository at this point in the history
Modified flow to consider personal account user same as organization
  • Loading branch information
henrymollman authored Nov 1, 2016
2 parents 2fc5fee + a6cb640 commit 8b6351b
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 66 deletions.
7 changes: 7 additions & 0 deletions client/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion client/controllers/controllerInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 1 addition & 7 deletions client/directives/accountsSelect/directiveAccountsSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ 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
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.

//- 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
Expand All @@ -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"
)
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -84,15 +84,15 @@ 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
//- a.small.link More about Runnabot
//- 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"
Expand All @@ -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
4 changes: 3 additions & 1 deletion client/directives/modals/ahaModal/ahaModalController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function AhaModalController(
fetchOwnerRepos,
fetchStackInfo,
github,
keypather,
loading,
ModalService,

Expand Down Expand Up @@ -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]);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function ChooseOrganizationModalController(
ahaGuide,
configEnvironment,
createNewSandboxForUserService,
currentOrg,
customWindowService,
errs,
eventTracking,
Expand Down Expand Up @@ -183,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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
xlink:href = "#icons-arrow-down"
)

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()}}"
)
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
ui-sref = "orgSelect"
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,37 @@ function InviteModalController(
inviteGithubUserToRunnable,
loading,

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
loading(IMC.name, true);
$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) {
Expand All @@ -52,11 +58,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);
Expand Down Expand Up @@ -85,4 +92,16 @@ function InviteModalController(
$rootScope.$emit('updateTeammateInvitations', IMC.invitesSent);
close(IMC.invitesSent);
};

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.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.invitedAll && IMC.orgMembers.all.length > 1) {
return 'You\'re amazing! You\'ve already invited everyone on your GitHub team to Runnable.';
}
};
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
.modal-backdrop.in
.modal-dialog.modal-xs.modal-invite(
ng-if = "$root.featureFlags.isPersonalAccount"
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
| 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.
footer.modal-footer
button.btn.btn-block.btn-md.white(
ui-sref = "orgSelect"
ui-sref-opts = "{reload: true}"
) 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

.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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function TeamManagementFormController(
$rootScope,
$scope,
$state,
currentOrg,
errs,
fetchOrgMembers,
inviteGithubUserToRunnable,
Expand All @@ -20,7 +21,8 @@ function TeamManagementFormController(
var TMMC = this;
angular.extend(TMMC, {
loading: true,
members: null
members: null,
isPersonalAccount: keypather.get(currentOrg, 'poppa.attrs.isPersonalAccount')
});

// Load initial state
Expand All @@ -36,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;
Expand All @@ -55,10 +58,16 @@ function TeamManagementFormController(
}
};
};
if (TMMC.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 () {
Expand All @@ -68,7 +77,8 @@ function TeamManagementFormController(
templateUrl: 'inviteModalView',
inputs: {
teamName: $state.params.userName,
unInvitedMembers: TMMC.members.uninvited
orgMembers: TMMC.members,
isPersonalAccount: TMMC.isPersonalAccount
}
})
.then(function (modal) {
Expand Down
Loading

0 comments on commit 8b6351b

Please sign in to comment.