diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb
index 2ed98b73b7..5dd1605a56 100644
--- a/app/controllers/enterprises_controller.rb
+++ b/app/controllers/enterprises_controller.rb
@@ -26,9 +26,13 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
class EnterprisesController < ApplicationController
+ include EnterpriseTrialHelper
+
layout 'admin'
menu_item :enterprise
+ before_action :augur_content_security_policy
+ before_action :chargebee_content_security_policy
before_action :require_admin
before_action :check_user_limit, only: [:show]
diff --git a/app/helpers/augur_helper.rb b/app/helpers/augur_helper.rb
deleted file mode 100644
index b116c2886d..0000000000
--- a/app/helpers/augur_helper.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module AugurHelper
- def augur_content_security_policy
- controller.append_content_security_policy_directives(
- connect_src: %w(augur.openproject-edge.com)
- )
- end
-end
diff --git a/app/helpers/enterprise_trial_helper.rb b/app/helpers/enterprise_trial_helper.rb
new file mode 100644
index 0000000000..cbbec62075
--- /dev/null
+++ b/app/helpers/enterprise_trial_helper.rb
@@ -0,0 +1,15 @@
+module EnterpriseTrialHelper
+ def augur_content_security_policy
+ append_content_security_policy_directives(
+ connect_src: %w(augur.openproject-edge.com)
+ )
+ end
+
+ def chargebee_content_security_policy
+ append_content_security_policy_directives(
+ script_src: %w(js.chargebee.com),
+ style_src: %w(js.chargebee.com openproject-enterprise-test.chargebee.com),
+ frame_src: %w(js.chargebee.com openproject-enterprise-test.chargebee.com)
+ )
+ end
+end
\ No newline at end of file
diff --git a/app/views/enterprises/_info.html.erb b/app/views/enterprises/_info.html.erb
index a1965907e6..63314f1a27 100644
--- a/app/views/enterprises/_info.html.erb
+++ b/app/views/enterprises/_info.html.erb
@@ -26,16 +26,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
-<%= augur_content_security_policy %>
+<% content_for :header_tags do %>
+
+<% end %>
- <%= t('js.admin.enterprise.upsale.become_hero') %>
<%= t('js.admin.enterprise.upsale.you_contribute') %>
+ <%= t('js.admin.enterprise.upsale.become_hero') %>
+ <%= t('js.admin.enterprise.upsale.you_contribute') %>
-
What are the benefits
+
<%= t('homescreen.blocks.upsale.description') %>
<%= image_tag "https://1t1rycb9er64f1pgy2iuseow-wpengine.netdna-ssl.com/wp-content/uploads/2017/06/icon-security-features.png",
diff --git a/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.html b/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.html
index a856be6b2e..6bd3f701b7 100644
--- a/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.html
+++ b/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.html
@@ -90,8 +90,7 @@
+ formControlName="newsletter_consent">
I want to receive the OpenProject
@@ -111,6 +110,7 @@
email sent - waiting for confirmation
{{ text.resend }}
+ Sorry, something went wrong. Please try to resend mail.
confirmed ✓
diff --git a/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.ts b/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.ts
index 502a53cd7b..0d713a7db7 100644
--- a/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.ts
+++ b/frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.ts
@@ -117,8 +117,8 @@ export class EnterpriseTrialModal extends OpModalComponent {
this.text = _.defaults(this.options.text, this.text);
}
+ // checks if form is valid and submits it
public onSubmit() {
- // check if form is valid and handle input errors
if (this.enterpriseTrialForm.valid) {
this.enterpriseTrialForm.addControl('_type', new FormControl('enterprise-trial'));
@@ -126,15 +126,20 @@ export class EnterpriseTrialModal extends OpModalComponent {
}
}
- public sendForm(form:FormGroup) {
+ // sends POST request with form object
+ // receives an enterprise trial link to access a token
+ private sendForm(form:FormGroup) {
+ const delay = 5000; // wait 5s until next request
+ const retries = 60; // keep trying for 5 minutes
const trialPath = 'https://augur.openproject-edge.com/public/v1/trials';
- // POST /public/v1/trials/ (send POST with form object)
+
+ // POST /public/v1/trials/
this.http.post(trialPath, form)
.toPromise()
.then((enterpriseTrial:any) => {
this.trialLink = enterpriseTrial._links.self.href;
- this.confirmMailAddress();
+ this.retryConfirmation(delay, retries);
})
.catch((error:HttpErrorResponse) => {
// mail is invalid or user already created a trial
@@ -147,7 +152,8 @@ export class EnterpriseTrialModal extends OpModalComponent {
});
}
- public confirmMailAddress() {
+ // gets a token from the trial link if user confirmed mail
+ private getToken() {
// 2) GET /public/v1/trials/:id
this.http
.get(this.baseUrlAugur + this.trialLink)
@@ -161,20 +167,10 @@ export class EnterpriseTrialModal extends OpModalComponent {
.catch((error:HttpErrorResponse) => {
// returns error 422 while waiting of confirmation
if (error.status === 422 && error.error.identifier === 'waiting_for_email_verification') {
- // open next modal window
- // status waiting
+ // open next modal window -> status waiting
this.status = 'mailSubmitted';
-
// get resend button link
this.resendLink = error.error._links.resend.href;
-
- // TODO add limit for retrying
- setTimeout( () => {
- // retry as long as modal is open and action is not cancelled
- if (!this.cancelled) {
- this.confirmMailAddress();
- }
- }, 5000);
} else if (_.get(error, 'error._type') === 'Error') {
this.notificationsService.addWarning(error.error.message);
} else {
@@ -184,45 +180,54 @@ export class EnterpriseTrialModal extends OpModalComponent {
});
}
- // TODO
+ // saves received token in controller
private saveToken(token:string) {
// POST /admin/enterprise (params[:enterprise_token][:encoded_token])
// -> if token is new (token_retrieved: false) save token in ruby controller
this.http.post(this.pathHelper.api.v3.appBasePath + '/admin/enterprise', { enterprise_token: { encoded_token: token } }, { withCredentials: true })
.toPromise()
.then((res:any) => {
- // TODO: needs clarification: show token to copy?
console.log('saveToken() success: ', res);
})
.catch((error:HttpErrorResponse) => {
console.log('saveToken() failed: ', error.error);
+ this.notificationsService.addWarning(error.error.description || I18n.t('js.error.internal'));
});
}
- // TODO: needs specification
+ // retries request while waiting for mail confirmation
+ private retryConfirmation(delay:number, retries:number) {
+ if (this.cancelled || this.confirmed) {
+ // stop if action was cancelled or confirmation link was clicked
+ return;
+ } else if (retries === 0) {
+ // action timed out -> show message
+ this.cancelled = true;
+ } else {
+ // retry as long as limit isn't reached
+ this.getToken();
+ setTimeout( () => {
+ this.retryConfirmation(delay, retries - 1);
+ }, delay);
+ }
+ }
+
+ // TODO: add enterprise onboarding youtube video
public startEnterpriseTrial() {
// open onboarding modal
this.status = 'startTrial';
- console.log(this.status);
- // on continue:
- // this.closeModal();
- // reload page to show enterprise trial
- }
-
- public checkMailField() {
- if (this.enterpriseTrialForm.value.email !== '' && this.enterpriseTrialForm.controls.email.errors) {
- this.errorMsg = 'Invalid e-mail address';
- } else {
- this.errorMsg = undefined;
- }
}
+ // resends mail if resend link has been clicked
public resendMail() {
this.http.post(this.baseUrlAugur + this.resendLink, {})
.toPromise()
.then((enterpriseTrial:any) => {
console.log('Mail has been resent.');
this.notificationsService.addSuccess('Mail has been resent. Please check your mails and click the confirmation link provided.');
+
+ this.cancelled = false;
+ this.retryConfirmation(5000, 6);
})
.catch((error:HttpErrorResponse) => {
console.log('An Error occured: ', error);
@@ -230,9 +235,13 @@ export class EnterpriseTrialModal extends OpModalComponent {
});
}
- public receiveNewsletter(event:any) {
- if (event.target.checked) {
- // subscribe to newsletter
+ // checks if mail is valid after input field was edited by the user
+ // displays message for user
+ public checkMailField() {
+ if (this.enterpriseTrialForm.value.email !== '' && this.enterpriseTrialForm.controls.email.errors) {
+ this.errorMsg = 'Invalid e-mail address';
+ } else {
+ this.errorMsg = undefined;
}
}
@@ -240,7 +249,7 @@ export class EnterpriseTrialModal extends OpModalComponent {
// cancel all actions (e.g. an already send request)
this.cancelled = true;
this.closeMe(event);
- // refresh page to show trial
+ // refresh page to show enterprise trial
if (this.status === 'startTrial' || this.confirmed) {
window.location.reload();
}
diff --git a/frontend/src/app/components/enterprise/enterprise.component.html b/frontend/src/app/components/enterprise/enterprise.component.html
index cb29a8f8ba..fc05b93230 100644
--- a/frontend/src/app/components/enterprise/enterprise.component.html
+++ b/frontend/src/app/components/enterprise/enterprise.component.html
@@ -1,6 +1,11 @@