Skip to content

Commit b67ccc1

Browse files
author
Myztiq
committed
Updated logic to have custom alert when the user changes their billing plan.
1 parent 3780ee6 commit b67ccc1

4 files changed

Lines changed: 60 additions & 24 deletions

File tree

client/directives/environment/environmentController.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ function EnvironmentController(
1515
$state,
1616
$timeout,
1717
$window,
18-
errs,
1918
favico,
2019
fetchUser,
2120
fetchDockerfileForContextVersion,
2221
fetchInstancesByPod,
2322
fetchOrgMembers,
24-
fetchOrgTeammateInvitations,
2523
helpCards,
2624
keypather,
2725
ModalService,
@@ -142,15 +140,35 @@ function EnvironmentController(
142140
$window.removeEventListener('scroll', scrollHelper);
143141
});
144142

145-
$scope.alert = null;
143+
EC.alert = null;
146144

147145
$scope.$on('alert', function (evt, data) {
148-
$scope.alert = data;
149-
$timeout(function () {
150-
$scope.alert = null;
151-
}, 5000);
146+
EC.alert = data;
147+
if (!data.planChanged) {
148+
$timeout(function () {
149+
EC.actions.closeAlert();
150+
}, 5000);
151+
}
152152
});
153153

154+
EC.actions = {
155+
closeAlert: function () {
156+
EC.alert = null;
157+
},
158+
goToBilling: function () {
159+
EC.actions.closeAlert();
160+
ModalService.showModal({
161+
controller: 'SettingsModalController',
162+
controllerAs: 'SEMC',
163+
templateUrl: 'settingsModalView',
164+
inputs: {
165+
tab: 'billing',
166+
subTab: 'billingForm'
167+
}
168+
});
169+
}
170+
};
171+
154172
$scope.helpPopover = {
155173
data: $scope.help,
156174
actions: {

client/directives/environment/environmentView.jade

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
//- new alerts
22
.grid-block.vertical.notification.notification-sm.js-animate.top-right(
33
ng-class = "{\
4-
'green': alert.type === 'success',\
5-
'red': alert.type === 'deleted',\
6-
'plan-changed text-center': $root.featureFlags.billingPlanChangedNotification\
4+
'green': EC.alert.type === 'success',\
5+
'red': EC.alert.type === 'deleted',\
6+
'plan-changed text-center': EC.alert.newPlan\
77
}"
8-
ng-if = "alert"
8+
ng-if = "EC.alert"
99
)
1010
.grid-block.align-center(
11-
ng-class = "{'justify-center': $root.featureFlags.billingPlanChangedNotification}"
11+
ng-class = "{'justify-center': EC.alert.newPlan}"
1212
)
1313
svg.anchor-left.iconnables.icons-check(
14-
ng-if = "alert.type === 'success'"
14+
ng-if = "EC.alert.type === 'success'"
1515
)
1616
use(
1717
xlink:href = "#icons-check"
1818
)
1919
svg.anchor-left.iconnables.icons-trash(
20-
ng-if = "alert.type === 'deleted'"
20+
ng-if = "EC.alert.type === 'deleted'"
2121
)
2222
use(
2323
xlink:href = "#icons-trash"
2424
)
25-
span {{alert.text}}
25+
span {{EC.alert.text}}
2626
a.link.small.link-undo(
2727
ng-if = "$root.featureFlags.undoDelete"
2828
) Undo
2929
.grid-block.vertical(
30-
ng-if = "$root.featureFlags.billingPlanChangedNotification"
30+
ng-if = "EC.alert.newPlan"
3131
)
3232
small.small You’ve been bumped into the next plan for 
3333
strong.strong free
3434
|  until your next billing period. 
3535
//- to billing tab
36-
a.link Plan Details
37-
button.btn.btn-xs.green Got it, thanks!
36+
a.link(
37+
ng-click = "EC.actions.goToBilling()"
38+
) Plan Details
39+
button.btn.btn-xs.green(
40+
ng-click = "EC.actions.closeAlert()"
41+
) Got it, thanks!
3842

3943
//- environment page
4044
.grid-block.environment-wrapper(

client/services/createAndBuildNewContainerService.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ function createAndBuildNewContainer(
1616
$q,
1717
$rootScope,
1818
createNewInstance,
19+
currentOrg,
1920
eventTracking,
2021
fetchInstancesByPod,
22+
fetchPlan,
2123
fetchUser,
2224
helpCards
2325
) {
@@ -27,11 +29,14 @@ function createAndBuildNewContainer(
2729
// Save this in case it changes
2830
var cachedActiveAccount = $rootScope.dataApp.data.activeAccount;
2931
var instance = null;
32+
var oldPlan = null;
3033
return $q.all({
3134
masterInstances: fetchInstancesByPod(cachedActiveAccount.oauthName()),
32-
user: fetchUser()
35+
user: fetchUser(),
36+
plan: fetchPlan()
3337
})
3438
.then(function (response) {
39+
oldPlan = response.plan.next.id;
3540
var instanceOptions = {
3641
name: containerName,
3742
owner: {
@@ -47,10 +52,6 @@ function createAndBuildNewContainer(
4752
return $q.when(createPromiseForState);
4853
})
4954
.then(function (newServerModel) {
50-
$rootScope.$broadcast('alert', {
51-
type: 'success',
52-
text: 'Container Created'
53-
});
5455
helpCards.hideActiveCard();
5556
if (options.isolation) {
5657
newServerModel.opts.isIsolationGroupMaster = false;
@@ -63,6 +64,20 @@ function createAndBuildNewContainer(
6364
instance
6465
);
6566
})
67+
.then(function (instance) {
68+
fetchPlan.cache.clear();
69+
return fetchPlan()
70+
.then(function (newPlan) {
71+
$rootScope.$broadcast('alert', {
72+
type: 'success',
73+
text: 'Container Created',
74+
newPlan: newPlan.next.id !== oldPlan
75+
});
76+
})
77+
.then(function () {
78+
return instance;
79+
});
80+
})
6681
.then(function (instance) {
6782
helpCards.refreshAllCards();
6883
return instance;

client/services/featureFlagService.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function featureFlags(
2121
backup: false,
2222
blankDockerfile: false, // allows users to skip the verification flow
2323
billing: false,
24-
billingPlanChangedNotification: false, // if plan changes because of container created
2524
cardStatus: false,
2625
connections: false,
2726
configTerminal: false, // flag for terminal in config view

0 commit comments

Comments
 (0)