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

[GH-61]: Adding "Create Issue" and "Attach Comment to Issue" modals #306

Merged
merged 81 commits into from
Jul 18, 2024

Conversation

raghavaggarwal2308
Copy link
Contributor

@raghavaggarwal2308 raghavaggarwal2308 commented Jun 20, 2022

Summary

Added a modal to create a GitLab issue on an existing project of the user.

  • Created API to get all user projects, project labels, project assignees, project milestones, GitLab issues, and create an issue.
  • Created a "CreateIssueModal" component to create an issue on GitLab and an "AttachCommentToIssueModal" component to attach comment to an existing issue on Gitlab.
  • Created a "CreateIssuePostMenuAction" and "AttachCommentToIssuePostMenuAction" component and registered it as "PostDropdownMenuComponent" to open the create issue modal and attach comment to issue modal.
  • Configured babel-loader to load .tsx and .ts files.
  • Upgraded the dependencies in package.json to match the dependencies in the GitHub plugin.

Screenshots

  • Click "Create Gitlab Issue" or "Attach to Gitlab issue" in the context menu (shown when a user connects their GitLab account with the plugin installed) on non-system messages
    Screenshot from 2022-07-06 22-14-15

  • Create Gilab issue modal will open
    Screenshot from 2022-06-20 23-21-30

  • Search and select a Project and title of the issue
    Screenshot from 2022-06-20 23-22-54

  • Select labels, assignees, milestone, and description if any, and click submit to create an issue
    Screenshot from 2022-06-20 23-23-54

  • Attach comment to issue modal
    Screenshot from 2022-07-06 22-15-56

Ticket

Fixes #61 (Adding create issue modal and Attach comment to issue modal)
Fixes #402

1. Converted files to .tsx
2. Defined proper types
1. Button in context menu to open "Attach to gitlab issue" modal.
2. Created modal to attach comment to issue.
1. Created api endpoint to attach comment to an issue.
1. Added message when comment is created.
1. Handled error while making call for searching issues.
1. Converted file to .tsx.
2. Removed redundant code.
1. Fixed error messages.
1. Made first letter of error lowercase
2. Used shorthand
3. fixed lint errors
…tlab into MI-1860

Review fixes:
1. Defined types and converted files to .tsx
1. Defined proper types
2. Changed file extension of types file to .d.ts
1. Corrected error messages in api.go.
2. Added EOF.
1. Moved type "Actions" from index.ts to main file.
2. Converted form_button to fuctional component.
3. Converted gitlab.jsx to .tsx.
1. Converted gitlab.tsx to funtional component.
2. Optional chaining while checking for error in loadoptions function.
Review Fixes and created new branch.
@mattermod
Copy link
Contributor

Hello @raghavaggarwal2308,

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.

@codecov
Copy link

codecov bot commented Jun 20, 2022

Codecov Report

Attention: Patch coverage is 2.57353% with 265 lines in your changes missing coverage. Please review.

Project coverage is 32.02%. Comparing base (191a11a) to head (e0e2765).
Report is 9 commits behind head on master.

Current head e0e2765 differs from pull request most recent head 6758220

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

Files Patch % Lines
server/api.go 3.12% 217 Missing ⚠️
server/command.go 0.00% 25 Missing ⚠️
server/plugin.go 0.00% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
- Coverage   34.02%   32.02%   -2.00%     
==========================================
  Files          22       22              
  Lines        4021     4293     +272     
==========================================
+ Hits         1368     1375       +7     
- Misses       2515     2780     +265     
  Partials      138      138              

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

@raghavaggarwal2308 raghavaggarwal2308 changed the title Adding create issue modal [GH-61]: Adding create issue modal Jun 21, 2022
1. Added "react-dom" dependency in package.json
1. Converted class components to functional components.
2. Used absolute paths.
1. Removed mapStateToProps/mapDispatchToProps from functional components and used useSelector/useDispatch.
Copy link
Contributor

@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.

Nice work @raghavaggarwal2308 👍 This feature has a high impact for the plugin

I gave the PR another review and left some comments. Generally approving but want to give you a chance to discuss before approving. Let me know what you think

Also, can you please create some gifs of this feature working so it's easy for UX designers to see it in action?


For the project selector in the attach comment modal #306 (comment)

Just a suggestion for point 4, we can also use the config setting "Gitlab Group". When the setting is empty we can show all issues and when it is specified we can display the issues related to that group only.

Are we able to filter on projects where the user is a member or collaborator, if the gitlab group is not set?

server/gitlab/api.go Outdated Show resolved Hide resolved
webapp/src/components/form_button.tsx Outdated Show resolved Hide resolved
webapp/src/components/form_button.tsx Outdated Show resolved Hide resolved
Comment on lines 6 to 13
type PropTypes = {
disabled?: boolean;
defaultMessage?: string,
btnClass?: string;
saving?: boolean;
savingMessage?: string;
onClick?: () => void;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Should some of these be set to required? I know this is likely copied from another project

Copy link
Contributor

Choose a reason for hiding this comment

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

This is used at multiple places, and each uses different props. So none of them are required.

Comment on lines +8 to +10
if (!projectName) {
return [];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So if a project has not been selected yet, we unconditionally return an empty array (of assignees for instance). Should we disable the select component in this case if it's always going to be empty?

Copy link
Contributor

@ayusht2810 ayusht2810 Jun 27, 2024

Choose a reason for hiding this comment

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

The assignees and other options are hidden for a user until the user selects the project. Same can be seen in the video. #306 (comment)

webapp/src/components/post_options/create_issue.tsx Outdated Show resolved Hide resolved
webapp/src/components/post_options/create_issue.tsx Outdated Show resolved Hide resolved
webapp/src/components/issue_attribute_selector.tsx Outdated Show resolved Hide resolved
};

const IssueAttributeSelector = ({isMulti, projectName, theme, label, onChange, loadOptions, selection}: PropTypes) => {
const [options, setOptions] = useState<SelectionType[]>([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't tell what SelectionType is or where it's defined

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +36 to +40
useEffect(() => {
if (projectName && prevProjectName !== projectName) {
loadSelectOptions();
}
}, [projectName]);
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 add prevProjectName to the array?

Suggested change
useEffect(() => {
if (projectName && prevProjectName !== projectName) {
loadSelectOptions();
}
}, [projectName]);
useEffect(() => {
if (projectName && prevProjectName !== projectName) {
loadSelectOptions();
}
}, [projectName, prevProjectName]);

Copy link
Contributor

Choose a reason for hiding this comment

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

We should really be using the react hooks eslint rule to find these sorts of cases

Copy link
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 prevProjectName in the array, as its value will change when we update the projectName

@mickmister
Copy link
Contributor

@raghavaggarwal2308 Are you or another developer planning on continuing work on this?

@raghavaggarwal2308
Copy link
Contributor Author

@raghavaggarwal2308 Are you or another developer planning on continuing work on this?

@mickmister Yeah, we will work on this ASAP. Apologies for the delay.

@ayusht2810
Copy link
Contributor

Video for the feature:
screen-capture (7).webm

@ayusht2810
Copy link
Contributor

@mickmister Fixed the review fixes. Please re-review.

Are we able to filter on projects where the user is a member or collaborator, if the gitlab group is not set?

Also can you provide more details on this comment?

@mickmister
Copy link
Contributor

Are we able to filter on projects where the user is a member or collaborator, if the gitlab group is not set?

Also can you provide more details on this comment?

@ayusht2810 If the gitlab group is not set in the system console: Can we make it so the user only sees projects where the user a member or collaborator? Meaning, the user shouldn't see projects that they have no association with in the project selectors

webapp/src/types/mattermost-webapp/index.d.ts Outdated Show resolved Hide resolved
webapp/src/types/gitlab_types.d.ts Outdated Show resolved Hide resolved
webapp/src/components/gitlab_project_selector/index.tsx Outdated Show resolved Hide resolved
webapp/src/components/form_button.tsx Outdated Show resolved Hide resolved
@mickmister mickmister removed the 2: Dev Review Requires review by a core committer label Jun 27, 2024
@raghavaggarwal2308
Copy link
Contributor Author

@mickmister Fixed the review comments added by you

@raghavaggarwal2308 raghavaggarwal2308 modified the milestones: v1.9.0, v1.10.0 Jul 1, 2024
@ayusht2810
Copy link
Contributor

@mickmister Fixed the review fixes. Please re-review

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.

@raghavaggarwal2308 Found a issue while testing this PR.
Issue: Private projects are accessible without any granted permissions (Access to the private repository is kept off from sysytem console).

Steps to reproduce:

  1. Enter a message in channel
  2. Go to the message action
  3. Select the option 'Create GitLab Issue'
  4. Check the project suggestions in the Project dropdown

Expected: Private projects should not be accessibile without the permission
Actual: Private projects are accessibile without the granted permission

@ayusht2810
Copy link
Contributor

Expected: Private projects should not be accessibile without the permission

@AayushChaudhary0001 Regarding the expected behavior, the system console settings for Enable Private Repositories is related to subscription and not to this issue creation feature as seen in the help text (Optional) Allow the plugin to work with private repositories for subscriptions. Should we update the help text to disable private repo for all the features if the setting is disabled?

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.

Approving this PR, as everything is working fine for this, will create a separate issue regarding the flow above.

@raghavaggarwal2308 raghavaggarwal2308 merged commit c7208c0 into mattermost:master Jul 18, 2024
7 checks passed
@raghavaggarwal2308 raghavaggarwal2308 deleted the create_issue_modal branch July 18, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: QA Review Requires review by a QA tester
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create issues through slash commands Backport github plugin improvements