This repository was archived by the owner on Dec 15, 2025. It is now read-only.
forked from DynamicsValue/fake-xrm-easy
-
Notifications
You must be signed in to change notification settings - Fork 1
Add auditing UI to Model-Driven App with global summary and record-specific views #121
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copilot
AI
changed the title
[WIP] Add MdA UI to show auditing views
Add auditing UI to Model-Driven App with global summary and record-specific views
Oct 17, 2025
Owner
|
@copilot keep going. Don't forget docs and tests. Make sure the aspnet app routes this property including the API |
Copilot stopped work on behalf of
rnwood due to an error
October 17, 2025 05:51
Owner
|
@copilot keep going, but first resolve merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements comprehensive auditing functionality for the Model-Driven App, adding both a global audit history view and record-specific audit tracking capabilities.
Key Changes:
- Added REST API endpoints for retrieving and managing audit data
- Created React components for displaying audit history at global and record levels
- Fixed a critical bug in audit logic where null
IsAuditEnabledvalues incorrectly disabled auditing - Integrated audit views into the existing MDA navigation and entity forms
Reviewed Changes
Copilot reviewed 37 out of 49 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Fake4DataverseCore/Fake4Dataverse.Core/src/Fake4Dataverse.Core/XrmFakedContext.Audit.cs |
Fixed null handling for IsAuditEnabled to treat null as "allow auditing" |
Fake4DataverseService/Fake4Dataverse.Service/src/Fake4Dataverse.Service/Controllers/AuditController.cs |
Added REST API controller with 5 endpoints for audit data access |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/components/AuditSummaryView.tsx |
Global audit history view with pagination and status toggle |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/components/AuditRecordView.tsx |
Record-specific audit history with expandable change details |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/components/Navigation.tsx |
Added "Audit History" navigation button |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/components/EntityForm.tsx |
Integrated audit history tab into entity forms |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/types/dataverse.ts |
Added TypeScript interfaces for audit data structures |
Fake4DataverseService/Fake4Dataverse.Service/mda-app/app/lib/dataverse-client.ts |
Added 5 client methods for audit API access |
Fake4DataverseService/Fake4Dataverse.Service.Tests/Controllers/AuditControllerTests.cs |
Comprehensive unit tests for all audit endpoints |
| Generated static files | Build artifacts from Next.js compilation |
- Add AuditController with endpoints for global summary and entity-specific audits - Add audit types to dataverse.ts - Add audit API methods to DataverseApiClient - Create AuditSummaryView component for global audit summary - Create AuditRecordView component for single record audit history - Add "Audit History" navigation item - Add audit history tab to EntityForm for existing records Co-authored-by: rnwood <[email protected]>
- Add AuditSummaryView.test.tsx with 5 test cases - Add AuditRecordView.test.tsx with 5 test cases - Add AuditControllerTests.cs with 9 test cases - All 33 React tests pass - All 8 C# service tests pass Co-authored-by: rnwood <[email protected]>
- Fix ShouldAuditEntity logic to treat null IsAuditEnabled as allowing auditing - Fix FilterAuditedAttributes to include attributes with null IsAuditEnabled - Update Program.cs to enable auditing for CDM entities (though not needed now) - Fix AuditControllerTests to use basic context factory - Add using statement for Microsoft.Xrm.Sdk.Metadata - Audit now works correctly with CDM metadata loaded from schemas Co-authored-by: rnwood <[email protected]>
Co-authored-by: rnwood <[email protected]>
3832c99 to
9195887
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements comprehensive auditing views for the Model-Driven App UI, allowing users to view audit history both globally and for individual records.
Changes
Backend API (
AuditController.cs)Added a new REST API controller that exposes audit functionality through the following endpoints:
GET /api/audit- List all audit records with pagination and filteringGET /api/audit/entity/{entityName}/{id}- Get audit history for a specific recordGET /api/audit/details/{auditId}- Get detailed attribute changes (old/new values)GET /api/audit/status- Check if auditing is enabledPOST /api/audit/status- Enable/disable auditingFrontend Components
AuditSummaryView Component
AuditRecordView Component
EntityForm Integration
Navigation Enhancement
Bug Fix: Audit Logic with CDM Metadata
Fixed a critical bug in
XrmFakedContext.Audit.cswhere nullIsAuditEnabledvalues were incorrectly treated as disabling auditing:Before:
After:
This change ensures that CDM metadata with null audit settings works correctly, treating null as "allow auditing" rather than "deny auditing."
Testing
C# Unit Tests (
AuditControllerTests.cs)React Component Tests
AuditSummaryView.test.tsx- 5 test casesAuditRecordView.test.tsx- 5 test casesUsage Example
Screenshot
The screenshot shows the main Model-Driven App interface with the audit navigation components integrated into the sidebar.
Notes
The audit system tracks all Create, Update, and Delete operations with:
This implementation leverages the existing
IAuditRepositoryinfrastructure in Fake4DataverseCore, making it easy to view and manage audit data through the web UI.Fixes #issue-number
Original prompt
Fixes #120
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.