-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix: Downtime notice for 2024-12-11 (#2896)
* Add support for showing timezone in date format (#2887) (cherry picked from commit 4177bf2) * Add global notices component with upcoming downtime message (#2888) (cherry picked from commit 3c86fff) * Downtime notice for 2024-12-11 --------- Co-authored-by: Nateowami <[email protected]> Co-authored-by: Nateowami <[email protected]>
- Loading branch information
1 parent
50ef858
commit bd525fa
Showing
9 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...IL.XForge.Scripture/ClientApp/src/app/shared/global-notices/global-notices.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<ng-container *transloco="let t; read: 'global_notices'"> | ||
@if (showDowntimeNotice) { | ||
<app-notice class="downtime-notice" type="warning" mode="fill-dark" icon="construction"> | ||
<div class="downtime-notice-content-wrapper"> | ||
<div> | ||
{{ | ||
t("upcoming_maintenance", { | ||
duration, | ||
startTime: i18n.formatDate(upcomingDowntime.start, { showTimeZone: true }) | ||
}) | ||
}} | ||
<a [href]="upcomingDowntime.detailsUrl" target="_blank">{{ t("learn_more") }}</a> | ||
</div> | ||
<button mat-icon-button (click)="showDowntimeNotice = false" [matTooltip]="t('close')"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
</div> | ||
</app-notice> | ||
} | ||
</ng-container> |
12 changes: 12 additions & 0 deletions
12
...IL.XForge.Scripture/ClientApp/src/app/shared/global-notices/global-notices.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.downtime-notice { | ||
margin: 0 auto 12px; | ||
padding-block: 6px; | ||
width: 65em; | ||
max-width: 100%; | ||
} | ||
|
||
.downtime-notice-content-wrapper { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/SIL.XForge.Scripture/ClientApp/src/app/shared/global-notices/global-notices.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatTooltipModule } from '@angular/material/tooltip'; | ||
import { TranslocoModule } from '@ngneat/transloco'; | ||
import { I18nService } from 'xforge-common/i18n.service'; | ||
import { NoticeComponent } from '../notice/notice.component'; | ||
|
||
@Component({ | ||
selector: 'app-global-notices', | ||
standalone: true, | ||
imports: [CommonModule, NoticeComponent, MatIconModule, MatButtonModule, MatTooltipModule, TranslocoModule], | ||
templateUrl: './global-notices.component.html', | ||
styleUrl: './global-notices.component.scss' | ||
}) | ||
export class GlobalNoticesComponent implements OnInit { | ||
// This is only an input so that the Storybook can turn this on even when it's off in the app | ||
@Input() showDowntimeNotice = false; | ||
|
||
upcomingDowntime = { | ||
start: new Date('2024-12-11 16:30 UTC'), | ||
durationMin: 2, | ||
durationMax: 3, | ||
durationUnit: 'hour', | ||
detailsUrl: 'https://software.sil.org/scriptureforge/news/' | ||
} as const; | ||
|
||
constructor(readonly i18n: I18nService) {} | ||
|
||
get duration(): string { | ||
return this.i18n.translateStatic(`global_notices.${this.upcomingDowntime.durationUnit}_range`, { | ||
min: this.upcomingDowntime.durationMin, | ||
max: this.upcomingDowntime.durationMax | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
const fifteenMinutesMs = 15 * 60 * 1000; | ||
const fifteenMinutesPastStart = new Date(this.upcomingDowntime.start.getTime() + fifteenMinutesMs); | ||
// Show the downtime notice up until 15 minutes past the start time. | ||
this.showDowntimeNotice = new Date() <= fifteenMinutesPastStart; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/SIL.XForge.Scripture/ClientApp/src/app/shared/global-notices/global-notices.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Meta, StoryObj } from '@storybook/angular'; | ||
import { GlobalNoticesComponent } from './global-notices.component'; | ||
|
||
const meta: Meta<GlobalNoticesComponent> = { | ||
title: 'Shared/Global Notices', | ||
component: GlobalNoticesComponent | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<GlobalNoticesComponent>; | ||
|
||
export const Default: Story = { | ||
args: { showDowntimeNotice: true } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters