Skip to content
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

merge main into release #579

Merged
merged 134 commits into from
Feb 7, 2025
Merged

merge main into release #579

merged 134 commits into from
Feb 7, 2025

Conversation

brunopacheco1
Copy link
Collaborator

@brunopacheco1 brunopacheco1 commented Feb 7, 2025

Summary by Sourcery

Merge the main branch into the release branch, introducing a new mobile-friendly navigation bar, refactoring the application provider for better error handling, and updating the header component for dynamic navigation item generation. Enhance dataset search and export functionalities, update the Dockerfile and CI workflows, and improve documentation and tests. Remove deprecated API routes and services.

New Features:

  • Introduce a new mobile-friendly navigation bar for better user experience on smaller screens.

Enhancements:

  • Refactor the application provider to use async/await for better error handling and code readability.
  • Update the header component to dynamically generate navigation items, reducing code duplication.
  • Improve the dataset search functionality by integrating new API endpoints for filters and dataset retrieval.
  • Enhance the dataset card component to include a button for exporting datasets in various formats.

Build:

  • Update the Dockerfile to use Node.js 22 and add environment variables for better configuration management.
  • Add new npm scripts for generating OpenAPI client schemas and types, improving the build process.

CI:

  • Enhance CI workflows to include additional metadata and labels for Docker images, improving traceability and documentation.

Deployment:

  • Add a middleware for handling authentication redirects, improving security and user experience.

Documentation:

  • Update the legal and privacy documentation to reflect changes in ownership and data processing practices.

Tests:

  • Add comprehensive tests for new API client functions, ensuring reliability and correctness of data retrieval and submission.

Chores:

  • Remove deprecated API routes and services, cleaning up the codebase and reducing maintenance overhead.

Renovate Bot and others added 30 commits December 4, 2024 07:04
…-devdependencies

chore(deps): update devdependencies (patch)
…-nextjs-monorepo

fix(deps): update dependency next to v14.2.19
…-nextjs-monorepo

fix(deps): update dependency next to v14.2.20
…-devdependencies

chore(deps): update dependency eslint-config-next to v14.2.20
…elemetry-js-monorepo

fix(deps): update opentelemetry-js monorepo to ^0.56.0 (minor)
…try.access.redhat.com-ubi9-nodejs-20-minimal-9.5.x

chore(deps): update registry.access.redhat.com/ubi9/nodejs-20-minimal docker tag to v9.5-1733824671
…try.access.redhat.com-ubi9-nodejs-20-minimal-9.5.x

chore(deps): update registry.access.redhat.com/ubi9/nodejs-20-minimal docker tag to v9.5-1734309067
feat: improve external service integration
…i-specifications

chore: update open-api-specifications
…-devdependencies

chore(deps): update dependency tailwindcss to v3.4.17
Snyk has created this PR to upgrade tailwind-merge from 2.5.3 to 2.5.5.

See this package in npm:
tailwind-merge

See this project in Snyk:
https://app.snyk.io/org/brunopacheco1/project/d90a5e56-2020-4abe-8f3a-101f4e46d57b?utm_source=github&utm_medium=referral&page=upgrade-pr
Snyk has created this PR to upgrade cmdk from 1.0.0 to 1.0.4.

See this package in npm:
cmdk

See this project in Snyk:
https://app.snyk.io/org/brunopacheco1/project/d90a5e56-2020-4abe-8f3a-101f4e46d57b?utm_source=github&utm_medium=referral&page=upgrade-pr
Snyk has created this PR to upgrade class-variance-authority from 0.7.0 to 0.7.1.

See this package in npm:
class-variance-authority

See this project in Snyk:
https://app.snyk.io/org/brunopacheco1/project/d90a5e56-2020-4abe-8f3a-101f4e46d57b?utm_source=github&utm_medium=referral&page=upgrade-pr
…try.access.redhat.com-ubi9-nodejs-20-minimal-9.5.x

chore(deps): update registry.access.redhat.com/ubi9/nodejs-20-minimal docker tag to v9.5-1734514731
…2929b7a6fe71756ca9ec645582a48f5

[Snyk] Upgrade class-variance-authority from 0.7.0 to 0.7.1
…a0715511e4452711f7df9a89d62f69e

[Snyk] Upgrade cmdk from 1.0.0 to 1.0.4
…234289bf1d994647ebf22e23f28ccfc

[Snyk] Upgrade tailwind-merge from 2.5.3 to 2.5.5
brunopacheco1 and others added 25 commits February 5, 2025 11:03
…portal-frontend-missing-form-validation

fix: ART-12382/missing form validation
…portal-frontend-custom-text-and-links-are-not-displayed

fix: ART-12303/custom text not displayed
…elemetry-auto-instrumentations-node-0.x

fix(deps): update dependency @opentelemetry/auto-instrumentations-node to ^0.56.0
…ove-header-small-screens

Art 12300 improve header small screens
@brunopacheco1 brunopacheco1 requested a review from nolliia February 7, 2025 12:57
Copy link
Contributor

sourcery-ai bot commented Feb 7, 2025

Reviewer's Guide by Sourcery

This pull request merges changes from main into the release branch. The implementation mainly consists of synchronizing updates across the application by refactoring type usages, updating API integrations and error handling, revising UI components for better usability and responsiveness, and modifying configuration files (Dockerfile, package.json, GitHub Workflows). In addition, extensive modifications were made to tests and OpenAPI specifications, ensuring the updated APIs and new types (migrating from legacy types to new ones from the /app/api directories) are used consistently throughout the codebase.

Class diagram for Revised Application Data Types

classDiagram
    class RetrievedApplication {
      +number id
      +ApplicationState state
      +RetrievedApplicationForm[] forms
      +Event[] events
      +License[] licenses
      +Attachment[] attachments
    }

    class RetrievedApplicationForm {
      +number id
      +Label[] externalTitle
      +RetrievedApplicationFormField[] fields
    }

    class RetrievedApplicationFormField {
      +number id
      +FormFieldType type
      +string value
      +FormFieldTableValue[][] tableValues
      +FormFieldOption[] options
    }

    class FormFieldOption {
      +string key
      +Label[] label
    }

    class Label {
      +string language
      +string name
    }

    %% Relationships
    RetrievedApplication --> RetrievedApplicationForm : contains
    RetrievedApplicationForm --> RetrievedApplicationFormField : contains
    RetrievedApplicationFormField --> FormFieldOption : uses
    FormFieldOption --> Label : uses
    RetrievedApplicationForm --> Label : externalTitle uses
Loading

File-Level Changes

Change Details Files
Refactored application provider and type migrations
  • Updated ApplicationProvider to use non-null assertions when accessing form fields and removed deprecated debounce implementations
  • Migrated from legacy types (e.g., Form, State) to new ones (RetrievedApplication, ApplicationState, FormFieldType) throughout the application provider and related utility functions
  • Enhanced error handling in API calls by catching errors and formatting validation warnings
  • Updated tests (in tests) to reflect new types and non-null assertions
src/providers/application/ApplicationProvider.tsx
src/utils/__tests__/application.test.ts
src/utils/application.ts
Updated UI components and navigation
  • Improved Header component by refactoring navigation items and responsiveness (e.g. modifying menu container and layout)
  • Updated PhoneInput component to use revised input types and props
src/components/Header/index.tsx
src/components/PhoneInput.tsx
Enhanced API integration and error handling
  • Replaced direct fetch calls with new functions (retrieveApplicationApi, addAttachmentToApplicationApi, submitApplicationApi, etc.)
  • Updated DatasetsProvider and FilterProvider components to use new API endpoints and types from /app/api
  • Adjusted various component props and state updates to work with migrated API types
src/providers/datasets/DatasetsProvider.tsx
src/providers/filters/FilterProvider.tsx
src/app/applications/[id]/FieldContainer.tsx
src/utils/application.ts
src/app/applications/[id]/DateFormField.tsx
src/app/applications/[id]/EmailFormField.tsx
src/app/applications/[id]/GenericInputFormField.tsx
src/app/applications/[id]/MultiSelectFormField.tsx
src/app/applications/[id]/OptionFormField.tsx
src/app/applications/[id]/PhoneFormField.tsx
src/app/applications/[id]/TextAreaFormField.tsx
Modernized legal and public facing content
  • Updated legal markdown in public/legal.md with revised owner details, conditions of use, and privacy notice
  • Improved website terms language and styling in legal documents
public/legal.md
Updated build configurations and dependency versions
  • Bumped dependency versions in package.json including fontawesome, nextjs, radixes and tailwind-merge
  • Modified Dockerfile to update Node.js version and add necessary file copies
  • Incorporated changes to GitHub workflows (main.yml and release.yml) with added labels and environment variables for container metadata
package.json
Dockerfile
.github/workflows/main.yml
.github/workflows/release.yml
Extensive type and API client migration to new structure
  • Replaced legacy type imports from '@/types/...' with new API types from '@/app/api/access-management/open-api/schemas' or '@/app/api/discovery/open-api/schemas'
  • Adjusted component props, API calls, and tests to align with the new types based on OpenAPI specifications
  • Added new OpenAPI specification files and code generation templates for API client creation
src/app/api/access-management/open-api/access-management.yml
src/app/api/discovery/open-api/discovery.yml
src/app/api/access-management/additional-types.ts
src/app/api/shared/schemas-and-types-directly.hbs
Introduction of additional utility and new routes
  • Added new Navbar component for mobile navigation and other UI enhancements
  • Introduced new files for sitemap, robots, and environment loading scripts
  • Implemented middleware for authentication redirection using Keycloak via NextAuth
src/components/Navbar/index.tsx
src/middleware.ts
src/sitemap.tsx
src/robots.tsx
scripts/start.js
scripts/generate-env.js
Expanded and updated tests for API integration and functionality
  • Added numerous new tests for API endpoints (e.g., submit application, add attachment, create application, list applications, retrieve filters, search datasets)
  • Updated test cases to match changes in types, error handling, and API responses
  • Improved mocks to use encryption helpers and session token handling
src/app/api/access-management/__tests__/*
src/app/api/discovery/__tests__/*
src/utils/__tests__/avatar.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brunopacheco1 brunopacheco1 merged commit 7bc5237 into releases/v1.3 Feb 7, 2025
7 checks passed
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @brunopacheco1 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Great overall refactoring and type updates; consider replacing repetitive non-null assertions (!) with proper type guards or runtime checks to improve robustness.
  • Verify that all API client changes are thoroughly integrated tested to catch any runtime issues due to type shifting and new module paths.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2024 PNED G.I.E.
#
# SPDX-License-Identifier: Apache-2.0
FROM registry.access.redhat.com/ubi9/nodejs-20-minimal:9.5-1732617235 AS base
FROM registry.access.redhat.com/ubi9/nodejs-22-minimal:9.5-1738870241 AS base
Copy link
Contributor

Choose a reason for hiding this comment

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

question (performance): Updated base image to Node.js 22.

Switching from Node.js 20 to Node.js 22 may provide performance and security improvements. Please confirm that all runtime dependencies and build scripts are compatible with Node.js 22.

@@ -30,8 +30,8 @@ export function createDatasetCardItems(dataset: SearchedDataset): CardItem[] {
},
{
text:
(dataset.publishers?.length > 0 &&
`Published by ${dataset.publishers.map((p) => p.name).join(", ")}`) ||
(dataset.publishers!.length > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

question (bug_risk): Check non-null assertion for publisher data.

Using the non-null assertion on 'dataset.publishers' signals that the value is expected to be present, but verify that this is guaranteed. If not, a fallback or conditional rendering might prevent potential runtime errors.

By using this website, users agree to abide by these website terms (in their most recent version, as available on the website). GDI Coordination reserves the right to modify this website and the website terms from time to time.
The data catalogue is operated as an online platform which allows its users to easily find diverse collection of datasets across various themes and organisations. To access the datasets the user must contact directly the relevant “Contact point”. The user may export the metadata of the dataset in the following formats: RDF, TTL, JSON-LD.

By using this website users agree to abide by these website terms (in their most recent version, as available on the website). The LNDS reserves the right to modify this website and the website terms from time to time.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Add a comma after "website" for better readability.

It should read "By using this website, users agree..."

Suggested change
By using this website users agree to abide by these website terms (in their most recent version, as available on the website). The LNDS reserves the right to modify this website and the website terms from time to time.
By using this website, users agree to abide by these website terms (in their most recent version, as available on the website). The LNDS reserves the right to modify this website and the website terms from time to time.

**Essential (Functional) cookies**:
| Cookies | Description | Duration |
|---------|-------------|----------|
| **Host-next-auth.csrf-token; **Secure-next-auth.callback-url; **Secure-next-auth.pkce.code_verifier; **Secure-next-auth.state | User authentication (Next.js auth options) | While the browser is open |
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Remove the extra space between "Host-next-auth.csrf-token;" and "**Secure-next-auth.callback-url".

Suggested change
| **Host-next-auth.csrf-token; **Secure-next-auth.callback-url; **Secure-next-auth.pkce.code_verifier; **Secure-next-auth.state | User authentication (Next.js auth options) | While the browser is open |
| **Host-next-auth.csrf-token;** **Secure-next-auth.callback-url;** **Secure-next-auth.pkce.code_verifier;** **Secure-next-auth.state | User authentication (Next.js auth options) | While the browser is open |

Comment on lines +15 to 16
const tokenDecrypted = decrypt(session[tokenType]);
return tokenDecrypted;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)

Suggested change
const tokenDecrypted = decrypt(session[tokenType]);
return tokenDecrypted;
return decrypt(session[tokenType]);


ExplanationSomething that we often see in people's code is assigning to a result variable
and then immediately returning it.

Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.

Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.

// SPDX-License-Identifier: Apache-2.0

export function getInitials(name?: string) {
if (!name) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!name) return null;
if (!name) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

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.

9 participants