[MM-51233] Updates for Trial Requests (#22620)
* Add new trial form to enrich trial requests with more customer info * Update snapshots * One more addition * Fixes from PR feedback * Fix types, i18n, update e2e tests * Fix linter * Fix i18n? * Fix blank translation * update snapshot * Update snapshot properly * Remove inapplicable test * Fix business email validation only happening once * UX Feedback * Fix linter * Fix linter again, not working locally * FIX LINTER * Move isvalid check until after some fields are set * Fix for overlapping modals * Fix linter * UX feedback * UX Feedback * Fix typo in error modal * [MM-51551] Add new Trial Form to Playbooks trial requests (#22650) * Playbooks start trial entrypoints opens new trial form modal * Fix style --------- Co-authored-by: Mattermost Build <build@mattermost.com> * [MM-51347] Trial form error modal for embargoed and air gapped entities (#22656) * Playbooks start trial entrypoints opens new trial form modal * Add support for air gapped environments when making trial requests * Add specific handling for embargoed entities * undo some code * Fix linter * Fix types * Fix style * Updates because TE has to upgrade to E0 before it can activate a trial --------- Co-authored-by: Mattermost Build <build@mattermost.com> --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -30,6 +30,7 @@ const ServerKey product.ServiceKey = "server"
|
||||
type licenseSvc interface {
|
||||
GetLicense() *model.License
|
||||
RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError
|
||||
RequestTrialLicenseWithExtraFields(requesterID string, trialRequest *model.TrialLicenseRequest) *model.AppError
|
||||
}
|
||||
|
||||
// Channels contains all channels related state.
|
||||
@@ -323,6 +324,10 @@ func (ch *Channels) License() *model.License {
|
||||
return ch.licenseSvc.GetLicense()
|
||||
}
|
||||
|
||||
func (ch *Channels) RequestTrialLicenseWithExtraFields(requesterID string, trialRequest *model.TrialLicenseRequest) *model.AppError {
|
||||
return ch.licenseSvc.RequestTrialLicenseWithExtraFields(requesterID, trialRequest)
|
||||
}
|
||||
|
||||
func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError {
|
||||
return ch.licenseSvc.RequestTrialLicense(requesterID, users, termsAccepted,
|
||||
receiveEmailsAccepted)
|
||||
|
||||
@@ -36,6 +36,51 @@ func (w *licenseWrapper) GetLicense() *model.License {
|
||||
return w.srv.License()
|
||||
}
|
||||
|
||||
func (w *licenseWrapper) RequestTrialLicenseWithExtraFields(requesterID string, trialRequest *model.TrialLicenseRequest) *model.AppError {
|
||||
if *w.srv.platform.Config().ExperimentalSettings.RestrictSystemAdmin {
|
||||
return model.NewAppError("RequestTrialLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
requester, err := w.srv.userService.GetUser(requesterID)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return model.NewAppError("RequestTrialLicense", MissingAccountError, nil, "", http.StatusNotFound).Wrap(err)
|
||||
default:
|
||||
return model.NewAppError("RequestTrialLicense", "app.user.get_by_username.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
if w.srv.Cloud.ValidateBusinessEmail(requesterID, trialRequest.ContactEmail) != nil {
|
||||
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request.business-email", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// Create a new struct only using the fields from the request that are allowed to be set by the client
|
||||
sanitizedRequest := &model.TrialLicenseRequest{
|
||||
ServerID: w.srv.TelemetryId(),
|
||||
Name: requester.GetDisplayName(model.ShowFullName),
|
||||
Email: requester.Email,
|
||||
SiteName: *w.srv.platform.Config().TeamSettings.SiteName,
|
||||
SiteURL: *w.srv.platform.Config().ServiceSettings.SiteURL,
|
||||
Users: trialRequest.Users,
|
||||
TermsAccepted: trialRequest.TermsAccepted,
|
||||
ReceiveEmailsAccepted: trialRequest.ReceiveEmailsAccepted,
|
||||
ContactName: trialRequest.ContactName,
|
||||
ContactEmail: trialRequest.ContactEmail,
|
||||
CompanyName: trialRequest.CompanyName,
|
||||
CompanySize: trialRequest.CompanySize,
|
||||
CompanyCountry: trialRequest.CompanyCountry,
|
||||
}
|
||||
|
||||
if !sanitizedRequest.IsValid() {
|
||||
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return w.srv.platform.RequestTrialLicense(sanitizedRequest)
|
||||
}
|
||||
|
||||
// DEPRECATED - use RequestTrialLicenseWithExtraFields instead. This function remains to support the Plugin API.
|
||||
func (w *licenseWrapper) RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError {
|
||||
if *w.srv.platform.Config().ExperimentalSettings.RestrictSystemAdmin {
|
||||
return model.NewAppError("RequestTrialLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
||||
|
||||
Ссылка в новой задаче
Block a user