Skip to content

Commit

Permalink
Merge pull request #444 from UiPath/fix/FTP_viewmodel_improvements
Browse files Browse the repository at this point in the history
FTP: Fixed viewmodel issues (72176, 72177, 72178)
  • Loading branch information
alexandru-petre authored Oct 18, 2024
2 parents 0c9e7d3 + 7c16062 commit 801e759
Show file tree
Hide file tree
Showing 35 changed files with 428 additions and 688 deletions.
8 changes: 8 additions & 0 deletions Activities/Activities.Cryptography.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.build.targets = Directory.build.targets
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared.Activities", "Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.shproj", "{4E20C041-2F59-408E-ADB3-0BCFAB48DE61}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared", "Shared\UiPath.Shared\UiPath.Shared.shproj", "{2E040804-8ED9-4FB8-BB8A-4A38479E2A9E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -56,7 +60,11 @@ Global
SolutionGuid = {5AC55779-EA32-41AD-BAAD-1808F8A412CB}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\UiPath.Shared\UiPath.Shared.projitems*{2629567d-4737-4a1b-9876-f00c948270e3}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{2e040804-8ed9-4fb8-bb8a-4a38479e2a9e}*SharedItemsImports = 13
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{4e20c041-2f59-408e-adb3-0bcfab48de61}*SharedItemsImports = 13
Shared\UiPath.Shared\UiPath.Shared.projitems*{92e8345e-2ca1-439d-926d-d979893840f5}*SharedItemsImports = 5
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{f6a198c8-1940-4cae-a0d3-d4e707f3b0a3}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{f6a198c8-1940-4cae-a0d3-d4e707f3b0a3}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
17 changes: 12 additions & 5 deletions Activities/Activities.FTP.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiPath.FTP", "FTP\UiPath.FTP\UiPath.FTP.csproj", "{E9137637-B657-4C22-85A5-2E30ADF82566}"
EndProject
Expand All @@ -19,10 +19,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
FTP\FTP.build.props = FTP\FTP.build.props
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared.Activities", "Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.shproj", "{4E20C041-2F59-408E-ADB3-0BCFAB48DE61}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared", "Shared\UiPath.Shared\UiPath.Shared.shproj", "{2E040804-8ED9-4FB8-BB8A-4A38479E2A9E}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -55,4 +56,10 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5AC55779-EA32-41AD-BAAD-1808F8A412CB}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\UiPath.Shared\UiPath.Shared.projitems*{2e040804-8ed9-4fb8-bb8a-4a38479e2a9e}*SharedItemsImports = 13
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{4e20c041-2f59-408e-adb3-0bcfab48de61}*SharedItemsImports = 13
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
34 changes: 20 additions & 14 deletions Activities/Activities.Python.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiPath.Python", "Python\UiPath.Python\UiPath.Python.csproj", "{A1783EAB-5BAF-49F1-8372-B467B57063CC}"
EndProject
Expand Down Expand Up @@ -29,19 +29,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Python\Python.build.props = Python\Python.build.props
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared", "Shared\UiPath.Shared\UiPath.Shared.shproj", "{2E040804-8ED9-4FB8-BB8A-4A38479E2A9E}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{0fbf5f7e-2ae4-4f4a-84cb-26b3a9e3119c}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{0fbf5f7e-2ae4-4f4a-84cb-26b3a9e3119c}*SharedItemsImports = 5
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{25ff4279-6ee6-441e-9d40-a40db81cb57c}*SharedItemsImports = 13
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{a1783eab-5baf-49f1-8372-b467b57063cc}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{a1783eab-5baf-49f1-8372-b467b57063cc}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{a6a27646-4889-4f95-a0df-dd78d287388f}*SharedItemsImports = 13
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{bcba78df-1513-44d3-83b3-37655a7f3887}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{bcba78df-1513-44d3-83b3-37655a7f3887}*SharedItemsImports = 5
Shared\UiPath.Shared.Activities.Design\UiPath.Shared.Activities.Design.projitems*{e116c90e-c6a0-4292-b1ff-e0746ffe95d5}*SharedItemsImports = 5
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{e270608b-ba9e-4972-a18e-34b93e6552b4}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -86,4 +76,20 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5AC55779-EA32-41AD-BAAD-1808F8A412CB}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{0fbf5f7e-2ae4-4f4a-84cb-26b3a9e3119c}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{0fbf5f7e-2ae4-4f4a-84cb-26b3a9e3119c}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{0fbf5f7e-2ae4-4f4a-84cb-26b3a9e3119c}*SharedItemsImports = 5
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{25ff4279-6ee6-441e-9d40-a40db81cb57c}*SharedItemsImports = 13
Shared\UiPath.Shared\UiPath.Shared.projitems*{2e040804-8ed9-4fb8-bb8a-4a38479e2a9e}*SharedItemsImports = 13
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{a1783eab-5baf-49f1-8372-b467b57063cc}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{a1783eab-5baf-49f1-8372-b467b57063cc}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{a6a27646-4889-4f95-a0df-dd78d287388f}*SharedItemsImports = 13
Python\UiPath.Python.Host.Shared\UiPath.Python.Host.Shared.projitems*{bcba78df-1513-44d3-83b3-37655a7f3887}*SharedItemsImports = 5
Shared\UiPath.Shared.Service\UiPath.Shared.Service.projitems*{bcba78df-1513-44d3-83b3-37655a7f3887}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{bcba78df-1513-44d3-83b3-37655a7f3887}*SharedItemsImports = 5
Shared\UiPath.Shared.Activities.Design\UiPath.Shared.Activities.Design.projitems*{e116c90e-c6a0-4292-b1ff-e0746ffe95d5}*SharedItemsImports = 5
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{e270608b-ba9e-4972-a18e-34b93e6552b4}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{e270608b-ba9e-4972-a18e-34b93e6552b4}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
<Import Project="..\..\Shared\UiPath.Shared\UiPath.Shared.projitems" Label="Shared" />
<Import Project="..\Cryptography.build.props" />
<PropertyGroup>
<TargetFrameworks>net461;net6.0-windows</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@
<Compile Condition="'$(TargetFramework)' != 'net6.0'" Remove="NetCore/**" />
</ItemGroup>
<Import Project="..\..\Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems" Label="Shared" />
<Import Project="..\..\Shared\UiPath.Shared\UiPath.Shared.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UiPath.FTP.Activities.Properties;
using UiPath.FTP.Activities.Properties;

namespace UiPath.FTP.Activities.Design.Properties
{
Expand Down
62 changes: 0 additions & 62 deletions Activities/FTP/UiPath.FTP.Activities/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,4 @@ public override string Description
}
}
}

public class LocalizedEnum
{
public string Name { get; private set; }
public Enum Value { get; private set; }

protected internal LocalizedEnum(string name, Enum value)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

Name = name;
Value = value;
}

/// <summary>
/// Method that returns a localized enum with the description as a name, if the description exists.
/// </summary>
/// <param name="enumType"></param>
/// <param name="value"></param>
/// <returns></returns>
public static LocalizedEnum GetLocalizedValue(Type enumType, object value)
{
var name = enumType.GetEnumName(value);
var field = enumType.GetField(name);
DescriptionAttribute descriptionAttribute = field?.GetCustomAttribute<DescriptionAttribute>();

return new LocalizedEnum(descriptionAttribute?.Description ?? name, value as Enum);
}
}

public class LocalizedEnum<T> : LocalizedEnum
{
protected LocalizedEnum(string name, Enum value) : base(name, value)
{
}

public static List<LocalizedEnum> GetLocalizedValues()
{
List<LocalizedEnum> localizedValues = new List<LocalizedEnum>();

Type enumType = typeof(T);
Array enumValues = Enum.GetValues(enumType);

foreach (Enum value in enumValues)
{
string name = enumType.GetEnumName(value);
FieldInfo field = enumType.GetField(name);
DescriptionAttribute descriptionAttribute = field?.GetCustomAttribute<DescriptionAttribute>();

localizedValues.Add(new LocalizedEnum(descriptionAttribute?.Description ?? name, value));
}

return localizedValues;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UiPath.Shared;

//NOTE: This class was taken from Activities repo
namespace UiPath.FTP.Activities.NetCore
Expand Down Expand Up @@ -90,7 +91,7 @@ public void BuildAndInsertMenuActions()
};
foreach (var propertyInfo in _properties.Where(pi => pi != targetPropertyInfo))
{


propertyInfo.Property.AddMenuAction(menuAction);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
using System.Activities.DesignViewModels;
using System.Activities.ViewModels;
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Removes a specified file from an FTP server.
/// </summary>
[ViewModelClass(typeof(DeleteViewModel))]
public partial class Delete
{
}
}
using UiPath.FTP.Activities.Properties;

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,24 +17,12 @@ public DeleteViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the file that is to be removed from the FTP server.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();

RemotePath.IsPrincipal = true;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
PersistValuesChangedDuringInit();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
using System.Activities.DesignViewModels;
using System.Activities.ViewModels;
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Checks whether a certain directory exists on an FTP server.
/// </summary>
[ViewModelClass(typeof(DirectoryExistsViewModel))]
public partial class DirectoryExists
{
}
}

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,34 +16,22 @@ public DirectoryExistsViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the FTP directory in which to check whether the indicated directory exists.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

/// <summary>
/// A boolean variable that states whether the indicated directory was found or not.
/// </summary>
public DesignOutArgument<bool> Exists { get; set; } = new DesignOutArgument<bool>();
public DesignOutArgument<bool> Exists { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();
PersistValuesChangedDuringInit();

int propertyOrderIndex = 1;

RemotePath.IsPrincipal = true;
RemotePath.OrderIndex = propertyOrderIndex++;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };

Exists.IsPrincipal = false;
Exists.OrderIndex = propertyOrderIndex++;
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
Exists.OrderIndex = propertyOrderIndex;
}
}
}
Loading

0 comments on commit 801e759

Please sign in to comment.