Example #1
0
        public DotNetNotInstalledVm(IInstalledSdkFollower mvm, INavigateTo navigate)
        {
            _InError = mvm.DotNetSdkInstalled
                       .Select(x => !x.Acceptable)
                       .ToGuiProperty(this, nameof(InError), deferSubscription: true);

            _CustomDisplayString = mvm.DotNetSdkInstalled
                                   .Select(x =>
            {
                if (x.Acceptable)
                {
                    return(string.Empty);
                }
                if (x.Version.IsNullOrWhitespace())
                {
                    return("While the app can open with the DotNet Runtime, it also needs the SDK to be able to function.");
                }
                else
                {
                    return($"While an SDK was found, it was not an acceptable version.  You had {x.Version}, but it must be at least {ParseNugetVersionString.MinVersion}");
                }
            })
                                   .ToGuiProperty(this, nameof(CustomDisplayString), string.Empty, deferSubscription: true);

            DownloadCommand = ReactiveCommand.Create(
                () =>
            {
                navigate.Navigate("https://dotnet.microsoft.com/download");
            });

            _ErrorString = this.WhenAnyValue(x => x.InError)
                           .Select(x => x ? $"DotNet SDK: Desired SDK not found" : null)
                           .ToGuiProperty(this, nameof(ErrorString), default, deferSubscription: true);
 public PatcherStoreListingVm(
     GitPatcherInitVm gitInit,
     PatcherListing listing,
     RepositoryListing repositoryListing,
     INavigateTo navigate)
 {
     Repository = new RepositoryStoreListingVm(repositoryListing);
     Raw        = listing;
     try
     {
         Name = Raw.Customization?.Nickname ?? Path.GetFileName(Raw.ProjectPath).TrimEnd(".csproj");
     }
     catch (Exception)
     {
         Name = "Error";
     }
     _isSelected = gitInit.WhenAnyValue(x => x.SelectedPatcher)
                   .Select(x => x == this)
                   .ToGuiProperty(this, nameof(IsSelected));
     OpenWebsite = ReactiveCommand.Create(() => navigate.Navigate(RepoPath));
     AddCommand  = ReactiveCommand.CreateFromTask(async() =>
     {
         await gitInit.AddStorePatcher(this);
     });
 }
Example #3
0
 /// <summary>
 /// Setup routine called just a few times at app startup. Tells the navigator which
 /// displays are which.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="navigateTo"></param>
 public void AddNavigateTo(NavigateControlId id, INavigateTo navigateTo)
 {
     if (NavigateTos.ContainsKey(id))
     {
         NavigateTos[id] = navigateTo;
     }
     else
     {
         NavigateTos.Add(id, navigateTo);
     }
 }
Example #4
0
 public ProfileExporter(
     INavigateTo navigate,
     IRetrieveSaveSettings retrieveSaveSettings,
     IPipelineSettingsPath pipelinePaths,
     IGuiSettingsPath guiPaths)
 {
     Navigate             = navigate;
     RetrieveSaveSettings = retrieveSaveSettings;
     PipelinePaths        = pipelinePaths;
     GuiPaths             = guiPaths;
 }
Example #5
0
        public GitPatcherVm(
            IGithubPatcherIdentifier ident,
            IPatcherNameVm nameVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            ISelectedProjectInputVm selectedProjectInput,
            IGitRemoteRepoPathInputVm remoteRepoPathInputVm,
            INavigateTo navigate,
            IAvailableTags availableTags,
            ILockToCurrentVersioning lockToCurrentVersioning,
            IAvailableProjects availableProjects,
            ICompilationProvider compilationProvider,
            IBaseRepoDirectoryProvider baseRepoDir,
            IGitStatusDisplay gitStatusDisplay,
            IDriverRepoDirectoryProvider driverRepoDirectoryProvider,
            IRunnerRepoDirectoryProvider runnerRepoDirectoryProvider,
            IGetRepoPathValidity getRepoPathValidity,
            IRepoClonesValidStateVm repoClonesValid,
            INugetDiffProviderVm nugetDiff,
            IGitPatcherState state,
            ILogger logger,
            IRunnableStateProvider runnableStateProvider,
            ILifetimeScope scope,
            IGitPatcherTargetingVm patcherTargeting,
            ICheckoutInputProvider checkoutInputProvider,
            IGitNugetTargetingVm nugetTargetingVm,
            IUpdateAllCommand updateAllCommand,
            IAttemptedCheckout attemptedCheckout,
            IPatcherIdProvider idProvider,
            ICopyOverExtraData copyOverExtraData,
            PatcherRenameActionVm.Factory renameFactory,
            DeleteUserData deleteUserData,
            PatcherUserSettingsVm.Factory settingsVmFactory,
            GithubPatcherSettings?settings = null)
            : base(
                scope, nameVm, selPatcher,
                confirmation, idProvider, renameFactory, settings)
        {
            _logger              = logger;
            _copyOverExtraData   = copyOverExtraData;
            SelectedProjectInput = selectedProjectInput;
            RemoteRepoPathInput  = remoteRepoPathInputVm;
            Locking              = lockToCurrentVersioning;
            RepoClonesValid      = repoClonesValid;
            NugetDiff            = nugetDiff;
            PatcherTargeting     = patcherTargeting;
            NugetTargeting       = nugetTargetingVm;
            UpdateAllCommand     = updateAllCommand;

            DeleteUserDataCommand = ReactiveCommand.Create(deleteUserData.Delete);

            ID = ident.Id;

            CopyInSettings(settings);

            LocalDriverRepoDirectory = driverRepoDirectoryProvider.Path.Path;
            LocalRunnerRepoDirectory = runnerRepoDirectoryProvider.Path.Path;

            _repoValidity = getRepoPathValidity.RepoPath
                            .Select(r => r.RunnableState)
                            .ToGuiProperty(this, nameof(RepoValidity), deferSubscription: true);

            AvailableProjects = availableProjects.Projects;

            AvailableTags = availableTags.Tags;

            _attemptedCheckout = checkoutInputProvider.Input
                                 .Select(attemptedCheckout.Attempted)
                                 .ToGuiProperty(this, nameof(AttemptedCheckout), deferSubscription: true);

            _runnableData = runnableStateProvider.WhenAnyValue(x => x.State.Item)
                            .ToGuiProperty(this, nameof(RunnableData), default(RunnerRepoInfo?), deferSubscription: true);

            _state = state.State
                     .ToGuiProperty(this, nameof(State), new ConfigurationState(ErrorResponse.Fail("Evaluating"))
            {
                IsHaltingError = false
            }, deferSubscription: true);

            OpenGitPageCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.RepoValidity)
                .Select(x => x.Succeeded),
                execute: () => navigate.Navigate(RemoteRepoPathInput.RemoteRepoPath));

            OpenGitPageToVersionCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyFallback(x => x.RunnableData)
                .Select(x => x != null),
                execute: () =>
            {
                try
                {
                    if (RunnableData is not {
                    } runnable)
                    {
                        return;
                    }
                    navigate.Navigate(Path.Combine(RemoteRepoPathInput.RemoteRepoPath, "tree", runnable.Target.Target));
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Error opening Git webpage");
                }
            });

            NavigateToInternalFilesCommand = ReactiveCommand.Create(() => navigate.Navigate(baseRepoDir.Path));

            PatcherSettings = settingsVmFactory(
                false,
                compilationProvider.State.Select(c =>
            {
                if (c.RunnableState.Failed)
                {
                    return(new PatcherUserSettingsVm.Inputs(c.RunnableState.BubbleFailure <FilePath>(), null, default));
                }
                return(new PatcherUserSettingsVm.Inputs(GetResponse <FilePath> .Succeed(c.Item.ProjPath), c.Item.TargetVersions.Synthesis, c.Item.MetaPath));
            })
                .DistinctUntilChanged())
                              .DisposeWith(this);

            _statusDisplay = gitStatusDisplay.StatusDisplay
                             .ToGuiProperty(this, nameof(StatusDisplay),
                                            new StatusRecord(
                                                Text: "Initializing",
                                                Processing: false,
                                                Blocking: false,
                                                Command: null), deferSubscription: true);

            SetToLastSuccessfulRunCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.LastSuccessfulRun)
                .Select(x =>
            {
                return(x != null &&
                       !x.TargetRepo.IsNullOrWhitespace() &&
                       !x.ProjectSubpath.IsNullOrWhitespace() &&
                       !x.Commit.IsNullOrWhitespace() &&
                       !x.MutagenVersion.IsNullOrWhitespace() &&
                       !x.SynthesisVersion.IsNullOrWhitespace());
            }),
                execute: () =>
            {
                if (LastSuccessfulRun == null)
                {
                    return;
                }
                RemoteRepoPathInput.RemoteRepoPath         = LastSuccessfulRun.TargetRepo;
                this.SelectedProjectInput.ProjectSubpath   = LastSuccessfulRun.ProjectSubpath;
                this.PatcherTargeting.TargetCommit         = LastSuccessfulRun.Commit;
                this.NugetTargeting.ManualMutagenVersion   = LastSuccessfulRun.MutagenVersion;
                this.NugetTargeting.ManualSynthesisVersion = LastSuccessfulRun.SynthesisVersion;
                this.PatcherTargeting.PatcherVersioning    = PatcherVersioningEnum.Commit;
                this.NugetTargeting.SynthesisVersioning    = PatcherNugetVersioningEnum.Manual;
                this.NugetTargeting.MutagenVersioning      = PatcherNugetVersioningEnum.Manual;
            });
        }
Example #6
0
        public GitPatcherInitVm(
            IPatcherInitializationVm init,
            ILogger logger,
            IPatcherFactory patcherFactory,
            INavigateTo navigateTo,
            IPathSanitation pathSanitation,
            PatcherStoreListingVm.Factory listingVmFactory,
            IRegistryListingsProvider listingsProvider,
            PatcherInitRenameValidator renamer)
        {
            _init           = init;
            _patcherFactory = patcherFactory;
            _renamer        = renamer;
            _pathSanitation = pathSanitation;
            Patcher         = patcherFactory.GetGitPatcher();

            _canCompleteConfiguration = this.WhenAnyValue(x => x.Patcher.RepoClonesValid.Valid)
                                        .Select(x => ErrorResponse.Create(x))
                                        .ToGuiProperty(this, nameof(CanCompleteConfiguration), ErrorResponse.Success);

            PatcherRepos = Observable.Return(Unit.Default)
                           .ObserveOn(RxApp.TaskpoolScheduler)
                           .SelectTask(async _ =>
            {
                try
                {
                    var customization = listingsProvider.Get(CancellationToken.None);

                    if (customization.Failed)
                    {
                        return(Observable.Empty <IChangeSet <PatcherStoreListingVm> >());
                    }

                    return(customization.Value
                           .SelectMany(repo =>
                    {
                        return repo.Patchers
                        .Select(p =>
                        {
                            return listingVmFactory(this, p, repo);
                        });
                    })
                           .AsObservableChangeSet());
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error downloading patcher listing");
                    Error = ErrorResponse.Fail(ex);
                }
                return(Observable.Empty <IChangeSet <PatcherStoreListingVm> >());
            })
                           .Switch()
                           .Sort(Comparer <PatcherStoreListingVm> .Create((x, y) => x.Name.CompareTo(y.Name)))
                           .Filter(this.WhenAnyValue(x => x.ShowAll)
                                   .DistinctUntilChanged()
                                   .Select(show => new Func <PatcherStoreListingVm, bool>(
                                               (p) =>
            {
                if (p.Raw.Customization?.Visibility is VisibilityOptions.Visible)
                {
                    return(true);
                }
                else if (p.Raw.Customization?.Visibility is VisibilityOptions.IncludeButHide)
                {
                    return(show);
                }
                else if (p.Raw.Customization?.Visibility is VisibilityOptions.Exclude)
                {
                    return(false);                                                                               // just in case.
                }
                else
                {
                    return(true);
                }
            })))
                           .Filter(this.WhenAnyValue(x => x.Search)
                                   .Debounce(TimeSpan.FromMilliseconds(350), RxApp.MainThreadScheduler)
                                   .Select(x => x.Trim())
                                   .DistinctUntilChanged()
                                   .Select(search =>
            {
                if (string.IsNullOrWhiteSpace(search))
                {
                    return(new Func <PatcherStoreListingVm, bool>(_ => true));
                }
                return(new Func <PatcherStoreListingVm, bool>(
                           (p) =>
                {
                    if (p.Name.Contains(search, StringComparison.OrdinalIgnoreCase))
                    {
                        return true;
                    }
                    if (p.Raw.Customization?.OneLineDescription?.Contains(search, StringComparison.OrdinalIgnoreCase) ?? false)
                    {
                        return true;
                    }
                    return false;
                }));
            }))
                           .ObserveOn(RxApp.MainThreadScheduler)
                           .ToObservableCollection(this);

            OpenPopulationInfoCommand = ReactiveCommand.Create(() => navigateTo.Navigate(Constants.ListingRepositoryAddress));
            ClearSearchCommand        = ReactiveCommand.Create(() => Search = string.Empty);
        }