forked from project-openubl/xhandler-rust
-
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.
- Loading branch information
1 parent
06b8474
commit 5dee1a7
Showing
17 changed files
with
737 additions
and
623 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 @@ | ||
src/routeTree.gen.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,3 @@ | ||
{ | ||
"singleQuote": false | ||
} |
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,37 +1,52 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
import react from 'eslint-plugin-react' | ||
import js from "@eslint/js"; | ||
import globals from "globals"; | ||
import reactHooks from "eslint-plugin-react-hooks"; | ||
import reactRefresh from "eslint-plugin-react-refresh"; | ||
import tseslint from "typescript-eslint"; | ||
import react from "eslint-plugin-react"; | ||
import prettierRecommended from "eslint-plugin-prettier/recommended"; | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ ignores: ["dist"] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked, ...tseslint.configs.stylisticTypeChecked], | ||
files: ['**/*.{ts,tsx}'], | ||
extends: [ | ||
js.configs.recommended, | ||
...tseslint.configs.recommendedTypeChecked, | ||
...tseslint.configs.stylisticTypeChecked, | ||
prettierRecommended, | ||
], | ||
files: ["**/*.{ts,tsx}"], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
parserOptions: { | ||
project: ['./tsconfig.node.json', './tsconfig.app.json'], | ||
project: ["./tsconfig.node.json", "./tsconfig.app.json"], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
react | ||
"react-hooks": reactHooks, | ||
"react-refresh": reactRefresh, | ||
react, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
"react-refresh/only-export-components": [ | ||
"warn", | ||
{ allowConstantExport: true }, | ||
], | ||
...react.configs.recommended.rules, | ||
...react.configs['jsx-runtime'].rules, | ||
...react.configs["jsx-runtime"].rules, | ||
"prettier/prettier": [ | ||
"warn", | ||
{ | ||
semi: false, | ||
singleQuote: false, | ||
trailingComma: "es5", | ||
}, | ||
], | ||
}, | ||
settings: { react: { version: '18.3' } }, | ||
settings: { react: { version: "18.3" } }, | ||
ignores: ["src/routeTree.gen.ts"], | ||
}, | ||
) | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,26 +1,26 @@ | ||
import * as React from "react"; | ||
import {AlertProps} from "@patternfly/react-core"; | ||
import { AlertProps } from "@patternfly/react-core"; | ||
|
||
export interface INotification { | ||
title: string; | ||
variant: AlertProps["variant"]; | ||
message?: React.ReactNode; | ||
hideCloseButton?: boolean; | ||
timeout?: number | boolean; | ||
title: string; | ||
variant: AlertProps["variant"]; | ||
message?: React.ReactNode; | ||
hideCloseButton?: boolean; | ||
timeout?: number | boolean; | ||
} | ||
|
||
export interface INotificationsProvider { | ||
children: React.ReactNode; | ||
children: React.ReactNode; | ||
} | ||
|
||
interface INotificationsContext { | ||
pushNotification: (notification: INotification) => void; | ||
dismissNotification: (key: string) => void; | ||
notifications: INotification[]; | ||
pushNotification: (notification: INotification) => void; | ||
dismissNotification: (key: string) => void; | ||
notifications: INotification[]; | ||
} | ||
|
||
const appContextDefaultValue = {} as INotificationsContext; | ||
|
||
export const NotificationsContext = React.createContext<INotificationsContext>( | ||
appContextDefaultValue | ||
appContextDefaultValue, | ||
); |
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,42 +1,46 @@ | ||
import * as React from "react"; | ||
import {INotification, INotificationsProvider, NotificationsContext} from "./NotificationsContext.tsx"; | ||
import { | ||
INotification, | ||
INotificationsProvider, | ||
NotificationsContext, | ||
} from "./NotificationsContext.tsx"; | ||
|
||
const notificationDefault: Pick<INotification, "hideCloseButton"> = { | ||
hideCloseButton: false, | ||
hideCloseButton: false, | ||
}; | ||
|
||
export const NotificationsProvider: React.FunctionComponent< | ||
INotificationsProvider | ||
> = ({children}: INotificationsProvider) => { | ||
const [notifications, setNotifications] = React.useState<INotification[]>([]); | ||
INotificationsProvider | ||
> = ({ children }: INotificationsProvider) => { | ||
const [notifications, setNotifications] = React.useState<INotification[]>([]); | ||
|
||
const pushNotification = ( | ||
notification: INotification, | ||
clearNotificationDelay?: number | ||
) => { | ||
setNotifications([ | ||
...notifications, | ||
{...notificationDefault, ...notification}, | ||
]); | ||
setTimeout(() => setNotifications([]), clearNotificationDelay ?? 10000); | ||
}; | ||
const pushNotification = ( | ||
notification: INotification, | ||
clearNotificationDelay?: number, | ||
) => { | ||
setNotifications([ | ||
...notifications, | ||
{ ...notificationDefault, ...notification }, | ||
]); | ||
setTimeout(() => setNotifications([]), clearNotificationDelay ?? 10000); | ||
}; | ||
|
||
const dismissNotification = (title: string) => { | ||
const remainingNotifications = notifications.filter( | ||
(n) => n.title !== title | ||
); | ||
setNotifications(remainingNotifications); | ||
}; | ||
|
||
return ( | ||
<NotificationsContext.Provider | ||
value={{ | ||
pushNotification, | ||
dismissNotification, | ||
notifications, | ||
}} | ||
> | ||
{children} | ||
</NotificationsContext.Provider> | ||
const dismissNotification = (title: string) => { | ||
const remainingNotifications = notifications.filter( | ||
(n) => n.title !== title, | ||
); | ||
setNotifications(remainingNotifications); | ||
}; | ||
|
||
return ( | ||
<NotificationsContext.Provider | ||
value={{ | ||
pushNotification, | ||
dismissNotification, | ||
notifications, | ||
}} | ||
> | ||
{children} | ||
</NotificationsContext.Provider> | ||
); | ||
}; |
Oops, something went wrong.