Skip to content

BDMS-777: Update the PDF preview and download button so that they only require view access.#272

Merged
TylerAdamMartinez merged 2 commits intostagingfrom
TAM-BDMS-777
Apr 29, 2026
Merged

BDMS-777: Update the PDF preview and download button so that they only require view access.#272
TylerAdamMartinez merged 2 commits intostagingfrom
TAM-BDMS-777

Conversation

@TylerAdamMartinez
Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem/context:

  • Previously, only admins could see this feature. After review, this feature should be accessible to anyone with view permissions.

How

Implementation summary - the following was changed/added/removed:

  • Swapped canManageAmp for canViewAmp on the PDF buttons.

Notes

Any special considerations, workarounds, or follow-up work to note?

  • N/A

@TylerAdamMartinez TylerAdamMartinez requested review from jeremyzilar and jirhiker and removed request for jirhiker April 29, 2026 14:50
@TylerAdamMartinez TylerAdamMartinez self-assigned this Apr 29, 2026
@TylerAdamMartinez TylerAdamMartinez added the bug Something isn't working label Apr 29, 2026
@github-actions
Copy link
Copy Markdown

Preview Deployment

Preview URL: https://preview-tam-bdms-777-auejgdbofq-uc.a.run.app

Note: This preview uses the staging API endpoints.

@github-actions
Copy link
Copy Markdown

Preview Deployment

Preview URL: https://preview-tam-bdms-777-auejgdbofq-uc.a.run.app

Note: This preview uses the staging API endpoints.

import { FieldCompilationNotesPdf } from '@/components/pdf/FieldCompilationNotesPdf'
import type { IContact, IWell } from '@/interfaces/ocotillo'
import { formatContactPhones } from '@/components/pdf/fieldCompilationPhoneFormatter'
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Used a library instead of trying to build a PDF decoder from scratch.

const extractPdfText = async (pdfBlob: Blob) => {
const data = new Uint8Array(await pdfBlob.arrayBuffer())

for (const match of decodedPdfText.matchAll(/<([0-9A-Fa-f]+)>/g)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The regex failed to capture all the text from the PDF, resulting in a test failure, even though the code behaved as expected.


describe('FieldCompilationNotesPdf', () => {
it('appends a final blank page with the requested text when no hydrograph image is provided', async () => {
it('renders all expected pages and content when no hydrograph image is provided', async () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Update the unit test name to more accurately reflect the test.

@TylerAdamMartinez TylerAdamMartinez merged commit 97769a7 into staging Apr 29, 2026
3 of 4 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the TAM-BDMS-777 branch April 29, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants