chore: add husky pre-commit hook and lint-staged configuration
- Created a pre-commit hook in .husky to run lint-staged. - Added .lintstagedrc.mjs to format frontend files with Prettier and apply Spotless to backend Java files. - Introduced .prettierignore to exclude specific directories from formatting.
This commit is contained in:
1 parent
5d2d85aa8c
commit
878da155bd
564 files changed
+61467
-47179
No files matched your search
@@ -1,23 +1,23 @@
|
||||
:host {
|
||||
display: block;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.confirmation-dialog h2 {
|
||||
margin-bottom: 8px;
|
||||
color: var(--text);
|
||||
font-size: 1.25rem;
|
||||
letter-spacing: -0.025em;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text);
|
||||
font-size: 1.25rem;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.confirmation-dialog p {
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.55;
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.confirmation-dialog .confirm-action.mat-mdc-unelevated-button {
|
||||
--mdc-filled-button-container-color: var(--danger);
|
||||
--mdc-filled-button-label-text-color: var(--accent-contrast);
|
||||
border-radius: 12px;
|
||||
font-weight: 700;
|
||||
--mdc-filled-button-container-color: var(--danger);
|
||||
--mdc-filled-button-label-text-color: var(--accent-contrast);
|
||||
border-radius: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
<div class="confirmation-dialog">
|
||||
<h2 mat-dialog-title>{{ data.title }}</h2>
|
||||
<mat-dialog-content>
|
||||
<p>{{ data.message }}</p>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="button" (click)="cancel()">Annuler</button>
|
||||
<button mat-flat-button type="button" class="confirm-action" (click)="accept()">
|
||||
{{ data.confirmLabel }}
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
<h2 mat-dialog-title>{{ data.title }}</h2>
|
||||
<mat-dialog-content>
|
||||
<p>{{ data.message }}</p>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="button" (click)="cancel()">Annuler</button>
|
||||
<button mat-flat-button type="button" class="confirm-action" (click)="accept()">
|
||||
{{ data.confirmLabel }}
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
</div>
|
||||
@@ -3,42 +3,42 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { ConfirmationDialog, ConfirmationDialogData } from './confirmation-dialog';
|
||||
|
||||
describe('ConfirmationDialog', () => {
|
||||
const data: ConfirmationDialogData = {
|
||||
title: 'Supprimer cet appartement ?',
|
||||
message: 'Êtes-vous sûr de vouloir supprimer cet appartement ?',
|
||||
confirmLabel: 'Supprimer',
|
||||
};
|
||||
const dialogRef = { close: vi.fn() };
|
||||
const data: ConfirmationDialogData = {
|
||||
title: 'Supprimer cet appartement ?',
|
||||
message: 'Êtes-vous sûr de vouloir supprimer cet appartement ?',
|
||||
confirmLabel: 'Supprimer',
|
||||
};
|
||||
const dialogRef = { close: vi.fn() };
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
],
|
||||
});
|
||||
});
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('shows the destructive action and lets the user cancel', () => {
|
||||
const fixture = TestBed.createComponent(ConfirmationDialog);
|
||||
fixture.detectChanges();
|
||||
it('shows the destructive action and lets the user cancel', () => {
|
||||
const fixture = TestBed.createComponent(ConfirmationDialog);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.nativeElement.querySelector('[mat-dialog-title]').textContent).toContain(
|
||||
data.title,
|
||||
);
|
||||
expect(fixture.nativeElement.textContent).toContain(data.message);
|
||||
expect(fixture.nativeElement.textContent).toContain(data.confirmLabel);
|
||||
expect(fixture.nativeElement.querySelector('[mat-dialog-title]').textContent).toContain(
|
||||
data.title,
|
||||
);
|
||||
expect(fixture.nativeElement.textContent).toContain(data.message);
|
||||
expect(fixture.nativeElement.textContent).toContain(data.confirmLabel);
|
||||
|
||||
fixture.nativeElement.querySelector('button:first-of-type').click();
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(false);
|
||||
});
|
||||
fixture.nativeElement.querySelector('button:first-of-type').click();
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it('returns true when the destructive action is selected', () => {
|
||||
const fixture = TestBed.createComponent(ConfirmationDialog);
|
||||
fixture.detectChanges();
|
||||
it('returns true when the destructive action is selected', () => {
|
||||
const fixture = TestBed.createComponent(ConfirmationDialog);
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.nativeElement.querySelector('.confirm-action').click();
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(true);
|
||||
});
|
||||
fixture.nativeElement.querySelector('.confirm-action').click();
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
@@ -3,26 +3,26 @@ import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/materia
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
export interface ConfirmationDialogData {
|
||||
title: string;
|
||||
message: string;
|
||||
confirmLabel: string;
|
||||
title: string;
|
||||
message: string;
|
||||
confirmLabel: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirmation-dialog',
|
||||
imports: [MatButtonModule, MatDialogModule],
|
||||
templateUrl: './confirmation-dialog.html',
|
||||
styleUrl: './confirmation-dialog.css',
|
||||
selector: 'app-confirmation-dialog',
|
||||
imports: [MatButtonModule, MatDialogModule],
|
||||
templateUrl: './confirmation-dialog.html',
|
||||
styleUrl: './confirmation-dialog.css',
|
||||
})
|
||||
export class ConfirmationDialog {
|
||||
readonly data = inject<ConfirmationDialogData>(MAT_DIALOG_DATA);
|
||||
private readonly dialogRef = inject(MatDialogRef<ConfirmationDialog>);
|
||||
readonly data = inject<ConfirmationDialogData>(MAT_DIALOG_DATA);
|
||||
private readonly dialogRef = inject(MatDialogRef<ConfirmationDialog>);
|
||||
|
||||
cancel(): void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
cancel(): void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
accept(): void {
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user