-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dashboard] Downtime in-app announcements (#18761)
* [dashboard] Downtime in-app announcements * [dashboard] Set correct port for hot reload to work * [dashboard] Display local time * adding static page for maintenance mode * [dashboard] maintenance screen: Add specific end time * [dashboard] in-app maintenance notification: Point to https://www.gitpodstatus.com instead of specific event * [proxy] Re-direct mechanism controlled by env var MAINTENANCE_REDIRECT --------- Co-authored-by: Brad Harris <[email protected]>
- Loading branch information
1 parent
66c3630
commit cebee56
Showing
15 changed files
with
223 additions
and
6 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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,45 @@ | ||
<!doctype html> | ||
<!-- | ||
Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
Licensed under the GNU Affero General Public License (AGPL). | ||
See License.AGPL.txt in the project root for license information. | ||
--> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="./favicon256.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta name="robots" content="noindex" /> | ||
<meta name="Gitpod" content="Always Ready-to-Code" /> | ||
<link rel="apple-touch-icon" href="./favicon192.png" /> | ||
<link rel="stylesheet" href="./index.css" /> | ||
<title>Gitpod - Maintenance</title> | ||
|
||
<script> | ||
(() => { | ||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches | ||
const theme = localStorage.getItem('theme') | ||
if (theme === "dark" || (prefersDark && !theme)) { | ||
document.documentElement.classList.toggle("dark", true); | ||
} | ||
})(); | ||
</script> | ||
</head> | ||
<body class="flex justify-center items-center"> | ||
<div class="flex flex-col justify-center items-center max-w-xl text-center"> | ||
<img src="./gitpod.svg" alt="Gitpod Logo" class="h-16 flex-shrink-0 mb-8" /> | ||
|
||
<h1 class="text-gray-900 dark:text-gray-100 font-bold text-3xl mb-4">Uncharacteristically unavailable</h1> | ||
|
||
<p clas="text-gray-200 dark:text-gray-800">Gitpod is performing essential maintenance. Things should be back to normal by <strong><time datetime="2023-09-24T06:00:00.000Z">06:00 UTC</time></strong> latest. We apologize for any inconvenience this has caused.</p> | ||
|
||
<p class="mt-16"> | ||
Check <a href="https://www.gitpodstatus.com/" class="gp-link">gitpodstatus.com</a> or follow | ||
<a href="https://twitter.com/Gitpodstatus" class="gp-link">@gitpodstatus</a> for updates. | ||
</p> | ||
</div> | ||
</body> | ||
</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,28 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
html, | ||
body { | ||
@apply h-full; | ||
} | ||
body { | ||
@apply bg-gray-100 dark:bg-gitpod-black text-black dark:text-white; | ||
} | ||
p { | ||
@apply text-gray-600 dark:text-gray-400; | ||
} | ||
} | ||
|
||
@layer components { | ||
.gp-link { | ||
@apply text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-500 cursor-pointer; | ||
} | ||
} |
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,116 @@ | ||
/** | ||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useCallback, useEffect, useState } from "react"; | ||
import Alert, { AlertType } from "./components/Alert"; | ||
import { useFeatureFlag } from "./data/featureflag-query"; | ||
import dayjs from "dayjs"; | ||
import utc from "dayjs/plugin/utc"; | ||
import timezone from "dayjs/plugin/timezone"; | ||
import advancedFormat from "dayjs/plugin/advancedFormat"; | ||
|
||
const KEY_APP_DISMISSED_NOTIFICATIONS = "gitpod-app-notifications-dismissed"; | ||
|
||
interface Notification { | ||
id: string; | ||
type: AlertType; | ||
message: JSX.Element; | ||
} | ||
|
||
dayjs.extend(utc); | ||
dayjs.extend(timezone); | ||
dayjs.extend(advancedFormat); | ||
|
||
function localizedTime(dateStr: string): JSX.Element { | ||
const formatted = dayjs.utc(dateStr).local().format("dddd, MMM. D, HH:mm (z)"); | ||
return <time dateTime={dateStr}>{formatted}</time>; | ||
} | ||
|
||
const SCHEDULED_DOWNTIME: Notification = { | ||
id: "230924-scheduled-downtime", | ||
type: "info", | ||
message: ( | ||
<span className="text-md"> | ||
Gitpod will be uncharacteristically unavailable for essential maintenance beginning{" "} | ||
<span className="font-semibold">{localizedTime("2023-09-24T05:00:00.000Z")}</span> and lasting up to one | ||
hour. We apologize for any inconvenience this may cause.{" "} | ||
<a className="gp-link" href="https://www.gitpodstatus.com" target="_blank" rel="noreferrer"> | ||
Learn more | ||
</a> | ||
</span> | ||
), | ||
}; | ||
|
||
export function AppNotifications() { | ||
const [topNotification, setTopNotification] = useState<Notification | undefined>(undefined); | ||
|
||
const downtimeNotificationEnabled = useFeatureFlag("scheduled_downtime_notification"); | ||
|
||
useEffect(() => { | ||
const notifications = []; | ||
if (downtimeNotificationEnabled) { | ||
notifications.push(SCHEDULED_DOWNTIME); | ||
} | ||
|
||
const dismissedNotifications = getDismissedNotifications(); | ||
const topNotification = notifications.find((n) => !dismissedNotifications.includes(n.id)); | ||
setTopNotification(topNotification); | ||
}, [downtimeNotificationEnabled, setTopNotification]); | ||
|
||
const dismissNotification = useCallback(() => { | ||
if (!topNotification) { | ||
return; | ||
} | ||
|
||
const dismissedNotifications = getDismissedNotifications(); | ||
dismissedNotifications.push(topNotification.id); | ||
setDismissedNotifications(dismissedNotifications); | ||
setTopNotification(undefined); | ||
}, [topNotification, setTopNotification]); | ||
|
||
if (!topNotification) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<div className="app-container pt-2"> | ||
<Alert | ||
type={topNotification.type} | ||
closable={true} | ||
onClose={() => dismissNotification()} | ||
showIcon={true} | ||
className="flex rounded mb-2 w-full" | ||
> | ||
<span>{topNotification.message}</span> | ||
</Alert> | ||
</div> | ||
); | ||
} | ||
|
||
function getDismissedNotifications(): string[] { | ||
try { | ||
const str = window.localStorage.getItem(KEY_APP_DISMISSED_NOTIFICATIONS); | ||
const parsed = JSON.parse(str || "[]"); | ||
if (!Array.isArray(parsed)) { | ||
window.localStorage.removeItem(KEY_APP_DISMISSED_NOTIFICATIONS); | ||
return []; | ||
} | ||
return parsed; | ||
} catch (err) { | ||
console.debug("Failed to parse dismissed notifications", err); | ||
window.localStorage.removeItem(KEY_APP_DISMISSED_NOTIFICATIONS); | ||
return []; | ||
} | ||
} | ||
|
||
function setDismissedNotifications(ids: string[]) { | ||
try { | ||
window.localStorage.setItem(KEY_APP_DISMISSED_NOTIFICATIONS, JSON.stringify(ids)); | ||
} catch (err) { | ||
console.debug("Failed to set dismissed notifications", err); | ||
window.localStorage.removeItem(KEY_APP_DISMISSED_NOTIFICATIONS); | ||
} | ||
} |
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