public SourceViewModel(IApplicationService applicationService) { GoToSourceCommand = new ReactiveCommand(); Tags = new ReactiveList <Tag>(); Branches = new ReactiveList <Branch>(); LoadCommand.RegisterAsyncTask(_ => Load(applicationService)); this.WhenAnyValue(x => x.SelectedView).Skip(1).Subscribe(_ => LoadCommand.Execute(null)); GoToSourceCommand.OfType <Tag>().Subscribe(x => { var vm = CreateViewModel <FilesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = x.LatestChangeset; vm.Folder = x.DisplayId; ShowViewModel(vm); }); GoToSourceCommand.OfType <Branch>().Subscribe(x => { var vm = CreateViewModel <FilesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = x.LatestChangeset; vm.Folder = x.DisplayId; ShowViewModel(vm); }); }
public ProjectsViewModel(IApplicationService applicationService, IAccountsService accountsService) { Account = accountsService.ActiveAccount; GoToProjectCommand = new ReactiveCommand(); Projects = new ReactiveCollection <Project>(new [] { CreatePersonalProject(accountsService.ActiveAccount) }); LoadCommand.RegisterAsyncTask(async x => { var getAllProjects = applicationService.StashClient.Projects.GetAll(); using (Projects.SuppressChangeNotifications()) { Projects.Clear(); Projects.Add(CreatePersonalProject(accountsService.ActiveAccount)); Projects.AddRange(await getAllProjects.ExecuteAsyncAll()); } }); GoToProjectCommand.OfType <Project>().Subscribe(x => { var vm = this.CreateViewModel <RepositoriesViewModel>(); vm.ProjectKey = x.Key; vm.Name = x.Name; ShowViewModel(vm); }); }
public PullRequestDiffViewModel(IApplicationService applicationService) { LoadCommand.RegisterAsyncTask(async _ => { Diff = (await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].PullRequests[PullRequestId].GetDiff(Path).ExecuteAsync()).Data; }); }
public RepositoriesViewModel(IApplicationService applicationService) { LoadCommand.RegisterAsyncTask(async _ => { Project = (await applicationService.StashClient.Projects[ProjectKey].Get().ExecuteAsync()).Data; var d = await applicationService.StashClient.Projects[ProjectKey].Repositories.GetAll().ExecuteAsync(); Repositories.Reset(d.Data.Values); }); }
public RelatedRepositoriesViewModel(IApplicationService applicationService) { ShowOwner = true; LoadCommand.RegisterAsyncTask(async _ => { var d = await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].GetRelated().ExecuteAsync(); Repositories.Reset(d.Data.Values); }); }
public BuildStatusesViewModel(IApplicationService applicationService) { BuildStatues = new ReactiveCollection <BuildStatus>(); GoToBuildStatusCommand = new ReactiveCommand(); GoToBuildStatusCommand.OfType <BuildStatus>().Subscribe(x => { var vm = CreateViewModel <WebBrowserViewModel>(); vm.Url = x.Url; ShowViewModel(vm); }); LoadCommand.RegisterAsyncTask(async _ => { BuildStatues.Reset((await applicationService.StashClient.BuildStatus[Node].GetStatus().ExecuteAsync()).Data.Values); }); }
public StartupViewModel(IAccountsService accountsService, IAccountValidatorService accountValidator) { AccountsService = accountsService; AccountValidator = accountValidator; GoToMainCommand = new ReactiveCommand(); GoToAccountsCommand = new ReactiveCommand(); GoToNewUserCommand = new ReactiveCommand(); BecomeActiveWindowCommand = new ReactiveCommand(); GoToAccountsCommand.Subscribe(_ => ShowViewModel(CreateViewModel <AccountsViewModel>())); GoToNewUserCommand.Subscribe(_ => ShowViewModel(CreateViewModel(typeof(IAddAccountViewModel)))); GoToMainCommand.Subscribe(_ => ShowViewModel(CreateViewModel(typeof(IMainViewModel)))); LoadCommand.RegisterAsyncTask(x => Load()); }
public FileViewModel(IApplicationService applicationService) { LoadCommand.RegisterAsyncTask(async _ => { var response = await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].GetFileContent(Path, Branch).ExecuteAsync(); if (response.Data.Lines == null) { throw new Exception("Unable to render this type of file."); } var content = new StringBuilder(); foreach (var line in response.Data.Lines) { content.AppendLine(line.Text); } Content = content.ToString().Trim(); }); }
public PullRequestParticipantsViewModel(IApplicationService applicationService) { GoToUserCommand = new ReactiveCommand(); Participants = new ReactiveCollection <PullRequestParticipant>(); LoadCommand.RegisterAsyncTask(async _ => { var pullRequest = applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].PullRequests[PullRequestId]; Participants.Reset((await pullRequest.GetAllParticipates().ExecuteAsync()).Data.Values); }); GoToUserCommand.OfType <PullRequestParticipant>().Subscribe(x => { var vm = CreateViewModel <ProfileViewModel>(); vm.UserSlug = x.User.Slug; ShowViewModel(vm); }); }
public PullRequestsViewModel(IApplicationService applicationService) { ApplicationService = applicationService; PullRequests = new ReactiveList <PullRequest>(); LoadCommand.RegisterAsyncTask(_ => Load()); this.WhenAnyValue(x => x.SelectedView).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan()); GoToPullRequestCommand = new ReactiveCommand(); GoToPullRequestCommand.OfType <PullRequest>().Subscribe(x => { var vm = CreateViewModel <PullRequestViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.PullRequestId = x.Id; ShowViewModel(vm); }); }
public ProfileViewModel(IApplicationService applicationService) { Repositories = new ReactiveList <Repository>(); GoToRepositoryCommand = new ReactiveCommand(); GoToRepositoryCommand.OfType <Repository>().Subscribe(x => { var vm = CreateViewModel <RepositoryViewModel>(); vm.ProjectKey = x.Project.Key; vm.RepositorySlug = x.Slug; ShowViewModel(vm); }); LoadCommand.RegisterAsyncTask(async _ => { User = (await applicationService.StashClient.Users[UserSlug].Get().ExecuteAsync()).Data; Repositories.Reset((await applicationService.StashClient.Users[UserSlug].Repositories.GetAll().ExecuteAsync()).Data.Values); }); }
public CommitsViewModel(IApplicationService applicationService) { Commits = new ReactiveCollection <Commit>(); GoToCommitCommand = new ReactiveCommand(); GoToCommitCommand.OfType <Commit>().Subscribe(x => { var vm = CreateViewModel <CommitViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Node = x.Id; ShowViewModel(vm); }); LoadCommand.RegisterAsyncTask(async x => { var response = await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].Commits.GetAll(until: Branch).ExecuteAsync(); Commits.Reset(response.Data.Values); }); }
public PullRequestChangesViewModel(IApplicationService applicationService) { Changes = new ReactiveList <Change>(); LoadCommand.RegisterAsyncTask(async _ => { Changes.Reset(await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].PullRequests[PullRequestId].GetAllChanges().ExecuteAsyncAll()); }); GoToDiffCommand = new ReactiveCommand(); GoToDiffCommand.OfType <Change>().Subscribe(x => { var vm = CreateViewModel <PullRequestDiffViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.PullRequestId = PullRequestId; vm.Path = x.Path.ToString; vm.Name = x.Path.Name; ShowViewModel(vm); }); }
public FilesViewModel(IApplicationService applicationService) { GoToSourceCommand = new ReactiveCommand(); Contents = new ReactiveCollection <Content>(); LoadCommand.RegisterAsyncTask(async _ => { var response = await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].GetContents(Path, Branch, false).ExecuteAsync(); ContentPath = response.Data.Path; Contents.Reset(response.Data.Children.Values); }); GoToSourceCommand.OfType <Content>().Subscribe(x => { if (string.Equals(x.Type, "FILE", StringComparison.OrdinalIgnoreCase)) { var vm = CreateViewModel <FileViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = Branch; vm.Path = Path + "/" + x.Path.Name; vm.FileName = x.Path.Name; ShowViewModel(vm); } else { var vm = CreateViewModel <FilesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = Branch; vm.Path = Path + "/" + x.Path.Name; vm.Folder = x.Path.Name; ShowViewModel(vm); } }); }
public PullRequestViewModel(IApplicationService applicationService) { Commits = new ReactiveList <Commit>(); Participants = new ReactiveList <PullRequestParticipant>(); Activities = new ReactiveList <Activity>(); GoToChangesCommand = new ReactiveCommand(); GoToCommitsCommand = new ReactiveCommand(); GoToCommentsCommand = new ReactiveCommand(); LoadCommand.RegisterAsyncTask(async _ => { var pullRequest = applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].PullRequests[PullRequestId]; PullRequest = (await pullRequest.Get().ExecuteAsync()).Data; Participants.Reset(PullRequest.Participants.Concat(PullRequest.Reviewers)); Commits.Reset((await pullRequest.GetAllCommits().ExecuteAsync()).Data.Values); pullRequest.GetAllActivities().ExecuteAsync().ContinueInBackground(x => Activities.Reset(x.Data.Values)); pullRequest.GetMergeResult().ExecuteAsync().ContinueInBackground(x => MergeResult = x.Data); var firstCommit = Commits.FirstOrDefault(); if (firstCommit != null) { applicationService.StashClient.BuildStatus[firstCommit.Id].GetStatus() .ExecuteAsync().ContinueInBackground(x => BuildStatus = x.Data.Values.ToArray()); } }); GoToCommitsCommand.Subscribe(x => { var vm = CreateViewModel <PullRequestCommitsViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.PullRequestId = PullRequestId; vm.Title = "Commits"; ShowViewModel(vm); }); GoToChangesCommand.Subscribe(x => { var vm = CreateViewModel <PullRequestChangesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.PullRequestId = PullRequestId; vm.PullRequestDestination = PullRequest.ToRef.Id; ShowViewModel(vm); }); GoToBuildStatusCommand = new ReactiveCommand(this.WhenAnyValue(x => x.BuildStatus, x => x != null && x.Length > 0)); GoToBuildStatusCommand.Subscribe(x => { var vm = CreateViewModel <BuildStatusesViewModel>(); vm.Node = Commits[0].Id; ShowViewModel(vm); }); GoToParticipantsCommand = new ReactiveCommand(); GoToParticipantsCommand.Subscribe(x => { var vm = CreateViewModel <PullRequestParticipantsViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.PullRequestId = PullRequestId; ShowViewModel(vm); }); }
public CommitViewModel(IApplicationService applicationService) { Changes = new ReactiveList <Change>(); Branches = new ReactiveList <Branch>(); LoadCommand.RegisterAsyncTask(async _ => { applicationService.StashClient.BranchUtilities.GetBranches(ProjectKey, RepositorySlug, Node) .ExecuteAsync().ContinueInBackground(x => Branches.Reset(x.Data.Values)); applicationService.StashClient.BuildStatus[Node].GetStatus() .ExecuteAsync().ContinueInBackground(x => BuildStatus = x.Data.Values.ToArray()); Commit = (await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].Commits[Node].Get().ExecuteAsync()).Data; Changes.Reset(await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].Commits[Node].GetAllChanges().ExecuteAsyncAll()); }); GoToBuildStatusCommand = new ReactiveCommand(this.WhenAnyValue(x => x.BuildStatus, x => x != null && x.Length > 0)); GoToBuildStatusCommand.Subscribe(_ => { var vm = CreateViewModel <BuildStatusesViewModel>(); vm.Node = Node; ShowViewModel(vm); }); GoToParentCommitCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Commit, x => x != null && x.Parents != null && x.Parents.Count > 0)); GoToParentCommitCommand.Subscribe(_ => { // if (Commit.Parents.Count > 1) // { // // Oh shit... More than one... // } // else { var firstParent = Commit.Parents.FirstOrDefault(); var vm = CreateViewModel <CommitViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Node = firstParent.Id; ShowViewModel(vm); } }); GoToBranchesCommand = new ReactiveCommand(this.Branches.CountChanged.Select(x => x > 0)); GoToBranchesCommand.Subscribe(_ => { // if (Branches.Count > 1) // { // // Oh shit... More than one... // } // else { var firstParent = Branches.FirstOrDefault(); var vm = CreateViewModel <CommitsViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = firstParent.Id; vm.Title = firstParent.DisplayId; ShowViewModel(vm); } }); GoToCommentsCommand = new ReactiveCommand(); GoToDiffCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Commit, x => x != null)); GoToDiffCommand.OfType <Change>().Subscribe(x => { var vm = CreateViewModel <CommitDiffViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Node = Node; vm.Path = x.Path.ToString; vm.Name = x.Path.Name; ShowViewModel(vm); }); }
public RepositoryViewModel(IApplicationService applicationService) { LoadCommand.RegisterAsyncTask(async _ => { applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].GetRelated().ExecuteAsync().ContinueWith(t => { if (t.Exception == null) { RelatedRepositories = t.Result.Data.Values.Count; } }, TaskScheduler.FromCurrentSynchronizationContext()); applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].GetForks().ExecuteAsync().ContinueWith(t => { if (t.Exception == null) { ForkedRepositories = t.Result.Data.Values.Count; } }, TaskScheduler.FromCurrentSynchronizationContext()); Repository = (await applicationService.StashClient.Projects[ProjectKey].Repositories[RepositorySlug].Get().ExecuteAsync()).Data; }); GoToSourceCommand = new ReactiveCommand(); GoToSourceCommand.Subscribe(_ => { var vm = CreateViewModel <SourceViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; ShowViewModel(vm); }); GoToPullRequestsCommand = new ReactiveCommand(); GoToPullRequestsCommand.Subscribe(_ => { var vm = CreateViewModel <PullRequestsViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; ShowViewModel(vm); }); GoToCommitsCommand = new ReactiveCommand(); GoToCommitsCommand.Subscribe(_ => { var vm = CreateViewModel <CommitsBranchViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; ShowViewModel(vm); }); GoToForksCommand = new ReactiveCommand(this.WhenAnyValue(x => x.ForkedRepositories).Any(x => x > 0)); GoToForksCommand.Subscribe(_ => { var vm = CreateViewModel <ForkedRepositoriesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Name = "Forks"; ShowViewModel(vm); }); GoToRelatedCommand = new ReactiveCommand(this.WhenAnyValue(x => x.RelatedRepositories).Any(x => x > 0)); GoToRelatedCommand.Subscribe(_ => { var vm = CreateViewModel <RelatedRepositoriesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Name = "Related"; ShowViewModel(vm); }); }