first commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86d9084a265d35f4db65c4e31e0b6769
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using Codice.LogWrapper;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.WebApi;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal class AutoLogin
|
||||
{
|
||||
internal enum State : byte
|
||||
{
|
||||
Off = 0,
|
||||
Started = 1,
|
||||
Running = 2,
|
||||
ResponseInit = 3,
|
||||
ResponseEnd = 4,
|
||||
ResponseSuccess = 5,
|
||||
ErrorNoToken = 20,
|
||||
ErrorTokenException = 21,
|
||||
ErrorResponseNull = 22,
|
||||
ErrorResponseError = 23,
|
||||
ErrorTokenEmpty = 24,
|
||||
}
|
||||
|
||||
internal void Run()
|
||||
{
|
||||
mPlasticWindow = GetPlasticWindow();
|
||||
|
||||
if (!string.IsNullOrEmpty(CloudProjectSettings.accessToken))
|
||||
{
|
||||
mLog.Debug("Run");
|
||||
ExchangeTokensAndJoinOrganizationInThreadWaiter(CloudProjectSettings.accessToken);
|
||||
return;
|
||||
}
|
||||
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorNoToken;
|
||||
}
|
||||
|
||||
void ExchangeTokensAndJoinOrganizationInThreadWaiter(string unityAccessToken)
|
||||
{
|
||||
int ini = Environment.TickCount;
|
||||
|
||||
TokenExchangeResponse tokenExchangeResponse = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseInit;
|
||||
tokenExchangeResponse = WebRestApiClient.PlasticScm.TokenExchange(unityAccessToken);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
mLog.DebugFormat(
|
||||
"TokenExchange time {0} ms",
|
||||
Environment.TickCount - ini);
|
||||
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenException;
|
||||
ExceptionsHandler.LogException(
|
||||
"TokenExchangeSetting",
|
||||
waiter.Exception);
|
||||
Debug.LogWarning(waiter.Exception.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tokenExchangeResponse == null)
|
||||
{
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseNull;
|
||||
var warning = PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeResponseNull);
|
||||
mLog.Warn(warning);
|
||||
Debug.LogWarning(warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tokenExchangeResponse.Error != null)
|
||||
{
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseError;
|
||||
var warning = string.Format(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeResponseError),
|
||||
tokenExchangeResponse.Error.Message, tokenExchangeResponse.Error.ErrorCode);
|
||||
mLog.ErrorFormat(warning);
|
||||
Debug.LogWarning(warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tokenExchangeResponse.AccessToken))
|
||||
{
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenEmpty;
|
||||
var warning = string.Format(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeAccessEmpty),
|
||||
tokenExchangeResponse.User);
|
||||
mLog.InfoFormat(warning);
|
||||
Debug.LogWarning(warning);
|
||||
return;
|
||||
}
|
||||
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseEnd;
|
||||
|
||||
Credentials credentials = new Credentials(
|
||||
new SEID(tokenExchangeResponse.User, false, tokenExchangeResponse.AccessToken),
|
||||
SEIDWorkingMode.SSOWorkingMode);
|
||||
|
||||
ShowOrganizationsPanel(credentials);
|
||||
});
|
||||
}
|
||||
|
||||
void ShowOrganizationsPanel(Credentials credentials)
|
||||
{
|
||||
mPlasticWindow = GetPlasticWindow();
|
||||
mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseSuccess;
|
||||
|
||||
CloudEditionWelcomeWindow.ShowWindow(
|
||||
PlasticGui.Plastic.WebRestAPI, null, true);
|
||||
|
||||
mCloudEditionWelcomeWindow = CloudEditionWelcomeWindow.GetWelcomeWindow();
|
||||
|
||||
mCloudEditionWelcomeWindow.GetOrganizations(credentials);
|
||||
|
||||
mCloudEditionWelcomeWindow.Focus();
|
||||
}
|
||||
|
||||
static PlasticWindow GetPlasticWindow()
|
||||
{
|
||||
var windows = Resources.FindObjectsOfTypeAll<PlasticWindow>();
|
||||
PlasticWindow plasticWindow = windows.Length > 0 ? windows[0] : null;
|
||||
|
||||
if (plasticWindow == null)
|
||||
plasticWindow = ShowWindow.Plastic();
|
||||
|
||||
return plasticWindow;
|
||||
}
|
||||
|
||||
PlasticWindow mPlasticWindow;
|
||||
CloudEditionWelcomeWindow mCloudEditionWelcomeWindow;
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("AutoLogin");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 806bdb4f911275c4ca1ee81fde4b4d4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,212 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Authentication;
|
||||
using Codice.Client.Common.Connection;
|
||||
using Codice.Client.Common.WebApi;
|
||||
using Codice.Client.Common.WebApi.Responses;
|
||||
using Codice.CM.Common;
|
||||
using Codice.LogWrapper;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
using Unity.PlasticSCM.Editor.Views.Welcome;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal interface IWelcomeWindowNotify
|
||||
{
|
||||
void ProcessLoginResponseWithOrganizations(Credentials credentials, List<string> cloudServers);
|
||||
|
||||
void Back();
|
||||
}
|
||||
|
||||
internal class CloudEditionWelcomeWindow :
|
||||
EditorWindow, IWelcomeWindowNotify, OAuthSignIn.INotify, GetCloudOrganizations.INotify
|
||||
{
|
||||
internal static void ShowWindow(
|
||||
IPlasticWebRestApi restApi,
|
||||
WelcomeView welcomeView,
|
||||
bool autoLogin = false)
|
||||
{
|
||||
sRestApi = restApi;
|
||||
sAutoLogin = autoLogin;
|
||||
CloudEditionWelcomeWindow window = GetWindow<CloudEditionWelcomeWindow>();
|
||||
|
||||
window.titleContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.SignInToUnityVCS));
|
||||
window.minSize = window.maxSize = new Vector2(450, 300);
|
||||
|
||||
window.mWelcomeView = welcomeView;
|
||||
|
||||
window.Show();
|
||||
}
|
||||
|
||||
internal static CloudEditionWelcomeWindow GetWelcomeWindow()
|
||||
{
|
||||
return GetWindow<CloudEditionWelcomeWindow>();
|
||||
}
|
||||
|
||||
internal void CancelJoinOrganization()
|
||||
{
|
||||
if (sAutoLogin)
|
||||
{
|
||||
mLog.Debug("CancelJoinOrganization");
|
||||
GetWindow<PlasticWindow>().GetWelcomeView().autoLoginState = AutoLogin.State.Started;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReplaceRootPanel(VisualElement panel)
|
||||
{
|
||||
rootVisualElement.Clear();
|
||||
rootVisualElement.Add(panel);
|
||||
}
|
||||
|
||||
internal SignInPanel GetSignInPanel()
|
||||
{
|
||||
return mSignInPanel;
|
||||
}
|
||||
|
||||
internal void GetOrganizations(Credentials credentials)
|
||||
{
|
||||
mCredentials = credentials;
|
||||
|
||||
GetCloudOrganizations.GetOrganizationsInThreadWaiter(
|
||||
mCredentials.User.Data,
|
||||
mCredentials.User.Password,
|
||||
new ProgressControlsForDialogs(),
|
||||
this,
|
||||
sRestApi,
|
||||
CmConnection.Get());
|
||||
}
|
||||
|
||||
void ShowOrganizationsPanel(
|
||||
Credentials credentials, List<string> cloudServers, string errorMessage)
|
||||
{
|
||||
mLog.DebugFormat("ShowOrganizationsPanel({0}, {1} orgs) {2}",
|
||||
credentials.Mode, cloudServers.Count, errorMessage);
|
||||
|
||||
mOrganizationPanel = new OrganizationPanel(
|
||||
this,
|
||||
cloudServers,
|
||||
errorMessage,
|
||||
GetWindowTitle(),
|
||||
joinedOrganization =>
|
||||
{
|
||||
mLog.DebugFormat("JoinedOrganization: {0}", joinedOrganization);
|
||||
ClientConfiguration.Save(
|
||||
joinedOrganization,
|
||||
credentials.Mode,
|
||||
credentials.User.Data,
|
||||
credentials.User.Password);
|
||||
});
|
||||
|
||||
ReplaceRootPanel(mOrganizationPanel);
|
||||
}
|
||||
|
||||
string GetWindowTitle()
|
||||
{
|
||||
return PlasticLocalization.Name.SignInToUnityVCS.GetString();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Dispose();
|
||||
|
||||
if (mWelcomeView != null)
|
||||
mWelcomeView.OnUserClosedConfigurationWindow();
|
||||
}
|
||||
|
||||
void Dispose()
|
||||
{
|
||||
if (mSignInPanel != null)
|
||||
mSignInPanel.Dispose();
|
||||
|
||||
if (mOrganizationPanel != null)
|
||||
mOrganizationPanel.Dispose();
|
||||
}
|
||||
|
||||
// Used by WaitingSignInPanel
|
||||
void OAuthSignIn.INotify.SignedInForCloud(
|
||||
string chosenProviderName, Credentials credentials)
|
||||
{
|
||||
mLog.Debug("SignedInForCloud");
|
||||
|
||||
GetOrganizations(credentials);
|
||||
}
|
||||
|
||||
void OAuthSignIn.INotify.SignedInForOnPremise(
|
||||
string server, string proxy, Credentials credentials)
|
||||
{
|
||||
// Won't run
|
||||
}
|
||||
|
||||
void OAuthSignIn.INotify.Cancel(string message)
|
||||
{
|
||||
mLog.Debug("Cancel");
|
||||
Focus();
|
||||
}
|
||||
|
||||
void GetCloudOrganizations.INotify.CloudOrganizationsRetrieved(List<string> cloudServers)
|
||||
{
|
||||
ShowOrganizationsPanel(mCredentials, cloudServers, errorMessage: null);
|
||||
}
|
||||
|
||||
void GetCloudOrganizations.INotify.Error(ErrorResponse.ErrorFields error)
|
||||
{
|
||||
ShowOrganizationsPanel(mCredentials, cloudServers: null, errorMessage: error.Message);
|
||||
}
|
||||
|
||||
void IWelcomeWindowNotify.ProcessLoginResponseWithOrganizations(
|
||||
Credentials credentials, List<string> cloudServers)
|
||||
{
|
||||
mLog.DebugFormat("ProcessLoginResponseWithOrganizations: {0} orgs", cloudServers.Count);
|
||||
mCredentials = credentials;
|
||||
ShowOrganizationsPanel(mCredentials, cloudServers, errorMessage: null);
|
||||
}
|
||||
|
||||
void IWelcomeWindowNotify.Back()
|
||||
{
|
||||
rootVisualElement.Clear();
|
||||
rootVisualElement.Add(mSignInPanel);
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
root.Clear();
|
||||
|
||||
mSignInPanel = new SignInPanel(this, sRestApi);
|
||||
|
||||
titleContent = new GUIContent(GetWindowTitle());
|
||||
|
||||
root.Add(mSignInPanel);
|
||||
|
||||
if (sAutoLogin)
|
||||
{
|
||||
mSignInPanel.SignInWithUnityIdButtonAutoLogin();
|
||||
}
|
||||
}
|
||||
|
||||
string mUserName;
|
||||
Credentials mCredentials;
|
||||
|
||||
OrganizationPanel mOrganizationPanel;
|
||||
SignInPanel mSignInPanel;
|
||||
WelcomeView mWelcomeView;
|
||||
|
||||
static IPlasticWebRestApi sRestApi;
|
||||
static bool sAutoLogin = false;
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("CloudEditionWelcomeWindow");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad54f9e1bb701142b116d0d1ed98437
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.Home;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.UIElements;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal class OrganizationPanel : VisualElement
|
||||
{
|
||||
internal OrganizationPanel(
|
||||
CloudEditionWelcomeWindow parentWindow,
|
||||
List<string> cloudServers,
|
||||
string errorMessage,
|
||||
string title,
|
||||
Action<string> organizationJoinedAction)
|
||||
{
|
||||
mParentWindow = parentWindow;
|
||||
mPrefetchedCloudServers = cloudServers;
|
||||
mPrefetchedErrorMessage = errorMessage;
|
||||
|
||||
mOnOrganizationJoined = organizationJoinedAction;
|
||||
|
||||
InitializeLayoutAndStyles();
|
||||
|
||||
BuildComponents(title);
|
||||
|
||||
OnEditorActivated();
|
||||
}
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
if (!mOrganizationJoined)
|
||||
mParentWindow.CancelJoinOrganization();
|
||||
|
||||
if (mJoinSingleOrganizationButton != null)
|
||||
mJoinSingleOrganizationButton.clicked -= JoinOrganizationButton_clicked;
|
||||
|
||||
if (mJoinMultipleOrganizationsButton != null)
|
||||
mJoinMultipleOrganizationsButton.clicked -= JoinOrganizationButton_clicked;
|
||||
|
||||
if (mOpenUnityDashboardButton != null)
|
||||
mOpenUnityDashboardButton.clicked -= OpenUnityDashboardButton_clicked;
|
||||
}
|
||||
|
||||
void OnEditorActivated()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mPrefetchedErrorMessage))
|
||||
{
|
||||
mProgressControls.ShowError(mPrefetchedErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPrefetchedCloudServers == null || mPrefetchedCloudServers.Count == 0)
|
||||
{
|
||||
mProgressControls.ShowError("Could not find cloud organizations");
|
||||
return;
|
||||
}
|
||||
|
||||
List<OrganizationInfo> organizationsInfo =
|
||||
OrganizationsInformation.FromServersOrdered(mPrefetchedCloudServers);
|
||||
|
||||
ProcessOrganizations(organizationsInfo);
|
||||
}
|
||||
|
||||
void ProcessOrganizations(List<OrganizationInfo> organizations)
|
||||
{
|
||||
this.Query<VisualElement>("noOrganization").Collapse();
|
||||
this.Query<VisualElement>("joinSingleOrganization").Collapse();
|
||||
this.Query<VisualElement>("joinMultipleOrganizations").Collapse();
|
||||
|
||||
if (organizations.Count == 0)
|
||||
{
|
||||
BuildNoOrganizationSection();
|
||||
|
||||
mOpenUnityDashboardButton = this.Q<Button>("openUnityDashboardButton");
|
||||
mOpenUnityDashboardButton.clicked += OpenUnityDashboardButton_clicked;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (organizations.Count == 1)
|
||||
{
|
||||
BuildSingleOrganizationSection(organizations.First());
|
||||
|
||||
mJoinSingleOrganizationButton = this.Q<Button>("joinSingleOrganizationButton");
|
||||
mJoinSingleOrganizationButton.clicked += JoinOrganizationButton_clicked;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BuildMultipleOrganizationsSection(organizations);
|
||||
|
||||
mJoinMultipleOrganizationsButton = this.Q<Button>("joinMultipleOrganizationsButton");
|
||||
mJoinMultipleOrganizationsButton.clicked += JoinOrganizationButton_clicked;
|
||||
mOrganizationToJoin = organizations.First().Server;
|
||||
}
|
||||
|
||||
void InitializeLayoutAndStyles()
|
||||
{
|
||||
this.LoadLayout(typeof(OrganizationPanel).Name);
|
||||
this.LoadStyle(typeof(OrganizationPanel).Name);
|
||||
}
|
||||
|
||||
void JoinOrganizationButton_clicked()
|
||||
{
|
||||
mOnOrganizationJoined(mOrganizationToJoin);
|
||||
|
||||
mOrganizationJoined = true;
|
||||
|
||||
// TODO: Closing the window for now. Need to connect this event to the main on boarding workflow.
|
||||
mParentWindow.Close();
|
||||
}
|
||||
|
||||
void OpenUnityDashboardButton_clicked()
|
||||
{
|
||||
Application.OpenURL(UnityUrl.UnityDashboard.Plastic.Get());
|
||||
}
|
||||
|
||||
void BuildComponents(string title)
|
||||
{
|
||||
mParentWindow.titleContent = new UnityEngine.GUIContent(title);
|
||||
|
||||
mProgressControls = new ProgressControlsForDialogs(null);
|
||||
|
||||
mProgressContainer = this.Q<VisualElement>("progressContainer");
|
||||
mProgressContainer.Add((VisualElement)mProgressControls);
|
||||
}
|
||||
|
||||
void BuildSingleOrganizationSection(OrganizationInfo organizationInfo)
|
||||
{
|
||||
this.SetControlText<Label>("confirmationMessage",
|
||||
PlasticLocalization.Name.JoinOrganizationTitle);
|
||||
|
||||
mOrganizationToJoin = organizationInfo.Server;
|
||||
|
||||
this.Query<VisualElement>("joinSingleOrganization").Show();
|
||||
|
||||
this.SetControlText<Label>("joinSingleOrganizationLabel",
|
||||
PlasticLocalization.Name.YouBelongToOrganization, organizationInfo.DisplayName);
|
||||
|
||||
this.SetControlText<Button>("joinSingleOrganizationButton",
|
||||
PlasticLocalization.Name.JoinButton);
|
||||
}
|
||||
|
||||
void BuildMultipleOrganizationsSection(List<OrganizationInfo> organizations)
|
||||
{
|
||||
organizations.Sort((x, y) =>
|
||||
string.Compare(x.DisplayName, y.DisplayName, StringComparison.CurrentCulture));
|
||||
|
||||
this.SetControlText<Label>("confirmationMessage",
|
||||
PlasticLocalization.Name.JoinOrganizationTitle);
|
||||
|
||||
this.Query<VisualElement>("joinMultipleOrganizations").Show();
|
||||
|
||||
this.SetControlText<Label>("joinMultipleOrganizationsLabel",
|
||||
PlasticLocalization.Name.YouBelongToSeveralOrganizations);
|
||||
|
||||
VisualElement organizationDropdown = this.Query<VisualElement>("organizationDropdown");
|
||||
ToolbarMenu toolbarMenu = new ToolbarMenu
|
||||
{
|
||||
text = organizations.First().DisplayName,
|
||||
};
|
||||
|
||||
foreach (OrganizationInfo organization in organizations)
|
||||
{
|
||||
string organizationDisplayName = organization.DisplayName;
|
||||
|
||||
toolbarMenu.menu.AppendAction(organizationDisplayName, x =>
|
||||
{
|
||||
toolbarMenu.text = organizationDisplayName;
|
||||
mOrganizationToJoin = organization.Server;
|
||||
}, DropdownMenuAction.AlwaysEnabled);
|
||||
organizationDropdown.Add(toolbarMenu);
|
||||
}
|
||||
|
||||
this.SetControlText<Button>("joinMultipleOrganizationsButton",
|
||||
PlasticLocalization.Name.JoinButton);
|
||||
}
|
||||
|
||||
void BuildNoOrganizationSection()
|
||||
{
|
||||
this.SetControlText<Label>("confirmationMessage",
|
||||
PlasticLocalization.Name.CreateOrganizationTitle);
|
||||
|
||||
this.Query<VisualElement>("noOrganization").Show();
|
||||
|
||||
this.SetControlImage("iconUnity",
|
||||
Images.Name.ButtonSsoSignInUnity);
|
||||
|
||||
this.SetControlText<Label>("noOrganizationLabel",
|
||||
PlasticLocalization.Name.ClickButtonBelowToCreateOrg);
|
||||
|
||||
this.SetControlText<Button>("openUnityDashboardButton",
|
||||
PlasticLocalization.Name.MainSidebarOpenUnityDashboardItem);
|
||||
}
|
||||
|
||||
string mOrganizationToJoin = "";
|
||||
bool mOrganizationJoined;
|
||||
|
||||
Button mJoinSingleOrganizationButton;
|
||||
Button mJoinMultipleOrganizationsButton;
|
||||
Button mOpenUnityDashboardButton;
|
||||
VisualElement mProgressContainer;
|
||||
|
||||
IProgressControls mProgressControls;
|
||||
|
||||
readonly CloudEditionWelcomeWindow mParentWindow;
|
||||
readonly List<string> mPrefetchedCloudServers;
|
||||
readonly string mPrefetchedErrorMessage;
|
||||
readonly Action<string> mOnOrganizationJoined;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 615ff93ab52eb8242a9194d4f711676f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Authentication;
|
||||
using Codice.Client.Common.WebApi;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.UIElements;
|
||||
using PlasticGui.Configuration.CloudEdition.Welcome;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal class SignInPanel : VisualElement
|
||||
{
|
||||
internal SignInPanel(
|
||||
CloudEditionWelcomeWindow parentWindow, IPlasticWebRestApi restApi)
|
||||
{
|
||||
mParentWindow = parentWindow;
|
||||
mRestApi = restApi;
|
||||
|
||||
InitializeLayoutAndStyles();
|
||||
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
mSignInWithUnityIdButton.clicked -= SignInWithUnityIdButton_Clicked;
|
||||
mSignInWithEmailButton.clicked -= SignInWithEmailButton_Clicked;
|
||||
mPrivacyPolicyStatementButton.clicked -= PrivacyPolicyStatementButton_Clicked;
|
||||
mSignUpButton.clicked -= SignUpButton_Clicked;
|
||||
|
||||
if (mSignInWithEmailPanel != null)
|
||||
mSignInWithEmailPanel.Dispose();
|
||||
|
||||
if (mWaitingSignInPanel != null)
|
||||
mWaitingSignInPanel.Dispose();
|
||||
}
|
||||
|
||||
void SignInWithEmailButton_Clicked()
|
||||
{
|
||||
mSignInWithEmailPanel = new SignInWithEmailPanel(mParentWindow, mRestApi);
|
||||
|
||||
mParentWindow.ReplaceRootPanel(mSignInWithEmailPanel);
|
||||
}
|
||||
|
||||
void SignUpButton_Clicked()
|
||||
{
|
||||
Application.OpenURL(UnityUrl.DevOps.GetSignUp());
|
||||
}
|
||||
|
||||
internal void SignInWithUnityIdButton_Clicked()
|
||||
{
|
||||
mWaitingSignInPanel = new WaitingSignInPanel(
|
||||
mParentWindow, mParentWindow, mRestApi);
|
||||
|
||||
mParentWindow.ReplaceRootPanel(mWaitingSignInPanel);
|
||||
|
||||
Guid state = Guid.NewGuid();
|
||||
|
||||
mWaitingSignInPanel.OAuthSignIn(
|
||||
GetAuthProviders.GetUnityIdAuthProvider(string.Empty, state),
|
||||
GetCredentialsFromState.Build(
|
||||
string.Empty, state, SEIDWorkingMode.SSOWorkingMode, mRestApi));
|
||||
}
|
||||
|
||||
internal void SignInWithUnityIdButtonAutoLogin()
|
||||
{
|
||||
mWaitingSignInPanel = new WaitingSignInPanel(
|
||||
mParentWindow, mParentWindow, mRestApi);
|
||||
|
||||
mWaitingSignInPanel.OnAutoLogin();
|
||||
|
||||
mParentWindow.ReplaceRootPanel(mWaitingSignInPanel);
|
||||
}
|
||||
|
||||
void PrivacyPolicyStatementButton_Clicked()
|
||||
{
|
||||
Application.OpenURL(UnityUrl.DevOps.GetPrivacyPolicy());
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
BuildSignUpArea();
|
||||
BuildSignInUnityIdArea();
|
||||
BuildSignInEmailArea();
|
||||
BuildPrivatePolicyArea();
|
||||
}
|
||||
|
||||
void BuildPrivatePolicyArea()
|
||||
{
|
||||
this.SetControlText<Label>(
|
||||
"privacyStatementText",
|
||||
PlasticLocalization.Name.PrivacyStatementText,
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.PrivacyStatement));
|
||||
|
||||
mPrivacyPolicyStatementButton = this.Query<Button>("privacyStatement");
|
||||
mPrivacyPolicyStatementButton.text = PlasticLocalization.Name.PrivacyStatement.GetString();
|
||||
mPrivacyPolicyStatementButton.clicked += PrivacyPolicyStatementButton_Clicked;
|
||||
}
|
||||
|
||||
void BuildSignInEmailArea()
|
||||
{
|
||||
this.SetControlImage(
|
||||
"iconEmail",
|
||||
Images.Name.ButtonSsoSignInEmail);
|
||||
|
||||
mSignInWithEmailButton = this.Query<Button>("emailButton");
|
||||
mSignInWithEmailButton.text = PlasticLocalization.Name.SignInWithEmail.GetString();
|
||||
mSignInWithEmailButton.clicked += SignInWithEmailButton_Clicked;
|
||||
}
|
||||
|
||||
void BuildSignInUnityIdArea()
|
||||
{
|
||||
this.SetControlImage(
|
||||
"iconUnity",
|
||||
Images.Name.ButtonSsoSignInUnity);
|
||||
|
||||
mSignInWithUnityIdButton = this.Query<Button>("unityIDButton");
|
||||
mSignInWithUnityIdButton.text = PlasticLocalization.Name.SignInWithUnityID.GetString();
|
||||
mSignInWithUnityIdButton.clicked += SignInWithUnityIdButton_Clicked;
|
||||
}
|
||||
|
||||
void BuildSignUpArea()
|
||||
{
|
||||
Label signUpLabel = this.Query<Label>("signUpLabel");
|
||||
signUpLabel.text = PlasticLocalization.Name.LoginOrSignUp.GetString();
|
||||
|
||||
mSignUpButton = this.Query<Button>("signUpButton");
|
||||
mSignUpButton.text = PlasticLocalization.Name.SignUpButton.GetString();
|
||||
mSignUpButton.clicked += SignUpButton_Clicked;
|
||||
}
|
||||
|
||||
void InitializeLayoutAndStyles()
|
||||
{
|
||||
AddToClassList("grow");
|
||||
|
||||
this.LoadLayout(typeof(SignInPanel).Name);
|
||||
this.LoadStyle(typeof(SignInPanel).Name);
|
||||
}
|
||||
|
||||
SignInWithEmailPanel mSignInWithEmailPanel;
|
||||
WaitingSignInPanel mWaitingSignInPanel;
|
||||
Button mSignInWithUnityIdButton;
|
||||
Button mSignInWithEmailButton;
|
||||
Button mPrivacyPolicyStatementButton;
|
||||
Button mSignUpButton;
|
||||
|
||||
readonly CloudEditionWelcomeWindow mParentWindow;
|
||||
readonly IPlasticWebRestApi mRestApi;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bba806fdb20eb5a4da6cc856323d6273
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,184 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Authentication;
|
||||
using Codice.Client.Common.WebApi;
|
||||
using Codice.Client.Common.WebApi.Responses;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.Configuration.CloudEdition.Welcome;
|
||||
using PlasticGui.Configuration.CloudEdition;
|
||||
using Unity.PlasticSCM.Editor.UI.UIElements;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal class SignInWithEmailPanel : VisualElement, GetCloudOrganizations.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 ShowSignUpNeeded()
|
||||
{
|
||||
mSignUpNeededNotificationContainer.Show();
|
||||
}
|
||||
|
||||
void HideSignUpNeeded()
|
||||
{
|
||||
mSignUpNeededNotificationContainer.Collapse();
|
||||
}
|
||||
|
||||
void GetCloudOrganizations.INotify.CloudOrganizationsRetrieved(
|
||||
List<string> cloudServers)
|
||||
{
|
||||
mNotify.ProcessLoginResponseWithOrganizations(mCredentials, cloudServers);
|
||||
}
|
||||
|
||||
void GetCloudOrganizations.INotify.Error(
|
||||
ErrorResponse.ErrorFields error)
|
||||
{
|
||||
if (error.ErrorCode == ErrorCodes.UserNotFound)
|
||||
{
|
||||
ShowSignUpNeeded();
|
||||
return;
|
||||
}
|
||||
|
||||
HideSignUpNeeded();
|
||||
((IProgressControls)mProgressControls).ShowError(error.Message);
|
||||
}
|
||||
|
||||
void CleanNotificationLabels()
|
||||
{
|
||||
mEmailNotificationLabel.text = string.Empty;
|
||||
mPasswordNotificationLabel.text = string.Empty;
|
||||
|
||||
HideSignUpNeeded();
|
||||
}
|
||||
|
||||
void SignInButton_Clicked()
|
||||
{
|
||||
CleanNotificationLabels();
|
||||
|
||||
ValidateEmailAndPassword.ValidationResult validationResult;
|
||||
if (!ValidateEmailAndPassword.IsValid(mEmailField.text, mPasswordField.text, out validationResult))
|
||||
{
|
||||
ShowValidationResult(validationResult);
|
||||
return;
|
||||
}
|
||||
|
||||
mCredentials = new Credentials(
|
||||
new SEID(mEmailField.text, false, mPasswordField.text),
|
||||
SEIDWorkingMode.LDAPWorkingMode);
|
||||
|
||||
GetCloudOrganizations.GetOrganizationsInThreadWaiter(
|
||||
mCredentials.User.Data,
|
||||
mCredentials.User.Password,
|
||||
mProgressControls,
|
||||
this,
|
||||
mRestApi,
|
||||
CmConnection.Get());
|
||||
}
|
||||
|
||||
void ShowValidationResult(
|
||||
ValidateEmailAndPassword.ValidationResult validationResult)
|
||||
{
|
||||
if (validationResult.UserError != null)
|
||||
{
|
||||
mEmailNotificationLabel.text = validationResult.UserError;
|
||||
}
|
||||
|
||||
if (validationResult.PasswordError != null)
|
||||
{
|
||||
mPasswordNotificationLabel.text = validationResult.PasswordError;
|
||||
}
|
||||
}
|
||||
|
||||
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<TextField>("email");
|
||||
mPasswordField = this.Q<TextField>("password");
|
||||
mEmailNotificationLabel = this.Q<Label>("emailNotification");
|
||||
mPasswordNotificationLabel = this.Q<Label>("passwordNotification");
|
||||
mSignInButton = this.Q<Button>("signIn");
|
||||
mBackButton = this.Q<Button>("back");
|
||||
mSignUpButton = this.Q<Button>("signUpButton");
|
||||
mProgressContainer = this.Q<VisualElement>("progressContainer");
|
||||
mSignUpNeededNotificationContainer = this.Q<VisualElement>("signUpNeededNotificationContainer");
|
||||
|
||||
mSignInButton.clicked += SignInButton_Clicked;
|
||||
mBackButton.clicked += BackButton_Clicked;
|
||||
mSignUpButton.clicked += SignUpButton_Clicked;
|
||||
mEmailField.FocusOnceLoaded();
|
||||
|
||||
mProgressControls = new ProgressControlsForDialogs(new VisualElement[] { mSignInButton });
|
||||
mProgressContainer.Add((VisualElement)mProgressControls);
|
||||
|
||||
this.SetControlText<Label>("signInLabel",
|
||||
PlasticLocalization.Name.SignInWithEmail);
|
||||
this.SetControlLabel<TextField>("email",
|
||||
PlasticLocalization.Name.Email);
|
||||
this.SetControlLabel<TextField>("password",
|
||||
PlasticLocalization.Name.Password);
|
||||
this.SetControlText<Button>("signIn",
|
||||
PlasticLocalization.Name.SignIn);
|
||||
this.SetControlText<Button>("back",
|
||||
PlasticLocalization.Name.BackButton);
|
||||
this.SetControlText<Label>("signUpNeededNotificationLabel",
|
||||
PlasticLocalization.Name.SignUpNeededNoArgs);
|
||||
this.SetControlText<Button>("signUpButton",
|
||||
PlasticLocalization.Name.SignUp);
|
||||
}
|
||||
|
||||
TextField mEmailField;
|
||||
TextField mPasswordField;
|
||||
|
||||
Label mEmailNotificationLabel;
|
||||
Label mPasswordNotificationLabel;
|
||||
|
||||
Button mSignInButton;
|
||||
Button mBackButton;
|
||||
Button mSignUpButton;
|
||||
|
||||
VisualElement mProgressContainer;
|
||||
VisualElement mSignUpNeededNotificationContainer;
|
||||
|
||||
Credentials mCredentials;
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
readonly IWelcomeWindowNotify mNotify;
|
||||
readonly IPlasticWebRestApi mRestApi;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85f4628ae66f0eb439e59db66adbc696
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Authentication;
|
||||
using Codice.Client.Common.WebApi;
|
||||
using Codice.CM.Common;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
|
||||
{
|
||||
internal class WaitingSignInPanel : VisualElement
|
||||
{
|
||||
internal WaitingSignInPanel(
|
||||
IWelcomeWindowNotify parentNotify,
|
||||
OAuthSignIn.INotify notify,
|
||||
IPlasticWebRestApi restApi)
|
||||
{
|
||||
mParentNotify = parentNotify;
|
||||
|
||||
mNotify = notify;
|
||||
mRestApi = restApi;
|
||||
|
||||
InitializeLayoutAndStyles();
|
||||
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
internal void OAuthSignIn(
|
||||
AuthProvider provider,
|
||||
IGetCredentialsFromState getCredentialsFromState)
|
||||
{
|
||||
mSignIn = new OAuthSignIn();
|
||||
|
||||
mSignIn.SignInForProviderInThreadWaiter(
|
||||
provider,
|
||||
string.Empty,
|
||||
mProgressControls,
|
||||
mNotify,
|
||||
new OAuthSignIn.Browser(),
|
||||
getCredentialsFromState);
|
||||
|
||||
ShowWaitingSpinner();
|
||||
}
|
||||
|
||||
internal void OnAutoLogin()
|
||||
{
|
||||
mCompleteOnBrowserLabel.visible = false;
|
||||
mCancelButton.visible = false;
|
||||
|
||||
mProgressControls.ProgressData.ProgressMessage =
|
||||
PlasticLocalization.Name.SigningIn.GetString();
|
||||
|
||||
ShowWaitingSpinner();
|
||||
}
|
||||
|
||||
internal void Dispose()
|
||||
{
|
||||
mCancelButton.clicked -= CancelButton_Clicked;
|
||||
}
|
||||
|
||||
void InitializeLayoutAndStyles()
|
||||
{
|
||||
this.LoadLayout(typeof(WaitingSignInPanel).Name);
|
||||
this.LoadStyle(typeof(WaitingSignInPanel).Name);
|
||||
}
|
||||
|
||||
void ShowWaitingSpinner()
|
||||
{
|
||||
var spinner = new LoadingSpinner();
|
||||
mProgressContainer.Add(spinner);
|
||||
spinner.Start();
|
||||
|
||||
var checkinMessageLabel = new Label(mProgressControls.ProgressData.ProgressMessage);
|
||||
checkinMessageLabel.style.paddingLeft = 20;
|
||||
mProgressContainer.Add(checkinMessageLabel);
|
||||
}
|
||||
|
||||
void CancelButton_Clicked()
|
||||
{
|
||||
mSignIn.Cancel();
|
||||
mParentNotify.Back();
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
this.SetControlText<Label>("signInToPlasticSCM",
|
||||
PlasticLocalization.Name.SignInToUnityVCS);
|
||||
|
||||
mCompleteOnBrowserLabel = this.Q<Label>("completeSignInOnBrowser");
|
||||
mCompleteOnBrowserLabel.text = PlasticLocalization.Name.CompleteSignInOnBrowser.GetString();
|
||||
|
||||
mProgressContainer = this.Q<VisualElement>("progressContainer");
|
||||
|
||||
mProgressControls = new UI.Progress.ProgressControlsForDialogs();
|
||||
|
||||
mCancelButton = this.Query<Button>("cancelButton");
|
||||
mCancelButton.text = PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CancelButton);
|
||||
mCancelButton.visible = true;
|
||||
mCancelButton.clicked += CancelButton_Clicked;
|
||||
}
|
||||
|
||||
Button mCancelButton;
|
||||
VisualElement mProgressContainer;
|
||||
Label mCompleteOnBrowserLabel;
|
||||
|
||||
OAuthSignIn mSignIn;
|
||||
|
||||
UI.Progress.ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
readonly IPlasticWebRestApi mRestApi;
|
||||
readonly OAuthSignIn.INotify mNotify;
|
||||
readonly IWelcomeWindowNotify mParentNotify;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077387e98bf29fb4a97bccfb592cfaf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user