Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6375-Disable-Login #14580

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public DynamoView DynamoView
/// </summary>
internal WebView2 webView;

/// <summary>
/// Stores the value that indicates if the SignIn Button will be enabled(default) or not
/// </summary>
bool enableSignInButton;

/// <summary>
/// This delegate is used in StaticSplashScreenReady events
/// </summary>
Expand Down Expand Up @@ -126,16 +131,12 @@ public void OnRequestStaticSplashScreen()
StaticSplashScreenReady?.Invoke();
}

/// <summary>
/// Stores the value that indicates if the SignIn Button will be enabled(default) or not
/// </summary>
bool enableSignInButton;

/// <summary>
/// Splash Screen Constructor.
/// <paramref name="enableSignInButton"/> Indicates if the SignIn Button will be enabled(default) or not.
/// <paramref name="enableSignIn"/> Indicates if the SignIn Button will be enabled(default) or not.
/// </summary>
public SplashScreen(bool enableSignInButton = true)
/// <param name="enableSignIn">Indicates if enable(default) the Sigin button or not</param>
public SplashScreen(bool enableSignIn = true)
{
InitializeComponent();

Expand All @@ -153,7 +154,7 @@ public SplashScreen(bool enableSignInButton = true)
RequestImportSettings = ImportSettings;
RequestSignIn = SignIn;
RequestSignOut = SignOut;
this.enableSignInButton = enableSignInButton;
this.enableSignInButton = enableSignIn;
}

private void DynamoModel_LanguageDetected()
Expand Down Expand Up @@ -405,29 +406,29 @@ await webView.CoreWebView2.ExecuteScriptAsync("window.setSignInStatus({" +
$"signInStatus: \"" + status + "\"})");
}
}

/// <summary>
/// Handle the login status changes on splash screen.
/// Enable or not the SignIn button on the fly.
/// </summary>
internal async void HandleSignInStatusChange(bool status)
/// <param name="enabled"></param>
internal async void SetSignInEnable(bool enabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to expose this as an API and provide an example of how to use it as part of this PR

Copy link
Contributor Author

@jesusalvino jesusalvino Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to expose this as an API and provide an example of how to use it as part of this PR

Sure, currently is just a method of the SplashScreen class, Do you want to extend it as part of the DynamoViewModel, like the RequestClose FYI @reddyashish ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please think about it in the integration context: https://github.com/DynamoDS/DynamoRevit/blob/master/src/DynamoRevit/DynamoRevit.cs#L334 how to disable it when trying to show it from integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to expose this as an API and provide an example of how to use it as part of this PR

@QilongTang @mjkkirschner @reddyashish , changing it to public is enough to expose it so can be called from other parts. Unfortunatelly after varioous tests on D4R deptly I have realized its method OnRequestDynamicSplashScreen is called before the splash creen is ready and it's being used by Revit on that way which IMHO is a bug because the splash screen is ready only when its web resources are completed loaded and ready to have access to the WV2's DOM. That's why an example over the current implementation of the flow between Dynamo and D4R doesn't work. Please let me know What Do you consider to complete this PR, thanks.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we sticking to a method, not some startup config for SplashScreen constructor? A method call is meant to fail after UI initialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we sticking to a method, not some startup config for SplashScreen constructor? A method call is meant to fail after UI initialized?

A method approach means the consumers can call it on demand / Yes because the consumers don't know when the UI is initialized properly (image above).

I have moved the responsibility to enable or not the SignIn button to the ctor so the consumers will be able to decide only at that time.

Now the Splashcreen is the responsible to enable or not the SignIn button only when the web resources are completely loaded.

The ctor will enable the SignIn button by default, otherwise it needs to set explicitly here https://github.com/DynamoDS/DynamoRevit/blob/master/src/DynamoRevit/DynamoRevit.cs#L334 according to the consumer's criteria.

image

Enabled
login1

Disabled
login2

{
if (webView?.CoreWebView2 != null)
{
await webView.CoreWebView2.ExecuteScriptAsync(@$"window.handleSignInStateChange({{""status"": ""{status}""}})");
await webView.CoreWebView2.ExecuteScriptAsync("window.setEnableSignInButton({" + $"enable: \"{enabled}\"" + "})");
}
}

/// <summary>
/// Enable or disable the SignIn button on splash screen.
/// Handle the login status changes on splash screen.
/// </summary>
/// <param name="enabled"></param>
internal async void SetSignInEnable(bool enabled)
internal async void HandleSignInStatusChange(bool status)
{
if (webView?.CoreWebView2 != null)
{
await webView.CoreWebView2.ExecuteScriptAsync(@$"window.setEnableSignInButton({{""enable"": ""{enabled}""}})");
await webView.CoreWebView2.ExecuteScriptAsync(@$"window.handleSignInStateChange({{""status"": ""{status}""}})");
}
}

/// <summary>
/// Setup the values for all labels on splash screen using resources
/// </summary>
Expand Down
Loading