-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/jetstream-authentication
- Loading branch information
Showing
9 changed files
with
132 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { logger } from '@jetstream/api-config'; | ||
import { getErrorMessageAndStackObj } from '@jetstream/shared/utils'; | ||
import { Announcement } from '@jetstream/types'; | ||
|
||
export function getAnnouncements(): Announcement[] { | ||
try { | ||
// This is a placeholder for the announcements that will be stored in the database eventually | ||
return [ | ||
{ | ||
id: 'auth-downtime-2024-11-15T15:00:00.000Z', | ||
title: 'Downtime', | ||
content: | ||
'We will be upgrading our authentication system with an expected start time of {start} in your local timezone. During this time, you will not be able to log in or use Jetstream. We expect the upgrade to take less than one hour.', | ||
replacementDates: [{ key: '{start}', value: '2024-11-16T18:00:00.000Z' }], | ||
expiresAt: '2024-11-16T20:00:00.000Z', | ||
createdAt: '2024-11-15T15:00:00.000Z', | ||
}, | ||
].filter(({ expiresAt }) => new Date(expiresAt) > new Date()); | ||
} catch (ex) { | ||
logger.error({ ...getErrorMessageAndStackObj(ex) }, 'Failed to get announcements'); | ||
return []; | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
apps/jetstream/src/app/components/core/AnnouncementAlerts.tsx
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,46 @@ | ||
import { Announcement } from '@jetstream/types'; | ||
import { Alert } from '@jetstream/ui'; | ||
import { useState } from 'react'; | ||
|
||
interface UnverifiedEmailAlertProps { | ||
announcements: Announcement[]; | ||
} | ||
|
||
const LS_KEY_PREFIX = 'announcement_dismissed_'; | ||
|
||
export function AnnouncementAlerts({ announcements }: UnverifiedEmailAlertProps) { | ||
if (!announcements || !announcements.length) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{announcements.map((announcement) => ( | ||
<AnnouncementAlert key={announcement.id} announcement={announcement} /> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
export function AnnouncementAlert({ announcement }: { announcement: Announcement }) { | ||
const key = `${LS_KEY_PREFIX}${announcement.id}`; | ||
const [dismissed, setDismissed] = useState(() => localStorage.getItem(key) === 'true'); | ||
|
||
if (dismissed || !announcement || !announcement.id || !announcement.content) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Alert | ||
type="warning" | ||
leadingIcon="warning" | ||
allowClose | ||
onClose={() => { | ||
localStorage.setItem(key, 'true'); | ||
setDismissed(true); | ||
}} | ||
> | ||
<span className="text-bold">{announcement.title}:</span> {announcement.content} | ||
</Alert> | ||
); | ||
} |
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
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