WaitingSignInPanel.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Codice.Client.Common;
  2. using PlasticGui;
  3. using PlasticGui.Configuration.CloudEdition.Welcome;
  4. using PlasticGui.WebApi;
  5. using Unity.PlasticSCM.Editor.UI.UIElements;
  6. using UnityEngine.UIElements;
  7. namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
  8. {
  9. internal class WaitingSignInPanel : VisualElement
  10. {
  11. internal WaitingSignInPanel(
  12. IWelcomeWindowNotify parentNotify,
  13. OAuthSignIn.INotify notify,
  14. IPlasticWebRestApi restApi,
  15. CmConnection cmConnection)
  16. {
  17. mParentNotify = parentNotify;
  18. mNotify = notify;
  19. mRestApi = restApi;
  20. mCmConnection = cmConnection;
  21. InitializeLayoutAndStyles();
  22. BuildComponents();
  23. }
  24. internal void OAuthSignInForConfigure(string ssoProviderName)
  25. {
  26. mSignIn = new OAuthSignIn();
  27. mSignIn.ForConfigure(
  28. mRestApi,
  29. ssoProviderName,
  30. mProgressControls,
  31. mNotify,
  32. mCmConnection);
  33. ShowWaitingSpinner();
  34. }
  35. internal void Dispose()
  36. {
  37. mCancelButton.clicked -= CancelButton_Clicked;
  38. }
  39. void CancelButton_Clicked()
  40. {
  41. mSignIn.Cancel();
  42. mParentNotify.Back();
  43. }
  44. void BuildComponents()
  45. {
  46. this.SetControlText<Label>("signInToPlasticSCM",
  47. PlasticLocalization.Name.SignInToPlasticSCM);
  48. this.SetControlText<Label>("completeSignInOnBrowser",
  49. PlasticLocalization.Name.CompleteSignInOnBrowser);
  50. mProgressContainer = this.Q<VisualElement>("progressContainer");
  51. mProgressControls = new UI.Progress.ProgressControlsForDialogs();
  52. mCancelButton = this.Query<Button>("cancelButton").First();
  53. mCancelButton.text = PlasticLocalization.GetString(
  54. PlasticLocalization.Name.CancelButton);
  55. mCancelButton.clicked += CancelButton_Clicked;
  56. }
  57. void InitializeLayoutAndStyles()
  58. {
  59. this.LoadLayout(typeof(WaitingSignInPanel).Name);
  60. this.LoadStyle("SignInSignUp");
  61. this.LoadStyle(typeof(WaitingSignInPanel).Name);
  62. }
  63. void ShowWaitingSpinner()
  64. {
  65. var spinner = new LoadingSpinner();
  66. mProgressContainer.Add(spinner);
  67. spinner.Start();
  68. var checkinMessageLabel = new Label(mProgressControls.ProgressData.ProgressMessage);
  69. checkinMessageLabel.style.paddingLeft = 10;
  70. mProgressContainer.Add(checkinMessageLabel);
  71. }
  72. Button mCancelButton;
  73. VisualElement mProgressContainer;
  74. OAuthSignIn mSignIn;
  75. UI.Progress.ProgressControlsForDialogs mProgressControls;
  76. readonly IPlasticWebRestApi mRestApi;
  77. readonly CmConnection mCmConnection;
  78. readonly OAuthSignIn.INotify mNotify;
  79. readonly IWelcomeWindowNotify mParentNotify;
  80. }
  81. }