Skip to content

Commit

Permalink
Include the path in the report, so we can show where things are.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Feb 8, 2022
1 parent 93041c1 commit 76c8492
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected override IEnumerable<uSyncAction> ReportElement(XElement node, string
if (item != null)
{
return uSyncActionHelper<IDictionaryItem>
.ReportAction(ChangeType.NoChange, item.ItemKey, filename, item.Key, this.Alias, "Existing Item will not be overwritten")
.ReportAction(ChangeType.NoChange, item.ItemKey, node.GetPath(), filename, item.Key, this.Alias, "Existing Item will not be overwritten")
.AsEnumerableOfOne<uSyncAction>();
}
}
Expand Down
12 changes: 7 additions & 5 deletions uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ virtual public IEnumerable<uSyncAction> ImportElement(XElement node, string file
{
// blocked
return uSyncActionHelper<TObject>
.ReportAction(ChangeType.NoChange, node.GetAlias(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, "Change stopped by delegate event")
.ReportAction(ChangeType.NoChange, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, "Change stopped by delegate event")
.AsEnumerableOfOne();
}

Expand Down Expand Up @@ -741,7 +741,7 @@ virtual public IEnumerable<uSyncAction> Export(TObject item, string folder, Hand
if (_mutexService.FireItemStartingEvent(new uSyncExportingItemNotification<TObject>(item, (ISyncHandler)this)))
{
return uSyncActionHelper<TObject>
.ReportAction(ChangeType.NoChange, GetItemName(item), string.Empty, GetItemKey(item), this.Alias,
.ReportAction(ChangeType.NoChange, GetItemName(item), string.Empty, string.Empty, GetItemKey(item), this.Alias,
"Change stopped by delegate event")
.AsEnumerableOfOne();
}
Expand Down Expand Up @@ -968,7 +968,7 @@ public IEnumerable<uSyncAction> ReportElement(XElement node, string filename, Ha
if (_mutexService.FireItemStartingEvent(new uSyncReportingItemNotification(node)))
{
return uSyncActionHelper<TObject>
.ReportAction(ChangeType.NoChange, node.GetAlias(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias,
.ReportAction(ChangeType.NoChange, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias,
"Change stopped by delegate event")
.AsEnumerableOfOne();
}
Expand All @@ -983,7 +983,9 @@ public IEnumerable<uSyncAction> ReportElement(XElement node, string filename, Ha
var change = IsItemCurrent(node, serializerOptions);

var action = uSyncActionHelper<TObject>
.ReportAction(change.Change, node.GetAlias(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, "");
.ReportAction(change.Change, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, "");



action.Message = "";

Expand Down Expand Up @@ -1043,7 +1045,7 @@ protected IEnumerable<uSyncAction> ReportItem(string file, HandlerSettings confi
}
else
{
return uSyncActionHelper<TObject>.ReportAction(ChangeType.NoChange, node.GetAlias(), file, node.GetKey(),
return uSyncActionHelper<TObject>.ReportAction(ChangeType.NoChange, node.GetAlias(), node.GetPath(), file, node.GetKey(),
this.Alias, "Will not be imported (Based on config)")
.AsEnumerableOfOne<uSyncAction>();
}
Expand Down
15 changes: 15 additions & 0 deletions uSync.BackOffice/uSyncAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public struct uSyncAction

public string FileName { get; set; }
public string Name { get; set; }

/// <summary>
/// 9.2 a nice path for the thing (displayed).
/// </summary>
public string Path { get; set; }
public bool RequiresPostProcessing { get; set; }

/// <summary>
Expand Down Expand Up @@ -99,6 +104,7 @@ public static uSyncAction SetAction(SyncAttempt<T> attempt, string filename, Gui
return action;
}

[Obsolete("Reporting with the Path gives better feedback to the user.")]
public static uSyncAction ReportAction(ChangeType changeType, string name, string file, Guid key, string handlerAlias, string message)
{
return new uSyncAction(true, name, typeof(T).Name, changeType, message, null, file, handlerAlias)
Expand All @@ -107,6 +113,15 @@ public static uSyncAction ReportAction(ChangeType changeType, string name, strin
};
}

public static uSyncAction ReportAction(ChangeType changeType, string name, string path, string file, Guid key, string handlerAlias, string message)
{
return new uSyncAction(true, name, typeof(T).Name, changeType, message, null, file, handlerAlias)
{
key = key,
Path = path
};
}

public static uSyncAction ReportActionFail(string name, string message)
=> new uSyncAction(false, name, typeof(T).Name, ChangeType.Fail, message, null, string.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
{{vm.getTypeName(result.itemType)}}
</div>
<div class="umb-table-cell umb-table__name">
{{result.name}}
<div>
{{result.name}}
<div class="muted" ng-if="result.path.length > 0"> > {{result.itemType.substring(1)}}{{result.path}}</div>
</div>
</div>
<div class="umb-table-cell">
{{result.change}}
Expand Down
12 changes: 12 additions & 0 deletions uSync.Core/Extensions/XElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public static Guid GetParentKey(this XElement node)
: Guid.Empty;
}

/// <summary>
/// get the nice path name that is stored in the xml, gives us somethign to show
/// the user in terms of location.
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public static string GetPath(this XElement node)
{
return node.Element("Info")?
.Element("Path").ValueOrDefault(string.Empty) ?? string.Empty;
}

/// <summary>
/// does the xml represent an 'Empty' item (deleted/renamed/etc)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
{{vm.getTypeName(result.itemType)}}
</div>
<div class="umb-table-cell umb-table__name">
{{result.name}}
<div>
{{result.name}}
<div class="muted" ng-if="result.path.length > 0"> > {{result.itemType.substring(1)}}{{result.path}}</div>
</div>
</div>
<div class="umb-table-cell">
{{result.change}}
Expand Down

0 comments on commit 76c8492

Please sign in to comment.