Skip to content

Commit 163e4d8

Browse files
committed
ux: validation tips for patch file in Apply popup
Signed-off-by: leo <longshuang@msn.cn>
1 parent c25a1c6 commit 163e4d8

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/ViewModels/Apply.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ public Models.ApplyWhiteSpaceMode SelectedWhiteSpaceMode
3131
public bool FromClipboard
3232
{
3333
get => _fromClipboard;
34-
set
35-
{
36-
if (SetProperty(ref _fromClipboard, value))
37-
ValidateProperty(_patchFile, nameof(PatchFile));
38-
}
34+
set => SetProperty(ref _fromClipboard, value);
3935
}
4036

4137
public bool ThreeWayMerge
@@ -61,10 +57,16 @@ public static ValidationResult ValidatePatchFile(string file, ValidationContext
6157
if (ctx.ObjectInstance is not Apply apply)
6258
return new ValidationResult("Invalid object instance!!!");
6359

64-
if (apply.FromClipboard || File.Exists(file))
60+
if (apply.FromClipboard)
6561
return ValidationResult.Success;
6662

67-
return new ValidationResult($"File '{file}' can NOT be found!!!");
63+
if (string.IsNullOrEmpty(file))
64+
return new ValidationResult("Please select a patch file!!!");
65+
66+
if (!File.Exists(file))
67+
return new ValidationResult($"File '{file}' can NOT be found!!!");
68+
69+
return ValidationResult.Success;
6870
}
6971

7072
public override async Task<bool> Sure()

0 commit comments

Comments
 (0)