Skip to content

Commit 702e039

Browse files
Admin messages (#17)
* Submodules added to refinery-entry * Added submodules to drone file * Installed missing packages * Added admin messages on refinery entry * Submodules merge * Installed package from submodule
1 parent ee4afc7 commit 702e039

File tree

12 files changed

+285
-76
lines changed

12 files changed

+285
-76
lines changed

.drone.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ platform:
66
arch: amd64
77

88
steps:
9+
- name: submodules
10+
image: alpine/git
11+
commands:
12+
- git submodule init
13+
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
14+
- "git submodule update --recursive"
915
- name: build and publish
1016
image: plugins/docker
1117
settings:
@@ -64,6 +70,12 @@ platform:
6470
arch: arm64
6571

6672
steps:
73+
- name: submodules
74+
image: alpine/git
75+
commands:
76+
- git submodule init
77+
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
78+
- "git submodule update --recursive"
6779
- name: build and publish
6880
image: plugins/docker
6981
settings:
@@ -93,6 +105,12 @@ platform:
93105
arch: amd64
94106

95107
steps:
108+
- name: submodules
109+
image: alpine/git
110+
commands:
111+
- git submodule init
112+
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
113+
- "git submodule update --recursive"
96114
- name: build and publish
97115
image: plugins/docker
98116
settings:
@@ -116,6 +134,12 @@ platform:
116134
arch: arm64
117135

118136
steps:
137+
- name: submodules
138+
image: alpine/git
139+
commands:
140+
- git submodule init
141+
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
142+
- "git submodule update --recursive"
119143
- name: build and publish
120144
image: plugins/docker
121145
settings:

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "submodules/javascript-functions"]
2+
path = submodules/javascript-functions
3+
url = [email protected]:code-kern-ai/submodule-javascript-functions.git
4+
[submodule "submodules/react-components"]
5+
path = submodules/react-components
6+
url = [email protected]:code-kern-ai/submodule-react-components.git

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@headlessui/react": "^1.7.18",
13+
"@nextui-org/react": "^1.0.0-beta.13",
1214
"@ory/client": "^1.1.24",
1315
"@ory/integrations": "^1.1.0",
1416
"@ory/kratos-client": "^0.11.1",
1517
"@ory/themes": "^0.0.101",
18+
"@tabler/icons-react": "^3.2.0",
19+
"@tailwindcss/forms": "^0.5.3",
1620
"@types/node": "18.15.12",
1721
"@types/react": "18.0.37",
1822
"@types/react-dom": "18.0.11",
@@ -23,7 +27,9 @@
2327
"next": "^12.2.0",
2428
"react": "^17.0.2",
2529
"react-dom": "^17.0.2",
30+
"react-i18next": "^14.1.2",
2631
"react-toastify": "^9.1.2",
32+
"rxjs": "^7.8.1",
2733
"styled-components": "^5.3.9",
2834
"typescript": "5.0.4"
2935
},
@@ -35,4 +41,4 @@
3541
"postcss": "^8.4.23",
3642
"tailwindcss": "^3.3.1"
3743
}
38-
}
44+
}

pages/settings.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,62 @@ import { AxiosError } from "axios"
33
import type { NextPage } from "next"
44
import Head from "next/head"
55
import { useRouter } from "next/router"
6-
import { useEffect, useState } from "react"
6+
import { useCallback, useEffect, useState } from "react"
77

88
import { Flow, Messages } from "../pkg"
99
import { handleFlowError } from "../pkg/errors"
1010
import ory from "../pkg/sdk"
1111
import { KernLogo } from "@/pkg/ui/Icons"
1212
import { prepareNodes } from "@/util/helper-functions"
13+
import { WebSocketsService } from "@/submodules/react-components/hooks/web-socket/WebSocketsService"
14+
import { getAllActiveAdminMessages, getUserInfoExtended } from "@/util/data-fetch"
15+
import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket"
16+
import { Application, CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants"
17+
import { AdminMessage } from "@/submodules/react-components/types/admin-messages"
18+
import { postProcessAdminMessages } from "@/submodules/react-components/helpers/admin-messages-helper"
19+
import AdminMessages from "@/submodules/react-components/components/AdminMessages"
1320

1421
const Settings: NextPage = () => {
1522
const [initialFlow, setInitialFlow]: any = useState<SettingsFlow>()
1623
const [changedFlow, setChangedFlow]: any = useState<SettingsFlow>()
1724
const [containsTotp, setContainsTotp] = useState<boolean>(false)
1825
const [containsBackupCodes, setContainsBackupCodes] = useState<boolean>(false)
1926
const [isOidc, setIsOidc] = useState(false);
27+
const [user, setUser] = useState<any>(null);
28+
const [activeAdminMessages, setActiveAdminMessages] = useState<AdminMessage[]>([]);
2029
// Get ?flow=... from the URL
2130
const router = useRouter()
2231
const { flow: flowId, return_to: returnTo } = router.query
2332

33+
useEffect(() => {
34+
getUserInfoExtended((res) => {
35+
setUser(res['data']['userInfo']);
36+
if (res) {
37+
if (res['data']?.["userInfo"]?.organizationId) {
38+
if (WebSocketsService.getConnectionOpened()) return;
39+
WebSocketsService.setConnectionOpened(true);
40+
WebSocketsService.initWsNotifications();
41+
}
42+
}
43+
});
44+
}, []);
45+
46+
useEffect(() => {
47+
refetchAdminMessagesAndProcess();
48+
}, []);
49+
50+
const handleWebsocketNotification = useCallback((msgParts: string[]) => {
51+
if (msgParts[1] == 'admin_message') {
52+
refetchAdminMessagesAndProcess();
53+
}
54+
}, []);
55+
56+
function refetchAdminMessagesAndProcess() {
57+
getAllActiveAdminMessages((res) => setActiveAdminMessages(postProcessAdminMessages(res["data"]["allActiveAdminMessages"])));
58+
}
59+
60+
useWebsocket(user?.organizationId, Application.ENTRY, CurrentPage.ENTRY_LAYOUT, handleWebsocketNotification)
61+
2462
useEffect(() => {
2563
// If the router is not ready yet, or we already have a flow, do nothing.
2664
if (!router.isReady || initialFlow) {
@@ -162,6 +200,9 @@ const Settings: NextPage = () => {
162200
</div>
163201
<div className="img-container">
164202
</div>
203+
<AdminMessages
204+
adminMessages={activeAdminMessages}
205+
setActiveAdminMessages={setActiveAdminMessages} />
165206
</>
166207
)
167208
}

services/basic-fetch/util.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

smodules

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
pull() {
4+
echo "Pulling data...";
5+
git submodule foreach git pull
6+
echo "Pulling done";
7+
}
8+
9+
10+
push() {
11+
echo "Preparing push...";
12+
git submodule foreach git add .
13+
git submodule foreach git commit -m "$@"
14+
git submodule foreach git push
15+
echo "Pushed (if there were any changes that is...)";
16+
}
17+
18+
19+
init() {
20+
echo "Initializing submodules..."
21+
git submodule update --init
22+
git submodule foreach git checkout dev
23+
echo "Initializing complete"
24+
}
25+
26+
if [ "$1" == "init" ]; then
27+
init
28+
else
29+
if [ "$1" == "pull" ]; then
30+
pull
31+
else
32+
if [ "$1" == "push" ]; then
33+
if [ -z ${2+x} ];
34+
then echo "Please provide a commit message";
35+
else push "$2";
36+
fi
37+
fi
38+
fi
39+
fi

styles/globals.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
15
*,
26
::before,
37
::after {
@@ -166,9 +170,10 @@ button.button-sign-in:focus {
166170
padding-top: 0.25rem;
167171
}
168172

169-
.divider-outer:before, .divider-outer:after {
173+
.divider-outer:before,
174+
.divider-outer:after {
170175
content: "";
171-
border-bottom: 1px solid #D1D5DB;
176+
border-bottom: 1px solid #D1D5DB;
172177
flex: 1 0 auto;
173178
height: .3rem;
174179
}

submodules/javascript-functions

Submodule javascript-functions added at bda7bcd

submodules/react-components

Submodule react-components added at 22a1063

tailwind.config.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1+
const defaultTheme = require('tailwindcss/defaultTheme')
2+
13
/** @type {import('tailwindcss').Config} */
24
module.exports = {
3-
content: [
4-
'./pages/**/*.{js,ts,jsx,tsx}',
5-
'./components/**/*.{js,ts,jsx,tsx}',
6-
'./app/**/*.{js,ts,jsx,tsx}',
7-
],
5+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
86
theme: {
7+
fontSize: {
8+
xs: ['0.75rem', { lineHeight: '1rem' }],
9+
sm: ['0.875rem', { lineHeight: '1.5rem' }],
10+
base: ['1rem', { lineHeight: '1.75rem' }],
11+
lg: ['1.125rem', { lineHeight: '2rem' }],
12+
xl: ['1.25rem', { lineHeight: '2rem' }],
13+
'2xl': ['1.5rem', { lineHeight: '2rem' }],
14+
'3xl': ['2rem', { lineHeight: '2.5rem' }],
15+
'4xl': ['2.5rem', { lineHeight: '3.5rem' }],
16+
'5xl': ['3rem', { lineHeight: '3.5rem' }],
17+
'6xl': ['3.75rem', { lineHeight: '1' }],
18+
'7xl': ['4.5rem', { lineHeight: '1.1' }],
19+
'8xl': ['6rem', { lineHeight: '1' }],
20+
'9xl': ['8rem', { lineHeight: '1' }],
21+
},
922
extend: {
10-
23+
borderRadius: {
24+
'4xl': '2rem',
25+
},
26+
fontFamily: {
27+
sans: ['Inter', ...defaultTheme.fontFamily.sans],
28+
mono: ['DM Mono', ...defaultTheme.fontFamily.mono],
29+
},
30+
maxWidth: {
31+
'2xl': '40rem',
32+
},
1133
},
1234
},
13-
plugins: [],
35+
plugins: [require('@tailwindcss/forms')],
36+
content: ['./src/**/*.{js,jsx,ts,tsx}', './submodules/react-components/**/*.{js,jsx,ts,tsx}'],
37+
safelist: [
38+
// new safelist logic https://tailwindcss.com/docs/content-configuration#using-regular-expressions
39+
{ pattern: /(text)-(slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(500|600|700|800)/ },
40+
{ pattern: /(border)-(slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(300|400|500)/ },
41+
{ pattern: /(bg)-(slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(50|100|200|300|500)/ },
42+
{ pattern: /grid-cols-(\d+)/ },
43+
],
1444
}

0 commit comments

Comments
 (0)