Skip to content

Commit

Permalink
Add ability to hide IsUsageReportingApproved and (#10217)
Browse files Browse the repository at this point in the history
* Add ability to hide IsUsageReportingApproved and IsAnalyticsReportingApproved from Dynamo UI

* Move HideReportOptions to DynamoViewModel

* Move HideReportOptions to StartConfiguration

* Make HideReportOptions public and readonly

So it can't be modified outside the constructor but still accessible by WPF
  • Loading branch information
DmytroMuravskyi authored and QilongTang committed Dec 13, 2019
1 parent 56e292c commit 9d6f504
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ public bool BackgroundPreviewActive
{
get { return BackgroundPreviewViewModel.Active; }
}


public bool HideReportOptions { get; }

#endregion

public struct StartConfiguration
Expand All @@ -485,6 +487,11 @@ public struct StartConfiguration
/// at startup in order to be used to pass in host specific resources to DynamoViewModel
/// </summary>
public IBrandingResourceProvider BrandingResourceProvider { get; set; }

/// <summary>
/// If true, Analytics and Usage options are hidden from UI
/// </summary>
public bool HideReportOptions { get; set; }
}

public static DynamoViewModel Start(StartConfiguration startConfiguration = new StartConfiguration())
Expand Down Expand Up @@ -532,6 +539,7 @@ protected DynamoViewModel(StartConfiguration startConfiguration)
this.model.CommandStarting += OnModelCommandStarting;
this.model.CommandCompleted += OnModelCommandCompleted;

this.HideReportOptions = startConfiguration.HideReportOptions;
UsageReportingManager.Instance.InitializeCore(this);
this.WatchHandler = startConfiguration.WatchHandler;
var pmExtension = model.GetPackageManagerExtension();
Expand Down
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,15 @@
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}"
IsChecked="{Binding Path=IsAnalyticsReportingApproved, Mode=OneWay, Source={x:Static service:UsageReportingManager.Instance} }"
ToolTip="{x:Static p:Resources.DynamoViewSettingMenuEnableSummaryReportingTooltip}"
Visibility="{Binding HideReportOptions, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}"
Focusable="False"/>
<MenuItem Header="{x:Static p:Resources.DynamoViewSettingMenuEnableDataReporting}"
Name="ToggleIsUsageReportingApprovedCommand"
Command="{Binding Path=ToggleIsUsageReportingApprovedCommand, Source={x:Static service:UsageReportingManager.Instance} }"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}"
IsChecked="{Binding Path=IsUsageReportingApproved, Mode=OneWay, Source={x:Static service:UsageReportingManager.Instance} }"
ToolTip="{x:Static p:Resources.DynamoViewSettingMenuEnableDataReportingTooltip}"
Visibility="{Binding HideReportOptions, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}"
Focusable="False" />
<Separator />
<MenuItem Focusable="False"
Expand Down
8 changes: 6 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,12 @@ private void DynamoView_Loaded(object sender, EventArgs e)

//Backing up IsFirstRun to determine whether to show Gallery
var isFirstRun = dynamoViewModel.Model.PreferenceSettings.IsFirstRun;
// If first run, Collect Info Prompt will appear
UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider);

if (!dynamoViewModel.HideReportOptions)
{
// If first run, Collect Info Prompt will appear
UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider);
}

WorkspaceTabs.SelectedIndex = 0;
dynamoViewModel = (DataContext as DynamoViewModel);
Expand Down

0 comments on commit 9d6f504

Please sign in to comment.