Skip to content

Commit

Permalink
Merge branch 'main' into terminal_events-to-sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-devtron authored Mar 1, 2024
2 parents 9168e89 + 599e752 commit 541bc7e
Show file tree
Hide file tree
Showing 84 changed files with 9,275 additions and 42,198 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ GLOBAL_API_TIMEOUT=60000
TRIGGER_API_TIMEOUT=60000
LOGIN_DT_LOGO=
SIDEBAR_DT_LOGO=
USE_V2=
ENABLE_EXTERNAL_ARGO_CD=false
LOG_TERMINAL_EVENTS_TO_SENTRY=false
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json .
COPY yarn.lock .
# Copy .npmrc if it exists, otherwise don't fail
COPY .npmr[c] .
RUN yarn install --network-timeout 600000

COPY src/ src
Expand Down
12 changes: 0 additions & 12 deletions config-overrides.js

This file was deleted.

196 changes: 159 additions & 37 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,154 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet">
<link
href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700;900&display=swap"
rel="stylesheet"
/>
<link rel="shortcut icon" href="/favicon.ico" />
<script src="/dashboard/env-config.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#06c" />
<meta name="robots" content="noindex, nofollow" />
<!--
<head>
<meta charset="utf-8" />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"
rel="stylesheet"
/>
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet" />
<link
href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700;900&display=swap"
rel="stylesheet"
/>
<link rel="shortcut icon" href="/favicon.ico" />
<script src="/dashboard/env-config.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#06c" />
<meta name="robots" content="noindex, nofollow" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<link rel="manifest" href="/manifest.json" />

<title>Devtron</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root">
<div
style="
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #fff;
"
>
<svg width="80" height="80" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
.svg__loader_group-top {
animation: top-shape 1.2s infinite;
transform-origin: center center;
}
.svg__loader_group-bottom {
animation: bottom-shape 1.2s infinite;
transform-origin: center center;
}

.svg__loader_shapepath-top {
animation: path-fill 1.2s infinite;
}
.svg__loader_shapepath-bottom {
animation: path-fill 1.2s infinite;
}

.svg__loader_rotating-group {
animation: rotate-group 1.2s infinite reverse;
transform-origin: center center;
}

@keyframes path-fill {
0% {
fill: #3989d9;
}
30% {
fill: #3989d9;
}
45% {
fill: #abcff3;
}
100% {
fill: #3989d9;
}
}

<title>Devtron</title>
@keyframes top-shape {
0% {
transform: translateX(0px) translateY(0px) rotate(0deg);
transform-origin: center center;
}
30% {
transform: translateX(0px) translateY(0px) rotate(10deg);
transform-origin: center center;
}
45% {
transform: translateX(-6px) translateY(-6px) rotate(15deg);
transform-origin: center center;
}

100% {
transform: translateX(0px) translateY(0px) rotate(0deg);
transform-origin: center center;
}
}

</head>
@keyframes bottom-shape {
0% {
transform: translateX(0px) translateY(0px) rotate(0deg);
transform-origin: center center;
}
30% {
transform: translateX(0px) translateY(0px) rotate(10deg);
transform-origin: center center;
}
45% {
transform: translateX(6px) translateY(6px) rotate(15deg);
transform-origin: center center;
}

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
100% {
transform: translateX(0px) translateY(0px) rotate(0deg);
transform-origin: center center;
}
}

@keyframes rotate-group {
0% {
transform: rotate(0deg);
}
44% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
animation-timing-function: ease-in-out;
}
}
</style>
<rect width="100" height="100" rx="20" fill="#E5F2FF" />
<g class="svg__loader_rotating-group">
<g class="svg__loader_group-top">
<path
class="svg__loader_shapepath-top"
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"
fill="#3989D9"
/>
</g>
<g class="svg__loader_group-bottom">
<path
class="svg__loader_shapepath-bottom"
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"
fill="#3989D9"
/>
</g>
</g>
</svg>
</div>
</div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -38,18 +157,21 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
<!-- Discord widget -->
<script type="text/javascript">
if (!window._env_.HIDE_DISCORD) {
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>');
}
</script>
<script>
let title_el = document.querySelector("title");
if (window.location.origin === "https://preview.devtron.ai")
title_el.innerHTML = "Devtron Sandbox";
</script>
<script type="module" src="/src/index.tsx"></script>
--></body>

<!-- # INSERT SCRIPT HERE -->
<script type="module" src="/src/index.tsx"></script>

<!-- Discord widget -->
<script type="text/javascript">
if (!window._env_.HIDE_DISCORD) {
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>',
)
}
</script>
<script>
let title_el = document.querySelector('title')
if (window.location.origin === 'https://preview.devtron.ai') title_el.innerHTML = 'Devtron Sandbox'
</script>
</html>
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "/dashboard",
"dependencies": {
"@devtron-labs/devtron-fe-common-lib": "0.0.64",
"@devtron-labs/devtron-fe-common-lib": "0.0.67",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rjsf/core": "^5.13.3",
"@rjsf/utils": "^5.13.3",
Expand All @@ -25,9 +25,8 @@
"http-proxy-middleware": "^2.0.6",
"marked": "4.3.0",
"moment": "^2.29.4",
"monaco-editor": "0.38.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"monaco-yaml": "4.0.4",
"monaco-editor": "0.45.0",
"monaco-yaml": "5.1.1",
"query-string": "^7.1.1",
"react": "^17.0.2",
"react-csv": "^2.2.2",
Expand All @@ -38,7 +37,7 @@
"react-gtm-module": "^2.0.11",
"react-keybind": "^0.9.4",
"react-mde": "^11.5.0",
"react-monaco-editor": "^0.54.0",
"react-monaco-editor": "^0.55.0",
"react-router-dom": "^5.3.4",
"react-select": "^5.2.2",
"react-toastify": "^8.2.0",
Expand Down Expand Up @@ -122,7 +121,9 @@
"workbox-window": "7.0.0",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
"workbox-routing": "^7.0.0"
"workbox-routing": "^7.0.0",
"workbox-navigation-preload": "7.0.0",
"workbox-strategies": "7.0.0"
},
"jest": {
"collectCoverageFrom": [
Expand Down
62 changes: 56 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export default function App() {
const updateToastRef = useRef(null)
const [errorPage, setErrorPage] = useState<boolean>(false)
const isOnline = useOnline()
const refreshing = useRef(false)
const [bgUpdated, setBGUpdated] = useState(false)
const [validating, setValidating] = useState(true)
const [approvalToken, setApprovalToken] = useState<string>('')
const [approvalType, setApprovalType] = useState<APPROVAL_MODAL_TYPE>(APPROVAL_MODAL_TYPE.CONFIG)
Expand Down Expand Up @@ -129,7 +131,22 @@ export default function App() {
}
}

function handleControllerChange() {
if (refreshing.current) {
return
}
if (document.visibilityState === 'visible') {
window.location.reload()
refreshing.current = true
} else {
setBGUpdated(true)
}
}

useEffect(() => {
if (navigator.serviceWorker) {
navigator.serviceWorker.addEventListener('controllerchange', handleControllerChange)
}
// If not K8S_CLIENT then validateToken otherwise directly redirect
if (!window._env_.K8S_CLIENT) {
// By Passing validations for direct email approval notifications
Expand All @@ -142,6 +159,9 @@ export default function App() {
setValidating(false)
defaultRedirection()
}
return () => {
navigator.serviceWorker.removeEventListener('controllerchange', handleControllerChange)
}
}, [])

const {
Expand All @@ -150,9 +170,20 @@ export default function App() {
} = useRegisterSW({
onRegisteredSW(swUrl, r) {
console.log(`Service Worker at: ${swUrl}`)
if (r) {
r.update()
}
r &&
setInterval(async () => {
if (!(!r.installing && navigator)) return
if ('connection' in navigator && !navigator.onLine) return
const resp = await fetch(swUrl, {
cache: 'no-store',
headers: {
cache: 'no-store',
'cache-control': 'no-cache',
},
})

if (resp?.status === 200) await r.update()
}, 1000 * 60)
},
onRegisterError(error) {
console.log('SW registration error', error)
Expand All @@ -169,10 +200,11 @@ export default function App() {
if (window.isSecureContext && navigator.serviceWorker) {
// check for sw updates on page change
navigator.serviceWorker.getRegistrations().then((regs) => regs.forEach((reg) => reg.update()))
if (!needRefresh) {
return
if (needRefresh) {
update()
} else if (toast.isActive(updateToastRef.current)) {
toast.dismiss(updateToastRef.current)
}
update()
}
}, [location])

Expand Down Expand Up @@ -200,6 +232,24 @@ export default function App() {
}
}, [needRefresh])

useEffect(() => {
if (!bgUpdated) {
return
}
const bgUpdatedToastBody = (
<UpdateToast
onClick={() => window.location.reload()}
text="This page has been updated. Please save any unsaved changes and refresh."
buttonText="Reload"
/>
)
if (toast.isActive(updateToastRef.current)) {
toast.update(updateToastRef.current, { render: bgUpdatedToastBody })
} else {
updateToastRef.current = toast.info(bgUpdatedToastBody, { autoClose: false, closeButton: false })
}
}, [bgUpdated])

return (
<Suspense fallback={null}>
{validating ? (
Expand Down
Loading

0 comments on commit 541bc7e

Please sign in to comment.