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

[MM-420] Add feature to support multiple orgs in plugin settings #773

Merged
merged 15 commits into from
Jul 30, 2024

Conversation

ayusht2810
Copy link
Contributor

Summary

  • Added feature to support multiple orgs in plugin settings
  • Updated Readme

Ticket Link

Fixes #552

What to test?

  • Add comma separated organizations name in plugin settings.
  • Test all the features required with the above change and check if we get all the details related to different organization

Checklist

  • Completed dev testing
  • make test Ran test cases and ensured they are passing
  • make check-style Ran style check and ensured both webapp and server pass the checks

@ayusht2810 ayusht2810 self-assigned this Apr 30, 2024
@ayusht2810 ayusht2810 added the 2: Dev Review Requires review by a core committer label Apr 30, 2024
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to using this feature on Community!

@@ -298,3 +298,42 @@ func TestLastN(t *testing.T) {
assert.Equal(t, tc.Expected, lastN(tc.Text, tc.N))
}
}

func TestGetOrganizations(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table tests ❤️

server/plugin/api.go Outdated Show resolved Hide resolved
server/plugin/plugin.go Outdated Show resolved Hide resolved
server/plugin/utils.go Outdated Show resolved Hide resolved
server/plugin/utils.go Outdated Show resolved Hide resolved
if len(org) != 0 {
orgField = fmt.Sprintf("org:%v", org)
for _, org := range orgs {
if len(org) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can org be ""?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if a user enters orgA,orgB, as values in the system console, the last value after splitting the string will be an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we guard for that case in getOrganizations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we guard for that case in getOrganizations?

@hanzei Can you please elaborate more on this comment? We have already added the guard to the getOrganizations function. Do you mean to remove it from here and apply the condition separately, wherever it is required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slice returned from getOrganizations can never contain an empty string, right? Do we need the additional check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hanzei There was an additional check present in the lhs_request.go file, which I have removed now. Now, we only have this check present in the getOrganizations function.

server/plugin/utils.go Outdated Show resolved Hide resolved
server/plugin/plugin.go Outdated Show resolved Hide resolved
server/plugin/api.go Outdated Show resolved Hide resolved
server/plugin/utils.go Outdated Show resolved Hide resolved
…pdate function definition and minor reveiw fixes
@ayusht2810
Copy link
Contributor Author

@hanzei fixed the review comments. Please re-review.

@ayusht2810 ayusht2810 requested a review from hanzei May 1, 2024 16:57
server/plugin/utils.go Outdated Show resolved Hide resolved
if len(org) != 0 {
orgField = fmt.Sprintf("org:%v", org)
for _, org := range orgs {
if len(org) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we guard for that case in getOrganizations?

server/plugin/plugin.go Outdated Show resolved Hide resolved
@ayusht2810
Copy link
Contributor Author

@hanzei Fixed the review comments. Please re-review

@ayusht2810 ayusht2810 requested a review from hanzei May 7, 2024 12:01
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

server/plugin/plugin.go Outdated Show resolved Hide resolved
if len(org) != 0 {
orgField = fmt.Sprintf("org:%v", org)
for _, org := range orgs {
if len(org) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slice returned from getOrganizations can never contain an empty string, right? Do we need the additional check here?

Copy link
Member

@mickmister mickmister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work on this! 🚀 I have a few suggestions and questions to make sure we don't miss anything here. Nice work!

README.md Outdated Show resolved Hide resolved
plugin.json Outdated Show resolved Hide resolved
server/plugin/configuration.go Outdated Show resolved Hide resolved
server/plugin/graphql/lhs_request.go Outdated Show resolved Hide resolved
webapp/src/components/sidebar_right/sidebar_right.jsx Outdated Show resolved Hide resolved
webapp/src/reducers/index.js Outdated Show resolved Hide resolved
server/plugin/plugin.go Show resolved Hide resolved
server/plugin/plugin.go Outdated Show resolved Hide resolved
Copy link

@AayushChaudhary0001 AayushChaudhary0001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has been tested for the following scenario:

  • Support for multiple orgs
  • Data updated for multiple orgs in LHS
  • Notification for all the orgs for which subscription is created

The PR was wroking fine for all the above scenarios, LGTM. Approved.

@mickmister
Copy link
Member

@AayushChaudhary0001 Did you also test the case of not having an org configured?

@AayushChaudhary0001
Copy link

@mickmister Yes, I have tested it with empty field as well for the org support, works fine even if no org is added.

@mickmister
Copy link
Member

@AayushChaudhary0001 Got it, thank you 👍

@mickmister
Copy link
Member

@ayusht2810 There are some conflicts to resolve here

@mickmister
Copy link
Member

@Kshitij-Katiyar @raghavaggarwal2308 I'm curious where this is at currently? On the community server we're currently unable to efficiently collaborate on the mattermost-community projects. Not super urgent, but I don't want this to fall through here. Just checking in

@raghavaggarwal2308 raghavaggarwal2308 added this to the v2.3.0 milestone Jun 21, 2024
@Kshitij-Katiyar
Copy link
Contributor

@mickmister Fixed the conflicts and updated the code with the suggestions. Please have a look.

webapp/src/reducers/index.ts Outdated Show resolved Hide resolved
webapp/src/types/github_types.ts Outdated Show resolved Hide resolved
@Kshitij-Katiyar
Copy link
Contributor

@mickmister Fixed the suggestions, please have a look.

@AayushChaudhary0001
Copy link

@ayusht2810 I found a issue while testing this PR:
Issue: Data is not getting updated for multiple orgs in LHS

Steps to reproduce:

  1. Connect a github account to Mattermost
  2. Go to plugin settings of Github on Mattermost
  3. Add multiple orgs
  4. Check the data in LHS

Actual - Multiple orgs data is not getting updated in LHS
Expected - Multiple orgs data should get updated in LHS

@hanzei hanzei added the 3: QA Review Requires review by a QA tester label Jul 8, 2024
@raghavaggarwal2308 raghavaggarwal2308 modified the milestones: v2.3.0, v2.4.0 Jul 8, 2024
@raghavaggarwal2308
Copy link
Contributor

@AayushChaudhary0001 The above issue is fixed now. Please re-test.

Copy link

@arush-vashishtha arush-vashishtha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has been tested for the following scenarios:

  • Support for multiple orgs
  • Data updated for multiple orgs in LHS
  • Notification for all the orgs for which subscription is created

The PR was working fine for all the above mentioned conditions, LGTM. Approved

plugin.json Outdated Show resolved Hide resolved
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
@wiggin77 wiggin77 removed the 2: Dev Review Requires review by a core committer label Jul 29, 2024
@raghavaggarwal2308 raghavaggarwal2308 merged commit d1a6d8d into master Jul 30, 2024
9 checks passed
@raghavaggarwal2308 raghavaggarwal2308 deleted the MM-420 branch July 30, 2024 07:52
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Make it possible to configure multiple GitHub Organizations
8 participants