Skip to content

[GH-669]: "Add org selector to create issue modal" thoratvinod:issue-669 - #766

Merged
Kshitij-Katiyar merged 6 commits into
mattermost:masterfrom
cyrusjc:cyrusjc/optimize-github-modal
May 23, 2025
Merged

[GH-669]: "Add org selector to create issue modal" thoratvinod:issue-669#766
Kshitij-Katiyar merged 6 commits into
mattermost:masterfrom
cyrusjc:cyrusjc/optimize-github-modal

Conversation

@cyrusjc

@cyrusjc cyrusjc commented Apr 9, 2024

Copy link
Copy Markdown
Contributor

Fixes #669
Takes #675 to the finish line.

@mattermost-build

Copy link
Copy Markdown
Contributor

Hello @cyrusjc,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@hanzei
hanzei requested review from ayusht2810 and raghavaggarwal2308 and removed request for hanzei and mickmister April 9, 2024 06:54
@hanzei

hanzei commented Apr 9, 2024

Copy link
Copy Markdown
Contributor

@raghavaggarwal2308 @ayusht2810 Can you please review the community contribution?

@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Apr 9, 2024
@codecov-commenter

codecov-commenter commented Apr 9, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 2.00000% with 98 lines in your changes are missing coverage. Please review.

Project coverage is 15.93%. Comparing base (da4c4df) to head (aecfd27).
Report is 3 commits behind head on master.

Current head aecfd27 differs from pull request most recent head a95d58b

Please upload reports for the commit a95d58b to get more accurate results.

Files Patch % Lines
server/plugin/api.go 2.00% 98 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #766      +/-   ##
==========================================
- Coverage   16.16%   15.93%   -0.23%     
==========================================
  Files          17       17              
  Lines        6021     6117      +96     
==========================================
+ Hits          973      975       +2     
- Misses       5003     5097      +94     
  Partials       45       45              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ayusht2810 ayusht2810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution! @cyrusjc
I have just a few suggestions and clarifications.

Comment thread server/plugin/api.go Outdated
Comment thread server/plugin/api.go Outdated
Comment thread server/plugin/api.go Outdated
Comment thread server/plugin/api.go Outdated
Comment thread server/plugin/api.go Outdated
Comment thread webapp/src/components/github_repo_selector/github_repo_selector.jsx Outdated
Comment thread webapp/src/components/github_repo_selector/github_repo_selector.jsx Outdated
}
}

onChangeForOrg = (_, org) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we remove the first parameter here, if it is not used anywhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could probably change it... the signature here is the same before changes:

onChange = (_, name) => {
const repo = this.props.yourRepos.find((r) => r.full_name === name);
this.props.onChange({name, permissions: repo.permissions});
}

Not sure exactly why it was written this way but I'll remove placeholder from here and the other onChange signature mention in the another suggestion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just tested removing the first parameter and it seems like it 's vital to the functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please tell us what errors or issues you had after making the changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The repository now displays what I think are the local files on the server after removing the first parameter as shown:

Suggested change
onChangeForOrg = (_, org) => {
onChangeForOrg = (org) => {

image

Comment thread webapp/src/components/github_repo_selector/github_repo_selector.jsx
Comment thread webapp/src/components/github_repo_selector/github_repo_selector.jsx Outdated
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Comment thread server/plugin/api.go Outdated
c.Log.WithError(err).Warnf("Failed to list repositories")
p.writeAPIError(w, &APIErrorResponse{Message: "Failed to fetch repositories", StatusCode: http.StatusInternalServerError})
err := errors.New("Organization query param is empty")
c.Log.WithError(err).Warnf("Organization query param is empty")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why have we made this change? We will be printing the same message twice in the logs with this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I've changed it to the following:

Suggested change
c.Log.WithError(err).Warnf("Organization query param is empty")
c.Log.Warnf("Organization query param is empty")

I'm not sure what best practices are here but I haven't seen an example of context logging without an error. Would this be okay?

Comment thread server/plugin/api.go Outdated
p.writeAPIError(w, &APIErrorResponse{Message: "Failed to fetch repositories", StatusCode: http.StatusInternalServerError})
err := errors.New("Organization query param is empty")
c.Log.WithError(err).Warnf("Organization query param is empty")
p.writeAPIError(w, &APIErrorResponse{Message: "Bad request, must include organization name ", StatusCode: http.StatusBadRequest})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we need to write Bad request in the error, as it is already stated in the status code. Also, can we use the message as present in line 1289, as it tells us where we must include the organization name? What are your thoughts on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think you make a good point, we can just use the logging message as it's more descriptive. I've changed it include the message in line 1289.

Suggested change
p.writeAPIError(w, &APIErrorResponse{Message: "Bad request, must include organization name ", StatusCode: http.StatusBadRequest})
p.writeAPIError(w, &APIErrorResponse{Message: "Organization query is empty, must include organization name ", StatusCode: http.StatusBadRequest})

Comment thread server/plugin/api.go Outdated
Comment thread webapp/src/action_types/index.js Outdated
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@mickmister
mickmister requested a review from ayusht2810 May 28, 2024 19:57

@mickmister mickmister left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this contribution @cyrusjc 👍 LGTM

There are some merge conflicts caused by typescript migration. Can you please take a look at this? Thank you

@cyrusjc cyrusjc closed this May 30, 2024
@cyrusjc
cyrusjc force-pushed the cyrusjc/optimize-github-modal branch from 1845085 to e958064 Compare May 30, 2024 09:42
@cyrusjc

cyrusjc commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

Ah I did a woopsies. I'll reopen this in a bit

@cyrusjc cyrusjc reopened this May 31, 2024
@mickmister
mickmister self-requested a review May 31, 2024 13:57
@mickmister
mickmister removed their request for review July 10, 2024 05:23
@wiggin77

Copy link
Copy Markdown
Member

@Kshitij-Katiyar how does this PR relate to your recent PR handling orgs?

@raghavaggarwal2308

Copy link
Copy Markdown

@wiggin77 The PR created by us is just fixing an issue in the existing multiple org functionality on master (not released yet) and this PR is adding the functionality to just the create issue modal:

  • In the multiple org feature, we added a functionality to add multiple orgs in the plugin settings and we get the data of the orgs selected in the system console in the create issue modal dropdown (and all the other places in the plugin). But in case no org is selected, we will have the data from all the orgs in the user's account.

  • The feature implemented in this PR adds a dropdown that has all the orgs listed in a dropdown and the user can filter the repos dropdown on the basis of that. Also, this PR makes it so that if an org (singular org i.e. behaviour before multi org PR was merged) is set in the plugin config then only that org will be listed in the dropdown.

To make this PR work with the multiple org feature we will have to make some tweaks since earlier there was only one org allowed in the config but now that behavior is changed to list multiple orgs.

@wiggin77

Copy link
Copy Markdown
Member

To make this PR work with the multiple org feature we will have to make some tweaks since earlier there was only one org allowed in the config but now that behavior is changed to list multiple orgs.

@raghavaggarwal2308 How much/time effort is needed to get this working with the current master branch?

@raghavaggarwal2308

Copy link
Copy Markdown

@wiggin77 I think it will take around 1 day to get this working with the master branch. Also, we will have to close this PR and create a new one, since this is created from a separate fork.

@wiggin77

Copy link
Copy Markdown
Member

@raghavaggarwal2308 let me know if/when this becomes ready for review.

@Kshitij-Katiyar
Kshitij-Katiyar requested a review from wiggin77 as a code owner May 1, 2025 10:21
@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

@wiggin77 I have resolved the conflicts on this PR, You can have a look

Comment thread server/plugin/api.go Outdated
githubClient := p.githubConnectUser(c.Context.Ctx, c.GHInfo)
orgList, err := getOrganizationList(c.Ctx, "", githubClient, github.ListOptions{PerPage: 50})
if err != nil {
c.Log.WithError(err).Warnf("Failed to list organizations")

@wiggin77 wiggin77 May 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this be an error level log? It is returning a 500 error on the request.

Same with all the other places a 500 error is written on the response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cyrusjc is not actively working on this PR so I will be fixing these issuse

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wiggin77 I have fixed these issues at multiple places

@wiggin77

wiggin77 commented May 1, 2025

Copy link
Copy Markdown
Member

@wiggin77 I have resolved the conflicts on this PR, You can have a look

@Kshitij-Katiyar there is a problem with the logging levels.

@Kshitij-Katiyar

Copy link
Copy Markdown
Contributor

@wiggin77 I have resolved the conflicts on this PR, You can have a look

@Kshitij-Katiyar there is a problem with the logging levels.

@wiggin77 Done with the fixes

Comment thread webapp/src/types/github_types.ts

@AayushChaudhary0001 AayushChaudhary0001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR is tested, and code changes are working fine on adding an organisation selector in the create issue modal to filter the repositories based on organisations for both MM local and cloud server, including public and private repositories.

LGTM, Approved.

@Kshitij-Katiyar
Kshitij-Katiyar merged commit c1ac2f9 into mattermost:master May 23, 2025
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer Lifecycle/1:stale 3: QA Review Requires review by a QA tester labels May 23, 2025
SCREEN88 added a commit to hhru/mattermost-plugin-forgejo that referenced this pull request Jun 17, 2026
Merge upstream mattermost-plugin-github (…4b03e0c, ~40 commits up to just
before the React 18 migration) into the Forgejo fork. Resolved conflicts
case-by-case: upstream logic by default, Forgejo specifics preserved.

Key resolutions / deviations from upstream:
- Telemetry removed (upstream mattermost#952): experimental/telemetry was dropped from
  server/public v0.1.21, so telemetry.go deleted and all tracker call sites
  removed (api.go, flows.go, plugin.go). Forced by the dependency, not a choice.
- graphql/ stays removed (fork already dropped it); go.mod tidied (shurcooL deps).
- Ported useGitHubClient + handleRevokedToken into plugin.go (Forgejo wording)
  so upstream's token-revocation handling works; wired into label/assignee/
  milestone fetchers.
- Brought in org selector endpoints mattermost#766 (getOrganizations/getReposByOrg/
  getRepository, getOrganizationList, RepoResponse/RepositoryResponse types),
  adapted to Forgejo names and the fork's package-level getRepositoryList/
  getRepositoryListByOrg signatures.
- Brought in default-repo command mattermost#938 (handlers + DefaultRepoKey/ErrNotFound),
  wired "default-repo" into CommandHandlers and autocomplete (was unused).
- Adopted upstream log-spam fix mattermost#951 and connect error propagation mattermost#934 with
  Forgejo wording; kept the fork's refresh-token decryption path.
- link_tooltip: openedByLink prefers user.html_url, falls back to the configured
  Forgejo instance (forgejo.pyn.ru) instead of github.com.
- webapp TS migrations: ported Forgejo renames into the new client.ts and
  user_attribute.ts/.tsx (getForgejoUser, forgejoUsers, baseURL, fa-git).
- post-menu create-issue/attach-comment adopted upstream's functional component
  form (registerPostDropdownMenuAction model) with Forgejo naming.

Tests: kept the fork's api_test/command_test/webhook_test (upstream's new
github-shaped suites mattermost#855 not ported in M1); updated help-command test (help no
longer fetches user info) and link_tooltip fallback test for Forgejo.

Gate: go build/vet/test, golangci-lint v2, webapp build/tsc/eslint/jest,
make dist — all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 Contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve performance of Create Issue modal repository selector