Skip to content

Commit

Permalink
fixup! feat(apps): create the code of conduct frontend application
Browse files Browse the repository at this point in the history
  • Loading branch information
josephperrott committed Apr 24, 2023
1 parent 1d3655e commit 3921c30
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 54 deletions.
2 changes: 1 addition & 1 deletion apps/code-of-conduct/app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ng_module(
)

sass_binary(
name = "app-style",
name = "style",
src = "app.component.scss",
)

Expand Down
5 changes: 4 additions & 1 deletion apps/code-of-conduct/app/block-user/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ package(default_visibility = ["//apps/code-of-conduct:__subpackages__"])

ng_module(
name = "block-user",
srcs = glob(["*.ts"]),
srcs = glob(
["*.ts"],
exclude = ["*.spec.ts"],
),
assets = [
":block-user.component.css",
":block-user.component.html",
Expand Down
19 changes: 10 additions & 9 deletions apps/code-of-conduct/app/block-user/block-user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
<form [formGroup]="blockUserForm">
<div class="two-column-row form-item">
<span class="username">
<mat-form-field floatLabel="always">
<mat-form-field>
<input
[readonly]="editMode"
required
Expand All @@ -24,19 +24,19 @@ <h1 class="mat-headline-3" mat-dialog-title>
<mat-form-field>
<mat-label>Block Until</mat-label>
<input
[style.display]="blockUserForm.controls.blockUntil.value === false ? 'none': ''"
[style.display]="blockUserForm.controls.blockUntil.value !== false"
readonly
required
matInput
[min]="tomorrow"
[max]="fiveYearsFromToday"
formControlName="blockUntil"
[matDatepicker]="picker">
<span class="block-until-indefinite" *ngIf="blockUserForm.controls.blockUntil.value === false">Blocked Indefinitely</span>
<mat-datepicker #picker></mat-datepicker>
<button #blockUntilMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="blockUntilMenu" mat-icon-button matSuffix>
<mat-icon>arrow_drop_down</mat-icon>
</button>
<span class="block-until-indefinite" *ngIf="blockUserForm.controls.blockUntil.value === false">Blocked Indefinitely</span>
<mat-datepicker #picker></mat-datepicker>
<button #blockUntilMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="blockUntilMenu" mat-icon-button matSuffix>
<mat-icon>arrow_drop_down</mat-icon>
</button>
</mat-form-field>
<mat-menu #blockUntilMenu="matMenu" yPosition="below" xPosition="before">
<button mat-menu-item (click)="picker.select(week)">
Expand Down Expand Up @@ -75,6 +75,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
<mat-form-field>
<mat-label>Comments</mat-label>
<textarea
rows="3"
formControlName="comments"
matInput
placeholder="The user broke the code of conduct by..."
Expand All @@ -83,7 +84,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
</div>
<div class="two-column-row form-item" *ngIf="editMode">
<span>
<mat-form-field floatLabel="always">
<mat-form-field>
<mat-label>Blocked By</mat-label>
<input
formControlName="blockedBy"
Expand All @@ -92,7 +93,7 @@ <h1 class="mat-headline-3" mat-dialog-title>
</mat-form-field>
</span>
<span>
<mat-form-field floatLabel="always">
<mat-form-field>
<input
readonly
matInput
Expand Down
4 changes: 2 additions & 2 deletions apps/code-of-conduct/app/block-user/block-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class BlockUserComponent {
blockedBy: new FormControl<string>('', {nonNullable: true}),
});

async blockUser() {
blockUser() {
this.blockUserForm.disable();
this.dialogRef.disableClose = true;

Expand All @@ -101,7 +101,7 @@ export class BlockUserComponent {
});
}

async updateUser() {
updateUser() {
this.dialogRef.disableClose = true;
this.blockService
.update(this.providedData.user!, this.blockUserForm.value)
Expand Down
9 changes: 9 additions & 0 deletions apps/code-of-conduct/app/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,32 @@ import {httpsCallable, getFunctions} from '@angular/fire/functions';
import {BehaviorSubject} from 'rxjs';

export interface BlockUserParams {
/** The username of the user being blocked. */
username: string;
/** The date to block the user until, or false if the block is indefinite. */
blockUntil: Date | false;
/** A statement or link to the context for the blocking. */
context: string;
/** Additional comments about the user block. */
comments: string;
}

export interface UnblockUserParams {
/** The username of the user being unblocked. */
username: string;
}

export interface BlockedUser extends BlockUserParams {
/** The display name of the person who blocked the user. */
blockedBy: string;
/** The date the block began. */
blockedOn: Date;
}

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

Expand Down
50 changes: 18 additions & 32 deletions apps/code-of-conduct/styles.scss
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
// Custom Theming for Angular Material
// For more information: https://material.angular.io/guide/theming
@use '@angular/material' as mat;
// Plus imports for other components in your app.


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

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

// The warn palette is optional (defaults to red).
$code-of-conduct-warn: mat.define-palette(mat.$red-palette);

// Create the theme object. A theme consists of configurations for individual
// theming systems such as "color" or "typography".
$code-of-conduct-theme: mat.define-light-theme((
color: (
primary: $code-of-conduct-primary,
accent: $code-of-conduct-accent,
warn: $code-of-conduct-warn,
),
typography: mat.define-typography-config(),
density: -1,
));

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include mat.all-component-themes($code-of-conduct-theme);

/* You can add global styles to this file, and also import other style files */

html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
html,
body {
height: 100%;
}
body {
margin: 0;
font-family: Roboto, 'Helvetica Neue', sans-serif;
}
9 changes: 0 additions & 9 deletions apps/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"value": "public,max-age=31536000,immutable"
}
]
},
{
"source": "/@(ngsw-worker.js|ngsw.json)",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache"
}
]
}
],
"rewrites": [
Expand Down
1 change: 1 addition & 0 deletions apps/shared/account/account.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const isLoggedInGuard = async () => {
const router = inject(Router);

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

0 comments on commit 3921c30

Please sign in to comment.