private void OnStartInstanceCommand() { try { if (!UserPromptUtils.YesNoPrompt( String.Format(Resources.CloudExplorerGceStartInstanceConfirmationPrompt, Instance.Name), String.Format(Resources.CloudExplorerGceStartInstanceConfirmationPromptCaption, Instance.Name))) { Debug.WriteLine($"The user cancelled starting instance {Instance.Name}."); return; } var operation = _owner.DataSource.StartInstance(Instance); UpdateInstanceState(operation); } catch (DataSourceException ex) { GcpOutputWindow.Activate(); GcpOutputWindow.OutputLine(String.Format(Resources.CloudExplorerGceFailedToStartInstanceMessage, Instance.Name, ex.Message)); } catch (OAuthException ex) { ShowOAuthErrorDialog(ex); } }
/// <summary> /// Ensures that the opt-in dialog is shown to the user. /// </summary> public static void EnsureAnalyticsOptIn() { var settings = GoogleCloudExtensionPackage.Instance.AnalyticsSettings; if (!settings.DialogShown) { Debug.WriteLine("Showing the opt-in dialog."); settings.OptIn = UserPromptUtils.YesNoPrompt(Resources.AnalyticsPromptMessage, Resources.AnalyticsPromptTitle); settings.DialogShown = true; settings.SaveSettingsToStorage(); } }
private void OnDeleteAccountCommand() { ExtensionAnalytics.ReportCommand(CommandName.DeleteAccountCommand, CommandInvocationSource.Button); Debug.WriteLine($"Attempting to delete account: {CurrentAccountName}"); if (!UserPromptUtils.YesNoPrompt( String.Format(Resources.ManageAccountsDeleteAccountPromptMessage, CurrentAccountName), Resources.ManageAccountsDeleteAccountPromptTitle)) { ExtensionAnalytics.ReportEvent("DeleteAccountCommandCancelled", "Cancelled"); Debug.WriteLine($"The user cancelled the deletion of the account."); return; } AccountsManager.DeleteAccount(CurrentUserAccount.UserAccount); // Refreshing everything. UserAccountsList = LoadUserCredentialsViewModel(); }
private async void OnOkCommand() { if (!UserPromptUtils.YesNoPrompt( String.Format(Resources.ResetPasswordConfirmationPromptMessage, UserName, _instance.Name), Resources.ResetPasswordConfirmationPromptTitle)) { Debug.WriteLine("The user cancelled resetting the password."); return; } try { Debug.WriteLine($"Resetting the password for the user {UserName}"); ResettingPassword = true; // The operation cannot be cancelled once it started, so we have to disable the buttons while // it is in flight. OkCommand.CanExecuteCommand = false; CancelCommand.CanExecuteCommand = false; _owner.IsCloseButtonEnabled = false; // Check that gcloud is in the right state to invoke the reset credentials method. if (!await GCloudWrapper.CanUseResetWindowsCredentialsAsync()) { if (!GCloudWrapper.IsGCloudCliInstalled()) { LinkPromptDialogWindow.PromptUser( Resources.ResetPasswordMissingGcloudTitle, Resources.ResetPasswordGcloudMissingMessage, new LinkInfo(link: "https://cloud.google.com/sdk/", caption: Resources.ResetPasswordGcloudLinkCaption)); } else { UserPromptUtils.ErrorPrompt( message: Resources.ResetPasswordGcloudMissingBetaMessage, title: Resources.ResetPasswordGcloudMissingComponentTitle); } return; } var context = new Context { CredentialsPath = CredentialsStore.Default.CurrentAccountPath, ProjectId = _projectId, AppName = GoogleCloudExtensionPackage.ApplicationName, AppVersion = GoogleCloudExtensionPackage.ApplicationVersion, }; var newCredentials = await GCloudWrapper.ResetWindowsCredentialsAsync( instanceName : _instance.Name, zoneName : _instance.GetZoneName(), userName : _userName, context : context); ResettingPassword = false; ShowPasswordWindow.PromptUser( userName: UserName, password: newCredentials.Password, instanceName: _instance.Name); } catch (GCloudException ex) { UserPromptUtils.ErrorPrompt( String.Format(Resources.ResetPasswordFailedPromptMessage, _instance.Name, ex.Message), Resources.ResetPasswordConfirmationPromptTitle); } finally { _owner.Close(); } }