private async Task <Octokit.Issue> UpdateIssue(Octokit.IssueUpdate update) { Issue = await _applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, update); await RetrieveEvents(); return(Issue); }
protected override Task<Octokit.Issue> Save() { try { var labels = Labels.Selected?.Select(y => y.Name).ToArray(); var milestone = Milestones.Selected?.Number; var user = Assignees.Selected?.Login; var issueUpdate = new Octokit.IssueUpdate { Body = Content, Assignee = user, Milestone = milestone, Title = Subject, }; if (labels != null && labels.Length > 0) { foreach (var label in labels) issueUpdate.AddLabel(label); } return _sessionService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, issueUpdate); } catch (Exception e) { throw new Exception("Unable to update issue! Please try again.", e); } }
private async Task <Octokit.Issue> UpdateIssue(Octokit.User assignee, Octokit.Milestone milestone, IEnumerable <Octokit.Label> labels) { var update = new Octokit.IssueUpdate { Assignee = assignee?.Login, Milestone = milestone?.Number }; update.ClearLabels(); foreach (var l in (labels ?? Enumerable.Empty <Octokit.Label>())) { update.AddLabel(l.Name); } using (_alertDialogFactory.Activate("Updating...")) { Issue = await _applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, update); InternalEvents.Reset(await RetrieveEvents()); return(Issue); } }
private async Task<Octokit.Issue> UpdateIssue(Octokit.User assignee, Octokit.Milestone milestone, IEnumerable<Octokit.Label> labels) { var update = new Octokit.IssueUpdate { Assignee = assignee?.Login, Milestone = milestone?.Number }; update.ClearLabels(); foreach (var l in (labels ?? Enumerable.Empty<Octokit.Label>())) update.AddLabel(l.Name); using (_alertDialogFactory.Activate("Updating...")) { Issue = await _applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, update); InternalEvents.Reset(await RetrieveEvents()); return Issue; } }
protected BaseIssueViewModel( IApplicationService applicationService, IMarkdownService markdownService) { _applicationService = applicationService; var issuePresenceObservable = this.WhenAnyValue(x => x.Issue, x => x.CanModify) .Select(x => x.Item1 != null && x.Item2); Events = InternalEvents.CreateDerivedCollection(x => x); _participants = Events.Changed .Select(_ => Events.Select(y => y.Actor).Distinct().Count()) .Select(x => x == 0 ? 1 : x) .ToProperty(this, x => x.Participants); GoToAssigneesCommand = ReactiveCommand.Create(issuePresenceObservable) .WithSubscription(_ => Assignees.LoadCommand.ExecuteIfCan()); GoToLabelsCommand = ReactiveCommand.Create(issuePresenceObservable) .WithSubscription(_ => Labels.LoadCommand.ExecuteIfCan()); GoToMilestonesCommand = ReactiveCommand.Create(issuePresenceObservable) .WithSubscription(_ => Milestones.LoadCommand.ExecuteIfCan()); _assignedUser = this.WhenAnyValue(x => x.Issue.Assignee) .ToProperty(this, x => x.AssignedUser); _assignedMilestone = this.WhenAnyValue(x => x.Issue.Milestone) .ToProperty(this, x => x.AssignedMilestone); _assignedLabels = this.WhenAnyValue(x => x.Issue.Labels) .ToProperty(this, x => x.AssignedLabels); _isClosed = this.WhenAnyValue(x => x.Issue.State) .Select(x => x == Octokit.ItemState.Closed) .ToProperty(this, x => x.IsClosed); Assignees = new IssueAssigneeViewModel( () => applicationService.GitHubClient.Issue.Assignee.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult(Issue.Assignee), x => UpdateIssue(new Octokit.IssueUpdate { Assignee = x.With(y => y.Login), Milestone = AssignedMilestone.With(y => (int?)y.Number) })); Milestones = new IssueMilestonesViewModel( () => applicationService.GitHubClient.Issue.Milestone.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult(Issue.Milestone), x => UpdateIssue(new Octokit.IssueUpdate { Assignee = AssignedUser.With(y => y.Login), Milestone = x.With(y => (int?)y.Number) })); Labels = new IssueLabelsViewModel( () => applicationService.GitHubClient.Issue.Labels.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult((IReadOnlyList <Octokit.Label>) new ReadOnlyCollection <Octokit.Label>(Issue.Labels.ToList())), x => { var update = new Octokit.IssueUpdate { Assignee = AssignedUser.With(y => y.Login), Milestone = AssignedMilestone.With(y => (int?)y.Number), }; foreach (var label in x.Select(y => y.Name)) { update.AddLabel(label); } return(UpdateIssue(update)); }); _markdownDescription = this.WhenAnyValue(x => x.Issue) .Select(x => ((x == null || string.IsNullOrEmpty(x.Body)) ? null : markdownService.Convert(x.Body))) .ToProperty(this, x => x.MarkdownDescription); LoadCommand = ReactiveCommand.CreateAsyncTask(t => Load(applicationService)); GoToOwnerCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Issue).Select(x => x != null)); GoToOwnerCommand.Select(_ => Issue.User).Subscribe(x => { var vm = this.CreateViewModel <UserViewModel>(); vm.Username = x.Login; NavigateTo(vm); }); ToggleStateCommand = ReactiveCommand.CreateAsyncTask(issuePresenceObservable, async t => { try { Issue = await applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, new Octokit.IssueUpdate { State = (Issue.State == Octokit.ItemState.Open) ? Octokit.ItemState.Closed : Octokit.ItemState.Open }); } catch (Exception e) { var close = (Issue.State == Octokit.ItemState.Open) ? "close" : "open"; throw new Exception("Unable to " + close + " the item. " + e.Message, e); } }); AddCommentCommand = ReactiveCommand.Create() .WithSubscription(_ => { var vm = this.CreateViewModel <IssueCommentViewModel>(); vm.RepositoryOwner = RepositoryOwner; vm.RepositoryName = RepositoryName; vm.Id = Id; vm.SaveCommand.Subscribe(x => InternalEvents.Add(new IssueCommentItemViewModel(x))); NavigateTo(vm); }); GoToUrlCommand = ReactiveCommand.Create(); GoToUrlCommand.OfType <string>().Subscribe(x => { var vm = this.CreateViewModel <WebBrowserViewModel>(); vm.Url = x; NavigateTo(vm); }); GoToUrlCommand.OfType <Uri>().Subscribe(x => { var vm = this.CreateViewModel <WebBrowserViewModel>(); vm.Url = x.AbsoluteUri; NavigateTo(vm); }); }