From 282a62e273df128f96633136ed81bb133b704dbf Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 11:54:15 +0530 Subject: [PATCH 01/66] :bug: Fixed issue with fetching cloudformation url --- lib/app-setup/root.tsx | 9 +++++++-- .../_a+/onboarding+/$a+/$cloudprovider+/validate-cp.tsx | 2 +- src/design-system/index.css | 5 ++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/app-setup/root.tsx b/lib/app-setup/root.tsx index 29776665e..1214cd57c 100644 --- a/lib/app-setup/root.tsx +++ b/lib/app-setup/root.tsx @@ -1,4 +1,4 @@ -import { HeadersFunction } from '@remix-run/node'; +import { HeadersFunction, LinksFunction } from '@remix-run/node'; import { Link, Links, @@ -33,7 +33,7 @@ import tailwindBase from '~/design-system/tailwind-base.js'; import { isDev } from '../client/helpers/log'; import { getClientEnv, getServerEnv } from '../configs/base-url.cjs'; -export const links = () => [ +export const links: LinksFunction = () => [ { rel: 'stylesheet', href: stylesUrl }, { rel: 'stylesheet', href: reactToast }, { rel: 'stylesheet', href: skeletonCSS }, @@ -41,6 +41,11 @@ export const links = () => [ { rel: 'stylesheet', href: styleReactPulsable }, { rel: 'stylesheet', href: styleZenerSelect }, { rel: 'stylesheet', href: rcss }, + { + rel: 'stylesheet', + href: 'https://fonts.googleapis.com/css2?family=Familjen+Grotesk:ital,wght@0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap', + }, + { rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' }, ]; export const ErrorWrapper = ({ children, message }: any) => { diff --git a/src/apps/console/routes/_a+/onboarding+/$a+/$cloudprovider+/validate-cp.tsx b/src/apps/console/routes/_a+/onboarding+/$a+/$cloudprovider+/validate-cp.tsx index ba5f98eaa..195aa16d1 100644 --- a/src/apps/console/routes/_a+/onboarding+/$a+/$cloudprovider+/validate-cp.tsx +++ b/src/apps/console/routes/_a+/onboarding+/$a+/$cloudprovider+/validate-cp.tsx @@ -68,7 +68,7 @@ const Validator = ({ cloudProvider }: { cloudProvider: any }) => { const { data, isLoading: il } = useCustomSwr( () => parseName(cloudProvider) + isLoading, async () => { - if (!parseName(cloudProvider.metadata!.name)) { + if (!parseName(cloudProvider)) { throw new Error('Invalid cloud provider name'); } return api.checkAwsAccess({ diff --git a/src/design-system/index.css b/src/design-system/index.css index fb501bf72..4526c6ed7 100644 --- a/src/design-system/index.css +++ b/src/design-system/index.css @@ -1,7 +1,6 @@ -@import url('https://rsms.me/inter/inter.css'); -@import url('https://fonts.googleapis.com/css2?family=Familjen+Grotesk:ital,wght@0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap'); +/* @import url('https://rsms.me/inter/inter.css'); */ +/* @import url('https://fonts.googleapis.com/css2?family=Familjen+Grotesk:ital,wght@0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap'); */ @import 'css/slider.css'; - html{ font-feature-settings: "cv02", "cv03", "cv04", "cv11"; } From 208039f0867e860fba4dfe933f958af1bfbae842 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 11:57:34 +0530 Subject: [PATCH 02/66] :art: Increased debounce duration to 3 sec on resource watch --- lib/client/helpers/socket/useWatch.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/helpers/socket/useWatch.tsx b/lib/client/helpers/socket/useWatch.tsx index 067c896dd..a47f2b5e5 100644 --- a/lib/client/helpers/socket/useWatch.tsx +++ b/lib/client/helpers/socket/useWatch.tsx @@ -34,7 +34,7 @@ export const useSocketWatch = ( onUpdate(responses); } }, - 1000, + 3000, [responses] ); }; From 93fa63d5f7916f72bd870de3f9c5a3cbd240fe04 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 12:35:35 +0530 Subject: [PATCH 03/66] :art: Improved Ui for cluster --- Taskfile.yaml | 2 +- gql-queries-generator/doc/queries.graphql | 1 + lib/client/components/logger/index.tsx | 4 +- lib/client/helpers/socket/context.tsx | 6 +- src/apps/console/components/commons.tsx | 62 +++--- .../nodepools/nodepool-resources.tsx | 2 +- .../infra+/clusters/cluster-resources.tsx | 201 +++++++++++++----- .../server/gql/queries/cluster-queries.ts | 1 + src/generated/gql/server.ts | 1 + 9 files changed, 191 insertions(+), 89 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index bdac9c97d..cc9bb95da 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -159,7 +159,7 @@ tasks: msg: "var tag must have a value" silent: true vars: - IMAGE: ghcr.io/kloudlite/platform/web/{{.app}}-web:{{.tag}} + IMAGE: ghcr.io/kloudlite/kloudlite/web/{{.app}}:{{.tag}} cmds: - docker build --build-arg APP={{.app}} . -t {{.IMAGE}} - docker push {{.IMAGE}} diff --git a/gql-queries-generator/doc/queries.graphql b/gql-queries-generator/doc/queries.graphql index 0413536dc..cde388390 100644 --- a/gql-queries-generator/doc/queries.graphql +++ b/gql-queries-generator/doc/queries.graphql @@ -255,6 +255,7 @@ query consoleListClusters($search: SearchCluster, $pagination: CursorPaginationI edges { cursor node { + id displayName markedForDeletion metadata { diff --git a/lib/client/components/logger/index.tsx b/lib/client/components/logger/index.tsx index f38e92fc9..55d80d131 100644 --- a/lib/client/components/logger/index.tsx +++ b/lib/client/components/logger/index.tsx @@ -94,7 +94,7 @@ interface IHighlightIt { const LoadingComp = memo(() => ( -
+
Logs
@@ -123,7 +123,7 @@ const LoadingComp = memo(() => ( const log = logsMockData[Math.floor(Math.random() * 10)]; return (
-
+
{log}
); diff --git a/lib/client/helpers/socket/context.tsx b/lib/client/helpers/socket/context.tsx index 0fbbc6045..e4d3859be 100644 --- a/lib/client/helpers/socket/context.tsx +++ b/lib/client/helpers/socket/context.tsx @@ -110,7 +110,7 @@ export const useSubscribe = ( useDebounce( () => { - console.log('subscribing'); + logger.log('subscribing'); if (Array.isArray(msg)) { msg.forEach((m) => { sendMsg({ ...m, data: { ...m.data, event: 'subscribe' } }); @@ -120,7 +120,7 @@ export const useSubscribe = ( } return () => { - console.log('unsubscribing'); + logger.log('unsubscribing'); if (Array.isArray(msg)) { msg.forEach((m) => { clear(m); @@ -249,7 +249,7 @@ export const SockProvider = ({ children }: ChildrenProps) => { } }); } catch (e) { - console.log(e); + logger.error(e); } } }, diff --git a/src/apps/console/components/commons.tsx b/src/apps/console/components/commons.tsx index 5dde3b8f5..30764ecd3 100644 --- a/src/apps/console/components/commons.tsx +++ b/src/apps/console/components/commons.tsx @@ -1,21 +1,21 @@ -import { CopySimple, Question } from "@jengaicons/react"; -import { ReactNode, useState } from "react"; -import { ProdLogo } from "~/components/branding/prod-logo"; -import { WorkspacesLogo } from "~/components/branding/workspace-logo"; -import useClipboard from "~/root/lib/client/hooks/use-clipboard"; -import { generateKey, titleCase } from "~/components/utils"; +import { CopySimple, Question } from '@jengaicons/react'; +import { ReactNode, useState } from 'react'; +import { ProdLogo } from '~/components/branding/prod-logo'; +import { WorkspacesLogo } from '~/components/branding/workspace-logo'; +import useClipboard from '~/root/lib/client/hooks/use-clipboard'; +import { generateKey, titleCase } from '~/components/utils'; import { Github__Com___Kloudlite___Api___Pkg___Types__SyncState as SyncState, Github__Com___Kloudlite___Api___Pkg___Types__SyncAction as SyncAction, -} from "~/root/src/generated/gql/server"; -import Tooltip from "~/components/atoms/tooltip"; -import { Link } from "@remix-run/react"; -import { Button, IButton } from "~/components/atoms/button"; -import { ListItem } from "./console-list-components"; +} from '~/root/src/generated/gql/server'; +import Tooltip from '~/components/atoms/tooltip'; +import { Link } from '@remix-run/react'; +import { Button, IButton } from '~/components/atoms/button'; +import { ListItem } from './console-list-components'; import { parseUpdateOrCreatedBy, parseUpdateOrCreatedOn, -} from "../server/r-utils/common"; +} from '../server/r-utils/common'; import { ArrowLeft, ArrowRight, @@ -23,8 +23,8 @@ import { GitBranchFill, GitlabLogoFill, GithubLogoFill, -} from "./icons"; -import { IGIT_PROVIDERS } from "../hooks/use-git"; +} from './icons'; +import { IGIT_PROVIDERS } from '../hooks/use-git'; export const BlackProdLogo = ({ size = 16 }) => { return ; @@ -129,7 +129,7 @@ interface IUpdateMeta { } // Component for Status parsing -export type IStatus = "deleting" | "notready" | "syncing" | "none"; +export type IStatus = 'deleting' | 'notready' | 'syncing' | 'none'; interface IStatusMeta { markedForDeletion?: boolean; @@ -145,17 +145,17 @@ interface IStatusMeta { }; } -type IResourceType = "nodepool"; +type IResourceType = 'nodepool' | 'cluster'; type ICommonMeta = IUpdateMeta & IStatusMeta; const parseStatusComponent = ({ status }: { status: IStatus }) => { switch (status) { - case "deleting": + case 'deleting': return
Deleting...
; - case "notready": + case 'notready': return
Not Ready
; - case "syncing": + case 'syncing': return
Syncing
; default: return null; @@ -169,17 +169,17 @@ export const parseStatus = ({ item: IStatusMeta; type?: IResourceType; }) => { - let status: IStatus = "none"; + let status: IStatus = 'none'; if (item.markedForDeletion) { - status = "deleting"; + status = 'deleting'; } else if (!item.status?.isReady) { switch (type) { - case "nodepool": - status = "syncing"; + case 'nodepool': + status = 'syncing'; break; default: - status = "notready"; + status = 'notready'; } } @@ -200,7 +200,7 @@ export const listRender = ({ time: parseUpdateOrCreatedOn(resource), }; return { - key: generateKey(keyPrefix, "author"), + key: generateKey(keyPrefix, 'author'), className, render: () => ( @@ -215,7 +215,7 @@ export const listRender = ({ type?: IResourceType; }) => { return { - key: generateKey(keyPrefix, "status"), + key: generateKey(keyPrefix, 'status'), className, render: () => parseStatus({ item: resource, type }).component, status: parseStatus({ item: resource, type }).status, @@ -249,8 +249,8 @@ export const BottomNavigation = ({ primaryButton, secondaryButton, }: { - primaryButton?: Optional; - secondaryButton?: Optional; + primaryButton?: Optional; + secondaryButton?: Optional; }) => { return (
@@ -283,7 +283,7 @@ interface IReviewComponent { canEdit?: boolean; } export const ReviewComponent = ({ - title = "", + title = '', children, onEdit, canEdit = true, @@ -327,13 +327,13 @@ export const GitDetail = ({
Source
- {provider === "github" ? ( + {provider === 'github' ? ( ) : ( )} - {repository.replace("https://", "").replace(".git", "")} + {repository.replace('https://', '').replace('.git', '')}
diff --git a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx index b63094c20..98792ed0f 100644 --- a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx @@ -87,6 +87,7 @@ const ExtraButton = ({ /> ); }; + interface IResource { items: BaseType[]; onDelete: (item: BaseType) => void; @@ -369,7 +370,6 @@ const ListView = ({ items, onDelete, onEdit }: IResource) => { {items.map((item, index) => { const { name, id } = parseItem(item); const keyPrefix = `${RESOURCE_NAME}-${id}-${index}`; - // const lR = listRender({ keyPrefix, resource: item }); return ( [] }) => { ); }; -const ListView = ({ items }: { items: ExtractNodeType[] }) => { - const { account } = useParams(); +type BaseType = ExtractNodeType; + +interface IResource { + items: BaseType[]; + // onDelete: (item: BaseType) => void; + // onEdit: (item: BaseType) => void; +} + +const ListDetail = ( + props: Omit & { + open: string; + item: BaseType; + setOpen: ISetState; + } +) => { + const { item, open, setOpen } = props; + + const { name, id } = parseItem(item); + const keyPrefix = `${RESOURCE_NAME}-${id}`; + const lR = listRender({ keyPrefix, resource: item }); + + const { account } = useOutletContext(); + + const isLatest = dayjs(item.updateTime).isAfter(dayjs().subtract(3, 'hour')); + + const tempStatus = listStatus({ + key: keyPrefix, + item, + className: 'basis-full text-center', + }); + return ( - - {items.map((item, index) => { - const { name, id, provider } = parseItem(item); - const keyPrefix = `${RESOURCE_NAME}-${id}-${index}`; - const lR = listRender({ keyPrefix, resource: item }); +
+
+
+ {id}
+ } + avatar={} + /> +
- const statusRender = lR.statusRender({ - className: 'min-w-[80px] mx-[25px] basis-full text-center', - }); + {isLatest && ( +
+ + + +
+ ); +}; + +const ListView = ({ items }: IResource) => { + const [open, setOpen] = useState(''); + + return ( + + {items.map((item, index) => { + const { name, id } = parseItem(item); + const keyPrefix = `${RESOURCE_NAME}-${id}-${index}`; return ( ( - } - /> - ), - }, - tempStatus, - listFlex({ key: 'flex-1' }), - { - key: generateKey(keyPrefix, `${provider}`), - className: 'min-w-[150px] text-start', - render: () => , - }, - lR.authorRender({ className: 'min-w-[180px] w-[180px]' }), - { - key: generateKey(keyPrefix, 'action'), - render: () => ( - + ), }, ]} /> ); + + // return ( + // ( + // } + // /> + // ), + // }, + // + // tempStatus, + // listFlex({ key: 'flex-1' }), + // { + // key: generateKey(keyPrefix, `${provider}`), + // className: 'min-w-[150px] text-start', + // render: () => , + // }, + // lR.authorRender({ className: 'min-w-[180px] w-[180px]' }), + // { + // key: generateKey(keyPrefix, 'action'), + // render: () => ( + // + // ), + // }, + // ]} + // /> + // ); })} ); diff --git a/src/apps/console/server/gql/queries/cluster-queries.ts b/src/apps/console/server/gql/queries/cluster-queries.ts index ef2cddc1c..82d0e9e50 100644 --- a/src/apps/console/server/gql/queries/cluster-queries.ts +++ b/src/apps/console/server/gql/queries/cluster-queries.ts @@ -78,6 +78,7 @@ export const clusterQueries = (executor: IExecutor) => ({ edges { cursor node { + id displayName markedForDeletion metadata { diff --git a/src/generated/gql/server.ts b/src/generated/gql/server.ts index 7688b8ec5..387db054d 100644 --- a/src/generated/gql/server.ts +++ b/src/generated/gql/server.ts @@ -1805,6 +1805,7 @@ export type ConsoleListClustersQuery = { edges: Array<{ cursor: string; node: { + id: string; displayName: string; markedForDeletion?: boolean; creationTime: any; From 78e2e970e0f32a088dc9dde25c3c91ab939b0c37 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 13:19:01 +0530 Subject: [PATCH 04/66] :bug: Fixed issue with logs-block width --- lib/client/components/logger/index.tsx | 16 +++- lib/configs/base-url.cjs | 3 +- .../overview+/logs-n-metrics/route.tsx | 2 +- .../infra+/clusters/cluster-resources.tsx | 74 ++++++------------- 4 files changed, 41 insertions(+), 54 deletions(-) diff --git a/lib/client/components/logger/index.tsx b/lib/client/components/logger/index.tsx index 55d80d131..6b2007f95 100644 --- a/lib/client/components/logger/index.tsx +++ b/lib/client/components/logger/index.tsx @@ -691,14 +691,28 @@ const LogComp = ({ } }, []); + const wRef = useRef(null); + + const getFullWidthInPx = () => { + if (wRef.current) { + return wRef.current.clientWidth; + } + return '100%'; + }; + return isClientSide ? (
diff --git a/lib/configs/base-url.cjs b/lib/configs/base-url.cjs index d4d541d2e..96ae00947 100644 --- a/lib/configs/base-url.cjs +++ b/lib/configs/base-url.cjs @@ -86,7 +86,8 @@ const baseUrls = () => { cookieDomain, baseUrl: bUrl, githubAppName: 'kloudlite-dev', - socketUrl: `wss://websocket.${bUrl}`, + // socketUrl: `wss://websocket.${bUrl}`, + socketUrl: `wss://websocket.kloudlite.io`, observeUrl: `https://observe.${bUrl}`, }; }; diff --git a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/overview+/logs-n-metrics/route.tsx b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/overview+/logs-n-metrics/route.tsx index 6f4b3e22c..7ab4a9904 100644 --- a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/overview+/logs-n-metrics/route.tsx +++ b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/overview+/logs-n-metrics/route.tsx @@ -7,8 +7,8 @@ import { parseName } from '~/console/server/r-utils/common'; import { Clock, ListNumbers } from '@jengaicons/react'; import { cn } from '~/components/utils'; import { useDataState } from '~/console/page-components/common-state'; -import { IClusterContext } from '../../_layout'; import LogComp from '~/root/lib/client/components/logger'; +import { IClusterContext } from '../../_layout'; const LogsAndMetrics = () => { const { cluster, account } = useOutletContext(); diff --git a/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx b/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx index fb7c05d71..270c2e7c0 100644 --- a/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx @@ -197,14 +197,16 @@ const ListDetail = ( size="sm" variant="basic" content={open === item.id ? 'Hide Logs' : 'Show Logs'} - onClick={() => + onClick={(e) => { + e.preventDefault(); + setOpen((s) => { if (s === item.id) { return ''; } return item.id; - }) - } + }); + }} /> )} @@ -217,9 +219,13 @@ const ListDetail = (
- + { const [open, setOpen] = useState(''); + const { account } = useParams(); return ( {items.map((item, index) => { const { name, id } = parseItem(item); const keyPrefix = `${RESOURCE_NAME}-${id}-${index}`; + + const lR = listRender({ keyPrefix, resource: item }); + const statusRender = lR.statusRender({ + className: 'min-w-[80px] mx-[25px] basis-full text-center', + }); + return ( { ]} /> ); - - // return ( - // ( - // } - // /> - // ), - // }, - // - // tempStatus, - // listFlex({ key: 'flex-1' }), - // { - // key: generateKey(keyPrefix, `${provider}`), - // className: 'min-w-[150px] text-start', - // render: () => , - // }, - // lR.authorRender({ className: 'min-w-[180px] w-[180px]' }), - // { - // key: generateKey(keyPrefix, 'action'), - // render: () => ( - // - // ), - // }, - // ]} - // /> - // ); })} ); From 903d3760f448feda6d01c1781a6a97c50512c0ad Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 13:34:47 +0530 Subject: [PATCH 05/66] :bug: Fixed issues with logs layouting --- lib/client/helpers/log.ts | 4 +- lib/configs/base-url.cjs | 4 +- .../console/page-components/log-action.tsx | 48 +++++++++++++++++++ .../app+/$app+/logs-n-metrics/route.tsx | 43 ++--------------- .../nodepools/nodepool-resources.tsx | 11 ++++- .../infra+/clusters/cluster-resources.tsx | 12 ++++- .../components/atoms/animate-hide.tsx | 3 ++ 7 files changed, 80 insertions(+), 45 deletions(-) create mode 100644 src/apps/console/page-components/log-action.tsx diff --git a/lib/client/helpers/log.ts b/lib/client/helpers/log.ts index e3cc635c7..0f9d8781e 100644 --- a/lib/client/helpers/log.ts +++ b/lib/client/helpers/log.ts @@ -7,9 +7,9 @@ const getNodeEnv = () => { const env = (() => { if (typeof window !== 'undefined') { // @ts-ignore - return window.ENV; + return window.NODE_ENV; } - return process.env.ENV; + return process.env.NODE_ENV; })(); if (env) { diff --git a/lib/configs/base-url.cjs b/lib/configs/base-url.cjs index 96ae00947..fdc2dd6a8 100644 --- a/lib/configs/base-url.cjs +++ b/lib/configs/base-url.cjs @@ -86,8 +86,8 @@ const baseUrls = () => { cookieDomain, baseUrl: bUrl, githubAppName: 'kloudlite-dev', - // socketUrl: `wss://websocket.${bUrl}`, - socketUrl: `wss://websocket.kloudlite.io`, + socketUrl: `wss://websocket.${bUrl}`, + // socketUrl: `wss://websocket.kloudlite.io`, observeUrl: `https://observe.${bUrl}`, }; }; diff --git a/src/apps/console/page-components/log-action.tsx b/src/apps/console/page-components/log-action.tsx new file mode 100644 index 000000000..57ae6e040 --- /dev/null +++ b/src/apps/console/page-components/log-action.tsx @@ -0,0 +1,48 @@ +import { cn } from '~/components/utils'; +import { Clock, ListNumbers } from '@jengaicons/react'; +import { useDataState } from './common-state'; + +const LogAction = () => { + const { state, setState } = useDataState<{ + linesVisible: boolean; + timestampVisible: boolean; + }>('logs'); + + return ( +
+
{ + setState((s) => ({ ...s, linesVisible: !s.linesVisible })); + }} + className="flex items-center justify-center font-bold text-xl cursor-pointer select-none active:translate-y-[1px] transition-all" + > + + + +
+
{ + setState((s) => ({ + ...s, + timestampVisible: !s.timestampVisible, + })); + }} + className="flex items-center justify-center font-bold text-xl cursor-pointer select-none active:translate-y-[1px] transition-all" + > + + + +
+
+ ); +}; + +export default LogAction; diff --git a/src/apps/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/logs-n-metrics/route.tsx b/src/apps/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/logs-n-metrics/route.tsx index 8ea1645d2..32248e351 100644 --- a/src/apps/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/logs-n-metrics/route.tsx +++ b/src/apps/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/logs-n-metrics/route.tsx @@ -7,12 +7,11 @@ import { dayjs } from '~/components/molecule/dayjs'; import { parseValue } from '~/console/page-components/util'; import { ApexOptions } from 'apexcharts'; import { parseName } from '~/console/server/r-utils/common'; -import { Clock, ListNumbers } from '@jengaicons/react'; -import { cn } from '~/components/utils'; import { useDataState } from '~/console/page-components/common-state'; import { observeUrl } from '~/root/lib/configs/base-url.cjs'; -import { IAppContext } from '../_layout'; import LogComp from '~/root/lib/client/components/logger'; +import LogAction from '~/console/page-components/log-action'; +import { IAppContext } from '../_layout'; const LogsAndMetrics = () => { const { app, project, account } = useOutletContext(); @@ -87,7 +86,7 @@ const LogsAndMetrics = () => { }, }; - const { state, setState } = useDataState<{ + const { state } = useDataState<{ linesVisible: boolean; timestampVisible: boolean; }>('logs'); @@ -239,41 +238,7 @@ const LogsAndMetrics = () => { width: '100%', height: '70vh', title: 'Logs', - actionComponent: ( -
-
{ - setState((s) => ({ ...s, linesVisible: !s.linesVisible })); - }} - className="flex items-center justify-center font-bold text-xl cursor-pointer select-none active:translate-y-[1px] transition-all" - > - - - -
-
{ - setState((s) => ({ - ...s, - timestampVisible: !s.timestampVisible, - })); - }} - className="flex items-center justify-center font-bold text-xl cursor-pointer select-none active:translate-y-[1px] transition-all" - > - - - -
-
- ), + actionComponent: , websocket: { account: parseName(account), cluster: project.clusterName || '', diff --git a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx index 98792ed0f..64727ac8a 100644 --- a/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/infra+/$cluster+/nodepools/nodepool-resources.tsx @@ -35,6 +35,8 @@ import { dayjs } from '~/components/molecule/dayjs'; import LogComp from '~/root/lib/client/components/logger'; import { useWatchReload } from '~/lib/client/helpers/socket/useWatch'; import { IClusterContext } from '~/console/routes/_main+/$account+/infra+/$cluster+/_layout'; +import LogAction from '~/console/page-components/log-action'; +import { useDataState } from '~/console/page-components/common-state'; import HandleNodePool from './handle-nodepool'; import { findNodePlanWithCategory, @@ -208,6 +210,11 @@ const ListDetail = ( const isLatest = dayjs(item.updateTime).isAfter(dayjs().subtract(3, 'hour')); + const { state } = useDataState<{ + linesVisible: boolean; + timestampVisible: boolean; + }>('logs'); + return (
@@ -278,12 +285,14 @@ const ListDetail = ( width: '100%', height: '40rem', title: 'Logs', - hideLineNumber: true, + hideLineNumber: !state.linesVisible, + hideTimestamp: !state.timestampVisible, websocket: { account: parseName(account), cluster: item.clusterName, trackingId: item.id, }, + actionComponent: , }} /> diff --git a/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx b/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx index 270c2e7c0..abfd64b98 100644 --- a/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/infra+/clusters/cluster-resources.tsx @@ -30,6 +30,8 @@ import { dayjs } from '~/components/molecule/dayjs'; import { Button } from '~/components/atoms/button'; import AnimateHide from '~/components/atoms/animate-hide'; import LogComp from '~/root/lib/client/components/logger'; +import LogAction from '~/console/page-components/log-action'; +import { useDataState } from '~/console/page-components/common-state'; const RESOURCE_NAME = 'cluster'; @@ -179,6 +181,11 @@ const ListDetail = ( className: 'basis-full text-center', }); + const { state } = useDataState<{ + linesVisible: boolean; + timestampVisible: boolean; + }>('logs'); + return (
@@ -220,22 +227,25 @@ const ListDetail = (
e.preventDefault()} show={open === item.id} className="w-full flex pt-4xl justify-center items-center" > , }} /> diff --git a/src/design-system/components/atoms/animate-hide.tsx b/src/design-system/components/atoms/animate-hide.tsx index 82fb9dcf7..6417b7feb 100644 --- a/src/design-system/components/atoms/animate-hide.tsx +++ b/src/design-system/components/atoms/animate-hide.tsx @@ -6,17 +6,20 @@ interface IAnimateHide { show: boolean; initial?: boolean; className?: string; + onClick?: (e: React.MouseEvent) => void; } const AnimateHide = ({ children, show, initial = false, className, + onClick, }: IAnimateHide) => { return ( {show && ( Date: Mon, 11 Mar 2024 15:46:19 +0530 Subject: [PATCH 06/66] :bug: Fixed issue with steps on onboarding --- src/apps/console/page-components/new-cluster.tsx | 8 ++++---- src/apps/console/routes/_a+/new-team.tsx | 2 +- .../routes/_a+/onboarding+/$a+/new-cloud-provider.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/apps/console/page-components/new-cluster.tsx b/src/apps/console/page-components/new-cluster.tsx index 31a2fef63..92f1eb8f6 100644 --- a/src/apps/console/page-components/new-cluster.tsx +++ b/src/apps/console/page-components/new-cluster.tsx @@ -352,10 +352,10 @@ export const NewCluster = ({ providerSecrets, cloudProvider }: props) => { step={2} label="Add your cloud provider" /> - {/* */} + {getView()} diff --git a/src/apps/console/routes/_a+/new-team.tsx b/src/apps/console/routes/_a+/new-team.tsx index 31dfd877f..e849a3b34 100644 --- a/src/apps/console/routes/_a+/new-team.tsx +++ b/src/apps/console/routes/_a+/new-team.tsx @@ -89,7 +89,7 @@ const NewAccount = () => {
- {/* */} + diff --git a/src/apps/console/routes/_a+/onboarding+/$a+/new-cloud-provider.tsx b/src/apps/console/routes/_a+/onboarding+/$a+/new-cloud-provider.tsx index 454a25db2..526177957 100644 --- a/src/apps/console/routes/_a+/onboarding+/$a+/new-cloud-provider.tsx +++ b/src/apps/console/routes/_a+/onboarding+/$a+/new-cloud-provider.tsx @@ -143,7 +143,7 @@ const NewCloudProvider = () => { />
- {/* */} + From 06b8746a2a5190b422351516e46068f163af5c27 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 18:31:15 +0530 Subject: [PATCH 07/66] :bug: Fixed issue with logger component scroll and page reload --- lib/app-setup/root.tsx | 5 +- lib/client/components/logger/index.tsx | 32 +++---- lib/client/components/reload-indicator.tsx | 37 ++++++++ lib/client/helpers/reloader.ts | 8 +- lib/configs/base-url.cjs | 4 +- src/apps/console/components/listV2.tsx | 11 ++- src/apps/console/components/loading.tsx | 23 ++++- .../_main+/$account+/projects/route.tsx | 92 +++++++++++-------- .../components/atoms/animate-hide.tsx | 3 +- 9 files changed, 139 insertions(+), 76 deletions(-) create mode 100644 lib/client/components/reload-indicator.tsx diff --git a/lib/app-setup/root.tsx b/lib/app-setup/root.tsx index 1214cd57c..9ed4b2d9a 100644 --- a/lib/app-setup/root.tsx +++ b/lib/app-setup/root.tsx @@ -21,7 +21,6 @@ import Container from '~/components/atoms/container'; import ProgressContainer, { useProgress, } from '~/components/atoms/progress-bar'; -// import { SelectPortalContainer } from '~/components/atoms/select'; import Tooltip from '~/components/atoms/tooltip'; import { BrandLogo } from '~/components/branding/brand-logo'; import { ToastContainer } from '~/components/molecule/toast'; @@ -30,7 +29,8 @@ import styleZenerSelect from '@oshq/react-select/index.css'; import stylesUrl from '~/design-system/index.css'; import rcss from 'react-highlightjs-logs/dist/index.css'; import tailwindBase from '~/design-system/tailwind-base.js'; -import { isDev } from '../client/helpers/log'; +import { ReloadIndicator } from '~/lib/client/components/reload-indicator'; +import { isDev } from '~/lib/client/helpers/log'; import { getClientEnv, getServerEnv } from '../configs/base-url.cjs'; export const links: LinksFunction = () => [ @@ -202,6 +202,7 @@ const Root = ({ + diff --git a/lib/client/components/logger/index.tsx b/lib/client/components/logger/index.tsx index 6b2007f95..85bd5c3ea 100644 --- a/lib/client/components/logger/index.tsx +++ b/lib/client/components/logger/index.tsx @@ -15,7 +15,7 @@ import React, { useRef, useState, } from 'react'; -import { ViewportList } from 'react-viewport-list'; +import { ViewportList, ViewportListRef } from 'react-viewport-list'; import { dayjs } from '~/components/molecule/dayjs'; import { ISearchInfProps, @@ -28,6 +28,7 @@ import { generatePlainColor } from '~/root/lib/utils/color-generator'; import ReactPulsable from 'react-pulsable'; import { ChildrenProps } from '~/components/types'; import { logsMockData } from './dummy'; +import { LoadingIndicator } from '../reload-indicator'; const pulsableContext = createContext(false); @@ -499,22 +500,14 @@ const LogBlock = ({ const [showAll, setShowAll] = useState(true); - const ref = useRef(null); + const ref = useRef(null); useEffect(() => { - (async () => { - if ( - follow && - ref.current && - // @ts-ignore - typeof ref.current.scrollToIndex === 'function' - ) { - // @ts-ignore - ref.current.scrollToIndex({ - index: data.length - 1, - }); - } - })(); + if (follow && ref.current) { + ref.current.scrollToIndex({ + index: data.length - 1, + }); + } }, [data, maxLines]); return ( @@ -575,13 +568,8 @@ const LogBlock = ({
- + {(log, index) => { return (
+ +
)} diff --git a/lib/client/components/reload-indicator.tsx b/lib/client/components/reload-indicator.tsx new file mode 100644 index 000000000..c55a342d5 --- /dev/null +++ b/lib/client/components/reload-indicator.tsx @@ -0,0 +1,37 @@ +import { CircleFill, CircleNotch } from '@jengaicons/react'; +import { useRevalidator } from '@remix-run/react'; +import { cn } from '~/components/utils'; + +export const LoadingIndicator = ({ + className, + size = 1, +}: { + className?: string; + size?: number; +}) => { + return ( +
+ + +
+ ); +}; + +export const ReloadIndicator = () => { + const { state } = useRevalidator(); + + if (state === 'loading') { + return ( +
+ +
+ ); + } + + return null; +}; diff --git a/lib/client/helpers/reloader.ts b/lib/client/helpers/reloader.ts index d4ea4ea3e..5d6cac682 100644 --- a/lib/client/helpers/reloader.ts +++ b/lib/client/helpers/reloader.ts @@ -1,9 +1,9 @@ -import { useLocation, useNavigate } from '@remix-run/react'; +import { useRevalidator } from '@remix-run/react'; export const useReload = () => { - const location = useLocation(); - const navigate = useNavigate(); + const revalidator = useRevalidator(); + return () => { - navigate(location.pathname + location.search, { replace: true }); + revalidator.revalidate(); }; }; diff --git a/lib/configs/base-url.cjs b/lib/configs/base-url.cjs index fdc2dd6a8..96ae00947 100644 --- a/lib/configs/base-url.cjs +++ b/lib/configs/base-url.cjs @@ -86,8 +86,8 @@ const baseUrls = () => { cookieDomain, baseUrl: bUrl, githubAppName: 'kloudlite-dev', - socketUrl: `wss://websocket.${bUrl}`, - // socketUrl: `wss://websocket.kloudlite.io`, + // socketUrl: `wss://websocket.${bUrl}`, + socketUrl: `wss://websocket.kloudlite.io`, observeUrl: `https://observe.${bUrl}`, }; }; diff --git a/src/apps/console/components/listV2.tsx b/src/apps/console/components/listV2.tsx index 28bb13995..29d256311 100644 --- a/src/apps/console/components/listV2.tsx +++ b/src/apps/console/components/listV2.tsx @@ -1,6 +1,7 @@ import * as RovingFocusGroup from '@radix-ui/react-roving-focus'; import { KeyboardEvent, ReactNode, useRef } from 'react'; import { cn } from '~/components/utils'; +import logger from '~/root/lib/client/helpers/log'; import { LoadingPlaceHolder } from './loading'; const focusableElement = 'a[href], button, input, select, textarea'; @@ -77,7 +78,7 @@ const handleKeyNavigation = ( } } } catch { - console.log('Error focusing'); + logger.error('Error focusing'); } }; @@ -224,7 +225,7 @@ const Root = ({ }: IRoot) => { const ref = useRef(null); - console.log(data); + // logger.log(data); return ( <> {!loading && ( @@ -250,7 +251,7 @@ const Root = ({ } } } catch { - console.log('Error Focusing'); + logger.error('Error Focusing'); } }} onKeyDown={(e) => { @@ -265,7 +266,7 @@ const Root = ({ )} > {data?.headers.map((h, index) => ( -
+
{h.render()}
))} @@ -274,7 +275,7 @@ const Root = ({ {data?.rows.map((r, index) => ( ); }; + +export const LoadingIndicator = ({ + className, + size = 1, +}: { + className?: string; + size?: 1 | 2 | 3; +}) => { + return ( +
+ + +
+ ); +}; diff --git a/src/apps/console/routes/_main+/$account+/projects/route.tsx b/src/apps/console/routes/_main+/$account+/projects/route.tsx index 640dd417d..27361edb3 100644 --- a/src/apps/console/routes/_main+/$account+/projects/route.tsx +++ b/src/apps/console/routes/_main+/$account+/projects/route.tsx @@ -10,6 +10,7 @@ import { IRemixCtx } from '~/root/lib/types/common'; import fake from '~/root/fake-data-generator/fake'; import { ensureAccountSet } from '~/console/server/utils/auth-utils'; import { GQLServerHandler } from '~/console/server/gql/saved-queries'; +import { useReload } from '~/root/lib/client/helpers/reloader'; import Tools from './tools'; import ProjectResourcesV2 from './project-resources-v2'; @@ -153,47 +154,58 @@ const Projects = () => { }; }; - return ( - - {({ projectsData, clustersCount, cloudProviderSecretsCount }) => { - const projects = projectsData.edges?.map(({ node }) => node); - if (!projects) { - return null; - } + const reloadPage = useReload(); - return ( - 0 && ( -
); }; diff --git a/src/design-system/components/atoms/animate-hide.tsx b/src/design-system/components/atoms/animate-hide.tsx index 6417b7feb..8fc8a90cb 100644 --- a/src/design-system/components/atoms/animate-hide.tsx +++ b/src/design-system/components/atoms/animate-hide.tsx @@ -1,5 +1,6 @@ import { AnimatePresence, motion } from 'framer-motion'; import { ReactNode } from 'react'; +import { cn } from '../utils'; interface IAnimateHide { children: ReactNode; @@ -35,7 +36,7 @@ const AnimateHide = ({ height: 0, y: -5, }} - className={className} + className={cn(className, 'overflow-hidden')} > {children} From ef628c558317b227828924647918db4723b0e674 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 11 Mar 2024 18:31:54 +0530 Subject: [PATCH 08/66] :coffin: Removed dead code --- .../_main+/$account+/projects/route.tsx | 92 ++++++++----------- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/src/apps/console/routes/_main+/$account+/projects/route.tsx b/src/apps/console/routes/_main+/$account+/projects/route.tsx index 27361edb3..640dd417d 100644 --- a/src/apps/console/routes/_main+/$account+/projects/route.tsx +++ b/src/apps/console/routes/_main+/$account+/projects/route.tsx @@ -10,7 +10,6 @@ import { IRemixCtx } from '~/root/lib/types/common'; import fake from '~/root/fake-data-generator/fake'; import { ensureAccountSet } from '~/console/server/utils/auth-utils'; import { GQLServerHandler } from '~/console/server/gql/saved-queries'; -import { useReload } from '~/root/lib/client/helpers/reloader'; import Tools from './tools'; import ProjectResourcesV2 from './project-resources-v2'; @@ -154,58 +153,47 @@ const Projects = () => { }; }; - const reloadPage = useReload(); - return ( -
-
{ - reloadPage(); - }} - > - reloadPage -
- - {({ projectsData, clustersCount, cloudProviderSecretsCount }) => { - const projects = projectsData.edges?.map(({ node }) => node); - if (!projects) { - return null; - } - - return ( - 0 && ( -
+ + {({ projectsData, clustersCount, cloudProviderSecretsCount }) => { + const projects = projectsData.edges?.map(({ node }) => node); + if (!projects) { + return null; + } + + return ( + 0 && ( +