Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-271] Updated logic for sidebar header to show assigned MRs instead of opened MRs #394

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Each user in Mattermost is connected with their own personal GitLab account. Use

### Sidebar buttons

Team members can stay up-to-date with how many reviews, unread messages, assignments, and open merge requests they have by using buttons in the Mattermost sidebar.
Team members can stay up-to-date with how many reviews, todos, assigned issues, and assigned merge requests they have by using buttons in the Mattermost sidebar.

## Admin guide

Expand Down Expand Up @@ -142,7 +142,7 @@ Connect your Mattermost account to your GitLab account using `/gitlab connect` a

### Get "To Do" items

Use `/gitlab todo` to get a list of unread messages and merge requests awaiting your review.
Use `/gitlab todo` to get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review.

### Update settings

Expand Down
6 changes: 3 additions & 3 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ func (p *Plugin) completeConnectUserToGitlab(c *Context, w http.ResponseWriter,
"Turn off notifications with `/gitlab settings notifications off`.\n\n"+
"##### Sidebar Buttons\n"+
"Check out the buttons in the left-hand sidebar of Mattermost.\n"+
"* The first button tells you how many merge requests you have submitted.\n"+
"* The first button tells you how many merge requests you are assigned to.\n"+
"* The second shows the number of merge requests that are awaiting your review.\n"+
"* The third shows the number of merge requests and issues you are assigned to.\n"+
"* The fourth tracks the number of unread messages you have.\n"+
"* The third shows the number of issues you are assigned to.\n"+
"* The fourth tracks the number of todos you have.\n"+
"* The fifth will refresh the numbers.\n\n"+
"Click on them!\n\n"+
"##### Slash Commands\n"+
Expand Down
6 changes: 3 additions & 3 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

const commandHelp = `* |/gitlab connect| - Connect your Mattermost account to your GitLab account
* |/gitlab disconnect| - Disconnect your Mattermost account from your GitLab account
* |/gitlab todo| - Get a list of unread messages and merge requests awaiting your review
* |/gitlab todo| - Get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review
* |/gitlab subscriptions list| - Will list the current channel subscriptions
* |/gitlab subscriptions add owner[/repo] [features]| - Subscribe the current channel to receive notifications about opened merge requests and issues for a group or repository
* |features| is a comma-delimited list of one or more the following:
Expand Down Expand Up @@ -248,7 +248,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (res
_, text, err := p.GetToDo(ctx, info)
if err != nil {
p.client.Log.Warn("can't get todo in command", "err", err.Error())
return p.getCommandResponse(args, "Encountered an error getting your to do items."), nil
return p.getCommandResponse(args, "Encountered an error getting your todo items."), nil
}
return p.getCommandResponse(args, text), nil
case "me":
Expand Down Expand Up @@ -773,7 +773,7 @@ func getAutocompleteData(config *configuration) *model.AutocompleteData {
disconnect := model.NewAutocompleteData("disconnect", "", "disconnect your GitLab account")
gitlab.AddCommand(disconnect)

todo := model.NewAutocompleteData("todo", "", "Get a list of unread messages and merge requests awaiting your review")
todo := model.NewAutocompleteData("todo", "", "Get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review")
gitlab.AddCommand(todo)

subscriptions := model.NewAutocompleteData("subscriptions", "[command]", "Available commands: Add, List, Delete")
Expand Down
36 changes: 18 additions & 18 deletions server/gitlab/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type Issue struct {
}

type LHSContent struct {
PRs []*MergeRequest `json:"prs"`
Reviews []*MergeRequest `json:"reviews"`
Assignments []*Issue `json:"assignments"`
Unreads []*internGitlab.Todo `json:"unreads"`
AssignedPRs []*MergeRequest `json:"yourAssignedPrs"`
Reviews []*MergeRequest `json:"reviews"`
AssignedIssues []*Issue `json:"yourAssignedIssues"`
Todos []*internGitlab.Todo `json:"todos"`
}

// NewGroupHook creates a webhook associated with a GitLab group
Expand Down Expand Up @@ -303,21 +303,21 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T
return err
})

var assignments []*Issue
var issues []*Issue
grp.Go(func() error {
assignments, err = g.GetYourAssignments(ctx, user, client)
issues, err = g.GetYourAssignedIssues(ctx, user, client)
return err
})

var mergeRequests []*MergeRequest
grp.Go(func() error {
mergeRequests, err = g.GetYourPrs(ctx, user, client)
mergeRequests, err = g.GetYourAssignedPrs(ctx, user, client)
return err
})

var unreads []*internGitlab.Todo
var todos []*internGitlab.Todo
grp.Go(func() error {
unreads, err = g.GetUnreads(ctx, user, client)
todos, err = g.GetToDoList(ctx, user, client)
return err
})

Expand All @@ -326,10 +326,10 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T
}

return &LHSContent{
Reviews: reviews,
PRs: mergeRequests,
Assignments: assignments,
Unreads: unreads,
Reviews: reviews,
AssignedPRs: mergeRequests,
AssignedIssues: issues,
Todos: todos,
}, nil
}

Expand Down Expand Up @@ -394,13 +394,13 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internG
return mergeRequests, nil
}

func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) {
func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) {
opened := stateOpened
scope := scopeAll
var mrs []*internGitlab.MergeRequest
if g.gitlabGroup == "" {
opt := &internGitlab.ListMergeRequestsOptions{
AuthorID: &user.GitlabUserID,
AssigneeID: internGitlab.AssigneeID(user.GitlabUserID),
State: &opened,
Scope: &scope,
ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage},
Expand All @@ -418,7 +418,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, client *internG
}
} else {
opt := &internGitlab.ListGroupMergeRequestsOptions{
AuthorID: &user.GitlabUserID,
AssigneeID: internGitlab.AssigneeID(user.GitlabUserID),
State: &opened,
Scope: &scope,
ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage},
Expand Down Expand Up @@ -547,7 +547,7 @@ func (g *gitlab) fetchYourPrDetails(c context.Context, log logger.Logger, client
return nil
}

func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) {
func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) {
opened := stateOpened
scope := scopeAll
var issues []*internGitlab.Issue
Expand Down Expand Up @@ -607,7 +607,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, client
return result, nil
}

func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) {
func (g *gitlab) GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) {
var todos []*internGitlab.Todo

opt := &internGitlab.ListTodosOptions{
Expand Down
6 changes: 3 additions & 3 deletions server/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ type Gitlab interface {
GetProject(ctx context.Context, user *UserInfo, token *oauth2.Token, owner, repo string) (*internGitlab.Project, error)
GetYourPrDetails(ctx context.Context, log logger.Logger, user *UserInfo, token *oauth2.Token, prList []*PRDetails) ([]*PRDetails, error)
GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error)
GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error)
GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error)
GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error)
GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error)
GetProjectHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string, repo string) ([]*WebhookInfo, error)
GetGroupHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string) ([]*WebhookInfo, error)
NewProjectHook(ctx context.Context, user *UserInfo, token *oauth2.Token, projectID interface{}, projectHookOptions *AddWebhookOptions) (*WebhookInfo, error)
Expand Down
52 changes: 26 additions & 26 deletions server/gitlab/mocks/mock_gitlab.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions server/mocks/mock_gitlab.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading