Skip to content

Commit

Permalink
Fix comments and increase maximum tab width
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed May 20, 2016
1 parent ebb2bce commit 172f6f8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCore/Configuration/Configurations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class Configurations
/// <summary>
/// Default width of tab
/// </summary>
public static readonly int TabDefaultWidth = 200;
public static readonly int TabDefaultWidth = 250;
#endregion

#region Information Bubble
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ private void Save(object parameter)
if (!String.IsNullOrEmpty(Model.CurrentWorkspace.FileName))
{
// For read-only file, re-direct save to save-as
if (this.CurrentSpace.IsReadOnly)//DynamoUtilities.PathHelper.IsReadOnlyPath(this.CurrentSpace.FileName))
if (this.CurrentSpace.IsReadOnly)
ShowSaveDialogAndSaveResult(parameter);
else
SaveAs(Model.CurrentWorkspace.FileName);
Expand Down
17 changes: 9 additions & 8 deletions src/DynamoUtilities/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ public static Exception CreateFolderIfNotExist(string folderPath)
/// <summary>
/// Checks if the file path string is valid and file exist.
/// </summary>
/// <param name="folderPath"></param>
/// <param name="filePath">File path</param>
/// <returns></returns>
public static bool IsValidPath(string folderPath)
public static bool IsValidPath(string filePath)
{
return (!string.IsNullOrEmpty(folderPath) && (File.Exists(folderPath)));
return (!string.IsNullOrEmpty(filePath) && (File.Exists(filePath)));
}

/// <summary>
/// Check if user has readonly privilege to the folder path.
/// </summary>
/// <param name="folderPath">Folder path</param>
/// <param name="filePath">File path</param>
/// <returns></returns>
public static bool IsReadOnlyPath(string folderPath)
public static bool IsReadOnlyPath(string filePath)
{
if (IsValidPath(folderPath))
if (IsValidPath(filePath))
{
FileInfo Finfo = new FileInfo(folderPath);
FileInfo Finfo = new FileInfo(filePath);
// We mark the path read only when
// 1. file read-only
// 2. user does not have write access to the folder
return Finfo.IsReadOnly || !HasWritePermissionOnDir(folderPath);
return Finfo.IsReadOnly || !HasWritePermissionOnDir(Finfo.Directory.ToString());
}
else
return false;
Expand All @@ -71,6 +71,7 @@ public static bool HasWritePermissionOnDir(string folderPath)

foreach (FileSystemAccessRule rule in accessRules)
{
// When current rule does not contain setting related to WRITE, skip.
if ((FileSystemRights.Write & rule.FileSystemRights) != FileSystemRights.Write)
continue;

Expand Down
5 changes: 5 additions & 0 deletions test/DynamoCoreTests/CustomNodeWorkspaceOpening.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public void CanOpenWorkspaceWithMissingCustomNodeThenFixByOpeningNeededCustomNod
public void CanLoadReadOnlyNode()
{
// Open a read-only custom node
Assert.IsFalse(DynamoUtilities.PathHelper.IsReadOnlyPath(@"core\CustomNodes\add_Read_only.dyf"));

OpenTestFile(@"core\CustomNodes", "add_Read_only.dyf");
var nodeWorkspace = CurrentDynamoModel.Workspaces.FirstOrDefault(x => x is CustomNodeWorkspaceModel);
Assert.IsNotNull(nodeWorkspace);
Expand All @@ -50,6 +52,9 @@ public void CanLoadReadOnlyNode()
var homeWorkspace = CurrentDynamoModel.CurrentWorkspace as HomeWorkspaceModel;
Assert.NotNull(homeWorkspace);
homeWorkspace.Run();

var funcNode = homeWorkspace.Nodes.OfType<Function>().First();
Assert.IsTrue(funcNode.Definition.IsProxy);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 172f6f8

Please sign in to comment.