Skip to content

Commit b2bda4c

Browse files
committed
fixup! feat(apps): create the code of conduct frontend application
1 parent 1d3655e commit b2bda4c

File tree

8 files changed

+68
-55
lines changed

8 files changed

+68
-55
lines changed

apps/code-of-conduct/app/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ng_module(
2323
)
2424

2525
sass_binary(
26-
name = "app-style",
26+
name = "style",
2727
src = "app.component.scss",
2828
)
2929

apps/code-of-conduct/app/block-user/BUILD.bazel

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
load("//tools:defaults.bzl", "ng_module")
1+
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library")
22
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
33

44
package(default_visibility = ["//apps/code-of-conduct:__subpackages__"])
55

66
ng_module(
77
name = "block-user",
8-
srcs = glob(["*.ts"]),
8+
srcs = glob(
9+
["*.ts"],
10+
exclude = ["*.spec.ts"],
11+
),
912
assets = [
1013
":block-user.component.css",
1114
":block-user.component.html",
@@ -24,3 +27,25 @@ sass_binary(
2427
name = "block-user-style",
2528
src = "block-user.component.scss",
2629
)
30+
31+
ts_library(
32+
name = "test_lib",
33+
testonly = True,
34+
srcs = glob(["*.spec.ts"]),
35+
deps = [
36+
":block-user",
37+
"@npm//@angular/common",
38+
"@npm//@angular/core",
39+
"@npm//@angular/fire",
40+
"@npm//@angular/forms",
41+
"@npm//@angular/material",
42+
"@npm//@types/jasmine",
43+
],
44+
)
45+
46+
karma_web_test_suite(
47+
name = "test",
48+
deps = [
49+
":test_lib",
50+
],
51+
)

apps/code-of-conduct/app/block-user/block-user.component.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
88
<form [formGroup]="blockUserForm">
99
<div class="two-column-row form-item">
1010
<span class="username">
11-
<mat-form-field floatLabel="always">
11+
<mat-form-field>
1212
<input
1313
[readonly]="editMode"
1414
required
@@ -24,19 +24,19 @@ <h1 class="mat-headline-3" mat-dialog-title>
2424
<mat-form-field>
2525
<mat-label>Block Until</mat-label>
2626
<input
27-
[style.display]="blockUserForm.controls.blockUntil.value === false ? 'none': ''"
27+
[style.display]="blockUserForm.controls.blockUntil.value !== false"
2828
readonly
2929
required
3030
matInput
3131
[min]="tomorrow"
3232
[max]="fiveYearsFromToday"
3333
formControlName="blockUntil"
3434
[matDatepicker]="picker">
35-
<span class="block-until-indefinite" *ngIf="blockUserForm.controls.blockUntil.value === false">Blocked Indefinitely</span>
36-
<mat-datepicker #picker></mat-datepicker>
37-
<button #blockUntilMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="blockUntilMenu" mat-icon-button matSuffix>
38-
<mat-icon>arrow_drop_down</mat-icon>
39-
</button>
35+
<span class="block-until-indefinite" *ngIf="blockUserForm.controls.blockUntil.value === false">Blocked Indefinitely</span>
36+
<mat-datepicker #picker></mat-datepicker>
37+
<button #blockUntilMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="blockUntilMenu" mat-icon-button matSuffix>
38+
<mat-icon>arrow_drop_down</mat-icon>
39+
</button>
4040
</mat-form-field>
4141
<mat-menu #blockUntilMenu="matMenu" yPosition="below" xPosition="before">
4242
<button mat-menu-item (click)="picker.select(week)">
@@ -75,6 +75,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
7575
<mat-form-field>
7676
<mat-label>Comments</mat-label>
7777
<textarea
78+
rows="3"
7879
formControlName="comments"
7980
matInput
8081
placeholder="The user broke the code of conduct by..."
@@ -83,7 +84,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
8384
</div>
8485
<div class="two-column-row form-item" *ngIf="editMode">
8586
<span>
86-
<mat-form-field floatLabel="always">
87+
<mat-form-field>
8788
<mat-label>Blocked By</mat-label>
8889
<input
8990
formControlName="blockedBy"
@@ -92,7 +93,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
9293
</mat-form-field>
9394
</span>
9495
<span>
95-
<mat-form-field floatLabel="always">
96+
<mat-form-field>
9697
<input
9798
readonly
9899
matInput

apps/code-of-conduct/app/block-user/block-user.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class BlockUserComponent {
8686
blockedBy: new FormControl<string>('', {nonNullable: true}),
8787
});
8888

89-
async blockUser() {
89+
blockUser() {
9090
this.blockUserForm.disable();
9191
this.dialogRef.disableClose = true;
9292

@@ -101,7 +101,7 @@ export class BlockUserComponent {
101101
});
102102
}
103103

104-
async updateUser() {
104+
updateUser() {
105105
this.dialogRef.disableClose = true;
106106
this.blockService
107107
.update(this.providedData.user!, this.blockUserForm.value)

apps/code-of-conduct/app/block.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,32 @@ import {httpsCallable, getFunctions} from '@angular/fire/functions';
1515
import {BehaviorSubject} from 'rxjs';
1616

1717
export interface BlockUserParams {
18+
/** The username of the user being blocked. */
1819
username: string;
20+
/** The date to block the user until, or false if the block is indefinite. */
1921
blockUntil: Date | false;
22+
/** A statement or link to the context for the blocking. */
2023
context: string;
24+
/** Additional comments about the user block. */
2125
comments: string;
2226
}
2327

2428
export interface UnblockUserParams {
29+
/** The username of the user being unblocked. */
2530
username: string;
2631
}
2732

2833
export interface BlockedUser extends BlockUserParams {
34+
/** The display name of the person who blocked the user. */
2935
blockedBy: string;
36+
/** The date the block began. */
3037
blockedOn: Date;
3138
}
3239

3340
export type BlockedUserFromFirestore = BlockedUser & {
41+
/** The date the block began, as a unix timestamp */
3442
blockedOn: number;
43+
/** The date the block ends, as a unix timestamp, or false if the block is indefinite. */
3544
blockUntil: number | false;
3645
};
3746

apps/code-of-conduct/styles.scss

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
1-
// Custom Theming for Angular Material
2-
// For more information: https://material.angular.io/guide/theming
31
@use '@angular/material' as mat;
4-
// Plus imports for other components in your app.
52

6-
7-
// Include the common styles for Angular Material. We include this here so that you only
8-
// have to load a single css file for Angular Material in your app.
9-
// Be sure that you only ever include this mixin once!
103
@include mat.core();
114

12-
// Define the palettes for your theme using the Material Design palettes available in palette.scss
13-
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
14-
// hue. Available color palettes: https://material.io/design/color/
155
$code-of-conduct-primary: mat.define-palette(mat.$teal-palette);
166
$code-of-conduct-accent: mat.define-palette(mat.$blue-palette, A200, A100, A400);
7+
$code-of-conduct-theme: mat.define-light-theme(
8+
(
9+
color: (
10+
primary: $code-of-conduct-primary,
11+
accent: $code-of-conduct-accent,
12+
),
13+
typography: mat.define-typography-config(),
14+
density: -1,
15+
)
16+
);
1717

18-
// The warn palette is optional (defaults to red).
19-
$code-of-conduct-warn: mat.define-palette(mat.$red-palette);
20-
21-
// Create the theme object. A theme consists of configurations for individual
22-
// theming systems such as "color" or "typography".
23-
$code-of-conduct-theme: mat.define-light-theme((
24-
color: (
25-
primary: $code-of-conduct-primary,
26-
accent: $code-of-conduct-accent,
27-
warn: $code-of-conduct-warn,
28-
),
29-
typography: mat.define-typography-config(),
30-
density: -1,
31-
));
32-
33-
// Include theme styles for core and each component used in your app.
34-
// Alternatively, you can import and @include the theme mixins for each component
35-
// that you are using.
3618
@include mat.all-component-themes($code-of-conduct-theme);
3719

38-
/* You can add global styles to this file, and also import other style files */
39-
40-
html, body { height: 100%; }
41-
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
20+
html,
21+
body {
22+
height: 100%;
23+
}
24+
body {
25+
margin: 0;
26+
font-family: Roboto, 'Helvetica Neue', sans-serif;
27+
}

apps/firebase.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
"value": "public,max-age=31536000,immutable"
1818
}
1919
]
20-
},
21-
{
22-
"source": "/@(ngsw-worker.js|ngsw.json)",
23-
"headers": [
24-
{
25-
"key": "Cache-Control",
26-
"value": "no-cache"
27-
}
28-
]
2920
}
3021
],
3122
"rewrites": [

apps/shared/account/account.guard.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const isLoggedInGuard = async () => {
88
const router = inject(Router);
99

1010
if (!(await firstValueFrom(account.isLoggedIn$))) {
11+
// TODO: Determine a way to better manage the path used.
1112
router.navigate(['login']);
1213
return false;
1314
}

0 commit comments

Comments
 (0)