-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl/cluster status #107
Impl/cluster status #107
Changes from all commits
7b3fb08
4203614
c416955
ed65866
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,7 +7,13 @@ import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form'; | |||||||||||||
import Yup from '~/root/lib/server/helpers/yup'; | ||||||||||||||
import { handleError } from '~/root/lib/utils/common'; | ||||||||||||||
import Select from '~/components/atoms/select'; | ||||||||||||||
import { parseName, parseNodes } from '../server/r-utils/common'; | ||||||||||||||
import { listStatus, parseStatus } from '~/console/components/sync-status'; | ||||||||||||||
import { IClusters } from '~/console/server/gql/queries/cluster-queries'; | ||||||||||||||
import { | ||||||||||||||
ExtractNodeType, | ||||||||||||||
parseName, | ||||||||||||||
parseNodes, | ||||||||||||||
} from '../server/r-utils/common'; | ||||||||||||||
import { ensureAccountClientSide } from '../server/utils/auth-utils'; | ||||||||||||||
import { INewProjectFromAccountLoader } from '../routes/_a+/$a+/new-project'; | ||||||||||||||
import { useConsoleApi } from '../server/gql/api-provider'; | ||||||||||||||
|
@@ -19,6 +25,14 @@ import MultiStepProgress, { | |||||||||||||
import MultiStepProgressWrapper from '../components/multi-step-progress-wrapper'; | ||||||||||||||
import { TitleBox } from '../components/raw-wrapper'; | ||||||||||||||
|
||||||||||||||
const statusRender = (item: ExtractNodeType<IClusters>) => { | ||||||||||||||
return listStatus({ | ||||||||||||||
key: parseName(item), | ||||||||||||||
item, | ||||||||||||||
className: 'text-center', | ||||||||||||||
}); | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
const NewProject = () => { | ||||||||||||||
const { clustersData } = useLoaderData<INewProjectFromAccountLoader>(); | ||||||||||||||
const clusters = parseNodes(clustersData); | ||||||||||||||
|
@@ -125,22 +139,49 @@ const NewProject = () => { | |||||||||||||
placeholder="Select a cluster" | ||||||||||||||
value={values.clusterName} | ||||||||||||||
options={async () => [ | ||||||||||||||
...clusters.map((clster) => ({ | ||||||||||||||
label: clster.displayName, | ||||||||||||||
value: parseName(clster), | ||||||||||||||
cluster: clster, | ||||||||||||||
render: () => ( | ||||||||||||||
<div className="flex flex-col"> | ||||||||||||||
<div>{clster.displayName}</div> | ||||||||||||||
<div className="bodySm text-text-soft"> | ||||||||||||||
{parseName(clster)} | ||||||||||||||
...clusters | ||||||||||||||
.filter( | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (llm): It seems like the filtering logic for clusters based on their status ('deleting') has been introduced. I recommend adding unit tests to verify that clusters with a status of 'deleting' are indeed filtered out and not displayed as options. This is crucial to ensure the UI behaves as expected and only presents valid clusters to the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (llm): Considering the addition of conditional rendering based on the cluster status ('ready', 'syncing', 'notready'), it would be beneficial to include integration or end-to-end tests. These tests should verify that the UI correctly displays the cluster information and status indicators according to the cluster's current state. This ensures that users receive accurate feedback on the cluster status. |
||||||||||||||
(clster) => parseStatus({ item: clster }) !== 'deleting' | ||||||||||||||
) | ||||||||||||||
.map((clster) => ({ | ||||||||||||||
label: clster.displayName, | ||||||||||||||
value: parseName(clster), | ||||||||||||||
cluster: clster, | ||||||||||||||
render: () => ( | ||||||||||||||
<div> | ||||||||||||||
{parseStatus({ item: clster }) === 'ready' ? ( | ||||||||||||||
<div className="flex flex-col"> | ||||||||||||||
<div>{clster.displayName}</div> | ||||||||||||||
<div className="bodySm text-text-soft"> | ||||||||||||||
{parseName(clster)} | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
) : ( | ||||||||||||||
// parseStatus({ item: clster }) === 'syncing' || | ||||||||||||||
// parseStatus({ item: clster }) === 'notready' ? | ||||||||||||||
<div className="flex text-text-disabled"> | ||||||||||||||
<div className="flex-grow"> | ||||||||||||||
<div className="flex flex-col"> | ||||||||||||||
<div>{clster.displayName}</div> | ||||||||||||||
<div className="bodySm"> | ||||||||||||||
{parseName(clster)} | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
<div className="flex flex-grow-0 items-center"> | ||||||||||||||
{statusRender( | ||||||||||||||
clster as ExtractNodeType<IClusters> | ||||||||||||||
).render()} | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
)} | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
), | ||||||||||||||
})), | ||||||||||||||
), | ||||||||||||||
})), | ||||||||||||||
Comment on lines
+143
to
+180
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (llm): The filtering and mapping logic for clusters based on their status introduces a significant amount of complexity within the JSX. Consider abstracting this logic into a separate function or utilizing useMemo to avoid recalculating this on every render, especially since this operation depends on the clusters' data which might not change on every render. This could improve readability and performance. |
||||||||||||||
]} | ||||||||||||||
onChange={(_, v) => { | ||||||||||||||
handleChange('clusterName')(dummyEvent(v)); | ||||||||||||||
onChange={(v) => { | ||||||||||||||
if (parseStatus({ item: v.cluster }) === 'ready') | ||||||||||||||
handleChange('clusterName')(dummyEvent(v.value)); | ||||||||||||||
Comment on lines
+183
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (rule): Sourcery has identified the following issue:
Suggested change
ExplanationIt is recommended to always use braces and create explicit statement blocks.Using the allowed syntax to just write a single statement can lead to very confusing |
||||||||||||||
}} | ||||||||||||||
/> | ||||||||||||||
<div className="flex flex-row justify-start"> | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import { | |
parseUpdateOrCreatedBy, | ||
parseUpdateOrCreatedOn, | ||
} from '~/console/server/r-utils/common'; | ||
import { memo, useState } from 'react'; | ||
import { useState } from 'react'; | ||
import Popup from '~/components/molecule/popup'; | ||
import { HighlightJsLogs } from 'react-highlightjs-logs'; | ||
import { yamlDump } from '~/console/components/diff-viewer'; | ||
|
@@ -32,13 +32,13 @@ import AnimateHide from '~/components/atoms/animate-hide'; | |
import { ISetState } from '~/console/page-components/app-states'; | ||
import { Button } from '~/components/atoms/button'; | ||
import { dayjs } from '~/components/molecule/dayjs'; | ||
import LogComp from '~/root/lib/client/components/logger'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (llm): The introduction of a new logging component ( |
||
import HandleNodePool from './handle-nodepool'; | ||
import { | ||
findNodePlanWithCategory, | ||
findNodePlanWithSpec, | ||
} from './nodepool-utils'; | ||
import { IAccountContext } from '../../../_layout'; | ||
import LogComp from '~/root/lib/client/components/logger'; | ||
|
||
const RESOURCE_NAME = 'nodepool'; | ||
type BaseType = ExtractNodeType<INodepools>; | ||
|
@@ -186,7 +186,6 @@ const ListDetail = ( | |
</div> | ||
); | ||
case 'azure': | ||
case 'do': | ||
case 'gcp': | ||
default: | ||
return null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
{ | ||
transformer: (data: ConsoleCreateClusterMutation) => | ||
data.infra_createCluster, | ||
vars(_: ConsoleCreateClusterMutationVariables) { }, | ||
vars(_: ConsoleCreateClusterMutationVariables) {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (llm): Given the changes in GraphQL queries and mutations, it's crucial to ensure that the corresponding tests are updated or added to cover these changes. This includes verifying that the queries and mutations behave as expected with the new or modified variables, and that error handling is properly implemented. This is important for maintaining the reliability of the API interactions. |
||
} | ||
), | ||
deleteCluster: executor( | ||
|
@@ -44,7 +44,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
{ | ||
transformer: (data: ConsoleDeleteClusterMutation) => | ||
data.infra_deleteCluster, | ||
vars(_: ConsoleDeleteClusterMutationVariables) { }, | ||
vars(_: ConsoleDeleteClusterMutationVariables) {}, | ||
} | ||
), | ||
clustersCount: executor( | ||
|
@@ -57,7 +57,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleClustersCountQuery) => data.infra_listClusters, | ||
vars(_: ConsoleClustersCountQueryVariables) { }, | ||
vars(_: ConsoleClustersCountQueryVariables) {}, | ||
} | ||
), | ||
|
||
|
@@ -171,7 +171,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleListClustersQuery) => data.infra_listClusters, | ||
vars(_: ConsoleListClustersQueryVariables) { }, | ||
vars(_: ConsoleListClustersQueryVariables) {}, | ||
} | ||
), | ||
getCluster: executor( | ||
|
@@ -212,8 +212,6 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
aws { | ||
k3sMasters { | ||
iamInstanceProfileRole | ||
imageId | ||
imageSSHUsername | ||
instanceType | ||
nodes | ||
nvidiaGpuEnabled | ||
|
@@ -283,7 +281,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleGetClusterQuery) => data.infra_getCluster, | ||
vars(_: ConsoleGetClusterQueryVariables) { }, | ||
vars(_: ConsoleGetClusterQueryVariables) {}, | ||
} | ||
), | ||
getKubeConfig: executor( | ||
|
@@ -299,7 +297,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
`, | ||
{ | ||
transformer: (data: ConsoleGetKubeConfigQuery) => data.infra_getCluster, | ||
vars(_: ConsoleGetClusterQueryVariables) { }, | ||
vars(_: ConsoleGetClusterQueryVariables) {}, | ||
} | ||
), | ||
updateCluster: executor( | ||
|
@@ -313,7 +311,7 @@ export const clusterQueries = (executor: IExecutor) => ({ | |
{ | ||
transformer: (data: ConsoleUpdateClusterMutation) => | ||
data.infra_updateCluster, | ||
vars(_: ConsoleUpdateClusterMutationVariables) { }, | ||
vars(_: ConsoleUpdateClusterMutationVariables) {}, | ||
} | ||
), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (llm): The modification to the
IStatus
type to include 'ready' is a significant change. It's important to ensure that all components consumingIStatus
properly handle the new 'ready' status. This might include rendering logic, styling, or even business logic changes. If not already covered, adding tests to verify these components react appropriately to the 'ready' status would mitigate potential issues.