Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Dec 9, 2024
1 parent 7921c9f commit e842bfd
Show file tree
Hide file tree
Showing 11 changed files with 436 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ SOKETI_SECRET=__CHANGE_ME_A8PRgk5qpfLxkfLU

NOVU_VERSION=2.1.0

NOVU_APPLICATION_IDENTIFIER=
NOVU_API_HOST=api-novu.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
NOVU_API_URL="${NOVU_API_URL:-https://${NOVU_API_HOST}}"
NOVU_DASHBOARD_URL=https://novu.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
Expand Down
1 change: 1 addition & 0 deletions bin/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ lib/js/core
lib/js/i18n
lib/js/liform-react
lib/js/navigation
lib/js/notification
lib/js/phrasea-ui
lib/js/react-auth
lib/js/react-form
Expand Down
3 changes: 3 additions & 0 deletions databox/client/config-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ window.config.muiTheme = ${stackConfig.theme.replace(/^export\s+const\s+themeOpt
sentryRelease: env.SENTRY_RELEASE,
pusherHost: env.SOKETI_HOST,
pusherKey: env.SOKETI_KEY,
novuAppIdentifier: env.NOVU_APPLICATION_IDENTIFIER,
novuSocketUrl: env.NOVU_WS_URL,
novuApiUrl: env.NOVU_API_URL,
};
});
2 changes: 2 additions & 0 deletions databox/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@alchemy/core": "workspace:*",
"@alchemy/i18n": "workspace:*",
"@alchemy/navigation": "workspace:*",
"@alchemy/notification": "workspace:*",
"@alchemy/phrasea-ui": "workspace:*",
"@alchemy/react-auth": "workspace:*",
"@alchemy/react-form": "workspace:*",
Expand All @@ -27,6 +28,7 @@
"@mui/material": "^5.16.7",
"@mui/x-tree-view": "^6.17.0",
"@novu/framework": "^2.5.2",
"@novu/react": "^2.6.2",
"@tanstack/react-query": "^5.59.0",
"@toast-ui/react-image-editor": "^3.15.2",
"ace-builds": "^1.36.2",
Expand Down
17 changes: 15 additions & 2 deletions databox/client/src/components/Layout/MainAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {ThemeEditorContext} from '@alchemy/theme-editor';
import config from '../../config';
import {keycloakClient} from '../../api/api-client';
import {DashboardMenu} from '@alchemy/react-ps';
import {Notifications} from '@alchemy/notification';
import {useModals} from '@alchemy/navigation';
import ChangeTheme from './ChangeTheme';
import ThemeEditor from './ThemeEditor';
Expand Down Expand Up @@ -121,7 +122,19 @@ export default function MainAppBar({onToggleLeftPanel}: Props) {
}}
></Box>

<Box sx={{flexGrow: 0}}>
{user ? <Box sx={{
flexGrow: 0,
mr: 1,

}}>
<Notifications
appIdentifier={config.novuAppIdentifier!}
userId={user.id}
socketUrl={config.novuSocketUrl!}
apiUrl={config.novuApiUrl!}
/>
</Box> : null}
<div style={{flexGrow: 0}}>
{!user ? (
<MenuItem component={'a'} href={getLoginUrl()}>
{t('menu.sign_in', 'Sign in')}
Expand Down Expand Up @@ -182,7 +195,7 @@ export default function MainAppBar({onToggleLeftPanel}: Props) {
]}
/>
)}
</Box>
</div>

{config.displayServicesMenu && (
<div style={{flexGrow: 0}}>
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ services:
- CONFIGURATOR_S3_REGION=${S3_REGION}
- CONFIGURATOR_S3_BUCKET_NAME
- CONFIGURATOR_S3_USE_PATH_STYLE_ENDPOINT=${S3_USE_PATH_STYLE_ENDPOINT}
- NOVU_APPLICATION_IDENTIFIER
- NOVU_WS_URL
- NOVU_API_URL
volumes:
- ./configs:/configs
labels:
Expand Down Expand Up @@ -1160,6 +1163,7 @@ services:
REDIS_CACHE_SERVICE_HOST: ${NOVU_REDIS_CACHE_SERVICE_HOST}
REDIS_CACHE_SERVICE_PORT: ${NOVU_REDIS_CACHE_SERVICE_PORT}
NOVU_SECRET_KEY: ${NOVU_SECRET_KEY}
STORE_ENCRYPTION_KEY: ${NOVU_STORE_ENCRYPTION_KEY}
extra_hosts:
- ws-novu.${PHRASEA_DOMAIN}:${PS_GATEWAY_IP}
- bridge-novu.${PHRASEA_DOMAIN}:${PS_GATEWAY_IP}
Expand All @@ -1184,6 +1188,7 @@ services:
REDIS_PASSWORD: ${NOVU_REDIS_PASSWORD}
JWT_SECRET: ${NOVU_JWT_SECRET}
NOVU_SECRET_KEY: ${NOVU_SECRET_KEY}
NOVU_API_URL: ${NOVU_API_URL}
labels:
- "traefik.enable=true"
- "traefik.project_name=${COMPOSE_PROJECT_NAME}"
Expand Down Expand Up @@ -1226,9 +1231,11 @@ services:
- internal
environment:
- NOVU_SECRET_KEY
- NOVU_API_URL
- NEXT_PUBLIC_NOVU_SECRET_KEY=${NOVU_SECRET_KEY}
- NEXT_PUBLIC_NOVU_APPLICATION_IDENTIFIER=${NOVU_APPLICATION_IDENTIFIER}
- NEXT_PUBLIC_NOVU_SUBSCRIBER_ID=${NOVU_SUBSCRIBER_ID}
- NEXT_PUBLIC_NOVU_API_URL=${NOVU_API_URL}
labels:
- "traefik.enable=true"
- "traefik.project_name=${COMPOSE_PROJECT_NAME}"
Expand Down
3 changes: 3 additions & 0 deletions lib/js/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export type WindowConfig = {
analytics?: AnalyticsConfig;
pusherHost?: Readonly<string>;
pusherKey?: Readonly<string>;
novuAppIdentifier?: Readonly<string>;
novuSocketUrl?: Readonly<string>;
novuApiUrl?: Readonly<string>;
}

export type SentryConfig = Pick<WindowConfig,
Expand Down
68 changes: 68 additions & 0 deletions lib/js/notification/components/Notifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {Bell, Inbox, InboxContent} from '@novu/react';
import {IconButton, Menu} from "@mui/material";
import React from "react";


type Props = {
appIdentifier: string;
socketUrl: string;
apiUrl: string;
userId: string;
};

export default function Notifications({
appIdentifier,
socketUrl,
apiUrl,
userId,
}: Props) {
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);

const handlePopoverOpen = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};

const handlePopoverClose = () => {
setAnchorEl(null);
};
const open = Boolean(anchorEl);
const popoverId = 'mouse-over-popover';

return <>
<Inbox
applicationIdentifier={appIdentifier}
subscriberId={userId}
socketUrl={socketUrl}
backendUrl={apiUrl}
>
<IconButton
aria-owns={open ? popoverId : undefined}
aria-haspopup="true"
onClick={handlePopoverOpen}
>
<Bell/>
</IconButton>

<Menu
style={{
marginTop: 30,
}}
id={popoverId}
open={open}
anchorEl={anchorEl}
anchorOrigin={{
vertical: 'top',
horizontal: 'right',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
onClose={handlePopoverClose}
>
<InboxContent/>
</Menu>
</Inbox>
</>
}
5 changes: 5 additions & 0 deletions lib/js/notification/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Notifications from './components/Notifications'

export {
Notifications,
};
20 changes: 20 additions & 0 deletions lib/js/notification/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@alchemy/notification",
"version": "1.0.0",
"public": true,
"main": "index.ts",
"dependencies": {
"@novu/react": "^2.6.2"
},
"peerDependencies": {
"react": "^18.2.0",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.16.7"
},
"devDependencies": {
"@types/react": "^18.3.11",
"react": "^18.3.1",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.16.7"
}
}
Loading

0 comments on commit e842bfd

Please sign in to comment.