Skip to content

Conversation

@twestos
Copy link
Contributor

@twestos twestos commented Jun 4, 2025

This pull request introduces the AdminUiFieldFormatMetadata type to enhance field formatting options across multiple examples and updates the AdminUiFieldMetadata type to include a new format property. Additionally, it modifies the admin UI components to support formatting for dates and currencies. Below is a breakdown of the most important changes:

Type Enhancements

  • Added AdminUiFieldFormatMetadata type with properties for format, timezone, type, and variant across various types.generated.ts files in multiple examples, including auth-zero, aws-cognito, federation, microsoft-entra, okta, rest-with-auth, and rest. This type enables more granular control over field formatting. [1] [2] [3] [4] [5] [6]

Admin UI Updates

  • Updated the AdminUiFieldMetadata type to include a new format property, linking it to the AdminUiFieldFormatMetadata type. This change ensures fields can specify formatting metadata for display purposes. [1] [2] [3] [4] [5] [6]

Backend Schema Changes

  • Enhanced the Employee class in sqlite schema to include adminUIOptions for birthDate and hireDate fields, specifying date formats and timezones.
  • Updated the InvoiceLine class in sqlite schema to include adminUIOptions for the unitPrice field, enabling currency formatting.

Admin UI Component Enhancements

  • Introduced the formatValue function in src/packages/admin-ui-components/src/entity-list/columns.tsx to handle field formatting for dates and currencies using the luxon library.
  • Modified cellForType function to apply formatting for array values and simple values using the formatValue function. [1] [2]

@twestos twestos requested a review from Copilot June 4, 2025 02:20
Copy link
Contributor

Copilot AI left a 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 adds support for date, timezone, and currency formatting metadata across multiple examples and implements rendering logic in the admin UI.

  • Introduces AdminUiFieldFormatMetadata and adds a format property to AdminUiFieldMetadata in all generated schemas.
  • Annotates Employee and InvoiceLine schema fields with adminUIOptions to specify date and currency formats.
  • Implements formatValue in columns.tsx and integrates it into cellForType for formatted display.

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/packages/admin-ui-components/src/entity-list/columns.tsx Added formatValue utility and applied it in cell rendering.
src/examples/sqlite/src/types.generated.ts Added AdminUiFieldFormatMetadata and format to field metadata.
src/examples/sqlite/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format to frontend metadata.
src/examples/sqlite/src/backend/schema/invoice-line.ts Added currency format metadata to unitPrice.
src/examples/sqlite/src/backend/schema/employee.ts Added date format and timezone metadata to birthDate and hireDate.
src/examples/rest/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/rest/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/rest-with-auth/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/rest-with-auth/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/rest-with-auth/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/okta/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/okta/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/microsoft-entra/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/microsoft-entra/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/federation/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/federation/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/aws-cognito/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/aws-cognito/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/auth-zero/src/types.generated.ts Added AdminUiFieldFormatMetadata and format.
src/examples/auth-zero/src/frontend/types.generated.ts Added AdminUiFieldFormatMetadata and format.

Copy link
Member

@thekevinbrown thekevinbrown left a comment

Choose a reason for hiding this comment

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

Approach looks good to me, just need to get those tests passing and we're good to go!

@thekevinbrown
Copy link
Member

Quality Gate Failed Quality Gate failed

Failed conditions 70.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

^ this is because of the .generated.ts files. They should be excluded from analysis. I've added this setting and we'll see if that works.

@thekevinbrown
Copy link
Member

Note for the future, the reason for the duplication is so that there's no dependency between core and admin-ui-components. We could pull these out into a shared types package but that feels worse for maintenance to us than just having the duplication, so in this case we're going to ignore the SonarQube recommendation on duplication.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
30.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@twestos twestos merged commit 19b0452 into main Jun 6, 2025
16 of 17 checks passed
@twestos twestos deleted the feature/cell-format-field-option branch June 6, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants