-
Notifications
You must be signed in to change notification settings - Fork 3
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
[MI-2820]: Modified API endpoint to require a project to be provided #144
Conversation
1. Updated API to support creating pipeline subscriptions. 2. Updated the UI for subscription modal to display pipeline event types. 3. Updated the UI of subscription card for for displaying pipeline subscriptions.
…ure-devops into MI-2315
…Created" event type
…eployment started" and "Release deployment completed"
…Run state changed" event type
…ure-devops into MI-2343
…in-azure-devops into MI-2304
…ure-devops into MI-2315
…pipeline job request from requested user via MM post.
…ure-devops into MI-2339
…d/rejected Pipeline release request.
…e central login into it, formatted code (#32) * [MI-2669]: Created a hook for intercepting redux changes and moved the central login into it, formatted code * [MI-2669]: Modified comment * [MI-2669]: Review fixes --------- Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…ser for oAuth. (#35) * [MI-2748]: Implemented 1:1 mapping between MM user and Azure DevOps user for oAuth. * [MI-2748]: Added 1 test case and http response code * [MI-2748]: Fixed condition * [MI-2748]: Fixed token refresh logic * [MI-2748]: Fixed CI * [MI-2748]: Fixed CI * [MI-2748]: Review fixes * [MI-2748]: Fixed CI * [MI-2748]: Review fixes * [MI-2748]: Review fixes --------- Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…om plugin's server. (#36) * [MI-2750]: Implemented fetching channel list on webapp and remove from plugin's server. * [MI-2750]: Review fixes * [MI-2750]: Changed comment message --------- Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
…er (#37) * [MI-2765]: Used @mattermost/client for making webapp calls to MM server * [MI-2765]: Review fix * [MI-2765]: Review fix * [MI-2765]: Removed Mattermost API call RTK service * [MI-2765]: Fixed CI --------- Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
server/plugin/api.go
Outdated
|
||
organization := pathParams[constants.PathParamOrganization] | ||
project := pathParams[constants.PathParamProject] | ||
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: strings.ToLower(organization), ProjectName: cases.Title(language.Und).String(project)}); !isProjectLinked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot going on in this line. Maybe break this into local variables first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
server/plugin/api.go
Outdated
organization := pathParams[constants.PathParamOrganization] | ||
project := pathParams[constants.PathParamProject] | ||
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: strings.ToLower(organization), ProjectName: cases.Title(language.Und).String(project)}); !isProjectLinked { | ||
p.API.LogError(fmt.Sprintf("Project %s is not linked", project)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use LogWarn
since there isn't an actionable step for the admin to fix this. Please keep this is mind for other features/fixes implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, fixed
} | ||
|
||
organization := pathParams[constants.PathParamOrganization] | ||
project := pathParams[constants.PathParamProject] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could "return early" if project
is blank right? Before we interact with the store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have made organization
and project
as path params here so, if they are empty this API will not be called and we will not reach here and get 404
@avas27JTG Could you please rebase against |
server/plugin/api.go
Outdated
@@ -413,6 +413,26 @@ func (p *Plugin) handleGetSubscriptions(w http.ResponseWriter, r *http.Request) | |||
return | |||
} | |||
|
|||
projectList, err := p.Store.GetAllProjects(mattermostUserID) | |||
if err != nil { | |||
p.API.LogError(constants.ErrorFetchProjectList, "Error", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about using LogWarn
instead here
server/plugin/api.go
Outdated
@@ -432,7 +452,6 @@ func (p *Plugin) handleGetSubscriptions(w http.ResponseWriter, r *http.Request) | |||
channelID := r.URL.Query().Get(constants.QueryParamChannelID) | |||
serviceType := r.URL.Query().Get(constants.QueryParamServiceType) | |||
eventType := r.URL.Query().Get(constants.QueryParamEventType) | |||
project := r.URL.Query().Get(constants.QueryParamProject) | |||
if project != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the intended functionality when project
is an empty string? The code reads a bit weird because there is a large block for handling when it's not empty, but then the function ends after that block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code will reach here only when the project
is not empty and it's valid i.e. linked/exists on the plugin
and in that case, we are returning the array of subscriptions
Removed this check as it's no longer needed now as we have made it required now
Modified API endpoint to require a project to be provided