Skip to content
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

WEB: Previous account cluster list are showing while account switching #280

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6130,6 +6130,33 @@ query authCli_getEnvironment($name: String!) {
}
}

mutation authCli_cloneEnvironment($clusterName: String!, $sourceEnvName: String!, $destinationEnvName: String!, $displayName: String!, $environmentRoutingMode: Github__com___kloudlite___operator___apis___crds___v1__EnvironmentRoutingMode!) {
core_cloneEnvironment(
clusterName: $clusterName
sourceEnvName: $sourceEnvName
destinationEnvName: $destinationEnvName
displayName: $displayName
environmentRoutingMode: $environmentRoutingMode
) {
id
displayName
clusterName
metadata {
name
namespace
}
status {
isReady
message {
RawMessage
}
}
spec {
targetNamespace
}
}
}

query authCli_getSecret($envName: String!, $name: String!) {
core_getSecret(envName: $envName, name: $name) {
displayName
Expand Down Expand Up @@ -6486,6 +6513,24 @@ query authCli_listImportedManagedResources($envName: String!, $search: SearchImp
}
}

query authCli_listByokClusters($search: SearchCluster, $pagination: CursorPaginationIn) {
infra_listBYOKClusters(search: $search, pagination: $pagination) {
edges {
cursor
node {
displayName
id
metadata {
name
namespace
}
updateTime
}
}
totalCount
}
}

mutation authSetRemoteAuthHeader($loginId: String!, $authHeader: String) {
auth_setRemoteAuthHeader(loginId: $loginId, authHeader: $authHeader)
}
Expand Down
70 changes: 70 additions & 0 deletions src/apps/auth/server/gql/cli-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,46 @@ export const cliQueries = (executor: IExecutor) => ({
vars: (_: any) => {},
}
),
cli_cloneEnvironment: executor(
gql`
mutation Core_cloneEnvironment(
$clusterName: String!
$sourceEnvName: String!
$destinationEnvName: String!
$displayName: String!
$environmentRoutingMode: Github__com___kloudlite___operator___apis___crds___v1__EnvironmentRoutingMode!
) {
core_cloneEnvironment(
clusterName: $clusterName
sourceEnvName: $sourceEnvName
destinationEnvName: $destinationEnvName
displayName: $displayName
environmentRoutingMode: $environmentRoutingMode
) {
id
displayName
clusterName
metadata {
name
namespace
}
status {
isReady
message {
RawMessage
}
}
spec {
targetNamespace
}
}
}
`,
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Inconsistent error handling in transformer functions

The transformer function in cli_listByokClusters directly returns the data, while cli_cloneEnvironment doesn't have a transformer. This inconsistency could lead to unexpected behavior or difficulties in error handling. Consider standardizing the approach across both functions.

transformer: (data: any) => data.core_cloneEnvironment,
vars(_: any) {},
}
),
cli_getSecret: executor(
gql`
query Core_getSecret($envName: String!, $name: String!) {
Expand Down Expand Up @@ -863,4 +903,34 @@ export const cliQueries = (executor: IExecutor) => ({
vars(_: any) {},
}
),
cli_listByokClusters: executor(
gql`
query Infra_listBYOKClusters(
$search: SearchCluster
$pagination: CursorPaginationIn
) {
infra_listBYOKClusters(search: $search, pagination: $pagination) {
edges {
cursor
node {
displayName
id
metadata {
name
namespace
}
updateTime
}
}
totalCount
}
}
`,
{
transformer: (data: any) => {
return data.infra_listBYOKClusters;
},
vars(_: any) {},
}
),
});
22 changes: 11 additions & 11 deletions src/apps/console/page-components/handle-environment.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useCallback, useEffect, useState } from 'react';
import Select from '~/components/atoms/select';
import Popup from '~/components/molecule/popup';
import { toast } from '~/components/molecule/toast';
import { useReload } from '~/root/lib/client/helpers/reloader';
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 { NameIdView } from '../components/name-id-view';
import { IDialog } from '../components/types.d';
import { useConsoleApi } from '../server/gql/api-provider';
import { DIALOG_TYPE } from '../utils/commons';
import { IEnvironment } from '../server/gql/queries/environment-queries';
import { NameIdView } from '../components/name-id-view';
import { parseName, parseNodes } from '../server/r-utils/common';
import { DIALOG_TYPE } from '../utils/commons';

const ClusterSelectItem = ({
label,
Expand Down Expand Up @@ -55,7 +55,7 @@ const HandleEnvironment = ({ show, setShow }: IDialog<IEnvironment | null>) => {

useEffect(() => {
getClusters();
}, []);
}, [show]);

const [validationSchema] = useState<any>(
Yup.object({
Expand Down Expand Up @@ -127,14 +127,14 @@ const HandleEnvironment = ({ show, setShow }: IDialog<IEnvironment | null>) => {
}
},
});

useEffect(() => {
if (clusterList.length > 0) {
setValues((v) => ({
...v,
clusterName: clusterList.find((c) => c.ready)?.value || '',
}));
}
setValues((v) => ({
...v,
clusterName:
clusterList.length > 0
? clusterList.find((c) => c.ready)?.value || ''
: '',
}));
}, [clusterList, show]);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable react/destructuring-assignment */
import { useCallback, useEffect, useState } from 'react';
import Select from '~/components/atoms/select';
import Popup from '~/components/molecule/popup';
import { toast } from '~/components/molecule/toast';
import CommonPopupHandle from '~/console/components/common-popup-handle';
Expand All @@ -15,8 +17,6 @@ import { useReload } from '~/root/lib/client/helpers/reloader';
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 { useCallback, useEffect, useState } from 'react';

type IDialog = IDialogBase<ExtractNodeType<IEnvironments>>;

Expand Down
12 changes: 6 additions & 6 deletions src/apps/console/routes/_main+/$account+/environments/route.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Plus } from '~/console/components/icons';
import { defer } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { useState } from 'react';
import { Button } from '~/components/atoms/button.jsx';
import { Plus } from '~/console/components/icons';
import { LoadingComp, pWrapper } from '~/console/components/loading-component';
import { IShowDialog } from '~/console/components/types.d';
import Wrapper from '~/console/components/wrapper';
import HandleScope from '~/console/page-components/handle-environment';
import { parseNodes } from '~/console/server/r-utils/common';
import { getPagination, getSearch } from '~/console/server/utils/common';
import { IRemixCtx } from '~/root/lib/types/common';
import fake from '~/root/fake-data-generator/fake';
import { IRemixCtx } from '~/root/lib/types/common';

import { ensureAccountSet } from '~/console/server/utils/auth-utils';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
import { IEnvironment } from '~/console/server/gql/queries/environment-queries';
import { EmptyEnvironmentImage } from '~/console/components/empty-resource-images';
import Tools from './tools';
import { IEnvironment } from '~/console/server/gql/queries/environment-queries';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
import { ensureAccountSet } from '~/console/server/utils/auth-utils';
import EnvironmentResourcesV2 from './environment-resources-v2';
import Tools from './tools';

export const loader = async (ctx: IRemixCtx) => {
ensureAccountSet(ctx);
Expand Down
Loading
Loading