|
| 1 | +--- |
| 2 | +description: |
| 3 | +globs: |
| 4 | +alwaysApply: true |
| 5 | +--- |
| 6 | + |
| 7 | +# Implementation Plan for a New Pluggable Widget |
| 8 | + |
| 9 | +This document outlines a step-by-step plan to design, build, test, and integrate a new pluggable widget in Mendix. |
| 10 | + |
| 11 | +## 1. Planning and Requirements |
| 12 | + |
| 13 | +- **Define the Widget's Purpose:** Clearly state what the widget does, its name (e.g., "ProgressCircle"), its category, target data, and required properties (e.g., value, maximum, showLabel, onClick). |
| 14 | +- **Check Existing Patterns:** Review similar widgets for best practices and to avoid duplicating functionality. |
| 15 | + |
| 16 | +## 2. Environment Setup |
| 17 | + |
| 18 | +- **Prerequisites:** Install Node.js (using the version specified in the repository), Mendix Studio Pro. |
| 19 | +- **Folder Structure:** Create a new package under `packages/pluggableWidgets/` in the monorepo or use a standalone directory. |
| 20 | + |
| 21 | +4. Define Widget Properties in XML |
| 22 | + Edit the generated XML file (e.g., ProgressCircle.xml) to define properties and property groups. |
| 23 | + |
| 24 | +Ensure property keys match the TypeScript props. |
| 25 | + |
| 26 | +Do not change the widget's unique ID unless necessary. |
| 27 | + |
| 28 | +5. Implement the React Component |
| 29 | + Modify the generated .tsx file to match the XML-defined properties. |
| 30 | + |
| 31 | +Use Mendix API types (e.g., EditableValue, DynamicValue, ActionValue) correctly. |
| 32 | + |
| 33 | +Implement basic rendering and add error/loading states. |
| 34 | + |
| 35 | +Import SCSS for styling and use Atlas UI classes. |
| 36 | + |
| 37 | +6. Build and Run in Studio Pro |
| 38 | + Set the MX_PROJECT_PATH environment variable to your test project's directory, you can ask what the project name running in Studio Pro is so that we can se the MX_PROJECT_PATH. The path is: /Users/rahman.unver/Mendix/ProjectName, this path is always same for the macOS version of Studio Pro. For Windows version, our path is /Volumes/[C] Windows11/Users/Rahman.Unver/Documents/ProjectName. example setting: |
| 39 | + Windows: |
| 40 | + |
| 41 | +- export MX_PROJECT_PATH=/Volumes/[C] Windows11/Users/Rahman.Unver/Documents/DocumentViewerWidget |
| 42 | +- export MX_PROJECT_PATH=/Users/rahman.unver/Mendix/RichTextTest |
| 43 | + |
| 44 | +Run pnpm start (or npm start) to build and watch for changes. |
| 45 | + |
| 46 | +In Studio Pro, synchronize the app directory to load the widget. |
| 47 | + |
| 48 | +Place the widget on a test page and configure properties. |
| 49 | + |
| 50 | +7. Iterative Development |
| 51 | + Develop and test iteratively. |
| 52 | + |
| 53 | +Use browser developer tools for debugging. |
| 54 | + |
| 55 | +Adjust XML and TS code as needed when adding new properties or handling edge cases. |
| 56 | + |
| 57 | +8. Testing and Validation |
| 58 | + Write unit tests for critical logic using Jest, React Testing Library mainly. |
| 59 | + |
| 60 | +Perform UI/functional testing within a Mendix project. |
| 61 | + |
| 62 | +Test responsiveness, performance, and edge cases. |
| 63 | + |
| 64 | +9. Documentation and Metadata |
| 65 | + Update the widget's README with usage instructions and limitations. |
| 66 | + |
| 67 | +Ensure XML descriptions and property captions are clear. |
| 68 | + |
| 69 | +Optionally, add an icon for the widget. |
| 70 | + |
| 71 | +10. Packaging and Sharing |
| 72 | + Run npm run build to produce an MPK file. |
| 73 | + |
| 74 | +Test the MPK in a fresh Mendix project. |
| 75 | + |
| 76 | +Update version numbers and changelogs before distribution. |
| 77 | + |
| 78 | +Common Gotchas: |
| 79 | + |
| 80 | +Ensure XML and TypeScript props match exactly. |
| 81 | + |
| 82 | +Install all third-party dependencies. |
| 83 | + |
| 84 | +Maintain case sensitivity in IDs and keys. |
| 85 | + |
| 86 | +Clean up event listeners to avoid memory leaks. |
| 87 | + |
| 88 | +Ensure compatibility with the target Mendix version. |
| 89 | + |
| 90 | +### Github PR Template |
| 91 | + |
| 92 | +<!------STARTS HERE-----> |
| 93 | +<!-- |
| 94 | +IMPORTANT: Please read and follow instructions below on how to |
| 95 | +open and submit your pull request. |
| 96 | +
|
| 97 | +REQUIRED STEPS: |
| 98 | +1. Specify correct pull request type. |
| 99 | +2. Write meaningful description. |
| 100 | +3. Run `pnpm lint` and `pnpm test` in packages you changed and make sure they have no errors. |
| 101 | +4. Add new tests (if needed) to cover new functionality. |
| 102 | +5. Read checklist below. |
| 103 | +
|
| 104 | +CHECKLIST: |
| 105 | +- Do you have a JIRA story for your pull request? |
| 106 | + - If yes, please format the PR title to match the `[XX-000]: description` pattern. |
| 107 | + - If no, please write your PR title using conventional commit rules. |
| 108 | +- Does your change require a new version of the widget/module? |
| 109 | + - If yes, run `pnpm -w changelog` or update the `CHANGELOG.md` and bump the version manually. |
| 110 | + - If no, ignore. |
| 111 | +- Do you have related PRs in other Mendix repositories? |
| 112 | + - If yes, please link all related pull requests in the description. |
| 113 | + - If no, ignore. |
| 114 | +- Does your change touch XML, or is it a new feature or behavior? |
| 115 | + - If yes, if necessary, please create a PR with updates in the documentation (https://github.com/mendix/docs). |
| 116 | + - If no, ignore. |
| 117 | + - Is your change a bug fix or a new feature? |
| 118 | + - If yes, please add a description (last section in the template) of what should be tested and what steps are needed to test it. |
| 119 | + - If no, ignore. |
| 120 | +--> |
| 121 | + |
| 122 | +<!-- |
| 123 | +What type of changes does your PR introduce? |
| 124 | +Uncomment relevant sections below by removing `<!--` at the beginning of the line. |
| 125 | +--> |
| 126 | + |
| 127 | +### Pull request type |
| 128 | + |
| 129 | +<!-- No code changes (changes to documentation, CI, metadata, etc.) |
| 130 | +<!----> |
| 131 | + |
| 132 | +<!-- Dependency changes (any modification to dependencies in `package.json`) |
| 133 | +<!----> |
| 134 | + |
| 135 | +<!-- Refactoring (e.g. file rename, variable rename, etc.) |
| 136 | +<!----> |
| 137 | + |
| 138 | +<!-- Bug fix (non-breaking change which fixes an issue) |
| 139 | +<!----> |
| 140 | + |
| 141 | +<!-- New feature (non-breaking change which adds functionality) |
| 142 | +<!----> |
| 143 | + |
| 144 | +<!-- Breaking change (fix or feature that would cause existing functionality to change) |
| 145 | +<!----> |
| 146 | + |
| 147 | +<!-- Test related change (New E2E test, test automation, etc.) |
| 148 | +<!----> |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +<!--- |
| 153 | +Describe your changes in detail. |
| 154 | +Try to explain WHAT and WHY you change, fix or refactor. |
| 155 | +--> |
| 156 | + |
| 157 | +### Description |
| 158 | + |
| 159 | +<!-- |
| 160 | +Please uncomment and fill in the following section |
| 161 | +to describe which part of the package needs to be tested |
| 162 | +and how it can be tested. |
| 163 | +--> |
| 164 | +<!-- |
| 165 | +### What should be covered while testing? |
| 166 | +--> |
| 167 | + |
| 168 | +<!------ENDS HERE-----> |
| 169 | + |
| 170 | +Keep this template in mind if I ever ask you to open a PR through command console, Github CLI or similar. |
0 commit comments