-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
RestateContext
and extract health check and version to se…
…parate libs (#77) Signed-off-by: Nik Nasr <[email protected]>
- Loading branch information
Showing
43 changed files
with
727 additions
and
86 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './lib/api/client'; | ||
export * from './lib/AdminBaseUrlProvider'; | ||
export * from './lib/api/hooks'; | ||
export type * from './lib/api/type'; | ||
export * from './lib/AdminBaseUrlProvider'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
], | ||
"plugins": [] | ||
} |
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,7 @@ | ||
# health | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test health` to execute the unit tests via [Vitest](https://vitest.dev/). |
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 @@ | ||
const nx = require('@nx/eslint-plugin'); | ||
const baseConfig = require('../../../eslint.config.js'); | ||
|
||
module.exports = [ | ||
...baseConfig, | ||
...nx.configs['flat/react'], | ||
{ | ||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], | ||
// Override or add rules here | ||
rules: {}, | ||
}, | ||
]; |
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,9 @@ | ||
{ | ||
"name": "health", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/features/health/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"// targets": "to see all targets run: nx show project health --web", | ||
"targets": {} | ||
} |
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,2 @@ | ||
export * from './lib/HealthIndicator'; | ||
export * from './lib/HealthCheckNotification'; |
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,42 @@ | ||
import { useRestateContext } from '@restate/features/restate-context'; | ||
import { Button } from '@restate/ui/button'; | ||
import { Icon, IconName } from '@restate/ui/icons'; | ||
import { HideNotification, LayoutOutlet, LayoutZone } from '@restate/ui/layout'; | ||
import { useDeferredValue, useState } from 'react'; | ||
|
||
export function HealthCheckNotification() { | ||
const { status } = useRestateContext(); | ||
const isDegraded = status === 'DEGRADED'; | ||
const deferredIsDegraded = useDeferredValue(isDegraded); | ||
const [canBeOpened, setCanBeOpened] = useState(true); | ||
const deferredCanBeOpened = useDeferredValue(canBeOpened); | ||
|
||
if (deferredIsDegraded && deferredCanBeOpened) { | ||
return ( | ||
<LayoutOutlet zone={LayoutZone.Notification}> | ||
<div className="flex items-center gap-2 bg-orange-100 rounded-xl bg-orange-200/60 shadow-lg shadow-zinc-800/5 border border-orange-200 text-orange-800 px-3 text-sm"> | ||
<Icon | ||
name={IconName.TriangleAlert} | ||
className="w-4 h-4 fill-current2" | ||
/>{' '} | ||
Your Restate server is currently experiencing issues. | ||
<Button | ||
variant="icon" | ||
className="ml-auto" | ||
onClick={(event) => { | ||
event.target.dataset.variant = 'hidden'; | ||
setTimeout(() => { | ||
setCanBeOpened(false); | ||
}, 100); | ||
}} | ||
> | ||
<Icon name={IconName.X} /> | ||
</Button> | ||
</div> | ||
{(!isDegraded || !canBeOpened) && <HideNotification />} | ||
</LayoutOutlet> | ||
); | ||
} | ||
|
||
return null; | ||
} |
Oops, something went wrong.