Skip to content

Commit 541bc7e

Browse files
Merge branch 'main' into terminal_events-to-sentry
2 parents 9168e89 + 599e752 commit 541bc7e

File tree

84 files changed

+9275
-42198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+9275
-42198
lines changed

Diff for: .env

+2
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ GLOBAL_API_TIMEOUT=60000
4141
TRIGGER_API_TIMEOUT=60000
4242
LOGIN_DT_LOGO=
4343
SIDEBAR_DT_LOGO=
44+
USE_V2=
45+
ENABLE_EXTERNAL_ARGO_CD=false
4446
LOG_TERMINAL_EVENTS_TO_SENTRY=false

Diff for: Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ FROM node:20-alpine AS builder
33
WORKDIR /app
44
COPY package.json .
55
COPY yarn.lock .
6+
# Copy .npmrc if it exists, otherwise don't fail
7+
COPY .npmr[c] .
68
RUN yarn install --network-timeout 600000
79

810
COPY src/ src

Diff for: config-overrides.js

-12
This file was deleted.

Diff for: index.html

+159-37
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,154 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="utf-8" />
6-
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
7-
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet">
8-
<link
9-
href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700;900&display=swap"
10-
rel="stylesheet"
11-
/>
12-
<link rel="shortcut icon" href="/favicon.ico" />
13-
<script src="/dashboard/env-config.js"></script>
14-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
15-
<meta name="theme-color" content="#06c" />
16-
<meta name="robots" content="noindex, nofollow" />
17-
<!--
3+
<head>
4+
<meta charset="utf-8" />
5+
<link
6+
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"
7+
rel="stylesheet"
8+
/>
9+
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet" />
10+
<link
11+
href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700;900&display=swap"
12+
rel="stylesheet"
13+
/>
14+
<link rel="shortcut icon" href="/favicon.ico" />
15+
<script src="/dashboard/env-config.js"></script>
16+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
17+
<meta name="theme-color" content="#06c" />
18+
<meta name="robots" content="noindex, nofollow" />
19+
<!--
1820
manifest.json provides metadata used when your web app is installed on a
1921
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
2022
-->
21-
<link rel="manifest" href="/manifest.json" />
23+
<link rel="manifest" href="/manifest.json" />
24+
25+
<title>Devtron</title>
26+
</head>
27+
28+
<body>
29+
<noscript>You need to enable JavaScript to run this app.</noscript>
30+
<div id="root">
31+
<div
32+
style="
33+
height: 100vh;
34+
display: flex;
35+
justify-content: center;
36+
align-items: center;
37+
background-color: #fff;
38+
"
39+
>
40+
<svg width="80" height="80" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
41+
<style>
42+
.svg__loader_group-top {
43+
animation: top-shape 1.2s infinite;
44+
transform-origin: center center;
45+
}
46+
.svg__loader_group-bottom {
47+
animation: bottom-shape 1.2s infinite;
48+
transform-origin: center center;
49+
}
50+
51+
.svg__loader_shapepath-top {
52+
animation: path-fill 1.2s infinite;
53+
}
54+
.svg__loader_shapepath-bottom {
55+
animation: path-fill 1.2s infinite;
56+
}
57+
58+
.svg__loader_rotating-group {
59+
animation: rotate-group 1.2s infinite reverse;
60+
transform-origin: center center;
61+
}
2262

63+
@keyframes path-fill {
64+
0% {
65+
fill: #3989d9;
66+
}
67+
30% {
68+
fill: #3989d9;
69+
}
70+
45% {
71+
fill: #abcff3;
72+
}
73+
100% {
74+
fill: #3989d9;
75+
}
76+
}
2377

24-
<title>Devtron</title>
78+
@keyframes top-shape {
79+
0% {
80+
transform: translateX(0px) translateY(0px) rotate(0deg);
81+
transform-origin: center center;
82+
}
83+
30% {
84+
transform: translateX(0px) translateY(0px) rotate(10deg);
85+
transform-origin: center center;
86+
}
87+
45% {
88+
transform: translateX(-6px) translateY(-6px) rotate(15deg);
89+
transform-origin: center center;
90+
}
2591

92+
100% {
93+
transform: translateX(0px) translateY(0px) rotate(0deg);
94+
transform-origin: center center;
95+
}
96+
}
2697

27-
</head>
98+
@keyframes bottom-shape {
99+
0% {
100+
transform: translateX(0px) translateY(0px) rotate(0deg);
101+
transform-origin: center center;
102+
}
103+
30% {
104+
transform: translateX(0px) translateY(0px) rotate(10deg);
105+
transform-origin: center center;
106+
}
107+
45% {
108+
transform: translateX(6px) translateY(6px) rotate(15deg);
109+
transform-origin: center center;
110+
}
28111

29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
112+
100% {
113+
transform: translateX(0px) translateY(0px) rotate(0deg);
114+
transform-origin: center center;
115+
}
116+
}
117+
118+
@keyframes rotate-group {
119+
0% {
120+
transform: rotate(0deg);
121+
}
122+
44% {
123+
transform: rotate(0deg);
124+
}
125+
100% {
126+
transform: rotate(360deg);
127+
animation-timing-function: ease-in-out;
128+
}
129+
}
130+
</style>
131+
<rect width="100" height="100" rx="20" fill="#E5F2FF" />
132+
<g class="svg__loader_rotating-group">
133+
<g class="svg__loader_group-top">
134+
<path
135+
class="svg__loader_shapepath-top"
136+
d="M59.8584 21.95L38.6084 21.875C36.8042 21.8667 35.1292 22.8125 34.1792 24.3667L19.4625 48.5167C18.9899 49.293 18.7427 50.1855 18.7486 51.0943C18.7545 52.0031 19.0132 52.8924 19.4958 53.6625L30.9125 71.8792C31.2183 72.533 31.7308 73.0679 32.3709 73.4015C33.011 73.7351 33.7431 73.8488 34.4542 73.725C35.141 73.5973 35.7703 73.2572 36.2533 72.7525C36.7362 72.2478 37.0485 71.6042 37.1459 70.9125C37.2338 70.2725 37.143 69.6207 36.8834 69.0292L36.8334 68.9458C36.7375 68.7458 36.6167 68.5583 36.4875 68.3833L35.1958 66.3083L28.3458 55.3583C27.9912 54.8612 27.7883 54.2719 27.7617 53.6618C27.735 53.0517 27.8858 52.447 28.1958 51.9208C30.175 48.5958 34.5125 41.5042 35.4875 40.3458C35.854 40.0077 36.2862 39.7489 36.7572 39.5854C37.2282 39.4219 37.7279 39.3574 38.225 39.3958L43.6208 39.8125C43.8939 39.8472 44.1535 39.951 44.3752 40.1142C44.5969 40.2773 44.7733 40.4943 44.8876 40.7447C45.0019 40.9951 45.0504 41.2705 45.0286 41.5448C45.0067 41.8192 44.9151 42.0834 44.7625 42.3125L42.5125 45.7917C42.3947 45.9427 42.2915 46.1045 42.2042 46.275V46.2792C41.8913 46.8936 41.8029 47.5981 41.9542 48.2708C42.0838 48.8505 42.391 49.3753 42.833 49.7721C43.275 50.1689 43.8298 50.4179 44.4201 50.4844C45.0103 50.5509 45.6066 50.4316 46.1259 50.1431C46.6451 49.8546 47.0614 49.4113 47.3167 48.875L62.0625 26.225C63.2084 24.4667 62.0709 22.0625 60 21.9542C59.9528 21.9515 59.9056 21.9501 59.8584 21.95Z"
137+
fill="#3989D9"
138+
/>
139+
</g>
140+
<g class="svg__loader_group-bottom">
141+
<path
142+
class="svg__loader_shapepath-bottom"
143+
d="M65.4458 26.2375C66.1567 26.1108 66.8896 26.2217 67.5313 26.553C68.1729 26.8844 68.6876 27.4178 68.9958 28.0709L80.4875 46.2334C81.4833 47.7959 81.5041 49.7959 80.55 51.3792L65.9375 75.5917C65.4801 76.3555 64.8332 76.9882 64.0594 77.4284C63.2855 77.8686 62.4111 78.1014 61.5208 78.1042L40.2708 78.125C40.2236 78.1263 40.1764 78.1263 40.1291 78.125C38.0583 78.025 36.9125 75.625 38.0458 73.8625L52.6916 51.1459C52.9442 50.6078 53.3584 50.162 53.8765 49.8707C54.3946 49.5794 54.9907 49.4571 55.5816 49.5209C56.1725 49.5847 56.7288 49.8313 57.1728 50.2265C57.6168 50.6216 57.9264 51.1455 58.0583 51.725C58.2135 52.3963 58.1295 53.1007 57.8208 53.7167C57.7327 53.8889 57.628 54.0564 57.5083 54.2084L55.2791 57.6959C55.1264 57.9255 55.035 58.1904 55.0135 58.4654C54.9921 58.7403 55.0413 59.0162 55.1566 59.2667C55.2718 59.5173 55.4493 59.7342 55.672 59.8968C55.8947 60.0595 56.1554 60.1624 56.4291 60.1959L61.8291 60.5875C62.3261 60.6226 62.8249 60.5548 63.2944 60.3885C63.764 60.2222 64.1942 59.9609 64.5583 59.6209C65.1 58.975 66.6666 56.4959 68.2916 53.8417L69.2666 52.2459C70.2333 50.6542 71.1458 49.1209 71.8041 48.0125C72.1109 47.4853 72.2584 46.8805 72.2288 46.2712C72.1992 45.6619 71.9938 45.0743 71.6375 44.5792L71.6583 44.5667L64.7375 33.6584L63.4416 31.5875C63.3053 31.4122 63.1866 31.2238 63.0875 31.025L63.0375 30.95C62.7742 30.3581 62.6805 29.7046 62.7666 29.0625C62.8608 28.3703 63.1702 27.7251 63.6509 27.2182C64.1317 26.7113 64.7595 26.3682 65.4458 26.2375Z"
144+
fill="#3989D9"
145+
/>
146+
</g>
147+
</g>
148+
</svg>
149+
</div>
150+
</div>
151+
<!--
33152
This HTML file is a template.
34153
If you open it directly in the browser, you will see an empty page.
35154
@@ -38,18 +157,21 @@
38157
39158
To begin the development, run `npm start` or `yarn start`.
40159
To create a production bundle, use `npm run build` or `yarn build`.
41-
-->
42-
</body>
43-
<!-- Discord widget -->
44-
<script type="text/javascript">
45-
if (!window._env_.HIDE_DISCORD) {
46-
document.write('<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>const crate = new Crate({server: "769482988882493450",channel: "769508553118842881", location: ["bottom", "left"], color: "#023263"});crate.notify({content: "Need help?",timeout: 8000,avatar: "https://i.postimg.cc/MK5M3H87/1516624713231.jpg"});<\/script>');
47-
}
48-
</script>
49-
<script>
50-
let title_el = document.querySelector("title");
51-
if (window.location.origin === "https://preview.devtron.ai")
52-
title_el.innerHTML = "Devtron Sandbox";
53-
</script>
54-
<script type="module" src="/src/index.tsx"></script>
160+
--></body>
161+
162+
<!-- # INSERT SCRIPT HERE -->
163+
<script type="module" src="/src/index.tsx"></script>
164+
165+
<!-- Discord widget -->
166+
<script type="text/javascript">
167+
if (!window._env_.HIDE_DISCORD) {
168+
document.write(
169+
'<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>const crate = new Crate({server: "769482988882493450",channel: "769508553118842881", location: ["bottom", "left"], color: "#023263"});crate.notify({content: "Need help?",timeout: 8000,avatar: "https://i.postimg.cc/MK5M3H87/1516624713231.jpg"});<\/script>',
170+
)
171+
}
172+
</script>
173+
<script>
174+
let title_el = document.querySelector('title')
175+
if (window.location.origin === 'https://preview.devtron.ai') title_el.innerHTML = 'Devtron Sandbox'
176+
</script>
55177
</html>

Diff for: package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.0.64",
7+
"@devtron-labs/devtron-fe-common-lib": "0.0.67",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",
@@ -25,9 +25,8 @@
2525
"http-proxy-middleware": "^2.0.6",
2626
"marked": "4.3.0",
2727
"moment": "^2.29.4",
28-
"monaco-editor": "0.38.0",
29-
"monaco-editor-webpack-plugin": "^7.1.0",
30-
"monaco-yaml": "4.0.4",
28+
"monaco-editor": "0.45.0",
29+
"monaco-yaml": "5.1.1",
3130
"query-string": "^7.1.1",
3231
"react": "^17.0.2",
3332
"react-csv": "^2.2.2",
@@ -38,7 +37,7 @@
3837
"react-gtm-module": "^2.0.11",
3938
"react-keybind": "^0.9.4",
4039
"react-mde": "^11.5.0",
41-
"react-monaco-editor": "^0.54.0",
40+
"react-monaco-editor": "^0.55.0",
4241
"react-router-dom": "^5.3.4",
4342
"react-select": "^5.2.2",
4443
"react-toastify": "^8.2.0",
@@ -122,7 +121,9 @@
122121
"workbox-window": "7.0.0",
123122
"workbox-core": "^7.0.0",
124123
"workbox-precaching": "^7.0.0",
125-
"workbox-routing": "^7.0.0"
124+
"workbox-routing": "^7.0.0",
125+
"workbox-navigation-preload": "7.0.0",
126+
"workbox-strategies": "7.0.0"
126127
},
127128
"jest": {
128129
"collectCoverageFrom": [

Diff for: src/App.tsx

+56-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export default function App() {
4747
const updateToastRef = useRef(null)
4848
const [errorPage, setErrorPage] = useState<boolean>(false)
4949
const isOnline = useOnline()
50+
const refreshing = useRef(false)
51+
const [bgUpdated, setBGUpdated] = useState(false)
5052
const [validating, setValidating] = useState(true)
5153
const [approvalToken, setApprovalToken] = useState<string>('')
5254
const [approvalType, setApprovalType] = useState<APPROVAL_MODAL_TYPE>(APPROVAL_MODAL_TYPE.CONFIG)
@@ -129,7 +131,22 @@ export default function App() {
129131
}
130132
}
131133

134+
function handleControllerChange() {
135+
if (refreshing.current) {
136+
return
137+
}
138+
if (document.visibilityState === 'visible') {
139+
window.location.reload()
140+
refreshing.current = true
141+
} else {
142+
setBGUpdated(true)
143+
}
144+
}
145+
132146
useEffect(() => {
147+
if (navigator.serviceWorker) {
148+
navigator.serviceWorker.addEventListener('controllerchange', handleControllerChange)
149+
}
133150
// If not K8S_CLIENT then validateToken otherwise directly redirect
134151
if (!window._env_.K8S_CLIENT) {
135152
// By Passing validations for direct email approval notifications
@@ -142,6 +159,9 @@ export default function App() {
142159
setValidating(false)
143160
defaultRedirection()
144161
}
162+
return () => {
163+
navigator.serviceWorker.removeEventListener('controllerchange', handleControllerChange)
164+
}
145165
}, [])
146166

147167
const {
@@ -150,9 +170,20 @@ export default function App() {
150170
} = useRegisterSW({
151171
onRegisteredSW(swUrl, r) {
152172
console.log(`Service Worker at: ${swUrl}`)
153-
if (r) {
154-
r.update()
155-
}
173+
r &&
174+
setInterval(async () => {
175+
if (!(!r.installing && navigator)) return
176+
if ('connection' in navigator && !navigator.onLine) return
177+
const resp = await fetch(swUrl, {
178+
cache: 'no-store',
179+
headers: {
180+
cache: 'no-store',
181+
'cache-control': 'no-cache',
182+
},
183+
})
184+
185+
if (resp?.status === 200) await r.update()
186+
}, 1000 * 60)
156187
},
157188
onRegisterError(error) {
158189
console.log('SW registration error', error)
@@ -169,10 +200,11 @@ export default function App() {
169200
if (window.isSecureContext && navigator.serviceWorker) {
170201
// check for sw updates on page change
171202
navigator.serviceWorker.getRegistrations().then((regs) => regs.forEach((reg) => reg.update()))
172-
if (!needRefresh) {
173-
return
203+
if (needRefresh) {
204+
update()
205+
} else if (toast.isActive(updateToastRef.current)) {
206+
toast.dismiss(updateToastRef.current)
174207
}
175-
update()
176208
}
177209
}, [location])
178210

@@ -200,6 +232,24 @@ export default function App() {
200232
}
201233
}, [needRefresh])
202234

235+
useEffect(() => {
236+
if (!bgUpdated) {
237+
return
238+
}
239+
const bgUpdatedToastBody = (
240+
<UpdateToast
241+
onClick={() => window.location.reload()}
242+
text="This page has been updated. Please save any unsaved changes and refresh."
243+
buttonText="Reload"
244+
/>
245+
)
246+
if (toast.isActive(updateToastRef.current)) {
247+
toast.update(updateToastRef.current, { render: bgUpdatedToastBody })
248+
} else {
249+
updateToastRef.current = toast.info(bgUpdatedToastBody, { autoClose: false, closeButton: false })
250+
}
251+
}, [bgUpdated])
252+
203253
return (
204254
<Suspense fallback={null}>
205255
{validating ? (

0 commit comments

Comments
 (0)