Fix : Undo Btn Hide, Refresh btn refreshes the grid, empty mappings w…#4108
Conversation
…ill not be downloaded
WalkthroughThis pull request updates the WireMock pages by modifying grid control properties and enhancing functionality. The user interface now displays refresh and undo options in the grid. New event handlers and methods have been added to refresh the grid data and handle downloads dynamically, including checks for empty mapping lists and improvements in file path construction. Additionally, a new solution context variable is introduced and a user message entry is added to indicate when no mappings are available for download. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant Controller
participant Grid
User->>UI: Click Refresh Button
UI->>Controller: Invoke RefreshMappings()
Controller->>Grid: Call SetGridData()
Grid-->>Controller: Return Updated Data
Controller-->>UI: Update Grid Display
sequenceDiagram
participant User
participant UI
participant xDownloadMapping_Click
participant FileSystem
User->>UI: Click Download Mapping Button
UI->>xDownloadMapping_Click: Trigger Download Event
xDownloadMapping_Click->>xDownloadMapping_Click: Check if Grid Data is Empty
alt Grid is empty
xDownloadMapping_Click-->>User: Display "No Mapping Available" Message
else
xDownloadMapping_Click->>FileSystem: Create Directory & Construct File Path
FileSystem-->>xDownloadMapping_Click: Return File Path
xDownloadMapping_Click-->>User: Process and Save Download
end
Suggested Reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
Ginger/GingerCoreCommon/ReporterLib/UserMsgsPool.cs (1)
818-829: 🧹 Nitpick (assertive)Consider standardizing WireMock message formats.
The WireMock-related messages have some inconsistencies in their formatting:
- Some messages start with a space (lines 819, 820, 821, 822, 823)
- Some messages have different punctuation patterns
Apply this diff to standardize the message formats:
- { eUserMsgKey.WireMockConnectionSuccess, new UserMsg(eUserMsgType.INFO, "WireMock Connection Success", " WireMock Connection Successful.", eUserMsgOption.OK, eUserMsgSelection.None) }, - { eUserMsgKey.WireMockMappingDownload, new UserMsg(eUserMsgType.INFO, "WireMock Mapping Download", " WireMock Mapping downloaded Successful.", eUserMsgOption.OK, eUserMsgSelection.None) }, - { eUserMsgKey.WireMockMappingDownloadFailed, new UserMsg(eUserMsgType.ERROR, "WireMock Mapping Download", " WireMock Mapping download failed.", eUserMsgOption.OK, eUserMsgSelection.None) }, - { eUserMsgKey.WireMockMappingEmpty, new UserMsg(eUserMsgType.INFO, "No WireMock Mapping Found", " No WireMock Mapping Available to Show.", eUserMsgOption.OK, eUserMsgSelection.None) }, - { eUserMsgKey.WireMockMappingDownloadEmpty, new UserMsg(eUserMsgType.INFO, "No WireMock Mapping Found", " No WireMock Mapping Available to Download.", eUserMsgOption.OK, eUserMsgSelection.None) }, + { eUserMsgKey.WireMockConnectionSuccess, new UserMsg(eUserMsgType.INFO, "WireMock Connection Success", "WireMock Connection Successful.", eUserMsgOption.OK, eUserMsgSelection.None) }, + { eUserMsgKey.WireMockMappingDownload, new UserMsg(eUserMsgType.INFO, "WireMock Mapping Download", "WireMock Mapping downloaded successfully.", eUserMsgOption.OK, eUserMsgSelection.None) }, + { eUserMsgKey.WireMockMappingDownloadFailed, new UserMsg(eUserMsgType.ERROR, "WireMock Mapping Download", "WireMock Mapping download failed.", eUserMsgOption.OK, eUserMsgSelection.None) }, + { eUserMsgKey.WireMockMappingEmpty, new UserMsg(eUserMsgType.INFO, "No WireMock Mapping Found", "No WireMock Mapping available to show.", eUserMsgOption.OK, eUserMsgSelection.None) }, + { eUserMsgKey.WireMockMappingDownloadEmpty, new UserMsg(eUserMsgType.INFO, "No WireMock Mapping Found", "No WireMock Mapping available to download.", eUserMsgOption.OK, eUserMsgSelection.None) },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
Ginger/Ginger/ApplicationModelsLib/WireMockAPIModels/WireMockTemplatePage.xaml(1 hunks)Ginger/Ginger/ApplicationModelsLib/WireMockAPIModels/WireMockTemplatePage.xaml.cs(6 hunks)Ginger/Ginger/GeneralWindows/WireMockMappingPage.xaml(1 hunks)Ginger/Ginger/GeneralWindows/WireMockMappingPage.xaml.cs(3 hunks)Ginger/GingerCoreCommon/ReporterLib/UserMsgsPool.cs(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/Ginger/ApplicationModelsLib/WireMockAPIModels/WireMockTemplatePage.xaml.cs (1)
Learnt from: AmanPrasad43
PR: Ginger-Automation/Ginger#4100
File: Ginger/Ginger/ApplicationModelsLib/APIModels/APIModelPage.xaml.cs:44-44
Timestamp: 2025-02-13T11:58:42.226Z
Learning: In the APIModelPage class, WireMockMappingController (wmController) should be lazily initialized when needed rather than at construction time, as its usage is limited to specific scenarios.
🔇 Additional comments (11)
Ginger/Ginger/ApplicationModelsLib/WireMockAPIModels/WireMockTemplatePage.xaml (1)
62-63: LGTM! Grid control properties updated correctly.The changes to the grid control properties align with the PR objectives:
- ShowRefresh is now Visible to enable grid refresh functionality
- ShowUndo is explicitly set to Collapsed
Ginger/Ginger/GeneralWindows/WireMockMappingPage.xaml (1)
64-64: LGTM! Grid control properties are consistent.The grid control properties are consistent with WireMockTemplatePage.xaml and align with the PR objectives.
Ginger/Ginger/GeneralWindows/WireMockMappingPage.xaml.cs (3)
65-65: LGTM! Refresh button handler added correctly.The refresh button handler is properly set up to enable grid refresh functionality.
85-88: LGTM! RefreshMappings implementation is clean and consistent.The RefreshMappings method is implemented consistently with WireMockTemplatePage.
164-168: LGTM! Empty data source check improves error handling.The check for empty data source before attempting download improves user experience by providing appropriate feedback.
Ginger/Ginger/ApplicationModelsLib/WireMockAPIModels/WireMockTemplatePage.xaml.cs (4)
73-77: LGTM! Button handlers are properly configured.The download and refresh button handlers are correctly set up to enable grid functionality.
94-98: LGTM! RefreshMappings implementation is clean.The RefreshMappings method is implemented correctly to refresh grid data.
252-256: LGTM! Empty data source check improves error handling.The check for empty data source before attempting download improves user experience by providing appropriate feedback.
266-280: LGTM! File path construction is robust.The file path construction:
- Uses solution folder as base path
- Creates directory if it doesn't exist
- Properly handles path separators
Ginger/GingerCoreCommon/ReporterLib/UserMsgsPool.cs (2)
187-187: LGTM! New enum value added for WireMock empty mapping download scenario.The new enum value
WireMockMappingDownloadEmptyis appropriately placed in the WireMock-related section of the enum.
823-823: LGTM! New user message added for WireMock empty mapping download scenario.The message is well-defined with:
- Appropriate type: INFO
- Clear caption: "No WireMock Mapping Found"
- Descriptive message: "No WireMock Mapping Available to Download"
- Default button: OK
- Default selection: None
| public WireMockMappingController wmController; | ||
| public ApplicationAPIModel mApplicationAPIModel; | ||
| Solution mSolution; |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider lazy initialization of WireMockMappingController.
Based on previous feedback, WireMockMappingController should be lazily initialized when needed rather than at construction time.
-public WireMockMappingController wmController;
+private WireMockMappingController wmController;
public ApplicationAPIModel mApplicationAPIModel;
Solution mSolution;Then initialize it only when needed:
-wmController = new WireMockMappingController();
+wmController ??= new WireMockMappingController();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public WireMockMappingController wmController; | |
| public ApplicationAPIModel mApplicationAPIModel; | |
| Solution mSolution; | |
| // Field declarations (e.g., around lines 30-32 in WireMockTemplatePage.xaml.cs) | |
| private WireMockMappingController wmController; | |
| public ApplicationAPIModel mApplicationAPIModel; | |
| Solution mSolution; | |
| // Elsewhere in the code where wmController is initialized (e.g., in the constructor): | |
| // Original code: | |
| // wmController = new WireMockMappingController(); | |
| // Updated code with lazy initialization: | |
| wmController ??= new WireMockMappingController(); |
…ill not be downloaded
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
Bug Fixes