Skip to content

Commit

Permalink
Merge pull request #280 from kloudlite/fix/switch-acc-issue
Browse files Browse the repository at this point in the history
WEB: Previous account cluster list are showing while account switching
  • Loading branch information
nxtCoder19 authored Aug 26, 2024
2 parents 26ac2b5 + 7fbf43e commit 53b1bcb
Show file tree
Hide file tree
Showing 9 changed files with 5,595 additions and 1,039 deletions.
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
}
}
}
`,
{
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

0 comments on commit 53b1bcb

Please sign in to comment.