Skip to content

Migrate all toolbar components to standalone and use the new syntax #32257

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

nicobytes
Copy link
Contributor

Proposed Changes

This pull request introduces significant updates to the dotcms-ui project, focusing on modernizing components by adopting Angular's standalone components, improving code maintainability, and simplifying module dependencies. The changes include refactoring the DotDropdownComponent, transitioning several components to standalone mode, and removing unused or redundant imports.

Component Refactoring and Modernization:

  • Refactored DotDropdownComponent to use Angular's signals and standalone components, replacing @Input and @Output with reactive inputs/outputs and computed properties for better state management. Removed the corresponding module (DotDropdownModule) as it is no longer needed. [1] [2] [3] [4]

Transition to Standalone Components:

  • Converted multiple components (DotToolbarComponent, DotToolbarAnnouncementsComponent, DotNotificationsItemComponent, and others) to standalone components, simplifying their dependency management by directly importing required modules and pipes. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Dependency Cleanup:

  • Removed unused imports like CommonModule and NgClass from components that no longer require them due to the transition to standalone components. This reduces unnecessary dependencies and improves build performance. [1] [2] [3] [4]

Test Updates:

  • Updated test configurations for components like DotToolbarNotificationsComponent to reflect the changes in imports and declarations caused by the transition to standalone components. [1] [2]

Module Updates:

  • Replaced DotToolbarModule with DotToolbarComponent in modules.ts to align with the standalone component approach. [1] [2]

These updates streamline the codebase, improve maintainability, and align with Angular's latest best practices.

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

** any additional useful context or info **

nicobytes added 3 commits May 27, 2025 16:14
…omputed properties for improved state management
…hub.com:dotCMS/core into 32256-new-angular-syntax-in-dottoolbarcomponent
nicobytes added 2 commits May 28, 2025 11:02
…and computed properties for improved state management and accessibility
@nicobytes nicobytes changed the title Apply Angular syntax and standalone in DotToolbarComponent Migrate to standalone all toolbar components May 29, 2025
@@ -1,10 +1,16 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';

import { INotification, NotificationIcons } from '@models/notifications';
import { DotCustomTimeModule } from '../../../../../_common/dot-custom-time.component/dot-custom-time.module';
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this component to the UI lib?

@@ -1,4 +1,4 @@
import { NgClass, CommonModule } from '@angular/common';
import { CommonModule } from '@angular/common';
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this component to the UI lib?

@@ -1,16 +1,18 @@
import { animate, style, transition, trigger } from '@angular/animations';
import {
Component,
computed,
Copy link
Member

Choose a reason for hiding this comment

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

Why not use dropdown from primeNg instead of DotDropdownComponent

…for improved readability and maintainability
@nicobytes nicobytes changed the title Migrate to standalone all toolbar components Migrate all toolbar components to standalone and use the new syntax May 29, 2025
@nicobytes nicobytes requested a review from Copilot May 29, 2025 20:54
Copy link
Contributor

@Copilot 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 modernizes several UI components by migrating them to Angular standalone components with reactive signals and the new Angular 17 template syntax, while cleaning up unused dependencies.

  • Refactors components (e.g., DotDropdownComponent, DotCrumbtrailComponent) to use standalone and reactive inputs/outputs.
  • Removes deprecated modules and unused imports.
  • Updates test suites and templates to align with new syntax (@if, @for, etc.).

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dot-login-as.component.ts Removed redundant CommonModule import in favor of standalone component usage.
dot-crumbtrail.service.ts Switched from Subject to BehaviorSubject with inferred type; removed unused import.
dot-crumbtrail.module.ts Entire module removed as part of the migration to standalone components.
dot-crumbtrail.component.ts Converted to standalone component; updated imports and providers.
dot-crumbtrail.component.spec.ts Updated tests utilizing Spectator and new test selectors.
dot-comment-and-assign-form.* Updated template syntax from *ngIf to @if blocks.
dot-textarea-content.component.html Updated template to use new Angular 17 directives.
dot-global-message.* Adjusted selectors to use lowercase data-testid and updated conditionals.
dot-empty-state.component.html Changed *ngIf/*ngFor to @if/@for syntax; improved conditional rendering.
dot-dropdown-component/* Replaced module with standalone component and migrated inputs/outputs to reactive signals.
shared.module.ts Removed unused DotDropdownModule from shared module imports/exports.
dot-starter.component.html, dot-whats-changed.component.html, dot-palette-input-filter.component.html Updated template syntax to new Angular 17 @if/@for directives and self-closing syntax.
modules.ts Replaced DotToolbarModule with the standalone DotToolbarComponent.

@@ -15,7 +15,7 @@ import {
@Injectable()
export class DotCrumbtrailService {
private URL_EXCLUDES = ['/content-types-angular/create/content'];
private crumbTrail: Subject<DotCrumb[]> = new BehaviorSubject([]);
private crumbTrail = new BehaviorSubject([]);
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Consider explicitly specifying a generic type for the BehaviorSubject (e.g., BehaviorSubject<DotCrumb[]>) to improve code clarity and maintainability.

Suggested change
private crumbTrail = new BehaviorSubject([]);
private crumbTrail = new BehaviorSubject<DotCrumb[]>([]);

Copilot uses AI. Check for mistakes.

@nicobytes nicobytes marked this pull request as ready for review May 29, 2025 20:56
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.

new Angular Syntax in DotToolbarComponent
2 participants