Skip to content

Commit

Permalink
feat(DUI2): Cnx 9068 update dui2 to use new fe2 terminology (#3200)
Browse files Browse the repository at this point in the history
* updates all user-facing terminology to use FE2 conditionally on fe2 button or account

* changes config fe2 default to true, and uses config first for activity and streams

* sets useFE2 to true for stored configs

* removes all terminology switching code

* removes config fe2 setting and fe2 prop in some view models

* removes unnecessary string interpolations
  • Loading branch information
clairekuang authored Feb 28, 2024
1 parent 4d73b7e commit 8f9ea2d
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 220 deletions.
11 changes: 5 additions & 6 deletions DesktopUI2/DesktopUI2/Models/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ public static Config Load()
var oldConfig = ConfigStorage.GetObject("config");
var newConfig = ConfigStorage.GetObject("configDUI");

if (!string.IsNullOrEmpty(newConfig))
{
return JsonConvert.DeserializeObject<Config>(newConfig);
}
Config deserializedConfig = !string.IsNullOrWhiteSpace(newConfig)
? JsonConvert.DeserializeObject<Config>(newConfig)
: JsonConvert.DeserializeObject<Config>(oldConfig);

return JsonConvert.DeserializeObject<Config>(oldConfig);
return deserializedConfig;
}
catch (Exception e) { }
return new Config();
Expand All @@ -45,5 +44,5 @@ public class Config
public bool DarkTheme { set; get; }
public bool OneClickMode { set; get; } = true;
public bool ShowImportExportAlert { set; get; } = true;
public bool UseFe2 { set; get; } = false;
public bool UseFe2 { set; get; }
}
11 changes: 4 additions & 7 deletions DesktopUI2/DesktopUI2/Styles/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@

<Style Selector="Button.Send">

<Style.Resources>
<conv:Fe2TextValueConverter x:Key="Fe2TextValueConverter" />
</Style.Resources>
<Setter Property="Template">
<ControlTemplate>
<Grid Margin="4">
Expand All @@ -76,7 +73,7 @@
Command="{Binding SendCommand, FallbackValue={x:Null}}"
IsDefault="True"
IsEnabled="{Binding Progress.IsProgressing, Converter={x:Static BoolConverters.Not}, FallbackValue=True}"
ToolTip.Tip="{Binding UseFe2, Converter={StaticResource Fe2TextValueConverter}, ConverterParameter='Send to this stream'}">
ToolTip.Tip="Send to this project">
<Button.Content>
<icons:MaterialIcon
Name="send"
Expand Down Expand Up @@ -140,7 +137,7 @@
CornerRadius="40"
IsDefault="True"
IsEnabled="{Binding Progress.IsProgressing, Converter={x:Static BoolConverters.Not}, FallbackValue=True}"
ToolTip.Tip="{Binding UseFe2, Converter={StaticResource Fe2TextValueConverter}, ConverterParameter='Send to this stream'}">
ToolTip.Tip="Send to this project">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="12">

Expand Down Expand Up @@ -233,7 +230,7 @@
Command="{Binding ReceiveCommand}"
IsDefault="True"
IsEnabled="{Binding Progress.IsProgressing, Converter={x:Static BoolConverters.Not}}"
ToolTip.Tip="{Binding UseFe2, Converter={StaticResource Fe2TextValueConverter}, ConverterParameter='Receive from this stream'}">
ToolTip.Tip="Receive from this project">
<Button.Content>
<icons:MaterialIcon
Name="receive"
Expand Down Expand Up @@ -301,7 +298,7 @@
CornerRadius="40"
IsDefault="True"
IsEnabled="{Binding Progress.IsProgressing, Converter={x:Static BoolConverters.Not}, FallbackValue=True}"
ToolTip.Tip="{Binding UseFe2, Converter={StaticResource Fe2TextValueConverter}, ConverterParameter='Receive from this stream'}">
ToolTip.Tip="Receive from this project">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="12">

Expand Down
4 changes: 2 additions & 2 deletions DesktopUI2/DesktopUI2/Styles/Playground.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<TextBlock
Margin="0,0,0,5"
Classes="Medium"
Text="Sample stream"
Text="Sample project"
TextTrimming="CharacterEllipsis" />
<!-- SENDER -->
<Grid Grid.Row="1" ColumnDefinitions="auto,auto,auto,*">
Expand Down Expand Up @@ -101,7 +101,7 @@
Margin="0,8,0,0"
Classes="Small"
Foreground="Gray"
Watermark="Commit message" />
Watermark="Version message" />
<m:ColorZone
Margin="0,10,0,0"
CornerRadius="25"
Expand Down
2 changes: 1 addition & 1 deletion DesktopUI2/DesktopUI2/ViewModels/ActivityViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ActivityViewModel(ActivityItem item, Client client)
Margin = new Thickness(10, 10, 10, 0);
Icon = "Pencil";
Align = HorizontalAlignment.Center;
Message = $"created this stream{Formatting.TimeAgo(item.time)}";
Message = $"created this project{Formatting.TimeAgo(item.time)}";
break;
}

Expand Down
13 changes: 1 addition & 12 deletions DesktopUI2/DesktopUI2/ViewModels/DialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,4 @@

namespace DesktopUI2.ViewModels;

public class DialogViewModel : ReactiveObject
{
//UI Binding
public bool UseFe2
{
get
{
var config = ConfigManager.Load();
return config.UseFe2;
}
}
}
public class DialogViewModel : ReactiveObject { }
48 changes: 11 additions & 37 deletions DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private async Task GetStreams()
MainUserControl.NotificationManager.Show(
new PopUpNotificationViewModel
{
Title = "⚠️ Could not get streams",
Title = "⚠️ Could not get projects",
Message =
$"With account {account.Account.userInfo.email} on server {account.Account.serverInfo.url}\n\n",
Type = NotificationType.Error
Expand Down Expand Up @@ -420,7 +420,7 @@ private void Client_OnUserStreamAdded(object sender, StreamInfo e)
MainUserControl.NotificationManager.Show(
new PopUpNotificationViewModel
{
Title = "🥳 You have a new Stream!",
Title = "🥳 You have a new project!",
Message = e.sharedBy == null ? $"You have created '{e.name}'." : $"'{e.name}' has been shared with you."
}
);
Expand Down Expand Up @@ -460,7 +460,7 @@ private void Client_OnUserStreamRemoved(object sender, StreamInfo e)
MainUserControl.NotificationManager.Show(
new PopUpNotificationViewModel
{
Title = "❌ Stream removed!",
Title = "❌ Project removed!",
Message = $"'{streamName}' has been deleted or un-shared."
}
);
Expand Down Expand Up @@ -535,7 +535,7 @@ private void GenerateMenuItems()
new MenuItemViewModel(LaunchManagerCommand, "Manage accounts in Manager", MaterialIconKind.AccountCog)
);

menu.Items.Add(new MenuItemViewModel(RefreshCommand, "Refresh streams & accounts", MaterialIconKind.Refresh));
menu.Items.Add(new MenuItemViewModel(RefreshCommand, "Refresh projects & accounts", MaterialIconKind.Refresh));
menu.Items.Add(
new MenuItemViewModel(ToggleDarkThemeCommand, "Toggle dark/light theme", MaterialIconKind.SunMoonStars)
);
Expand Down Expand Up @@ -760,7 +760,7 @@ private Tuple<bool, string> ValidateUrl(string url)
}
catch
{
return new Tuple<bool, string>(false, "URL is not a Stream.");
return new Tuple<bool, string>(false, "URL is not a project.");
}

return new Tuple<bool, string>(true, "");
Expand All @@ -770,7 +770,7 @@ private Tuple<bool, string> ValidateName(string name)
{
if (string.IsNullOrEmpty(name))
{
return new Tuple<bool, string>(false, "Streams need a name too!");
return new Tuple<bool, string>(false, "Projects need a name too!");
}

if (name.Trim().Length < 3)
Expand Down Expand Up @@ -801,8 +801,8 @@ private async void OpenStreamCommand(object streamAccountWrapper)
if (!await streamState.Client.IsStreamAccessible(streamState.StreamId).ConfigureAwait(true))
{
Dialogs.ShowDialog(
"Stream not found",
"Please ensure the stream exists and that you have access to it.",
"Project not found",
"Please ensure the project exists and that you have access to it.",
DialogIconKind.Error
);
return;
Expand All @@ -829,8 +829,8 @@ private async void OpenSavedStreamCommand(object streamViewModel)
if (!await svm.Client.IsStreamAccessible(svm.Stream.id).ConfigureAwait(true))
{
Dialogs.ShowDialog(
"Stream not found",
"Please ensure the stream exists and that you have access to it.",
"Project not found",
"Please ensure the project exists and that you have access to it.",
DialogIconKind.Error
);
return;
Expand Down Expand Up @@ -861,17 +861,6 @@ public void ToggleDarkThemeCommand()
ConfigManager.Save(config);
}

public void ToggleFe2Command()
{
Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary<string, object> { { "name", "Toggle Fe2" } });

var config = ConfigManager.Load();
config.UseFe2 = !config.UseFe2;
ConfigManager.Save(config);

this.RaisePropertyChanged(nameof(UseFe2));
}

public void RefreshCommand()
{
Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary<string, object> { { "name", "Refresh" } });
Expand Down Expand Up @@ -1014,28 +1003,13 @@ public List<StreamAccountWrapper> FilteredStreams
public bool HasSavedStreams => SavedStreams != null && SavedStreams.Any();
public bool HasStreams => FilteredStreams != null && FilteredStreams.Any();

//UI Binding
public bool UseFe2
{
get
{
var config = ConfigManager.Load();
return config.UseFe2;
}
}

public string StreamsText
{
get
{
if (string.IsNullOrEmpty(SearchQuery))
{
if (UseFe2)
{
return "ALL YOUR PROJECTS:";
}

return "ALL YOUR STREAMS:";
return "ALL YOUR PROJECTS:";
}

if (SearchQuery.Length <= 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ private void UpdateSelection(MappingSelectionInfo info)
}
else if (!AvailableRevitTypes.Any())
{
PromptMsg = "The selected branch does not contain any Revit types, try changing mapping data source.";
PromptMsg = "The selected model does not contain any Revit types, try changing mapping data source.";
}
else if (!AvailableRevitLevels.Any())
{
PromptMsg = "The selected branch does not contain any Revit levels, try changing mapping data source.";
PromptMsg = "The selected model does not contain any Revit levels, try changing mapping data source.";
}
else
{
Expand Down Expand Up @@ -244,7 +244,7 @@ private async Task<Base> GetCommit()
if (commit == null)
{
throw new Exception(
$"Branch {StreamSelector.SelectedBranch.name} in stream {StreamSelector.SelectedStream.Stream.id} has no commits"
$"Model {StreamSelector.SelectedBranch.name} in project {StreamSelector.SelectedStream.Stream.id} has no versions"
);
}

Expand Down Expand Up @@ -293,7 +293,7 @@ private void GetTypesAndLevels(Base model)
() =>
Dialogs.ShowMapperDialog(
"No types available",
"The selected stream does not contain any Revit types.\nMake sure to send Project Information > Families & Types from Revit\nusing the latest version of the connector.\n\n👉 And no worries, you can keep using Speckle Mapper with default types!",
"The selected project does not contain any Revit types.\nMake sure to send Project Information > Families & Types from Revit\nusing the latest version of the connector.\n\n👉 And no worries, you can keep using Speckle Mapper with default types!",
Material.Dialog.Icons.DialogIconKind.Info
)
);
Expand All @@ -314,7 +314,7 @@ private void GetTypesAndLevels(Base model)
() =>
Dialogs.ShowMapperDialog(
"No levels available",
"The selected stream does not contain any Revit levels.\nMake sure to send Project Information > Levels from Revit\nusing the latest version of the connector.",
"The selected project does not contain any Revit levels.\nMake sure to send Project Information > Levels from Revit\nusing the latest version of the connector.",
Material.Dialog.Icons.DialogIconKind.Info
)
);
Expand Down
4 changes: 2 additions & 2 deletions DesktopUI2/DesktopUI2/ViewModels/OneClickViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public OneClickViewModel(IScreen screen)
}
catch (Exception ex)
{
SpeckleLog.Logger.Fatal(ex, "Could not initialize one click screen {excep tionMessage}", ex.Message);
SpeckleLog.Logger.Fatal(ex, "Could not initialize one click screen {exceptionMessage}", ex.Message);
}
}

Expand Down Expand Up @@ -186,7 +186,7 @@ private async Task<StreamState> GetOrCreateStreamState()
.StreamCreate(
new StreamCreateInput
{
description = "Autogenerated Stream for QuickSend",
description = "Autogenerated project for QuickSend",
name = _fileName,
isPublic = false
}
Expand Down
18 changes: 6 additions & 12 deletions DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ private async Task GetCommits()
new Commit
{
id = ConnectorHelpers.LatestCommitString,
message = "Always receive the latest commit sent to this branch."
message = "Always receive the latest version sent to this model."
}
);
Commits = branch.commits.items;
Expand Down Expand Up @@ -653,12 +653,6 @@ public string LastUsed
}
}

//UI Binding
public bool UseFe2
{
get { return Client.Account.serverInfo.frontend2; }
}

public DateTime? LastUsedTime
{
get => StreamState.LastUsed;
Expand Down Expand Up @@ -814,7 +808,7 @@ public List<BranchViewModel> BranchesViewModel

if (!IsReceiver)
{
_branchesViewModel.Add(new BranchViewModel(new Branch { name = "Add New Branch" }, "Plus"));
_branchesViewModel.Add(new BranchViewModel(new Branch { name = "Add New Model" }, "Plus"));
}

return _branchesViewModel;
Expand Down Expand Up @@ -1233,7 +1227,7 @@ private async void Client_OnCommitCreated(object sender, CommitInfo info)
new PopUpNotificationViewModel
{
Title = $"🆕 {authorName} sent to {Stream.name}/{info.branchName}'",
Message = openOnline ? "Click to view it online" : "Click open the stream",
Message = openOnline ? "Click to view it online" : "Click open the project",
OnClick = () =>
{
//if in stream edit open online
Expand Down Expand Up @@ -1672,7 +1666,7 @@ public static void HandleCommandException(
notificationViewModel = new PopUpNotificationViewModel
{
Title = $"😞 {commandPrettyName} Failed!",
Message = $"Failed to fetch stream data from server. Reason: {ex.Message}",
Message = $"Failed to fetch project data from server. Reason: {ex.Message}",
Type = NotificationType.Error
};
break;
Expand Down Expand Up @@ -1773,8 +1767,8 @@ private void SaveCommand()
MainUserControl.NotificationManager.Show(
new PopUpNotificationViewModel
{
Title = "💾 Stream Saved",
Message = "This stream has been saved to this file",
Title = "💾 Project Saved",
Message = "This project has been saved to this file",
Type = NotificationType.Success
}
);
Expand Down
Loading

0 comments on commit 8f9ea2d

Please sign in to comment.