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

[MI-2820]: Modified API endpoint to require a project to be provided #144

Merged
merged 185 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 184 commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
85a669a
[MI-2304] Pipeline subscription
raghavaggarwal2308 Nov 1, 2022
21c0365
[MI-2315] Added slash command to add/list pipeline subscriptions
raghavaggarwal2308 Nov 1, 2022
1f0947e
[MI-2304] Fixed casing of event type description
raghavaggarwal2308 Nov 1, 2022
b73575d
Merge branch 'MI-2304' of github.com:Brightscout/mattermost-plugin-az…
raghavaggarwal2308 Nov 1, 2022
b201a3d
[MI-2321] Created notification post for "Release Created" and "Build …
raghavaggarwal2308 Nov 4, 2022
0798808
[MI-2321] Added notification post for "Release Abandoned", "Release d…
raghavaggarwal2308 Nov 8, 2022
b2dd84f
[MI-2321] Added notification post for "Run stage state changed" and "…
raghavaggarwal2308 Nov 8, 2022
a46984f
[MI-2321] Refactored code
raghavaggarwal2308 Nov 9, 2022
5839e9a
[MI-2321] Removed commented code
raghavaggarwal2308 Nov 9, 2022
53058ac
[MI-2321] Removed unused struct
raghavaggarwal2308 Nov 9, 2022
1f222ea
[MI-2321] Fixed bug: Pull reqest commented event notification not wor…
raghavaggarwal2308 Nov 9, 2022
e878063
[MI-2339][server]: Added support to show pipeline build link preview.
avas27JTG Nov 9, 2022
23f45e4
[MI-2339][server]: Added mock method for pipeline build
avas27JTG Nov 9, 2022
6b9b96e
[MI-2321] Fixed author icon css on notification post
raghavaggarwal2308 Nov 9, 2022
8963751
[MI-2339][server]: Updated error message
avas27JTG Nov 9, 2022
76d49bb
[MI-2343][server+webapp]: Added support to show pipeline release link…
avas27JTG Nov 9, 2022
731f2ee
Merge branch 'MI-2339' of github.com:Brightscout/mattermost-plugin-az…
avas27JTG Nov 9, 2022
32b6a67
[MI-2304] Review fixes
raghavaggarwal2308 Nov 16, 2022
4130bbf
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Nov 16, 2022
bd96af0
Merge branch 'MI-2304' of github.com:Brightscout/mattermost-plugin-az…
raghavaggarwal2308 Nov 16, 2022
b65ea80
[MI-2315] Review fixes
raghavaggarwal2308 Nov 16, 2022
1c7ca9a
[MI-2304] Review fixes
raghavaggarwal2308 Nov 17, 2022
c800d02
[MI-2345][server+webapp]: Added feature for user to Approve/Reject a …
avas27JTG Nov 17, 2022
05caef6
Merge branch 'MI-2315' of github.com:Brightscout/mattermost-plugin-az…
avas27JTG Nov 17, 2022
6e870e8
[MI-2339][server][review_fix]: Minor refactoring
avas27JTG Nov 17, 2022
d2c2ab9
[MI-2345][server]: Added mock method for UpdatePipelineApprovalRequest
avas27JTG Nov 18, 2022
7ae186e
[MI-2345][server]: Fixed variable name for failing CI
avas27JTG Nov 18, 2022
b92f752
[MI-2350][server]: Add feature to update status of an already approve…
avas27JTG Nov 21, 2022
1dd3333
[MI-2350][server]: Changed variable names to prevent shadow declarations
avas27JTG Nov 21, 2022
ef552c0
[MI-2304] Review fixes
raghavaggarwal2308 Nov 28, 2022
94a6312
[MI-2315] Review fixes
raghavaggarwal2308 Nov 28, 2022
da8182e
[MI-2321] Review fixes
raghavaggarwal2308 Nov 28, 2022
3431efb
[MI-2339][server][review_fix]: Added debug logs and changed casings
avas27JTG Nov 30, 2022
7cee8d6
Merge branch 'MI-2339' of github.com:Brightscout/mattermost-plugin-az…
avas27JTG Nov 30, 2022
571882c
[MI-2343][server][review_fix]: Minor refactoring
avas27JTG Nov 30, 2022
aa98b6d
[MI-2304] Review fixes
raghavaggarwal2308 Nov 30, 2022
4f41b91
[MI-2345][server][review_fix]: Minor refactoring
avas27JTG Nov 30, 2022
38042f8
[MI-2321] Review fixes
raghavaggarwal2308 Nov 30, 2022
c8ba4bf
Merge pull request #100 from Brightscout/MI-2304
raghavaggarwal2308 Nov 30, 2022
a456fc7
Merge pull request #102 from Brightscout/MI-2315
raghavaggarwal2308 Nov 30, 2022
1d1b3f6
Merge pull request #103 from Brightscout/MI-2321
raghavaggarwal2308 Nov 30, 2022
fd3d2d2
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
avas27JTG Nov 30, 2022
d9faef2
[MI-2339][server]: Changed pipeline icon name
avas27JTG Nov 30, 2022
140fb59
Merge branch 'master' of github.com:mattermost/mattermost-plugin-azur…
raghavaggarwal2308 Dec 5, 2022
1071ba6
Merge branch 'epic_phase_3' of github.com:mattermost/mattermost-plugi…
raghavaggarwal2308 Dec 5, 2022
af30300
Merge branch 'MI-2339' of github.com:mattermost/mattermost-plugin-azu…
raghavaggarwal2308 Dec 5, 2022
f89192d
Merge branch 'epic_phase_3' of github.com:mattermost/mattermost-plugi…
raghavaggarwal2308 Dec 5, 2022
4e63614
Merge branch 'MI-2345' of github.com:mattermost/mattermost-plugin-azu…
raghavaggarwal2308 Dec 5, 2022
a3cebf2
[MI-2419][server]: Added support to approve/reject run stage pipeline…
avas27JTG Dec 9, 2022
4e78400
[MI-2450] Added testcases and Makefile command to generate mocks
raghavaggarwal2308 Dec 12, 2022
ee378ee
[MI-2450] Added testcases for command.go
raghavaggarwal2308 Dec 13, 2022
8210205
[MI-2450] Delete cover.out file
raghavaggarwal2308 Dec 13, 2022
a83402d
[MI-2450] Added some more testcases for command.go
raghavaggarwal2308 Dec 13, 2022
dd22e18
[MI-2450] Removed cover.out file
raghavaggarwal2308 Dec 13, 2022
cdc7139
[MI-2456] Added testcases for handleSubscriptionNotification
raghavaggarwal2308 Dec 13, 2022
4e21f7e
[MI-2461] Added testcases for release link preview
raghavaggarwal2308 Dec 13, 2022
4c0d702
[MI-2450] Self review fix
raghavaggarwal2308 Dec 13, 2022
42ac8b9
[MI-2339][server]: Added support to show pipeline build link preview.…
avas27JTG Dec 14, 2022
297e050
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
avas27JTG Dec 14, 2022
149cdfe
[MI-2345][server][review_fix]: Changed place of path variable
avas27JTG Dec 14, 2022
63f9d59
Merge branch 'MI-2345' of github.com:Brightscout/mattermost-plugin-az…
avas27JTG Dec 14, 2022
5ff8230
[MI-2350][server][review_fix]: Changed spelling
avas27JTG Dec 14, 2022
a29189d
[MI-2463] Added testcases for pipeline job request
raghavaggarwal2308 Dec 14, 2022
8ab794f
[MI-2466] Added testcases for run stage job request feature
raghavaggarwal2308 Dec 15, 2022
c5de718
[MI-2463] Added testcases for client.go
raghavaggarwal2308 Dec 15, 2022
bdf7685
[MI-2466] Updated varible names
raghavaggarwal2308 Dec 15, 2022
9ce501b
[MI-2467] Updated documentation for pipeline features
raghavaggarwal2308 Dec 15, 2022
c2c675c
[MI-2462] Moved files in assets to public folder
raghavaggarwal2308 Dec 15, 2022
150560d
[MI-2474] Added comment modal for approving/rejecting pipeline requests
raghavaggarwal2308 Dec 19, 2022
e8ff0c2
Merge branch 'master' of github.com:mattermost/mattermost-plugin-azur…
raghavaggarwal2308 Dec 19, 2022
8d2b0b5
[MI-2341][webapp+server] Added filters for "Build" and "Release" even…
raghavaggarwal2308 Dec 19, 2022
ce42d14
[MI-2476] Enhancements:
raghavaggarwal2308 Dec 19, 2022
b8cd599
[MI-2476] Updated help command for pipelines
raghavaggarwal2308 Dec 19, 2022
0365479
[MI-2360] Updated APIs to create/delete subscriptions and subscriptio…
raghavaggarwal2308 Dec 19, 2022
fcb63fb
[MI-2474] Changed modal title
raghavaggarwal2308 Dec 20, 2022
43a9aa7
[MI-2470] Add dropdown for AreaPath field in create task modal
raghavaggarwal2308 Dec 21, 2022
6249638
[MI-2345][server+webapp]: Added feature for user to Approve/Reject a …
avas27JTG Dec 22, 2022
d025b9d
[MI-2343][server+webapp]: Added support to show pipeline release link…
avas27JTG Dec 22, 2022
11cd816
[MI-2359] Added filters in subscription modal for "Run" events (#118)
raghavaggarwal2308 Dec 22, 2022
cee0e11
[MI-2467] Review fixes
raghavaggarwal2308 Dec 23, 2022
5f5ec2a
[MI-2419][server]: Added support to approve/reject run stage pipeline…
avas27JTG Dec 23, 2022
aa73c82
[MI-2467] Review fix
raghavaggarwal2308 Dec 23, 2022
fb343ec
Merge branch 'epic_phase_3' of github.com:mattermost/mattermost-plugi…
avas27JTG Dec 23, 2022
a954af9
Merge pull request #10 from Brightscout/MI-2467
raghavaggarwal2308 Dec 23, 2022
73ba08e
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
avas27JTG Dec 23, 2022
13727a3
[MI-2495] Removed unused code
raghavaggarwal2308 Dec 23, 2022
13e7038
[MI-2495] Minor bug fixes
raghavaggarwal2308 Dec 23, 2022
e3e3405
[MI-2495] Reset unlink confirmation modal error state on hide.
raghavaggarwal2308 Dec 23, 2022
ffc4741
[Fix]: Fixed organization name for Pipelines (#132)
avas27JTG Dec 23, 2022
b5a01eb
[MI-2495] Code refactor
raghavaggarwal2308 Dec 23, 2022
37dc7bd
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 23, 2022
3c5e676
[MI-2495] Bump plugin version to v3.0.0
raghavaggarwal2308 Dec 23, 2022
f5fad8e
[MI-2495] Review fix
raghavaggarwal2308 Dec 23, 2022
768f36f
Merge pull request #16 from Brightscout/MI-2495
raghavaggarwal2308 Dec 23, 2022
e185772
[MI-2476] Review fix
raghavaggarwal2308 Dec 26, 2022
c869e67
[MI-2462] Review fix
raghavaggarwal2308 Dec 26, 2022
2a17b7c
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 26, 2022
8f86195
[MI-2462] Changed plugin version on plugin.go
raghavaggarwal2308 Dec 26, 2022
75e787c
Merge branch 'master' of github.com:mattermost/mattermost-plugin-azur…
raghavaggarwal2308 Dec 26, 2022
3f930d2
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 26, 2022
eaa4e67
[MI-2450] Fix testcases
raghavaggarwal2308 Dec 26, 2022
99f96ca
[MI-2450] Review fixes
raghavaggarwal2308 Dec 27, 2022
04e59ba
Merge branch 'MI-2450' of github.com:Brightscout/mattermost-plugin-az…
raghavaggarwal2308 Dec 27, 2022
c2bbe66
[MI-2456] Review fixes
raghavaggarwal2308 Dec 27, 2022
cc16221
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 27, 2022
c6018da
[MI-2461] Review fixes
raghavaggarwal2308 Dec 27, 2022
57a8c3d
[MI-2461] Removed unused image
raghavaggarwal2308 Dec 27, 2022
45659fa
Fixed lint error
raghavaggarwal2308 Dec 27, 2022
1335ef3
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 27, 2022
c08f39b
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 27, 2022
bacb265
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 27, 2022
1d2b561
[MI-2463] Removed unused code
raghavaggarwal2308 Dec 27, 2022
89c3596
[MI-2463] Fix testcases
raghavaggarwal2308 Dec 27, 2022
c286123
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 28, 2022
2578ff9
[MI-2466] Changed name of testcases
raghavaggarwal2308 Dec 28, 2022
419dc0c
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 28, 2022
07152c0
[MI-2462] Fix errors
raghavaggarwal2308 Dec 28, 2022
ff3890f
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 28, 2022
799e445
Merge branch 'MI-2474' of github.com:Brightscout/mattermost-plugin-az…
raghavaggarwal2308 Dec 28, 2022
25bdae1
[MI-2476] Fix invalid command constant
raghavaggarwal2308 Dec 28, 2022
9649927
[MI-2450] Review fixes
raghavaggarwal2308 Dec 28, 2022
0d477e9
[MI-2461] Review fixes
raghavaggarwal2308 Dec 28, 2022
94c71d0
[MI-2463] Review fixes
raghavaggarwal2308 Dec 28, 2022
8e179e7
[MI-2466] Review fixes
raghavaggarwal2308 Dec 28, 2022
85e2250
[MI-2461] Review fixes
raghavaggarwal2308 Dec 29, 2022
464812c
[MI-2474] Review fixes
raghavaggarwal2308 Dec 29, 2022
e4c31a8
Merge pull request #6 from Brightscout/MI-2456
raghavaggarwal2308 Dec 29, 2022
1141234
Merge pull request #14 from Brightscout/MI-2476
raghavaggarwal2308 Dec 29, 2022
da188e2
[MI-2470] Review fixes
raghavaggarwal2308 Dec 29, 2022
515d2b5
[MI-2450] Review fixes
raghavaggarwal2308 Dec 29, 2022
c58f46c
[MI-2474] Review fixes
raghavaggarwal2308 Dec 30, 2022
80779de
Merge branch 'MI-2474' of github.com:Brightscout/mattermost-plugin-az…
raghavaggarwal2308 Dec 30, 2022
17fa4fe
Merge pull request #8 from Brightscout/MI-2463
raghavaggarwal2308 Dec 30, 2022
1325681
[MI-2461] Review fixes
raghavaggarwal2308 Dec 30, 2022
8100d48
[MI-2470] Review fix
raghavaggarwal2308 Dec 30, 2022
eae16f8
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 30, 2022
4426ebe
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 30, 2022
a31f509
Merge pull request #7 from Brightscout/MI-2461
raghavaggarwal2308 Dec 30, 2022
4ebdcea
Merge pull request #11 from Brightscout/MI-2462
raghavaggarwal2308 Dec 30, 2022
e5f6e26
Merge pull request #15 from Brightscout/MI-2470
raghavaggarwal2308 Dec 30, 2022
0054e77
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 30, 2022
e8791b3
Merge pull request #9 from Brightscout/MI-2466
raghavaggarwal2308 Dec 30, 2022
5826f24
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 30, 2022
b40b787
[MI-2524] Fix and add testcases on branch MI-2474
raghavaggarwal2308 Dec 30, 2022
bcf9df6
[MI-2524] Review fixes
raghavaggarwal2308 Dec 30, 2022
b2eb70c
[MI-2524] Review fixes
raghavaggarwal2308 Dec 30, 2022
7fd8802
Merge pull request #19 from Brightscout/MI-2524
raghavaggarwal2308 Dec 30, 2022
f702d48
Merge pull request #12 from Brightscout/MI-2474
raghavaggarwal2308 Dec 30, 2022
74d534a
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
raghavaggarwal2308 Dec 30, 2022
c344a62
Merge pull request #4 from Brightscout/MI-2450
raghavaggarwal2308 Dec 30, 2022
44cddec
Bump plugin verstion to v3.1.0
raghavaggarwal2308 Dec 30, 2022
2b74225
Merge pull request #20 from Brightscout/release-3.1.0
raghavaggarwal2308 Dec 30, 2022
71f3356
[MI-2504][server+webapp]: Generated manifest files and Changed "Hide"…
avas27JTG Jan 4, 2023
28ff33d
Merge branch 'master' of github.com:Brightscout/mattermost-plugin-azu…
avas27JTG Jan 5, 2023
e89a2e6
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
avas27JTG Jan 5, 2023
615b9bc
[Fix]: Fixed Circle CI
avas27JTG Jan 11, 2023
266579e
[Fix]: Fixed manifest file
avas27JTG Jan 11, 2023
1ac30cc
[MI-2511] Created constants for common mocks
raghavaggarwal2308 Jan 11, 2023
2df3a96
[MI-2511] Review fixes
raghavaggarwal2308 Jan 11, 2023
4c6b7e6
[MI-2511] Review fix
raghavaggarwal2308 Jan 11, 2023
abf711e
Merge pull request #23 from Brightscout/MI-2511
raghavaggarwal2308 Jan 13, 2023
6112629
[MI-2611]: Fixed modals not opening on multiple clients in case of cl…
avas27JTG Jan 19, 2023
9c9c68c
[MI-2505]: Added logic to protect subscriptions notification webhook …
avas27JTG Jan 19, 2023
7433d0c
Merge branch 'master' of github.com:Brightscout/mattermost-plugin-azu…
avas27JTG Jan 19, 2023
4daf4e0
Merge branch 'epic_phase_3' of github.com:Brightscout/mattermost-plug…
avas27JTG Jan 19, 2023
72424ce
[MI-2613]: Fixed resetting error message on Link modal, showing descr…
avas27JTG Jan 19, 2023
3ab28e7
[MI-2621]: Created font icons for subscription card and changed subsc…
avas27JTG Jan 23, 2023
968391b
[Review fix]: Removed unused files
avas27JTG Jan 25, 2023
84596b6
[MI-2669]: Added some key-values in plugin.json file and created sepa…
avas27JTG Jan 31, 2023
baaa567
[MI-2672]: Removed consumerInput form subscription response, added va…
avas27JTG Feb 1, 2023
d22a81d
[Fix]: Updated manifest file
avas27JTG Feb 1, 2023
46b191e
[MI-2669]: Made changes for subscriptionID to be used as key for KV-s…
avas27JTG Feb 6, 2023
61e8f38
[MI-2669_1]: Added a top level CSS class as a unique selector (#31)
avas27JTG Feb 6, 2023
18ce68a
[MI-2669]: Created a hook for intercepting redux changes and moved th…
avas27JTG Feb 7, 2023
8c5b806
[Refactor]: Removed unused util
avas27JTG Feb 7, 2023
1e0fc5f
[MI-2669]: Created hook to fetch and load filters (#34)
avas27JTG Feb 7, 2023
6d00878
[Fix]: Moved subscriptionID field at the top in struct
avas27JTG Feb 7, 2023
b439dbc
[MI-2748]: Implemented 1:1 mapping between MM user and Azure DevOps u…
avas27JTG Feb 10, 2023
49dad5a
[MI-2750]: Implemented fetching channel list on webapp and removes fr…
avas27JTG Feb 13, 2023
0b1586b
[MI-2765]: Used @mattermost/client for making webapp calls to MM serv…
avas27JTG Feb 15, 2023
e5950fc
[MI-2820]: Modified API endpoint to require a project to be provided
avas27JTG Feb 24, 2023
6b20c52
[MI-2820]: Removed extra line
avas27JTG Feb 24, 2023
633b076
[MI-2820]: Review fixes
avas27JTG Feb 27, 2023
8af9234
Merge branch 'master' of github.com:mattermost/mattermost-plugin-azur…
avas27JTG Feb 27, 2023
3e5a793
[MI-2820]: Added LogWarn and refactored code
avas27JTG Feb 28, 2023
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
2 changes: 1 addition & 1 deletion server/constants/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
PathCreateTasks = "/tasks"
PathLinkProject = "/link"
PathSubscriptions = "/subscriptions"
PathGetSubscriptions = "/subscriptions/{team_id:[A-Za-z0-9]+}"
PathGetSubscriptions = "/subscriptions/{team_id:[A-Za-z0-9]+}/{organization:[A-Za-z0-9-]+}/{project:.+}"
PathSubscriptionNotifications = "/notification"
PathPipelineReleaseRequest = "/pipeline-release-request"
PathPipelineRunRequest = "/pipeline-run-request"
Expand Down
25 changes: 21 additions & 4 deletions server/plugin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Contributor

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

p.handleError(w, r, &serializers.Error{Code: http.StatusInternalServerError, Message: err.Error()})
return
}

organization := pathParams[constants.PathParamOrganization]
project := pathParams[constants.PathParamProject]
Copy link
Contributor

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

Copy link
Contributor Author

@avas27JTG avas27JTG Feb 27, 2023

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

organizationName := strings.ToLower(organization)
projectName := cases.Title(language.Und).String(project)
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{
OrganizationName: organizationName,
ProjectName: projectName,
}); !isProjectLinked {
p.API.LogWarn(fmt.Sprintf("Project %s is not linked", project))
p.handleError(w, r, &serializers.Error{Code: http.StatusBadRequest, Message: "requested project is not linked"})
return
}

var subscriptionList []*serializers.SubscriptionDetails
var subscriptionErr error
createdBy := r.URL.Query().Get(constants.QueryParamCreatedBy)
Expand All @@ -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 != "" {
Copy link
Contributor

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

Copy link
Contributor Author

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

subscriptionByProject := []*serializers.SubscriptionDetails{}
for _, subscription := range subscriptionList {
Expand Down Expand Up @@ -500,10 +519,8 @@ func (p *Plugin) handleGetSubscriptions(w http.ResponseWriter, r *http.Request)
}
}

subscriptionList = paginatedSubscriptions
p.writeJSON(w, paginatedSubscriptions)
}

p.writeJSON(w, subscriptionList)
}

func (p *Plugin) getReviewersListString(reviewersList []serializers.Reviewer) string {
Expand Down
60 changes: 27 additions & 33 deletions server/plugin/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,60 +704,58 @@ func TestHandleGetSubscriptions(t *testing.T) {
for _, testCase := range []struct {
description string
subscriptionList []*serializers.SubscriptionDetails
project string
err error
marshalError error
GetSubscriptionsForAccessibleChannelsOrProjectsError error
statusCode int
isTeamIDValid bool
isProjectLinked bool
}{
{
description: "HandleGetSubscriptions: valid",
subscriptionList: []*serializers.SubscriptionDetails{},
statusCode: http.StatusOK,
isTeamIDValid: true,
isProjectLinked: true,
},
{
description: "HandleGetSubscriptions: project as a query param",
project: testutils.MockProjectName,
statusCode: http.StatusOK,
isTeamIDValid: true,
},
{
description: "HandleGetSubscriptions: error while fetching subscription list",
err: errors.New("error while fetching subscription list"),
statusCode: http.StatusInternalServerError,
isTeamIDValid: true,
},
{
description: "HandleGetSubscriptions: empty subscription list",
statusCode: http.StatusOK,
isTeamIDValid: true,
},
{
description: "HandleGetSubscriptions: marshaling gives error",
marshalError: errors.New("error while marshaling"),
statusCode: http.StatusInternalServerError,
isTeamIDValid: true,
description: "HandleGetSubscriptions: error while fetching subscription list",
err: errors.New("error while fetching subscription list"),
statusCode: http.StatusInternalServerError,
isTeamIDValid: true,
isProjectLinked: true,
},
{
description: "HandleGetSubscriptions: GetSubscriptionsForAccessibleChannelsOrProjects gives error",
project: testutils.MockProjectName,
GetSubscriptionsForAccessibleChannelsOrProjectsError: errors.New("error while getting subscriptions for accessible channels or projects"),
statusCode: http.StatusInternalServerError,
isTeamIDValid: true,
description: "HandleGetSubscriptions: empty subscription list",
statusCode: http.StatusOK,
isTeamIDValid: true,
isProjectLinked: true,
},
{
description: "HandleGetSubscriptions: Team ID is invalid",
statusCode: http.StatusBadRequest,
isTeamIDValid: false,
},
{
description: "HandleGetSubscriptions: Project is not linked",
statusCode: http.StatusBadRequest,
isTeamIDValid: true,
isProjectLinked: false,
},
} {
t.Run(testCase.description, func(t *testing.T) {
mockAPI.On("LogError", testutils.GetMockArgumentsWithType("string", 3)...)
mockAPI.On("LogWarn", testutils.GetMockArgumentsWithType("string", 3)...)

monkey.PatchInstanceMethod(reflect.TypeOf(p), "IsProjectLinked", func(*Plugin, []serializers.ProjectDetails, serializers.ProjectDetails) (*serializers.ProjectDetails, bool) {
return &serializers.ProjectDetails{}, testCase.isProjectLinked
})

if testCase.isTeamIDValid {
mockedStore.EXPECT().GetAllSubscriptions(testutils.MockMattermostUserID).Return(testCase.subscriptionList, testCase.err)
if testCase.isProjectLinked {
mockedStore.EXPECT().GetAllSubscriptions(testutils.MockMattermostUserID).Return(testCase.subscriptionList, testCase.err)
}
mockedStore.EXPECT().GetAllProjects(testutils.MockMattermostUserID).Return([]serializers.ProjectDetails{}, nil)
}

monkey.Patch(json.Marshal, func(interface{}) ([]byte, error) {
Expand All @@ -768,11 +766,7 @@ func TestHandleGetSubscriptions(t *testing.T) {
return testCase.isTeamIDValid
})

monkey.PatchInstanceMethod(reflect.TypeOf(p), "GetSubscriptionsForAccessibleChannelsOrProjects", func(_ *Plugin, _ []*serializers.SubscriptionDetails, _, _, _ string) ([]*serializers.SubscriptionDetails, error) {
return nil, testCase.GetSubscriptionsForAccessibleChannelsOrProjectsError
})

req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("%s?project=%s", "/subscriptions", testCase.project), bytes.NewBufferString(`{}`))
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/subscriptions/%s/%s/%s", testutils.MockTeamID, testutils.MockOrganization, testutils.MockProjectName), bytes.NewBufferString(`{}`))
req.Header.Add(constants.HeaderMattermostUserID, testutils.MockMattermostUserID)

w := httptest.NewRecorder()
Expand Down
1 change: 1 addition & 0 deletions server/testutils/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
MockServiceType = "mockServiceType"
MockApproverID = "mockApproverID"
MockAzureDevopsUserID = "mockAzureDevopsUserID"
MockTeamID = "mockTeamID"
)

func GetMockArgumentsWithType(typeString string, num int) []interface{} {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/containers/Rhs/projectDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const ProjectDetails = memo((projectDetails: ProjectDetails) => {
const {makeApiRequestWithCompletionStatus, getApiState, state} = usePluginApi();

const subscriptionListApiParams = useMemo<FetchSubscriptionList>(() => ({
organization: organizationName,
project: projectName,
channel_id: showAllSubscriptions ? '' : currentChannelId,
page: paginationQueryParams.page,
Expand All @@ -58,7 +59,7 @@ const ProjectDetails = memo((projectDetails: ProjectDetails) => {
service_type: filter.serviceType,
event_type: filter.eventType,
team_id: currentTeamId,
}), [projectName, currentChannelId, currentTeamId, showAllSubscriptions, paginationQueryParams, filter]);
}), [organizationName, projectName, currentChannelId, currentTeamId, showAllSubscriptions, paginationQueryParams, filter]);

const {data, isLoading} = getApiState(pluginConstants.pluginApiServiceConfigs.getSubscriptionList.apiServiceName, subscriptionListApiParams);
const subscriptionListReturnedByApi = data as SubscriptionDetails[] || [];
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/services/pluginApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const azureDevOpsPluginApi = createApi({
}),
[Constants.pluginApiServiceConfigs.getSubscriptionList.apiServiceName]: builder.query<SubscriptionDetails[], FetchSubscriptionList>({
query: (params) => ({
url: `${Constants.pluginApiServiceConfigs.getSubscriptionList.path}/${params.team_id}`,
url: `${Constants.pluginApiServiceConfigs.getSubscriptionList.path}/${params.team_id}/${params.organization}/${params.project}`,
method: Constants.pluginApiServiceConfigs.getSubscriptionList.method,
params: {...params},
}),
Expand Down
1 change: 1 addition & 0 deletions webapp/src/types/common/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type FetchChannelParams = {
}

interface FetchSubscriptionList extends PaginationQueryParams {
organization: string;
project: string;
channel_id: string;
created_by: string;
Expand Down