Skip to content

Commit 8389fcc

Browse files
committed
devx related ui changes
2 parents 73ed23d + c3714a2 commit 8389fcc

25 files changed

+342
-368
lines changed

Diff for: Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM node:20.8.1-alpine as remix
1+
FROM node:20.8.1-alpine AS remix
22
WORKDIR /app
33
COPY ./package-production.json ./package.json
44
RUN npm i --frozen-lockfile
55

6-
FROM node:20.8.1-alpine as install
6+
FROM node:20.8.1-alpine AS install
77
RUN npm i -g pnpm
88
WORKDIR /app
99
COPY ./package.json ./package.json
@@ -19,7 +19,7 @@ COPY ./src/generated/plugin/package.json ./src/generated/plugin/pnpm-lock.yaml
1919

2020
RUN pnpm i -p --frozen-lockfile
2121

22-
FROM node:20.8.1-alpine as build
22+
FROM node:20.8.1-alpine AS build
2323
RUN npm i -g pnpm
2424
WORKDIR /app
2525
ARG APP

Diff for: src/apps/console/components/alert-modal.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface IAlertModal {
1313
title: ReactNode;
1414
okText?: string;
1515
okDisabled?: boolean;
16+
showOkButton?: boolean;
1617
cancelText?: string;
1718
variant?: ButtonVariants;
1819
footer?: boolean;
@@ -28,6 +29,7 @@ const AlertModal = ({
2829
title,
2930
okDisabled = false,
3031
okText = 'Delete',
32+
showOkButton = true,
3133
cancelText = 'Cancel',
3234
variant = 'critical',
3335
}: IAlertModal) => {
@@ -55,14 +57,16 @@ const AlertModal = ({
5557
{footer && (
5658
<AlertDialog.Footer>
5759
<AlertDialog.Button variant="basic" content={cancelText} closable />
58-
<AlertDialog.Button
59-
type="submit"
60-
disabled={okDisabled}
61-
variant={variant}
62-
content={okText}
63-
closable={false}
64-
loading={isLoading}
65-
/>
60+
{showOkButton && (
61+
<AlertDialog.Button
62+
type="submit"
63+
disabled={okDisabled}
64+
variant={variant}
65+
content={okText}
66+
closable={false}
67+
loading={isLoading}
68+
/>
69+
)}
6670
</AlertDialog.Footer>
6771
)}
6872
</form>

Diff for: src/apps/console/hooks/use-cluster-status-v2.tsx

-109
This file was deleted.

Diff for: src/apps/console/hooks/use-cluster-status-v3.tsx

+61-48
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useOutletContext, useParams } from '@remix-run/react';
12
import {
23
createContext,
34
useCallback,
@@ -7,29 +8,35 @@ import {
78
useState,
89
} from 'react';
910
import { ChildrenProps } from '~/components/types';
10-
import useDebounce from '~/root/lib/client/hooks/use-debounce';
1111
import { useSocketWatch } from '~/root/lib/client/helpers/socket/useWatch';
12-
import { useParams } from '@remix-run/react';
12+
import useDebounce from '~/root/lib/client/hooks/use-debounce';
13+
import { IAccountContext } from '../routes/_main+/$account+/_layout';
1314
import { useConsoleApi } from '../server/gql/api-provider';
1415

1516
const ctx = createContext<{
16-
clusters: {
17-
[key: string]: string;
18-
};
19-
setClusters: React.Dispatch<React.SetStateAction<{ [key: string]: string }>>;
17+
// clusters: {
18+
// [key: string]: string;
19+
// };
20+
// setClusters: React.Dispatch<React.SetStateAction<{ [key: string]: string }>>;
2021
addToWatchList: (clusterNames: string[]) => void;
2122
removeFromWatchList: (clusterNames: string[]) => void;
2223
}>({
23-
clusters: {},
24-
setClusters: () => {},
24+
// clusters: {},
25+
// setClusters: () => {},
2526
addToWatchList: () => {},
2627
removeFromWatchList: () => {},
2728
});
2829

29-
const ClusterStatusProvider = ({ children }: ChildrenProps) => {
30-
const [clusters, setClusters] = useState<{
31-
[key: string]: string;
32-
}>({});
30+
const ClusterStatusProvider = ({
31+
children,
32+
clustersMap,
33+
setClustersMap,
34+
}: ChildrenProps & {
35+
clustersMap: { [key: string]: string };
36+
setClustersMap: React.Dispatch<
37+
React.SetStateAction<{ [key: string]: string }>
38+
>;
39+
}) => {
3340
const [watchList, setWatchList] = useState<{
3441
[key: string]: number;
3542
}>({});
@@ -57,47 +64,54 @@ const ClusterStatusProvider = ({ children }: ChildrenProps) => {
5764

5865
const caller = (wl: { [key: string]: number }) => {
5966
const keys = Object.keys(wl);
60-
// console.log('nayak', wl, keys, Object.entries(wl));
61-
for (let i = 0; i < keys.length; i += 1) {
62-
(async () => {
63-
const w = keys[i];
64-
try {
65-
const { data: cluster } = await api.getClusterStatus({
66-
name: w,
67-
});
68-
setClusters((s) => {
69-
return {
70-
...s,
71-
[w]: cluster.lastOnlineAt,
72-
};
73-
});
74-
} catch (e) {
75-
console.log('error', e);
76-
}
77-
})();
78-
}
67+
68+
(async () => {
69+
try {
70+
const { data: clustersStatus } = await api.listClusterStatus({
71+
pagination: {
72+
first: 100,
73+
},
74+
search: {
75+
allClusters: {
76+
exact: true,
77+
matchType: 'exact',
78+
},
79+
text: {
80+
array: keys,
81+
matchType: 'array',
82+
},
83+
},
84+
});
85+
86+
setClustersMap((s) => {
87+
return {
88+
...s,
89+
...clustersStatus,
90+
};
91+
});
92+
} catch (e) {
93+
console.log('error', e);
94+
}
95+
})();
7996
};
8097

8198
useEffect(() => {
82-
const t2 = setTimeout(() => {
83-
caller(watchList);
84-
}, 1000);
85-
8699
const t = setInterval(() => {
87100
caller(watchList);
88101
}, 30 * 1000);
89102

90103
return () => {
91-
clearTimeout(t2);
92104
clearInterval(t);
93105
};
94106
}, [watchList]);
95107

96108
const { account } = useParams();
97109

98110
const topic = useCallback(() => {
99-
return Object.keys(clusters).map((c) => `account:${account}.cluster:${c}`);
100-
}, [clusters])();
111+
return Object.keys(clustersMap).map(
112+
(c) => `account:${account}.cluster:${c}`
113+
);
114+
}, [clustersMap])();
101115

102116
useSocketWatch(() => {
103117
caller(watchList);
@@ -128,12 +142,10 @@ const ClusterStatusProvider = ({ children }: ChildrenProps) => {
128142
<ctx.Provider
129143
value={useMemo(
130144
() => ({
131-
clusters,
132-
setClusters,
133145
addToWatchList,
134146
removeFromWatchList,
135147
}),
136-
[clusters, setClusters]
148+
[]
137149
)}
138150
>
139151
{children}
@@ -150,7 +162,8 @@ export const useClusterStatusV3 = ({
150162
clusterName?: string;
151163
clusterNames?: string[];
152164
}) => {
153-
const { clusters, addToWatchList, removeFromWatchList } = useContext(ctx);
165+
const { clustersMap } = useOutletContext<IAccountContext>();
166+
const { addToWatchList, removeFromWatchList: _ } = useContext(ctx);
154167
useDebounce(
155168
() => {
156169
if (!clusterName && !clusterNames) {
@@ -164,18 +177,18 @@ export const useClusterStatusV3 = ({
164177
}
165178

166179
return () => {
167-
if (clusterName) {
168-
removeFromWatchList([clusterName]);
169-
} else if (clusterNames) {
170-
removeFromWatchList(clusterNames);
171-
}
180+
// if (clusterName) {
181+
// removeFromWatchList([clusterName]);
182+
// } else if (clusterNames) {
183+
// removeFromWatchList(clusterNames);
184+
// }
172185
};
173186
},
174187
100,
175188
[clusterName, clusterNames]
176189
);
177190

178191
return {
179-
clusters,
192+
clustersMap,
180193
};
181194
};

Diff for: src/apps/console/page-components/app/compute.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect, useState } from 'react';
2-
import { Button } from '~/components/atoms/button';
32
import { NumberInput } from '~/components/atoms/input';
43
import Select from '~/components/atoms/select';
54
import Slider from '~/components/atoms/slider';
@@ -257,7 +256,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
257256
)}
258257

259258
<div className="flex flex-col gap-3xl pt-3xl">
260-
<Button
259+
{/* <Button
261260
size="sm"
262261
content={
263262
<span className="truncate text-left">Advanced options</span>
@@ -267,7 +266,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
267266
onClick={() => {
268267
setAdvancedOptions(!advancedOptions);
269268
}}
270-
/>
269+
/> */}
271270

272271
{/* {advancedOptions && (
273272
<Select

0 commit comments

Comments
 (0)