Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
murtaza-swati committed Apr 23, 2024
2 parents 5e10205 + ee53906 commit 7052db7
Show file tree
Hide file tree
Showing 26 changed files with 188 additions and 85 deletions.
19 changes: 17 additions & 2 deletions app/components/billing/authorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default Component.extend({
stripe: service(),
accounts: service(),
store: service(),
flashes: service(),

stripeElement: null,
account: null,
Expand All @@ -28,8 +29,9 @@ export default Component.extend({
isSubscribed: reads('subscription.isSubscribed'),
isIncomplete: reads('subscription.isIncomplete'),
isComplete: not('isIncomplete'),
canCancelSubscription: computed('isSubscribed', 'hasSubscriptionPermissions', 'freeV2Plan', 'isTrial', function () {
return this.isSubscribed && this.hasSubscriptionPermissions && !this.freeV2Plan && !this.isTrial;
cancellationRequested: reads('subscription.cancellationRequested'),
canCancelSubscription: computed('isSubscribed', 'hasSubscriptionPermissions', 'freeV2Plan', 'isTrial', 'cancellationRequested', function () {
return this.isSubscribed && this.hasSubscriptionPermissions && !this.freeV2Plan && !this.isTrial && !this.cancellationRequested;
}),

hasSubscriptionPermissions: computed('account.hasSubscriptionPermissions', 'account.permissions', function () {
Expand Down Expand Up @@ -118,6 +120,19 @@ export default Component.extend({
});
}),

cancelSubscription: task(function* () {
try {
yield this.subscription.cancelSubscription.perform();
this.flashes.successWithClose(
'Your cancellation request has been forwarded to Support. Our Support team will contact you soon.',
'We’re sorry to see you go'
);
// this.set('showCancelModal', true);
} catch (error) {
this.flashes.error('An error occurred when submitting your cancellation request. Please try again.');
}
}).drop(),

actions: {
complete(stripeElement) {
this.set('stripeElement', stripeElement);
Expand Down
12 changes: 12 additions & 0 deletions app/components/billing/first-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ export default Component.extend({
}
}).drop(),


skipSubscription() {
this.storage.clearBillingData();
this.storage.clearSelectedPlanId();
this.storage.wizardStep = 2;
this.wizard.update.perform(2);
this.router.transitionTo('account.repositories');
},

newV2Subscription() {
const plan = this.store.createRecord('v2-plan-config');
const billingInfo = this.store.createRecord('v2-billing-info');
Expand Down Expand Up @@ -290,6 +299,9 @@ export default Component.extend({
this.createSubscription.perform();
}
},
skipActivation() {
this.skipSubscription();
},
changeCountry(country) {
this.set('country', country);
this.set('hasLocalRegistration', false);
Expand Down
2 changes: 1 addition & 1 deletion app/components/billing/summary-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default Component.extend({
}
return this.subscription.validTo;
}),
isExpired: or('subscription.isExpired', 'subscription.manualSubscriptionExpired'),
isExpired: or('subscription.isExpired', 'subscription.subscriptionExpiredByDate'),
canceledOrExpired: or('isExpired', 'isCanceled'),
isCompleteAndNotExpired: and('hasNotExpired', 'isComplete'),
trial: reads('account.trial'),
Expand Down
2 changes: 1 addition & 1 deletion app/components/profile-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default Component.extend({
isOrganizationAdmin: and('isOrganization', 'hasAdminPermissions'),
showOrganizationSettings: computed('isOrganizationAdmin', 'isProVersion', 'hasSettingsReadPermissions', function () {
const forOrganization = !this.isOrganization || this.hasSettingsReadPermissions;
return this.isOrganizationAdmin && this.isProVersion && forOrganization;
return (this.isOrganizationAdmin || forOrganization) && this.isProVersion;
}),

showSubscriptionTab: computed('features.enterpriseVersion', 'hasPlanViewPermissions',
Expand Down
13 changes: 13 additions & 0 deletions app/components/temporary-announcement-banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Component from '@ember/component';
import config from 'travis/config/environment';

export default Component.extend({
message: '',
enabled: false,

init() {
this._super(...arguments);
this.set('enabled', config.tempBanner.tempBannerEnabled === 'true');
this.set('message', config.tempBanner.tempBannerMessage || '');
}
});
3 changes: 2 additions & 1 deletion app/models/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default Model.extend({
clientSecret: attr(),
paymentIntent: attr(),
planName: attr(),
cancellationRequested: attr('boolean'),

discount: belongsTo('discount', { async: false, inverse: 'subscription' }),
billingInfo: belongsTo('billing-info', { async: false, inverse: 'subscription' }),
Expand Down Expand Up @@ -128,7 +129,7 @@ export default Model.extend({
}).drop(),

cancelSubscription: task(function* (data) {
yield this.api.post(`/subscription/${this.id}/cancel`, {
yield this.api.post(`/subscription/${this.id}/pause`, {
data
});
yield this.accounts.fetchSubscriptions.perform();
Expand Down
11 changes: 10 additions & 1 deletion app/models/v2-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default Model.extend({
clientSecret: attr('string'),
paymentIntent: attr(),
scheduledPlanName: attr('string'),
cancellationRequested: attr('boolean'),
canceledAt: attr('date'),

v1SubscriptionId: attr('number'),
Expand All @@ -47,6 +48,14 @@ export default Model.extend({
isManual: equal('source', 'manual'),
isNotManual: not('isManual'),

subscriptionExpiredByDate: computed('validTo', function () {
let validTo = this.validTo;
let today = new Date().toISOString();
let date = Date.parse(today);
let validToDate = Date.parse(validTo);
return date > validToDate;
}),

isSubscribed: computed('status', function () {
return this.status === null || this.status == 'subscribed';
}),
Expand Down Expand Up @@ -234,7 +243,7 @@ export default Model.extend({
}).drop(),

cancelSubscription: task(function* (data) {
yield this.api.post(`/v2_subscription/${this.id}/cancel`, {
yield this.api.post(`/v2_subscription/${this.id}/pause`, {
data
});
yield this.accounts.fetchV2Subscriptions.perform();
Expand Down
9 changes: 8 additions & 1 deletion app/services/flashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ import { assert } from '@ember/debug';
const messageTypeToIcon = {
notice: 'icon-flag',
success: 'flash-success',
'success-with-close': 'flash-success',
error: 'flash-error'
};

const messageTypeToPreamble = {
notice: 'Heads up!',
success: 'Hooray!',
'success-with-close': 'Hooray!',
error: 'Oh no!'
};

const messageTypeToCloseButton = {
notice: true,
success: false,
'success-with-close': true,
error: true
};

Expand Down Expand Up @@ -91,7 +94,7 @@ export default Service.extend({
},

display(type, message, preamble, aboveOverlay = false) {
if (!['error', 'notice', 'success'].includes(type)) {
if (!['error', 'notice', 'success', 'success-with-close'].includes(type)) {
// eslint-disable-next-line
console.warn("WARNING: <service:flashes> display(type, message) function can only handle 'error', 'notice' and 'success' types");
}
Expand All @@ -111,6 +114,10 @@ export default Service.extend({
this.display('notice', message, preamble, aboveOverlay);
},

successWithClose(message, preamble = messageTypeToPreamble['success-with-close'], aboveOverlay = false) {
this.display('success-with-close', message, preamble, aboveOverlay);
},

custom(component, data = {}, className = null) {
assert('Component name is mandatory for custom flashes', !!component);
this.removeCustomsByClassName(className);
Expand Down
12 changes: 12 additions & 0 deletions app/styles/app/layouts/activation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@
margin-bottom: 44px;
}

#first-plan-skip {
margin-top: 60px;
margin-bottom: 10px;
}
#first-plan-skip-button {
margin-right: -140px;
padding-left: 110px;
font-size: 14px;
font-weight: 600;
color: $ansi-green;
}

.not-required-form-elem {
width: 100%;
margin-bottom: 10px;
Expand Down
9 changes: 9 additions & 0 deletions app/styles/app/layouts/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,12 @@ $env-var-value-background: lighten($cement-grey, 20);
margin-left: 20px;
}
}

.ember-tooltip {
min-width: 200px;
max-width: 1316px;

.tooltip-inner {
}

}
15 changes: 14 additions & 1 deletion app/styles/app/modules/flash.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
width: 100%;
}

li.notice, li.success, li.error, li.warning {
li.notice, li.success, li.error, li.warning, li.success-with-close {
opacity: 1;

@include z-index(flashes);
Expand Down Expand Up @@ -60,6 +60,19 @@
}
}

.success-with-close {
color: $turf-green;
background-color: $seed-green;

@include colorSVGFill($turf-green);

.flash-message svg {
height: 38px;
width: 32px;
margin-top: -5px;
}
}

.error {
color: $brick-red;
background-color: $quartz-red;
Expand Down
16 changes: 11 additions & 5 deletions app/templates/components/billing/authorization.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@
</button>
{{/if}}
</div>
{{#if this.canCancelSubscription}}
<div class='billing-subscription__buttons--cancel'>
{{#if this.canCancelSubscription}}
<a {{on 'click' (fn (mut this.showCancelModal) true)}} href='javascript: void(0);' class='link' data-test-open-cancel-subscription-modal='true'>
Cancel subscription
</a>
{{/if}}
<a {{on 'click' (action (perform this.cancelSubscription))}} href='javascript: void(0);' class='link' data-test-open-cancel-subscription-modal='true'>
Cancel subscription
</a>
</div>
{{else if this.subscription.cancellationRequested}}
<div class='billing-subscription__buttons--cancel'>
<a href='javascript: void(0);' class='link' data-test-cancellation-requested-button='true'>
Cancellation requested
</a>
</div>
{{/if}}
{{/if}}
</div>
{{/if}}
Expand Down
10 changes: 10 additions & 0 deletions app/templates/components/billing/first-plan.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,15 @@

</div>

<div class='mt-5 float-right' id="first-plan-skip">
{{#unless this.isLoading}}
<button id="first-plan-skip-button" class="no-button" {{action 'skipActivation' }}
data-test-skip-payment='true'>
skip
</button>
{{/unless}}
</div>


</TravisForm>
{{/if}}
17 changes: 8 additions & 9 deletions app/templates/components/billing/summary-v2.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
<div class='plan'>
<div>
<span class="payment-details-label plan-label-color">Current plan:</span>
<p class='plan-name flex flex--v-center' data-test-plan-name='true'>
<p class='plan-name flex flex--v-center' data-test-plan-name='true'>
{{#if this.subscription.plan}}
{{this.subscription.plan.name}}
{{else}}
Unknown plan
{{/if}}

{{#if this.subscription.isSubscribed}}
{{#if (and this.subscription.isSubscribed (not this.subscription.subscriptionExpiredByDate))}}
<span class="badge green square" data-test-active-status='true'>
active
</span>
Expand All @@ -52,7 +51,7 @@
<span data-test-plan-message='true' class='plan-overview__description--validity ml-3
{{if this.canceledOrExpired 'dark-red' 'cement-grey'}}'
>
{{#if this.isSubscribed}}
{{#if (and this.isSubscribed (not this.subscription.subscriptionExpiredByDate))}}
Valid until {{moment-format this.validto "MMMM D, YYYY"}}
{{else if this.isIncomplete}}
Incomplete
Expand All @@ -62,7 +61,7 @@
Expired {{moment-format this.subscription.validTo "MMMM D, YYYY"}}
{{/if}}
</span>

</p>
{{#if this.subscription.isManual}}
<div class='plan-overview__description' data-test-plan-description>
Expand Down Expand Up @@ -95,7 +94,7 @@
</div>
</section>
{{/if}}

</div>
{{/if}}
{{#if this.subscription.isNotManual }}
Expand Down Expand Up @@ -134,9 +133,9 @@
{{/if}}
{{/if}}
</div>
{{#if this.showPlanInfo}}
{{#if this.showPlanInfo}}
<div class='float-right flex plan-price-container'>
<span class="payment-details-label plan-price-label">Total:</span>
<span class="payment-details-label plan-price-label">Total:</span>
<span class="plan-price-info">
{{#if (or this.subscription.plan.isFree this.subscription.plan.isTrial)}}
Free
Expand All @@ -146,7 +145,7 @@
</span>
</div>
{{/if}}
</div>
</div>
{{/if}}
<!-- </div> -->
</div>
Expand Down
2 changes: 2 additions & 0 deletions app/templates/components/billing/summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
{{else}}
Expires {{moment-from-now this.subscription.validTo}} on {{moment-format this.subscription.validTo "MMMM DD"}}
{{/if}}
{{else if (and this.isComplete this.subscription.cancellationRequested)}}
Expires {{moment-from-now this.subscription.validTo}} on {{moment-format this.subscription.validTo "MMMM DD"}}, cancellation requested
{{else if (and this.isComplete this.isExpired)}}
Expired {{moment-format this.subscription.validTo "MMMM D, YYYY"}}
{{/if}}
Expand Down
Loading

0 comments on commit 7052db7

Please sign in to comment.