diff --git a/gql-queries-generator/doc/queries.graphql b/gql-queries-generator/doc/queries.graphql index 8ee2c42d0..eeb98ec69 100644 --- a/gql-queries-generator/doc/queries.graphql +++ b/gql-queries-generator/doc/queries.graphql @@ -2846,6 +2846,7 @@ query consoleListBuildRuns($repoName: String!, $search: SearchBuildRuns, $pq: Cu edges { cursor node { + id clusterName creationTime markedForDeletion @@ -3989,8 +3990,8 @@ query authCli_getDevice($clusterName: String!, $name: String!) { } } -query authCli_listDevices($pq: CursorPaginationIn) { - infra_listVPNDevices(pq: $pq) { +query authCli_listDevices($pq: CursorPaginationIn, $clusterName: String) { + infra_listVPNDevices(clusterName: $clusterName, pq: $pq) { edges { node { displayName diff --git a/src/apps/auth/server/gql/queries/device-queries.ts b/src/apps/auth/server/gql/queries/device-queries.ts index 9d0824729..d7bca0a14 100644 --- a/src/apps/auth/server/gql/queries/device-queries.ts +++ b/src/apps/auth/server/gql/queries/device-queries.ts @@ -13,7 +13,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_updateVPNDevicePorts, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_CoreUpdateDeviceEnv: executor( @@ -32,7 +32,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_updateVPNDeviceEnv, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), @@ -69,7 +69,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_listVPNDevicesForUser, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_getCoreDevice: executor( @@ -98,7 +98,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_getVPNDevice, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_createCoreDevice: executor( @@ -117,7 +117,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_createVPNDevice, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), @@ -129,7 +129,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.core_updateVPNDevicePorts, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), @@ -170,14 +170,17 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_getVPNDevice, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_listDevices: executor( gql` - query Infra_listVPNDevices($pq: CursorPaginationIn) { - infra_listVPNDevices(pq: $pq) { + query Infra_listVPNDevices( + $pq: CursorPaginationIn + $clusterName: String + ) { + infra_listVPNDevices(clusterName: $clusterName, pq: $pq) { edges { node { displayName @@ -210,7 +213,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_listVPNDevices, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), @@ -246,7 +249,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_updateVPNDevice, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), @@ -266,7 +269,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_updateVPNDevicePorts, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_updateDeviceNs: executor( @@ -285,7 +288,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_updateVPNDeviceNs, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), cli_createDevice: executor( @@ -306,7 +309,7 @@ export const vpnQueries = (executor: IExecutor) => ({ `, { transformer: (data: any) => data.infra_createVPNDevice, - vars: (_: any) => { }, + vars: (_: any) => {}, } ), }); diff --git a/src/apps/console/components/color-generator.tsx b/src/apps/console/components/color-generator.tsx index 600457511..ed534eadf 100644 --- a/src/apps/console/components/color-generator.tsx +++ b/src/apps/console/components/color-generator.tsx @@ -69,4 +69,8 @@ const generateColor = (str = '#', contrast: Contrast = 'dark') => { )}, ${generateColorFromName(`${str + str + str}`, cc, contrast)})`; }; +export const generatePlainColor = (str = '#') => { + const cc = colorCode(str); + return generateColorFromName(str, cc, 'dark'); +}; export default generateColor; diff --git a/src/apps/console/components/logger.tsx b/src/apps/console/components/logger.tsx index ef363ace0..b0756937e 100644 --- a/src/apps/console/components/logger.tsx +++ b/src/apps/console/components/logger.tsx @@ -16,7 +16,7 @@ import { import useClass from '~/root/lib/client/hooks/use-class'; import logger from '~/root/lib/client/helpers/log'; import { socketUrl } from '~/root/lib/configs/base-url.cjs'; -import generateColor from './color-generator'; +import { generatePlainColor } from './color-generator'; import Pulsable from './pulsable'; import { logsMockData } from '../dummy/data'; @@ -331,8 +331,9 @@ const LogLine = ({
+
{ }; w.onopen = () => { + // console.log('socket connected'); res(w); }; w.onerror = (e) => { + console.error(e); rej(e); }; w.onclose = () => { // wsclient.send(newMessage({ event: 'unsubscribe', data: 'test' })); - logger.log('socket disconnected'); + // logger.log('socket disconnected'); }; } catch (e) { rej(e); @@ -633,6 +636,7 @@ const useSocketLogs = ({ url, account, cluster, trackingId }: IuseLog) => { setIsLoading(true); const client = await wsclient; + console.log('client', client); setSocState(client); diff --git a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/buildruns-resources.tsx b/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/buildruns-resources.tsx index 2d180e958..e27b6e731 100644 --- a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/buildruns-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/buildruns-resources.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { toast } from '~/components/molecule/toast'; -import { generateKey, titleCase } from '~/components/utils'; +import { cn, generateKey, titleCase } from '~/components/utils'; import { ListBody, ListTitle, @@ -18,8 +18,21 @@ import { } from '~/console/server/r-utils/common'; import { useReload } from '~/root/lib/client/helpers/reloader'; import { handleError } from '~/root/lib/utils/common'; -import { useParams } from '@remix-run/react'; +import { useOutletContext, useParams } from '@remix-run/react'; import { IBuildRuns } from '~/console/server/gql/queries/build-run-queries'; +import AnimateHide from '~/components/atoms/animate-hide'; +import LogComp from '~/console/components/logger'; +import { Button } from '~/components/atoms/button'; +import { + CheckCircleFill, + GitBranch, + PlayCircleFill, + Tag, + XCircleFill, +} from '@jengaicons/react'; +import dayjs from 'dayjs'; +import { Badge } from '~/components/atoms/badge'; +import { IAccountContext } from '../../../_layout'; const RESOURCE_NAME = 'build run'; type BaseType = ExtractNodeType; @@ -77,13 +90,13 @@ const GridView = ({ items, onDelete }: IResource) => { { - // onDelete(item); - // }} - // /> - // } + // action={ + // { + // onDelete(item); + // }} + // /> + // } /> ), }, @@ -102,13 +115,119 @@ const GridView = ({ items, onDelete }: IResource) => { }; const ListItem = ({ item }: { item: BaseType }) => { - const { name, id, updateInfo } = parseItem(item); + const [open, setOpen] = useState(false); + const { account } = useOutletContext(); + const commitHash = item.metadata?.annotations['github.com/commit']; + + // eslint-disable-next-line no-nested-ternary + const state: 'running' | 'done' | 'error' = item.status?.isReady + ? 'done' + : item.status?.message?.RawMessage + ? 'error' + : 'running'; + + const isLatest = dayjs(item.updateTime).isAfter(dayjs().subtract(3, 'hour')); + return ( -
-
- +
+
+
+
+
+ + {state === 'done' && ( + + )} + + {state === 'error' && ( + + )} + + {state === 'running' && ( + + )} + +
+ + {item.metadata?.annotations['github.com/repository']}{' '} +
+ } + subtitle={ +
+ {`#${commitHash.substring( + commitHash.length - 7, + commitHash.length + )}`} + + {item.metadata?.annotations['github.com/branch']}{' '} +
+ } + /> +
+ +
+
+ {item.spec?.registry.repo.tags.map((tag) => ( + + ))} +
+
+
+ +
+ {parseUpdateOrCreatedOn(item)} +
+ + {/*
{JSON.stringify(item, null, 2)}
*/} + {isLatest && ( +
-
Logs
+ + + +
); }; @@ -116,7 +235,7 @@ const ListView = ({ items, onDelete }: IResource) => { return ( {items.map((item, index) => { - const { name, id, updateInfo } = parseItem(item); + const { name, id } = parseItem(item); const keyPrefix = `${RESOURCE_NAME}-${id}-${index}`; return ( { columns={[ { key: generateKey(keyPrefix, name + id), + className: 'w-full', render: () => , }, ]} diff --git a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/logs.tsx b/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/logs.tsx deleted file mode 100644 index 3f011d7aa..000000000 --- a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/logs.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { useOutletContext } from '@remix-run/react'; -import LogComp from '~/console/components/logger'; -import { parseName } from '~/console/server/r-utils/common'; -import { IAppContext } from '../route'; - -const BuildLogs = () => { - const { app, project, account } = useOutletContext(); - return ( -
- -
- ); -}; - -export default BuildLogs; diff --git a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/route.tsx b/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/route.tsx index f00b867a4..b3f69940b 100644 --- a/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/route.tsx +++ b/src/apps/console/routes/_main+/$account+/repo+/$repo+/buildruns/route.tsx @@ -7,7 +7,6 @@ import { GQLServerHandler } from '~/console/server/gql/saved-queries'; import { getPagination, getSearch } from '~/console/server/utils/common'; import { defer } from '@remix-run/node'; import fake from '~/root/fake-data-generator/fake'; -import SecondarySubHeader from '~/console/components/secondary-sub-header'; import Tools from './tools'; import BuildRunResources from './buildruns-resources'; @@ -24,7 +23,6 @@ export const loader = async (ctx: IRemixCtx) => { if (errors) { throw errors[0]; } - console.log(data); return { buildRunData: data }; }); diff --git a/src/apps/console/server/gql/queries/build-run-queries.tsx b/src/apps/console/server/gql/queries/build-run-queries.tsx index 66efd0590..3ba23ced9 100644 --- a/src/apps/console/server/gql/queries/build-run-queries.tsx +++ b/src/apps/console/server/gql/queries/build-run-queries.tsx @@ -22,6 +22,7 @@ export const buildRunQueries = (executor: IExecutor) => ({ edges { cursor node { + id clusterName creationTime markedForDeletion diff --git a/src/generated/gql/server.ts b/src/generated/gql/server.ts index cce30319e..667c4765b 100644 --- a/src/generated/gql/server.ts +++ b/src/generated/gql/server.ts @@ -4193,6 +4193,7 @@ export type ConsoleListBuildRunsQuery = { edges: Array<{ cursor: string; node: { + id: string; clusterName: string; creationTime: any; markedForDeletion?: boolean; @@ -5231,6 +5232,7 @@ export type AuthCli_GetDeviceQuery = { export type AuthCli_ListDevicesQueryVariables = Exact<{ pq?: InputMaybe; + clusterName?: InputMaybe; }>; export type AuthCli_ListDevicesQuery = {