From 1f2045c7560794cbb4f61525d277d2e128859928 Mon Sep 17 00:00:00 2001 From: Saniya <37302318+Saby-Bishops@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:05:56 -0600 Subject: [PATCH 1/4] chore: type community link dialog form --- .../community-link-dialog.component.ts | 69 ++++++++++++++----- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/src/app/community/community-link-dialog.component.ts b/src/app/community/community-link-dialog.component.ts index 0784f998cf..3116171164 100644 --- a/src/app/community/community-link-dialog.component.ts +++ b/src/app/community/community-link-dialog.component.ts @@ -1,26 +1,47 @@ import { Component, ViewChild, Inject } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA } from '@angular/material/legacy-dialog'; -import { MatStepper } from '@angular/material/stepper'; +import { MatStepper, MatStepperSelectionEvent } from '@angular/material/stepper'; import { CustomValidators } from '../validators/custom-validators'; import { TeamsService } from '../teams/teams.service'; import { switchMap } from 'rxjs/operators'; import { ValidatorService } from '../validators/validator.service'; import { PlanetMessageService } from '../shared/planet-message.service'; +interface CommunityLinkForm { + title: FormControl; + route: FormControl; + linkId: FormControl; + teamType: FormControl; + icon: FormControl; + platform: FormControl; +} + +type CommunityLinkSelection = { + db: 'teams' | 'social'; + title: string; + selector?: { type: 'team' | 'enterprise' }; +}; + +type TeamSelectionEvent = { + mode: 'team' | 'enterprise'; + teamId: string; + teamType: string; +}; + @Component({ templateUrl: './community-link-dialog.component.html', }) export class CommunityLinkDialogComponent { @ViewChild('linkStepper') linkStepper: MatStepper; - selectedLink: { db, title, selector? }; - links: { db, title, selector? }[] = [ + selectedLink?: CommunityLinkSelection; + links: CommunityLinkSelection[] = [ { db: 'teams', title: $localize`Teams`, selector: { type: 'team' } }, { db: 'teams', title: $localize`Enterprises`, selector: { type: 'enterprise' } }, { db: 'social', title: $localize`Web & Social` } ]; - linkForm: UntypedFormGroup; + linkForm: FormGroup; socialPlatforms = [ { value: 'instagram', label: 'Instagram' }, { value: 'facebook', label: 'Facebook' }, @@ -35,22 +56,29 @@ export class CommunityLinkDialogComponent { constructor( private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, - private fb: UntypedFormBuilder, + private fb: FormBuilder, private teamsService: TeamsService, private planetMessageService: PlanetMessageService, private validatorService: ValidatorService ) { - this.linkForm = this.fb.group({ - title: [ '', CustomValidators.required, ac => this.validatorService.isUnique$('teams', 'title', ac, {}) ], - route: [ '', CustomValidators.required ], - linkId: '', - teamType: '', - icon: '', - platform: '' + this.linkForm = this.fb.nonNullable.group({ + title: this.fb.nonNullable.control('', { + validators: [CustomValidators.required], + asyncValidators: [ac => this.validatorService.isUnique$('teams', 'title', ac, {})] + }), + route: this.fb.nonNullable.control('', { validators: [CustomValidators.required] }), + linkId: this.fb.nonNullable.control(''), + teamType: this.fb.nonNullable.control(''), + icon: this.fb.nonNullable.control(''), + platform: this.fb.nonNullable.control('') }); } - teamSelect({ mode, teamId, teamType }) { + get linkTitleForm(): FormControl { + return this.linkForm.controls.title; + } + + teamSelect({ mode, teamId, teamType }: TeamSelectionEvent) { this.linkForm.controls.route.setValue(this.teamsService.teamLinkRoute(mode, teamId)); this.linkForm.controls.linkId.setValue(teamId); this.linkForm.controls.teamType.setValue(teamType); @@ -59,14 +87,21 @@ export class CommunityLinkDialogComponent { this.linkStepper.next(); } - linkStepperChange({ selectedIndex }) { + linkStepperChange({ selectedIndex }: MatStepperSelectionEvent) { if (selectedIndex === 0 && this.linkForm.pristine !== true) { - this.linkForm.reset(); + this.linkForm.reset({ + title: '', + route: '', + linkId: '', + teamType: '', + icon: '', + platform: '' + }); } } linkSubmit() { - const linkTitle = this.linkForm.get('title')?.value; + const linkTitle = this.linkForm.controls.title.value; this.teamsService.createServicesLink(this.linkForm.value).pipe( switchMap(() => this.data.getLinks()) ).subscribe({ From e00246338900413c56b64c2adfceb0314d8d6c91 Mon Sep 17 00:00:00 2001 From: Saniya <37302318+Saby-Bishops@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:53:05 -0600 Subject: [PATCH 2/4] Fix typed link form usage --- src/app/community/community-link-dialog.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/community/community-link-dialog.component.ts b/src/app/community/community-link-dialog.component.ts index 3116171164..b418bd230c 100644 --- a/src/app/community/community-link-dialog.component.ts +++ b/src/app/community/community-link-dialog.component.ts @@ -1,7 +1,8 @@ import { Component, ViewChild, Inject } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA } from '@angular/material/legacy-dialog'; -import { MatStepper, MatStepperSelectionEvent } from '@angular/material/stepper'; +import { MatStepper } from '@angular/material/stepper'; +import { StepperSelectionEvent } from '@angular/cdk/stepper'; import { CustomValidators } from '../validators/custom-validators'; import { TeamsService } from '../teams/teams.service'; import { switchMap } from 'rxjs/operators'; @@ -87,7 +88,7 @@ export class CommunityLinkDialogComponent { this.linkStepper.next(); } - linkStepperChange({ selectedIndex }: MatStepperSelectionEvent) { + linkStepperChange({ selectedIndex }: StepperSelectionEvent) { if (selectedIndex === 0 && this.linkForm.pristine !== true) { this.linkForm.reset({ title: '', @@ -102,7 +103,9 @@ export class CommunityLinkDialogComponent { linkSubmit() { const linkTitle = this.linkForm.controls.title.value; - this.teamsService.createServicesLink(this.linkForm.value).pipe( + const link = this.linkForm.getRawValue(); + + this.teamsService.createServicesLink(link).pipe( switchMap(() => this.data.getLinks()) ).subscribe({ next: () => { From 83c5cc64fb5a4df3fc225d3335dfdf1d53f7971a Mon Sep 17 00:00:00 2001 From: mutugiii Date: Tue, 23 Dec 2025 21:56:47 +0300 Subject: [PATCH 3/4] use nonNullableFormBuilder for consistency --- .../community-link-dialog.component.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/community/community-link-dialog.component.ts b/src/app/community/community-link-dialog.component.ts index b418bd230c..28813e133d 100644 --- a/src/app/community/community-link-dialog.component.ts +++ b/src/app/community/community-link-dialog.component.ts @@ -1,5 +1,5 @@ import { Component, ViewChild, Inject } from '@angular/core'; -import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { NonNullableFormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA } from '@angular/material/legacy-dialog'; import { MatStepper } from '@angular/material/stepper'; import { StepperSelectionEvent } from '@angular/cdk/stepper'; @@ -57,21 +57,21 @@ export class CommunityLinkDialogComponent { constructor( private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, - private fb: FormBuilder, + private fb: NonNullableFormBuilder, private teamsService: TeamsService, private planetMessageService: PlanetMessageService, private validatorService: ValidatorService ) { - this.linkForm = this.fb.nonNullable.group({ - title: this.fb.nonNullable.control('', { + this.linkForm = this.fb.group({ + title: this.fb.control('', { validators: [CustomValidators.required], asyncValidators: [ac => this.validatorService.isUnique$('teams', 'title', ac, {})] }), - route: this.fb.nonNullable.control('', { validators: [CustomValidators.required] }), - linkId: this.fb.nonNullable.control(''), - teamType: this.fb.nonNullable.control(''), - icon: this.fb.nonNullable.control(''), - platform: this.fb.nonNullable.control('') + route: this.fb.control('', { validators: [CustomValidators.required] }), + linkId: this.fb.control(''), + teamType: this.fb.control(''), + icon: this.fb.control(''), + platform: this.fb.control('') }); } From a04514674dd331f175a4073a65a55dbfc939e79d Mon Sep 17 00:00:00 2001 From: dogi Date: Tue, 6 Jan 2026 08:30:01 -0500 Subject: [PATCH 4/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36372c77e4..ec6e9d732c 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "planet", "license": "AGPL-3.0", - "version": "0.21.19", + "version": "0.21.22", "myplanet": { "latest": "v0.41.22", "min": "v0.37.60"