Skip to content

Commit

Permalink
Merge pull request #289 from kloudlite/update/env-context
Browse files Browse the repository at this point in the history
Update webinar changes
  • Loading branch information
nxtCoder19 authored Sep 9, 2024
2 parents fee422c + d39bc98 commit af91c5b
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 192 deletions.
7 changes: 6 additions & 1 deletion web/src/apps/auth/routes/_providers+/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ const Login = () => {
const { githubLoginUrl, gitlabLoginUrl, googleLoginUrl } =
useOutletContext<IProviderContext>();
const [searchParams, _setSearchParams] = useSearchParams();
const callback = searchParams.get('callback');
const loginUrl = callback
? `/login?mode=email&callback=${callback}`
: `/login?mode=email`;

return (
<Container
Expand Down Expand Up @@ -198,7 +202,8 @@ const Login = () => {
variant="outline"
content={<span className="bodyLg-medium">Continue with email</span>}
prefix={<Envelope />}
to="/login/?mode=email"
// to="/login/?mode=email"
to={loginUrl}
block
linkComponent={Link}
/>
Expand Down
66 changes: 30 additions & 36 deletions web/src/apps/console/page-components/app/compute.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { useEffect, useState } from 'react';
import { Button } from '~/components/atoms/button';
import { NumberInput } from '~/components/atoms/input';
import Select from '~/components/atoms/select';
import Slider from '~/components/atoms/slider';
import { BottomNavigation } from '~/console/components/commons';
import ExtendedFilledTab from '~/console/components/extended-filled-tab';
import { useAppState } from '~/console/page-components/app-states';
import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form';
import Yup from '~/root/lib/server/helpers/yup';
import { FadeIn, parseValue } from '~/console/page-components/util';
import Select from '~/components/atoms/select';
import ExtendedFilledTab from '~/console/components/extended-filled-tab';
import { parseName, parseNodes } from '~/console/server/r-utils/common';
import useCustomSwr from '~/lib/client/hooks/use-custom-swr';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import { useMapper } from '~/components/utils';
import { BottomNavigation } from '~/console/components/commons';
import { useOutletContext } from '@remix-run/react';
import { useEffect, useState } from 'react';
import { Button } from '~/components/atoms/button';
import { IEnvironmentContext } from '~/console/routes/_main+/$account+/env+/$environment+/_layout';
import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form';
import { useUnsavedChanges } from '~/root/lib/client/hooks/use-unsaved-changes';
import { plans } from './datas';
import Yup from '~/root/lib/server/helpers/yup';
import appInitialFormValues, { mapFormValuesToApp } from './app-utils';
import { plans } from './datas';

const valueRender = ({
label,
Expand Down Expand Up @@ -50,25 +44,25 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
getReadOnlyContainer,
getContainer,
} = useAppState();
const api = useConsoleApi();
const { cluster } = useOutletContext<IEnvironmentContext>();
// const api = useConsoleApi();
// const { cluster } = useOutletContext<IEnvironmentContext>();
const [advancedOptions, setAdvancedOptions] = useState(false);
const { performAction } = useUnsavedChanges();

const {
data: nodepoolData,
isLoading: nodepoolLoading,
error: nodepoolLoadingError,
} = useCustomSwr('/nodepools', async () => {
return api.listNodePools({
clusterName: parseName(cluster),
pagination: {
first: 100,
orderBy: 'updateTime',
sortDirection: 'DESC',
},
});
});
// const {
// data: nodepoolData,
// isLoading: nodepoolLoading,
// error: nodepoolLoadingError,
// } = useCustomSwr('/nodepools', async () => {
// return api.listNodePools({
// clusterName: parseName(cluster),
// pagination: {
// first: 100,
// orderBy: 'updateTime',
// sortDirection: 'DESC',
// },
// });
// });

const { values, errors, handleChange, isLoading, submit, resetValues } =
useForm({
Expand All @@ -91,10 +85,10 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
},
});

const nodepools = useMapper(parseNodes(nodepoolData), (val) => ({
label: val.metadata?.name || '',
value: val.metadata?.name || '',
}));
// const nodepools = useMapper(parseNodes(nodepoolData), (val) => ({
// label: val.metadata?.name || '',
// value: val.metadata?.name || '',
// }));

/** ---- Only for edit mode in settings ----* */
useEffect(() => {
Expand Down Expand Up @@ -275,7 +269,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
}}
/>

{advancedOptions && (
{/* {advancedOptions && (
<Select
label="Nodepool Name"
size="lg"
Expand All @@ -293,7 +287,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => {
loading={nodepoolLoading}
showclear
/>
)}
)} */}
</div>
</div>
{mode === 'new' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
GearSix,
} from '~/console/components/icons';
import HandleScope from '~/console/page-components/handle-environment';
import { ICluster } from '~/console/server/gql/queries/cluster-queries';
import { IEnvironment } from '~/console/server/gql/queries/environment-queries';
import { ILoginUrls, ILogins } from '~/console/server/gql/queries/git-queries';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
Expand All @@ -30,8 +29,13 @@ import { IAccountContext } from '../../_layout';

const Environment = () => {
const rootContext = useOutletContext<IAccountContext>();
const { environment, managedTemplates, loginUrls, logins, cluster } =
useLoaderData();
const {
environment,
managedTemplates,
loginUrls,
logins,
// cluster
} = useLoaderData();

return (
<SubNavDataProvider>
Expand All @@ -42,7 +46,7 @@ const Environment = () => {
managedTemplates,
loginUrls,
logins,
cluster,
// cluster,
}}
/>
</SubNavDataProvider>
Expand Down Expand Up @@ -308,15 +312,15 @@ export const loader = async (ctx: IRemixCtx) => {
throw errors[0];
}

const { data: cData, errors: cErrors } = await GQLServerHandler(
ctx.request
).getCluster({
name: data.clusterName,
});
// const { data: cData, errors: cErrors } = await GQLServerHandler(
// ctx.request
// ).getCluster({
// name: data.clusterName,
// });

if (cErrors) {
throw cErrors[0];
}
// if (cErrors) {
// throw cErrors[0];
// }

const { data: logins, errors: loginErrors } = await GQLServerHandler(
ctx.request
Expand All @@ -339,15 +343,15 @@ export const loader = async (ctx: IRemixCtx) => {
loginUrls,
logins,
environment: envData,
cluster: cData,
// cluster: cData,
};
} catch (err) {
logger.error(err);
return handleError(err) as {
logins: ILogins;
loginUrls: ILoginUrls;
environment: IEnvironment;
cluster: ICluster;
// cluster: ICluster;
};
}
};
Expand All @@ -356,7 +360,7 @@ export interface IEnvironmentContext extends IAccountContext {
logins: LoaderResult<typeof loader>['logins'];
loginUrls: LoaderResult<typeof loader>['loginUrls'];
environment: LoaderResult<typeof loader>['environment'];
cluster: LoaderResult<typeof loader>['cluster'];
// cluster: LoaderResult<typeof loader>['cluster'];
}

export default Environment;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import ResourceExtraAction, {
IResourceExtraItem,
} from '~/console/components/resource-extra-action';
import { SyncStatusV2 } from '~/console/components/sync-status';
import { findClusterStatus } from '~/console/hooks/use-cluster-status';
import { useClusterStatusV2 } from '~/console/hooks/use-cluster-status-v2';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import { IApps } from '~/console/server/gql/queries/app-queries';
Expand All @@ -34,7 +33,7 @@ import {
parseName,
parseUpdateOrCreatedBy,
parseUpdateOrCreatedOn,
parseName as pn
parseName as pn,
} from '~/console/server/r-utils/common';
import { useReload } from '~/lib/client/helpers/reloader';
import { useWatchReload } from '~/lib/client/helpers/socket/useWatch';
Expand Down Expand Up @@ -239,8 +238,7 @@ const GridView = ({ items = [], onAction: _ }: IResource) => {
};

const ListView = ({ items = [], onAction }: IResource) => {
const { environment, account, cluster } =
useOutletContext<IEnvironmentContext>();
const { environment, account } = useOutletContext<IEnvironmentContext>();
const { clusters } = useClusterStatusV2();

// const [clusterOnlineStatus, setClusterOnlineStatus] = useState<
Expand Down Expand Up @@ -307,9 +305,6 @@ const ListView = ({ items = [], onAction }: IResource) => {
],
rows: items.map((i) => {
// const isClusterOnline = clusterOnlineStatus[parseName(cluster)];
const isClusterOnline = findClusterStatus(
clusters[parseName(cluster)]
);

const { name, id, updateInfo } = parseItem(i);
return {
Expand Down Expand Up @@ -337,9 +332,9 @@ const ListView = ({ items = [], onAction }: IResource) => {
return null;
}

if (!isClusterOnline) {
return <Badge type="warning">Cluster Offline</Badge>;
}
// if (!isClusterOnline) {
// return <Badge type="warning">Cluster Offline</Badge>;
// }

return <SyncStatusV2 item={i} />;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { GearSix, LinkBreak, Repeat } from '~/console/components/icons';
import { Link, useOutletContext, useParams } from '@remix-run/react';
import { useState } from 'react';
import { Badge } from '~/components/atoms/badge';
import Tooltip from '~/components/atoms/tooltip';
import { toast } from '~/components/molecule/toast';
import { generateKey, titleCase } from '~/components/utils';
import { CopyContentToClipboard } from '~/console/components/common-console-components';
import {
ListItem,
ListTitle,
} from '~/console/components/console-list-components';
import Grid from '~/console/components/grid';
import { GearSix, LinkBreak, Repeat } from '~/console/components/icons';
import ListGridView from '~/console/components/list-grid-view';
import ListV2 from '~/console/components/listV2';
import ResourceExtraAction, {
IResourceExtraItem,
} from '~/console/components/resource-extra-action';
import { SyncStatusV2 } from '~/console/components/sync-status';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import {
ExtractNodeType,
parseName,
parseName as pn,
parseUpdateOrCreatedBy,
parseUpdateOrCreatedOn,
parseName as pn,
} from '~/console/server/r-utils/common';
import { handleError } from '~/lib/utils/common';
import { toast } from '~/components/molecule/toast';
import { useReload } from '~/lib/client/helpers/reloader';
import { SyncStatusV2 } from '~/console/components/sync-status';
import { useWatchReload } from '~/lib/client/helpers/socket/useWatch';
import ListV2 from '~/console/components/listV2';
import { useState } from 'react';
import { Badge } from '~/components/atoms/badge';
import { CopyContentToClipboard } from '~/console/components/common-console-components';
import Tooltip from '~/components/atoms/tooltip';
import { handleError } from '~/lib/utils/common';
import { NN } from '~/root/lib/types/common';
// import HandleIntercept from './handle-intercept';
import { IExternalApps } from '~/console/server/gql/queries/external-app-queries';
Expand Down Expand Up @@ -236,8 +236,11 @@ const GridView = ({ items = [], onAction: _ }: IResource) => {
};

const ListView = ({ items = [], onAction }: IResource) => {
const { environment, cluster, account } =
useOutletContext<IEnvironmentContext>();
const {
environment,
// cluster,
account,
} = useOutletContext<IEnvironmentContext>();
return (
<ListV2.Root
linkComponent={Link}
Expand Down Expand Up @@ -302,21 +305,20 @@ const ListView = ({ items = [], onAction }: IResource) => {
</div>
) : null,
},
service: {
render: () => (
<AppServiceView
service={
environment?.spec?.targetNamespace
? `${parseName(i)}.${
environment?.spec?.targetNamespace
}.svc.${parseName(cluster)}.local`
: `${parseName(i)}.${parseName(
environment
)}.svc.${parseName(cluster)}.local`
}
/>
),
},
// service: {
// render: () => (
// <AppServiceView
// service={
// environment?.spec?.targetNamespace
// ? `${parseName(i)}.${environment?.spec?.targetNamespace
// }.svc.${parseName(cluster)}.local`
// : `${parseName(i)}.${parseName(
// environment
// )}.svc.${parseName(cluster)}.local`
// }
// />
// ),
// },
status: {
render: () => (
<div className="inline-block">
Expand Down
Loading

0 comments on commit af91c5b

Please sign in to comment.