Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
huzaifa-msft committed Oct 4, 2024
1 parent d01d4ae commit c2576d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
26 changes: 7 additions & 19 deletions src/AzureExtension/DevBox/DevBoxInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class DevBoxInstance : IComputeSystem, IComputeSystem2

public event TypedEventHandler<IComputeSystem, ComputeSystemState>? StateChanged;

private bool _hasPinOperationStarted;
private bool _isPinOperationInProgress;

public DevBoxInstance(
IDevBoxManagementService devBoxManagementService,
Expand Down Expand Up @@ -463,10 +463,7 @@ public ComputeSystemState GetState()

_log.Information($"Getting State for devBox: '{DisplayName}', Provisioning: {provisioningState}, Action: {actionState}, Power: {powerState}");

// When a pinning operation has occured the Dev Box state will be set to
// Saving. In the future both a 'Pinning' and a 'Unpinning' member should
// be added to the 'ComputeSystemOperations' SDK enumeration object.
if (_hasPinOperationStarted)
if (_isPinOperationInProgress)
{
return ComputeSystemState.Saving;
}
Expand Down Expand Up @@ -722,6 +719,9 @@ public IAsyncOperation<ComputeSystemOperationResult> DoPinActionAsync(string loc
{
return Task.Run(() =>
{
_isPinOperationInProgress = true;
StateChanged?.Invoke(this, GetState());
try
{
var errorString = ValidateWindowsAppAndItsParameters();
Expand Down Expand Up @@ -750,7 +750,7 @@ public IAsyncOperation<ComputeSystemOperationResult> DoPinActionAsync(string loc
exitCode = process.ExitCode;
if (exitCode == ExitCodeSuccess)
{
_hasPinOperationStarted = false;
_isPinOperationInProgress = false;
UpdateStateForUI();
return new ComputeSystemOperationResult();
}
Expand All @@ -762,7 +762,7 @@ public IAsyncOperation<ComputeSystemOperationResult> DoPinActionAsync(string loc
catch (Exception ex)
{
_log.Error(ex, $"Unable to perform the pinning action for DevBox: {DisplayName}");
_hasPinOperationStarted = false;
_isPinOperationInProgress = false;
UpdateStateForUI();
return new ComputeSystemOperationResult(ex, Constants.OperationsDefaultErrorMsg, "Pinning action failed");
}
Expand All @@ -771,33 +771,21 @@ public IAsyncOperation<ComputeSystemOperationResult> DoPinActionAsync(string loc

public IAsyncOperation<ComputeSystemOperationResult> PinToStartMenuAsync()
{
// Since there is no 'Pinning' state we'll say that the state is saving
_hasPinOperationStarted = true;
StateChanged?.Invoke(this, GetState());
return DoPinActionAsync("startMenu", "pin");
}

public IAsyncOperation<ComputeSystemOperationResult> UnpinFromStartMenuAsync()
{
// Since there is no 'Unpinning' state we'll say that the state is saving
_hasPinOperationStarted = true;
StateChanged?.Invoke(this, GetState());
return DoPinActionAsync("startMenu", "unpin");
}

public IAsyncOperation<ComputeSystemOperationResult> PinToTaskbarAsync()
{
// Since there is no 'Pinning' state we'll say that the state is saving
_hasPinOperationStarted = true;
StateChanged?.Invoke(this, GetState());
return DoPinActionAsync("taskbar", "pin");
}

public IAsyncOperation<ComputeSystemOperationResult> UnpinFromTaskbarAsync()
{
// Since there is no 'Unpinning' state we'll say that the state is saving
_hasPinOperationStarted = true;
StateChanged?.Invoke(this, GetState());
return DoPinActionAsync("taskbar", "unpin");
}

Expand Down
6 changes: 3 additions & 3 deletions src/AzureExtension/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,15 @@
<comment>Shown in Widget</comment>
</data>
<data name="DevBox_WAMError1" xml:space="preserve">
<value>The user account has been deleted from the tenant directory. Ensure that the account with which the user tries to sign in is registered in Microsoft Entra ID.</value>
<value>Error : 3399614467. The user account has been deleted from the tenant directory. Ensure that the account with which the user tries to sign in is registered in Microsoft Entra ID.</value>
<comment>Simplified error messages for WAM error 3399614467</comment>
</data>
<data name="DevBox_WAMError2" xml:space="preserve">
<value>Please refresh your multi-factor authentication. Account needs to be configured by the Microsoft Entra administrator with up-to-date MFA settings.</value>
<value>Error : 3399614476. Please refresh your multi-factor authentication. Account needs to be configured by the Microsoft Entra administrator with up-to-date MFA settings.</value>
<comment>Simplified error messages for WAM error 3399614476</comment>
</data>
<data name="DevBox_WAMErrorRefer" xml:space="preserve">
<value>For more details, please refer to https://learn.microsoft.com/en-us/entra/msal/dotnet/advanced/exceptions/wam-errors</value>
<comment>Redirect link to MS Learn page for additional info on WAM errors</comment>
<comment>{Locked="https://learn.microsoft.com/en-us/entra/msal/dotnet/advanced/exceptions/wam-errors"} Redirect link to MS Learn page for additional info on WAM errors</comment>
</data>
</root>

0 comments on commit c2576d7

Please sign in to comment.