-
Notifications
You must be signed in to change notification settings - Fork 480
Add report issue workflow to backend and toolbar UI #35717
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
592c663
Add report issue workflow to backend and UI
fmontes 0dbce49
refactor(report-issue): adopt signal-based inputs/outputs
fmontes 9bfeed6
Type report issue service response
fmontes 861834f
refactor(report-issue): relocate component to view/components
fmontes 0697fc5
Merge branch 'main' into fmontes/report-bug-button
fmontes 893ead0
refactor(report-issue): address review feedback
fmontes e5a999b
feat(report-issue): add anonymous toggle and operator PII opt-out
fmontes 5f5cad0
refactor(report-issue): namespace PII config constant
fmontes ebdd4cb
style(report-issue): fix import order lint errors
fmontes 70d14c9
fix format
fmontes 0cdc2cc
feat(report-issue): reflect operator PII opt-out in the dialog
fmontes 757c483
Merge branch 'main' into fmontes/report-bug-button
fmontes 09ceaac
fix(report-issue): match submit button type to actual behavior
fmontes b47bc19
Fix affected lint warnings
fmontes c9a310b
fix format
fmontes a006d25
Merge branch 'main' into fmontes/report-bug-button
fmontes 2da6787
Remove unrelated e2e lint changes
fmontes 0e40582
Address report issue review feedback
fmontes 8b8a301
Fix report issue PII config lookup
fmontes 2b4072c
Remove unrelated spec lint changes
fmontes 2df574c
Simplify report issue toolbar state
fmontes b76a26a
Add TSDoc for report issue UI
fmontes 3177d2a
Merge branch 'main' into fmontes/report-bug-button
fmontes 70c662f
Merge branch 'main' into fmontes/report-bug-button
fmontes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
core-web/apps/dotcms-ui/src/app/api/services/dot-report-issue.service.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { provideHttpClient } from '@angular/common/http'; | ||
| import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'; | ||
| import { TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { | ||
| DotReportIssueContentlet, | ||
| DotReportIssuePayload, | ||
| DotReportIssueService | ||
| } from './dot-report-issue.service'; | ||
|
|
||
| const MOCK_REPORT_ISSUE_CONTENTLET: DotReportIssueContentlet = { | ||
| archived: false, | ||
| baseType: 'CONTENT', | ||
| contentType: 'Bug', | ||
| folder: 'SYSTEM_FOLDER', | ||
| hasTitleImage: false, | ||
| host: 'host-id', | ||
| hostName: 'dotcms.dev', | ||
| identifier: 'identifier-id', | ||
| inode: 'inode-id', | ||
| languageId: 1, | ||
| live: false, | ||
| locked: false, | ||
| modDate: '1778806040235', | ||
| modUser: 'user-id', | ||
| modUserName: 'Bug Reporter', | ||
| owner: 'user-id', | ||
| sortOrder: 0, | ||
| stInode: 'stInode-id', | ||
| title: '/plugins [1.0.0-SNAPSHOT - Chrome]', | ||
| titleImage: 'screenshot', | ||
| url: '/content.inode-id', | ||
| working: true, | ||
| metadata: { | ||
| browser: 'Chrome', | ||
| url: 'http://localhost:8080/dotAdmin/#/plugins?mId=1a87' | ||
| } | ||
| }; | ||
|
|
||
| describe('DotReportIssueService', () => { | ||
| let service: DotReportIssueService; | ||
| let httpTesting: HttpTestingController; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| providers: [provideHttpClient(), provideHttpClientTesting(), DotReportIssueService] | ||
| }); | ||
|
|
||
| service = TestBed.inject(DotReportIssueService); | ||
| httpTesting = TestBed.inject(HttpTestingController); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| httpTesting.verify(); | ||
| }); | ||
|
|
||
| it('should submit report issue multipart payload with description and metadata', () => { | ||
| const payload: DotReportIssuePayload = { | ||
| description: 'Login button is unresponsive', | ||
| metadata: { | ||
| browser: 'Chrome', | ||
| url: 'http://localhost:8080/dotAdmin' | ||
| } | ||
| }; | ||
|
|
||
| service.reportIssue(payload).subscribe((response) => { | ||
| expect(response).toEqual(MOCK_REPORT_ISSUE_CONTENTLET); | ||
| }); | ||
|
|
||
| const req = httpTesting.expectOne('/api/v1/report-issue'); | ||
| expect(req.request.method).toBe('POST'); | ||
| expect(req.request.body).toBeInstanceOf(FormData); | ||
| expect(req.request.body.get('description')).toBe(payload.description); | ||
| expect(req.request.body.get('metadata')).toBe(JSON.stringify(payload.metadata)); | ||
| expect(req.request.body.get('screenshot')).toBeNull(); | ||
|
|
||
| req.flush({ entity: MOCK_REPORT_ISSUE_CONTENTLET }); | ||
| }); | ||
|
|
||
| it('should include screenshot when provided', () => { | ||
| const screenshot = new File(['image'], 'screenshot.png', { type: 'image/png' }); | ||
| const payload: DotReportIssuePayload = { | ||
| description: 'Issue with screenshot', | ||
| metadata: { | ||
| browser: 'Safari' | ||
| }, | ||
| screenshot | ||
| }; | ||
|
|
||
| service.reportIssue(payload).subscribe(); | ||
|
|
||
| const req = httpTesting.expectOne('/api/v1/report-issue'); | ||
| expect(req.request.method).toBe('POST'); | ||
| expect(req.request.body.get('screenshot')).toBe(screenshot); | ||
|
|
||
| req.flush({ entity: MOCK_REPORT_ISSUE_CONTENTLET }); | ||
| }); | ||
| }); |
81 changes: 81 additions & 0 deletions
81
core-web/apps/dotcms-ui/src/app/api/services/dot-report-issue.service.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { Observable } from 'rxjs'; | ||
|
|
||
| import { HttpClient } from '@angular/common/http'; | ||
| import { Injectable, inject } from '@angular/core'; | ||
|
|
||
| import { map } from 'rxjs/operators'; | ||
|
|
||
| import { DotCMSContentlet, DotCMSResponse } from '@dotcms/dotcms-models'; | ||
|
|
||
| export interface DotReportIssuePayload { | ||
| description: string; | ||
| metadata: Record<string, string>; | ||
| screenshot?: File | null; | ||
| } | ||
|
|
||
| export interface DotReportIssueUserMetadata { | ||
| email: string; | ||
| fullName: string; | ||
| userId: string; | ||
| } | ||
|
|
||
| export interface DotReportIssueMetadata { | ||
| browser?: string; | ||
| dotcmsBuildDate?: string; | ||
| dotcmsVersion?: string; | ||
| platform?: string; | ||
| referer?: string; | ||
| referrer?: string; | ||
| remoteAddress?: string; | ||
| requestUrl?: string; | ||
| serverName?: string; | ||
| submittedAt?: string; | ||
| url?: string; | ||
| user?: DotReportIssueUserMetadata; | ||
| userAgent?: string; | ||
| viewport?: string; | ||
| [key: string]: unknown; | ||
| } | ||
|
|
||
| export interface DotReportIssueScreenshotMetadata { | ||
| contentType: string; | ||
| editableAsText: boolean; | ||
| fileSize: number; | ||
| height?: number; | ||
| isImage: boolean; | ||
| length: number; | ||
| modDate: number; | ||
| name: string; | ||
| sha256: string; | ||
| title: string; | ||
| version: number; | ||
| width?: number; | ||
| } | ||
|
|
||
| export interface DotReportIssueContentlet extends DotCMSContentlet { | ||
| metadata?: DotReportIssueMetadata; | ||
| screenshot?: string; | ||
| screenshotContentAsset?: string; | ||
| screenshotMetaData?: DotReportIssueScreenshotMetadata; | ||
| screenshotVersion?: string; | ||
| } | ||
|
|
||
| @Injectable() | ||
| export class DotReportIssueService { | ||
| private readonly http = inject(HttpClient); | ||
|
|
||
| reportIssue(payload: DotReportIssuePayload): Observable<DotReportIssueContentlet> { | ||
| const formData = new FormData(); | ||
|
|
||
| formData.append('description', payload.description); | ||
| formData.append('metadata', JSON.stringify(payload.metadata)); | ||
|
|
||
| if (payload.screenshot) { | ||
| formData.append('screenshot', payload.screenshot); | ||
| } | ||
|
|
||
| return this.http | ||
| .post<DotCMSResponse<DotReportIssueContentlet>>('/api/v1/report-issue', formData) | ||
| .pipe(map((response) => response.entity)); | ||
| } | ||
| } |
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
84 changes: 84 additions & 0 deletions
84
...b/apps/dotcms-ui/src/app/view/components/dot-report-issue/dot-report-issue.component.html
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <p-dialog | ||
| [(visible)]="visible" | ||
| [header]="'report-an-issue' | dm" | ||
| [modal]="true" | ||
| [draggable]="false" | ||
| [resizable]="false" | ||
| [style]="{ width: '40rem' }" | ||
| appendTo="body" | ||
| data-testid="dot-report-issue-dialog" | ||
| (onHide)="handleClose()"> | ||
| <form | ||
| (ngSubmit)="save()" | ||
| [formGroup]="form" | ||
| class="form" | ||
| data-testid="dot-report-issue-form" | ||
| novalidate> | ||
| @if (errorMessage()) { | ||
| <p class="mb-4 text-red-500" data-testid="dot-report-issue-error-message"> | ||
| {{ errorMessage() }} | ||
| </p> | ||
| } | ||
| <div class="field"> | ||
| <label dotFieldRequired for="dot-report-issue-description-input"> | ||
| {{ 'report-an-issue.description' | dm }} | ||
| </label> | ||
| <textarea | ||
| formControlName="description" | ||
| id="dot-report-issue-description-input" | ||
| data-testid="dot-report-issue-description-input" | ||
| pInputTextarea | ||
| rows="6"></textarea> | ||
| @if (form.get('description')?.invalid && hasSubmitted()) { | ||
| <small class="p-invalid" data-testid="dot-report-issue-description-error"> | ||
| {{ errorMessages.descriptionRequired }} | ||
| </small> | ||
| } | ||
| </div> | ||
|
|
||
| <div class="field"> | ||
| <label for="dot-report-issue-screenshot-input"> | ||
| {{ 'report-an-issue.screenshot' | dm }} | ||
| </label> | ||
| <p-fileupload | ||
| #screenshotUpload | ||
| mode="advanced" | ||
| name="screenshot" | ||
| chooseIcon="pi pi-image" | ||
| [auto]="false" | ||
| [customUpload]="true" | ||
| [multiple]="false" | ||
| [showUploadButton]="false" | ||
| accept="image/png,image/jpeg,image/webp" | ||
| data-testid="dot-report-issue-screenshot-input" | ||
| id="dot-report-issue-screenshot-input" | ||
| (onSelect)="onScreenshotSelected($event)" | ||
| (onClear)="onScreenshotClear()"></p-fileupload> | ||
|
|
||
| @if (hasSubmitted() && getScreenshotErrorMessage(); as screenshotErrorMessage) { | ||
| <small class="p-invalid" data-testid="dot-report-issue-screenshot-error"> | ||
| {{ screenshotErrorMessage }} | ||
| </small> | ||
| } | ||
| </div> | ||
| </form> | ||
|
|
||
| <ng-template pTemplate="footer"> | ||
| <button | ||
| pButton | ||
| type="button" | ||
| class="p-button-outlined" | ||
| [label]="'cancel' | dm" | ||
| [disabled]="isSubmitting()" | ||
| data-testid="dot-report-issue-cancel-button" | ||
| (click)="handleClose()"></button> | ||
| <button | ||
| pButton | ||
| type="submit" | ||
| [label]="'submit' | dm" | ||
| [loading]="isSubmitting()" | ||
| [disabled]="isSubmitting()" | ||
| data-testid="dot-report-issue-submit-button" | ||
| (click)="save()"></button> | ||
| </ng-template> | ||
|
fmontes marked this conversation as resolved.
|
||
| </p-dialog> | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.