diff --git a/Dockerfile b/Dockerfile index 8383ae180..5a7ac1ae0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM node:20.8.1-alpine as remix +FROM node:20.8.1-alpine AS remix WORKDIR /app COPY ./package-production.json ./package.json RUN npm i --frozen-lockfile -FROM node:20.8.1-alpine as install +FROM node:20.8.1-alpine AS install RUN npm i -g pnpm WORKDIR /app COPY ./package.json ./package.json @@ -19,7 +19,7 @@ COPY ./src/generated/plugin/package.json ./src/generated/plugin/pnpm-lock.yaml RUN pnpm i -p --frozen-lockfile -FROM node:20.8.1-alpine as build +FROM node:20.8.1-alpine AS build RUN npm i -g pnpm WORKDIR /app ARG APP diff --git a/src/apps/console/components/alert-modal.tsx b/src/apps/console/components/alert-modal.tsx index 082d98375..aae883a60 100644 --- a/src/apps/console/components/alert-modal.tsx +++ b/src/apps/console/components/alert-modal.tsx @@ -13,6 +13,7 @@ export interface IAlertModal { title: ReactNode; okText?: string; okDisabled?: boolean; + showOkButton?: boolean; cancelText?: string; variant?: ButtonVariants; footer?: boolean; @@ -28,6 +29,7 @@ const AlertModal = ({ title, okDisabled = false, okText = 'Delete', + showOkButton = true, cancelText = 'Cancel', variant = 'critical', }: IAlertModal) => { @@ -55,14 +57,16 @@ const AlertModal = ({ {footer && ( - + {showOkButton && ( + + )} )} diff --git a/src/apps/console/hooks/use-cluster-status-depricated.tsx b/src/apps/console/hooks/use-cluster-status-depricated.tsx deleted file mode 100644 index 485b0d2ad..000000000 --- a/src/apps/console/hooks/use-cluster-status-depricated.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import { useParams } from '@remix-run/react'; -import { - Dispatch, - ReactNode, - SetStateAction, - createContext, - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from 'react'; -import { useSocketWatch } from '~/root/lib/client/helpers/socket/useWatch'; -import useDebounce from '~/root/lib/client/hooks/use-debounce'; -import { useConsoleApi } from '../server/gql/api-provider'; -import { IClustersStatus } from '../server/gql/queries/cluster-queries'; -import { ExtractNodeType, parseNodes } from '../server/r-utils/common'; - -type IClusterMap = { [key: string]: ExtractNodeType }; - -const ClusterStatusContext = createContext<{ - clusters: IClusterMap; - setClusters: Dispatch>; -}>({ clusters: {}, setClusters: () => {} }); - -const ClusterStatusProvider = ({ children }: { children: ReactNode }) => { - const [clusters, setClusters] = useState({}); - const api = useConsoleApi(); - const [update, setUpdate] = useState(false); - - const { account } = useParams(); - - const topic = useCallback(() => { - return Object.keys(clusters).map((c) => `account:${account}.cluster:${c}`); - }, [clusters])(); - - const listCluster = useCallback(async () => { - try { - const { data } = await api.listClusterStatus({ - pagination: { - first: 500, - }, - search: { - allClusters: { - exact: true, - matchType: 'exact', - }, - }, - }); - const parsed = parseNodes(data).reduce((acc, c) => { - acc[c.metadata.name] = c; - return acc; - }, {} as IClusterMap); - setClusters(parsed); - return parsed; - } catch (err) { - console.error(err); - return false; - } - }, []); - - useEffect(() => { - const interval = setInterval(() => { - listCluster(); - }, 30 * 1000); - - const onlineEvent = () => { - setTimeout(() => { - listCluster(); - }, 3000); - }; - - window.addEventListener('online', onlineEvent); - - return () => { - clearInterval(interval); - window.removeEventListener('online', onlineEvent); - }; - }, []); - - useDebounce( - () => { - listCluster(); - }, - 3000, - [update] - ); - - useSocketWatch(() => { - setUpdate((p) => !p); - }, topic); - - return ( - ({ clusters, setClusters }), - [clusters, setClusters] - )} - > - {children} - - ); -}; - -export default ClusterStatusProvider; - -export const useClusterStatusV2 = () => { - return useContext(ClusterStatusContext); -}; diff --git a/src/apps/console/hooks/use-cluster-status-v3.tsx b/src/apps/console/hooks/use-cluster-status-v3.tsx index a73651201..f6a4783fa 100644 --- a/src/apps/console/hooks/use-cluster-status-v3.tsx +++ b/src/apps/console/hooks/use-cluster-status-v3.tsx @@ -1,3 +1,4 @@ +import { useOutletContext, useParams } from '@remix-run/react'; import { createContext, useCallback, @@ -7,12 +8,10 @@ import { useState, } from 'react'; import { ChildrenProps } from '~/components/types'; -import useDebounce from '~/root/lib/client/hooks/use-debounce'; import { useSocketWatch } from '~/root/lib/client/helpers/socket/useWatch'; -import { useOutletContext, useParams } from '@remix-run/react'; -import { useConsoleApi } from '../server/gql/api-provider'; -import { parseName, parseNodes } from '../server/r-utils/common'; +import useDebounce from '~/root/lib/client/hooks/use-debounce'; import { IAccountContext } from '../routes/_main+/$account+/_layout'; +import { useConsoleApi } from '../server/gql/api-provider'; const ctx = createContext<{ // clusters: { @@ -43,7 +42,6 @@ const ClusterStatusProvider = ({ }>({}); const addToWatchList = (clusterNames: string[]) => { - console.log('nayak', clusterNames); setWatchList((s) => { const resp = clusterNames.reduce((acc, curr) => { if (!curr) { @@ -69,7 +67,7 @@ const ClusterStatusProvider = ({ (async () => { try { - const { data: clusters } = await api.listClusterStatus({ + const { data: clustersStatus } = await api.listClusterStatus({ pagination: { first: 100, }, @@ -85,17 +83,10 @@ const ClusterStatusProvider = ({ }, }); - const parsedNodes = parseNodes(clusters); - - const lastOnlineAt = parsedNodes.reduce((acc, curr) => { - acc[parseName(curr)] = curr.lastOnlineAt; - return acc; - }, {} as { [key: string]: string }); - setClustersMap((s) => { return { ...s, - ...lastOnlineAt, + ...clustersStatus, }; }); } catch (e) { @@ -172,7 +163,7 @@ export const useClusterStatusV3 = ({ clusterNames?: string[]; }) => { const { clustersMap } = useOutletContext(); - const { addToWatchList, removeFromWatchList } = useContext(ctx); + const { addToWatchList, removeFromWatchList: _ } = useContext(ctx); useDebounce( () => { if (!clusterName && !clusterNames) { @@ -186,11 +177,11 @@ export const useClusterStatusV3 = ({ } return () => { - if (clusterName) { - removeFromWatchList([clusterName]); - } else if (clusterNames) { - removeFromWatchList(clusterNames); - } + // if (clusterName) { + // removeFromWatchList([clusterName]); + // } else if (clusterNames) { + // removeFromWatchList(clusterNames); + // } }; }, 100, diff --git a/src/apps/console/page-components/app/compute.tsx b/src/apps/console/page-components/app/compute.tsx index b415a4256..0682a7365 100644 --- a/src/apps/console/page-components/app/compute.tsx +++ b/src/apps/console/page-components/app/compute.tsx @@ -1,5 +1,4 @@ import { useEffect, useState } from 'react'; -import { Button } from '~/components/atoms/button'; import { NumberInput } from '~/components/atoms/input'; import Select from '~/components/atoms/select'; import Slider from '~/components/atoms/slider'; @@ -257,7 +256,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => { )}
-