using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; using PlasticGui; using PlasticGui.Configuration.CloudEdition.Welcome; using PlasticGui.Configuration.CloudEdition; using PlasticGui.WebApi; using PlasticGui.WebApi.Responses; using Unity.PlasticSCM.Editor.UI.UIElements; namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome { internal class SignInWithEmailPanel : VisualElement, Login.INotify { internal SignInWithEmailPanel( IWelcomeWindowNotify notify, IPlasticWebRestApi restApi) { mNotify = notify; mRestApi = restApi; InitializeLayoutAndStyles(); BuildComponents(); } internal void Dispose() { mSignInButton.clicked -= SignInButton_Clicked; mBackButton.clicked -= BackButton_Clicked; mSignUpButton.clicked -= SignUpButton_Clicked; } void Login.INotify.SuccessForUnityPackage( OrganizationsResponse organizationResponse, string userName, string accessToken) { mNotify.ProcessLoginResponse(organizationResponse, userName, accessToken); } void Login.INotify.SuccessForConfigure( List organizations, bool canCreateAnOrganization, string userName, string password) { // empty implementation } void Login.INotify.SuccessForSSO( string organization) { // empty implementation } void Login.INotify.SuccessForProfile( string userName) { // empty implementation } void Login.INotify.SuccessForCredentials(string userName, string password) { // empty implementation } void Login.INotify.SuccessForHomeView(string userName) { // empty implementation } void Login.INotify.ValidationFailed( Login.ValidationResult validationResult) { if (validationResult.UserError != null) { mEmailNotificationLabel.text = validationResult.UserError; } if (validationResult.PasswordError != null) { mPasswordNotificationLabel.text = validationResult.PasswordError; } } void Login.INotify.SignUpNeeded( Login.Data loginData) { ShowSignUpNeeded(); } void ShowSignUpNeeded() { mSignUpNeededNotificationContainer.Show(); } void HideSignUpNeeded() { mSignUpNeededNotificationContainer.Collapse(); } void Login.INotify.Error( string message) { HideSignUpNeeded(); mProgressControls.ShowError(message); } void CleanNotificationLabels() { mEmailNotificationLabel.text = string.Empty; mPasswordNotificationLabel.text = string.Empty; HideSignUpNeeded(); } void SignInButton_Clicked() { CleanNotificationLabels(); Login.Run( mRestApi, new SaveCloudEditionCreds(), mEmailField.text, mPasswordField.text, string.Empty, string.Empty, Login.Mode.UnityPackage, mProgressControls, this); } void BackButton_Clicked() { mNotify.Back(); } void InitializeLayoutAndStyles() { this.LoadLayout(typeof(SignInWithEmailPanel).Name); this.LoadStyle(typeof(SignInWithEmailPanel).Name); } void SignUpButton_Clicked() { Application.OpenURL(UnityUrl.DevOps.GetSignUp()); } void BuildComponents() { mEmailField = this.Q("email"); mPasswordField = this.Q("password"); mEmailNotificationLabel = this.Q