Skip to content
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
4 changes: 2 additions & 2 deletions docs/feature-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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.



Expand All @@ -57,7 +57,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
35 changes: 17 additions & 18 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ func (p *Plugin) initializeAPI() {
apiRouter.HandleFunc("/user", p.checkAuth(p.attachContext(p.getGitlabUser), ResponseTypeJSON)).Methods(http.MethodPost)
apiRouter.HandleFunc("/todo", p.checkAuth(p.attachUserContext(p.postToDo), ResponseTypeJSON)).Methods(http.MethodPost)
apiRouter.HandleFunc("/reviews", p.checkAuth(p.attachUserContext(p.getReviews), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/yourprs", p.checkAuth(p.attachUserContext(p.getYourPrs), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/assignedprs", p.checkAuth(p.attachUserContext(p.getYourAssignedPrs), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/prdetails", p.checkAuth(p.attachUserContext(p.getPrDetails), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/yourassignments", p.checkAuth(p.attachUserContext(p.getYourAssignments), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/unreads", p.checkAuth(p.attachUserContext(p.getUnreads), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/assignedissues", p.checkAuth(p.attachUserContext(p.getYourAssignedIssues), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/todolist", p.checkAuth(p.attachUserContext(p.getToDoList), ResponseTypePlain)).Methods(http.MethodGet)
apiRouter.HandleFunc("/settings", p.checkAuth(p.attachUserContext(p.updateSettings), ResponseTypePlain)).Methods(http.MethodPost)

apiRouter.HandleFunc("/channel/{channel_id:[A-Za-z0-9]+}/subscriptions", p.checkAuth(p.attachUserContext(p.getChannelSubscriptions), ResponseTypeJSON)).Methods(http.MethodGet)
Expand Down Expand Up @@ -396,10 +396,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 Expand Up @@ -530,10 +530,10 @@ func (p *Plugin) getConnected(c *Context, w http.ResponseWriter, r *http.Request
p.writeAPIResponse(w, resp)
}

func (p *Plugin) getUnreads(c *UserContext, w http.ResponseWriter, r *http.Request) {
func (p *Plugin) getToDoList(c *UserContext, w http.ResponseWriter, r *http.Request) {
var result []*gitlabLib.Todo
err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error {
resp, err := p.GitlabClient.GetUnreads(c.Ctx, info, token)
resp, err := p.GitlabClient.GetToDoList(c.Ctx, info, token)
if err != nil {
return err
}
Expand All @@ -542,8 +542,8 @@ func (p *Plugin) getUnreads(c *UserContext, w http.ResponseWriter, r *http.Reque
})

if err != nil {
c.Log.WithError(err).Warnf("Unable to list unreads in GitLab API")
p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list unreads in GitLab API.", StatusCode: http.StatusInternalServerError})
c.Log.WithError(err).Warnf("Unable to list todos in GitLab API")
p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list todos in GitLab API.", StatusCode: http.StatusInternalServerError})
return
}

Expand All @@ -570,24 +570,23 @@ func (p *Plugin) getReviews(c *UserContext, w http.ResponseWriter, r *http.Reque
p.writeAPIResponse(w, result)
}

func (p *Plugin) getYourPrs(c *UserContext, w http.ResponseWriter, r *http.Request) {
var result []*gitlab.MergeRequest
func (p *Plugin) getYourAssignedPrs(c *UserContext, w http.ResponseWriter, r *http.Request) {
var assignedPRs []*gitlab.MergeRequest
err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error {
resp, err := p.GitlabClient.GetYourPrs(c.Ctx, info, token)
resp, err := p.GitlabClient.GetYourAssignedPrs(c.Ctx, info, token)
if err != nil {
return err
}
result = resp
assignedPRs = resp
return nil
})

if err != nil {
c.Log.WithError(err).Warnf("Can't list merge-request where author in GitLab API")
p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list merge-request in GitLab API.", StatusCode: http.StatusInternalServerError})
return
}

p.writeAPIResponse(w, result)
p.writeAPIResponse(w, assignedPRs)
}

func (p *Plugin) getPrDetails(c *UserContext, w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -615,10 +614,10 @@ func (p *Plugin) getPrDetails(c *UserContext, w http.ResponseWriter, r *http.Req
p.writeAPIResponse(w, result)
}

func (p *Plugin) getYourAssignments(c *UserContext, w http.ResponseWriter, r *http.Request) {
func (p *Plugin) getYourAssignedIssues(c *UserContext, w http.ResponseWriter, r *http.Request) {
var result []*gitlab.Issue
err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error {
resp, err := p.GitlabClient.GetYourAssignments(c.Ctx, info, token)
resp, err := p.GitlabClient.GetYourAssignedIssues(c.Ctx, info, token)
if err != nil {
return err
}
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
10 changes: 5 additions & 5 deletions server/gitlab/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.T
return mergeRequests, err
}

func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) {
func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) {
client, err := g.GitlabConnect(*token)
if err != nil {
return nil, err
Expand All @@ -366,7 +366,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.T

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 @@ -386,7 +386,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.T
}
} 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 @@ -518,7 +518,7 @@ func (g *gitlab) fetchYourPrDetails(c context.Context, log logger.Logger, client
return nil
}

func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error) {
func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error) {
client, err := g.GitlabConnect(*token)
if err != nil {
return nil, err
Expand Down Expand Up @@ -588,7 +588,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token *
return result, nil
}

func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*internGitlab.Todo, error) {
func (g *gitlab) GetToDoList(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*internGitlab.Todo, error) {
client, err := g.GitlabConnect(*token)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions server/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ 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, token *oauth2.Token) ([]*MergeRequest, error)
GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error)
GetYourAssignments(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error)
GetUnreads(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*internGitlab.Todo, error)
GetYourAssignedPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error)
GetYourAssignedIssues(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error)
GetToDoList(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*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.

Loading