зеркало из https://github.com/github/VisualStudio.git
Checking to see if the validators could be the problem
This commit is contained in:
Родитель
9e4d1e2d36
Коммит
b457c95c07
|
@ -109,7 +109,7 @@ namespace GitHub.SampleData
|
|||
set;
|
||||
}
|
||||
|
||||
public ReactivePropertyValidator<string> RepositoryNameValidator
|
||||
public ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> SafeRepositoryNameWarningValidator
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
|
@ -127,7 +127,7 @@ namespace GitHub.SampleData
|
|||
private set;
|
||||
}
|
||||
|
||||
public ReactivePropertyValidator<string> SafeRepositoryNameWarningValidator
|
||||
public ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> RepositoryNameValidator
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
|
|
|
@ -72,22 +72,21 @@ namespace GitHub.ViewModels.Dialog
|
|||
.IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters)
|
||||
.IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid);
|
||||
|
||||
var nonNullRepositoryName = this.WhenAny(
|
||||
x => x.RepositoryName,
|
||||
x => x.BaseRepositoryPath,
|
||||
(x, y) => x.Value)
|
||||
.WhereNotNull();
|
||||
var nameValidationConditions = this.WhenAny(
|
||||
model => model.RepositoryName,
|
||||
model => model.SelectedAccount,
|
||||
(repositoryName, account) => (repositoryName: repositoryName.Value, connection: (IConnection) null, account: account.Value))
|
||||
.Where(tuple => tuple.repositoryName != null);
|
||||
|
||||
RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName)
|
||||
.IfNullOrEmpty(Resources.RepositoryNameValidatorEmpty)
|
||||
.IfTrue(x => x.Length > 100, Resources.RepositoryNameValidatorTooLong)
|
||||
.IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists);
|
||||
RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nameValidationConditions)
|
||||
.IfTrue(tuple => string.IsNullOrEmpty(tuple.repositoryName), Resources.RepositoryNameValidatorEmpty)
|
||||
.IfTrue(tuple => tuple.repositoryName.Length > 100, Resources.RepositoryNameValidatorTooLong);
|
||||
|
||||
SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName)
|
||||
.Add(repoName =>
|
||||
SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nameValidationConditions)
|
||||
.Add(tuple =>
|
||||
{
|
||||
var parsedReference = GetSafeRepositoryName(repoName);
|
||||
return parsedReference != repoName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null;
|
||||
var parsedReference = GetSafeRepositoryName(tuple.repositoryName);
|
||||
return parsedReference != tuple.repositoryName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null;
|
||||
});
|
||||
|
||||
CreateRepository = InitializeCreateRepositoryCommand();
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace GitHub.ViewModels
|
|||
set { this.RaiseAndSetIfChanged(ref repositoryName, value); }
|
||||
}
|
||||
|
||||
public ReactivePropertyValidator<string> RepositoryNameValidator { get; protected set; }
|
||||
public ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> RepositoryNameValidator { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the repository after fixing it to be safe (dashes instead of spaces, etc)
|
||||
|
@ -62,7 +62,7 @@ namespace GitHub.ViewModels
|
|||
get { return safeRepositoryName.Value; }
|
||||
}
|
||||
|
||||
public ReactivePropertyValidator<string> SafeRepositoryNameWarningValidator { get; protected set; }
|
||||
public ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> SafeRepositoryNameWarningValidator { get; protected set; }
|
||||
|
||||
IAccount selectedAccount;
|
||||
/// <summary>
|
||||
|
|
|
@ -93,17 +93,17 @@ namespace GitHub.ViewModels.TeamExplorer
|
|||
if (!string.IsNullOrEmpty(defaultRepositoryName))
|
||||
RepositoryName = defaultRepositoryName;
|
||||
|
||||
this.WhenAny(x => x.SelectedConnection, x => x.SelectedAccount,
|
||||
(a,b) => true)
|
||||
.Where(x => RepositoryNameValidator.ValidationResult != null && SafeRepositoryNameWarningValidator.ValidationResult != null)
|
||||
.Subscribe(async _ =>
|
||||
{
|
||||
var name = RepositoryName;
|
||||
RepositoryName = null;
|
||||
await RepositoryNameValidator.ResetAsync();
|
||||
await SafeRepositoryNameWarningValidator.ResetAsync();
|
||||
RepositoryName = name;
|
||||
});
|
||||
// this.WhenAny(x => x.SelectedConnection, x => x.SelectedAccount,
|
||||
// (a,b) => true)
|
||||
// .Where(x => RepositoryNameValidator.ValidationResult != null && SafeRepositoryNameWarningValidator.ValidationResult != null)
|
||||
// .Subscribe(async _ =>
|
||||
// {
|
||||
// var name = RepositoryName;
|
||||
// RepositoryName = null;
|
||||
// await RepositoryNameValidator.ResetAsync();
|
||||
// await SafeRepositoryNameWarningValidator.ResetAsync();
|
||||
// RepositoryName = name;
|
||||
// });
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }
|
||||
|
@ -173,20 +173,22 @@ namespace GitHub.ViewModels.TeamExplorer
|
|||
|
||||
void InitializeValidation()
|
||||
{
|
||||
var nonNullRepositoryName = this.WhenAny(
|
||||
x => x.RepositoryName,
|
||||
x => x.Value)
|
||||
.WhereNotNull();
|
||||
var nameValidationConditions = this.WhenAny(model => model.RepositoryName,
|
||||
model => model.SelectedConnection,
|
||||
model => model.SelectedAccount,
|
||||
(repositoryName, connection, account) => (repositoryName: repositoryName.Value,
|
||||
connection: connection.Value, account: account.Value))
|
||||
.Where(tuple => tuple.repositoryName != null);
|
||||
|
||||
RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName)
|
||||
.IfNullOrEmpty(Resources.RepositoryNameValidatorEmpty)
|
||||
.IfTrue(x => x.Length > 100, Resources.RepositoryNameValidatorTooLong);
|
||||
RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nameValidationConditions)
|
||||
.IfTrue(tuple => string.IsNullOrEmpty(tuple.repositoryName), Resources.RepositoryNameValidatorEmpty)
|
||||
.IfTrue(tuple => tuple.repositoryName.Length > 100, Resources.RepositoryNameValidatorTooLong);
|
||||
|
||||
SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName)
|
||||
.Add(repoName =>
|
||||
SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nameValidationConditions)
|
||||
.Add(tuple =>
|
||||
{
|
||||
var parsedReference = GetSafeRepositoryName(repoName);
|
||||
return parsedReference != repoName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null;
|
||||
var parsedReference = GetSafeRepositoryName(tuple.repositoryName);
|
||||
return parsedReference != tuple.repositoryName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace GitHub.ViewModels
|
|||
/// dashes.
|
||||
/// </summary>
|
||||
string SafeRepositoryName { get; }
|
||||
ReactivePropertyValidator<string> RepositoryNameValidator { get; }
|
||||
ReactivePropertyValidator<string> SafeRepositoryNameWarningValidator { get; }
|
||||
ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> RepositoryNameValidator { get; }
|
||||
ReactivePropertyValidator<(string repositoryName, IConnection connection, IAccount account)> SafeRepositoryNameWarningValidator { get; }
|
||||
|
||||
string Description { get; set; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче