Skip to content

Commit

Permalink
Fix/repo name (#136)
Browse files Browse the repository at this point in the history
* 🐛 Fixed issue with repoName
  • Loading branch information
abdheshnayak authored Mar 12, 2024
1 parent 6f4b148 commit a569208
Showing 15 changed files with 99 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ tasks:
interactive: true
cmds:
- |
BASE_URL=dev.kloudlite.io
BASE_URL=gcp-production.kloudlite.io
COOKIE_DOMAIN=".kloudlite.io"
GATEWAY_URL="http://gateway.kloudlite.svc.cluster.local"
case {{.app}} in
2 changes: 1 addition & 1 deletion lib/client/helpers/log.ts
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ const logger = {
}

if (err) {
console.trace(err);
console.log(err);
if (!isDev) {
PostToHook(`\`\`\`${err}\`\`\``);
}
9 changes: 5 additions & 4 deletions src/apps/console/components/git.tsx
Original file line number Diff line number Diff line change
@@ -63,15 +63,16 @@ const githubInstallUrl = `https://github.com/apps/${githubAppName}/installations

const popupWindow = ({
url = '',
onClose = () => { },
onClose = () => {},
width = 800,
height = 500,
title = 'kloudlite',
}) => {
const frame = window.open(
url,
title,
`toolbar=no,scrollbars=yes,resizable=no,top=${window.screen.height / 2 - height / 2
`toolbar=no,scrollbars=yes,resizable=no,top=${
window.screen.height / 2 - height / 2
},left=${window.screen.width / 2 - width / 2},width=800,height=600`
);
const interval = setInterval(() => {
@@ -90,8 +91,8 @@ interface IBranch {

interface IListRenderer {
data:
| { name: string; updatedAt: any; private: true; url: string }[]
| undefined;
| { name: string; updatedAt: any; private: true; url: string }[]
| undefined;
onChange: (value: string) => void;
value: string;
isLoading?: boolean;
53 changes: 32 additions & 21 deletions src/apps/console/routes/_main+/$account+/repo+/$repo+/_layout.tsx
Original file line number Diff line number Diff line change
@@ -15,19 +15,13 @@ import {
import Breadcrum from '~/console/components/breadcrum';
import { CommonTabs } from '~/console/components/common-navbar-tabs';

import { IRemixCtx } from '~/root/lib/types/common';
import { IRemixCtx, LoaderResult } from '~/root/lib/types/common';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
import logger from '~/root/lib/client/helpers/log';
import { ILoginUrls, ILogins } from '~/console/server/gql/queries/git-queries';
import { IPackageContext } from '~/console/routes/_main+/$account+/packages+/_layout';

export interface IRepoContext extends IPackageContext {
logins: ILogins;
loginUrls: ILoginUrls;
}
const LocalBreadcrum = () => {
const { repo, account } = useParams();
const repoName = atob(repo || '');
const { account, repo } = useParams();
return (
<div className="flex flex-row items-center">
<Breadcrum.Button
@@ -44,16 +38,18 @@ const LocalBreadcrum = () => {
}
/>
<Breadcrum.Button
to={`/${account}/repo/${repoName}`}
to={`/${account}/repo/${repo}`}
LinkComponent={Link}
content={<span>{repoName}</span>}
content={<span>{atob(repo || '')}</span>}
/>
</div>
);
};

const Tabs = () => {
const { repo, account } = useParams();
const { account } = useParams();

const { repo } = useParams();
const iconSize = 16;
return (
<CommonTabs
@@ -103,14 +99,12 @@ const Tabs = () => {
/>
);
};
export const handle = () => {
return {
navbar: <Tabs />,
breadcrum: () => <LocalBreadcrum />,
};
};

export const loader = async (ctx: IRemixCtx) => {
const { repo } = ctx.params;

const repoName = atob(repo || '');

try {
const { data, errors } = await GQLServerHandler(ctx.request).getLogins({});

@@ -129,21 +123,38 @@ export const loader = async (ctx: IRemixCtx) => {
return {
loginUrls: e,
logins: data,
repoName,
};
} catch (err) {
logger.error(err);
}

const k: any = {};

return {
logins: k,
loginUrls: k,
repoName,
};
};

export const handle = () => {
return {
logins: {},
loginUrls: {},
navbar: <Tabs />,
breadcrum: () => <LocalBreadcrum />,
};
};

export interface IRepoContext extends IPackageContext {
logins: LoaderResult<typeof loader>['logins'];
loginUrls: LoaderResult<typeof loader>['loginUrls'];
repoName: LoaderResult<typeof loader>['repoName'];
}

const Repo = () => {
const rootContext = useOutletContext<IPackageContext>();
const { logins, loginUrls } = useLoaderData<typeof loader>();
return <Outlet context={{ ...rootContext, logins, loginUrls }} />;
const ctx = useLoaderData<typeof loader>();
return <Outlet context={{ ...rootContext, ...ctx }} />;
};

export default Repo;
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@ import {
XCircleFill,
} from '@jengaicons/react';
import dayjs from 'dayjs';
import { IAccountContext } from '../../../_layout';
import LogComp from '~/root/lib/client/components/logger';
import { IAccountContext } from '../../../_layout';

const RESOURCE_NAME = 'build run';
type BaseType = ExtractNodeType<IBuildRuns>;
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ export const loader = async (ctx: IRemixCtx) => {

const promise = pWrapper(async () => {
const { data, errors } = await GQLServerHandler(ctx.request).listBuildRuns({
repoName: repo,
repoName: atob(repo),
pq: getPagination(ctx),
search: getSearch(ctx),
});
Original file line number Diff line number Diff line change
@@ -10,17 +10,17 @@ import logger from '~/root/lib/client/helpers/log';
import { IRemixCtx } from '~/root/lib/types/common';
import { Plus } from '@jengaicons/react';
import { Button } from '~/components/atoms/button';
import fake from '~/root/fake-data-generator/fake';
import BuildResources from './build-resources';
import HandleBuild from './handle-builds';
import Tools from './tools';
import fake from "~/root/fake-data-generator/fake";

export const loader = async (ctx: IRemixCtx) => {
const { repo } = ctx.params;
const promise = pWrapper(async () => {
ensureAccountSet(ctx);
const { data, errors } = await GQLServerHandler(ctx.request).listBuilds({
repoName: repo,
repoName: atob(repo),
pagination: getPagination(ctx),
search: getSearch(ctx),
});
@@ -44,10 +44,10 @@ const Builds = () => {
return (
<>
<LoadingComp
data={promise}
skeletonData={{
buildData: fake.ConsoleListBuildsQuery.cr_listBuilds as any,
}}
data={promise}
skeletonData={{
buildData: fake.ConsoleListBuildsQuery.cr_listBuilds as any,
}}
>
{({ buildData }) => {
const builds = buildData.edges?.map(({ node }) => node);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/destructuring-assignment */
import { IDialogBase } from '~/console/components/types.d';
import { useOutletContext, useParams } from '@remix-run/react';
import { useOutletContext } from '@remix-run/react';
import { Checkbox } from '~/components/atoms/checkbox';
import Select from '~/components/atoms/select';
import { toast } from '~/components/molecule/toast';
@@ -119,8 +119,6 @@ const Root = (props: IDialog) => {
totalSteps: 2,
});

const { repo } = useParams();

const isAdvanceOptions = (data: any) => {
if (!data) {
return false;
@@ -306,6 +304,7 @@ const Root = (props: IDialog) => {
}}
error={!!errors.buildClusterName || !!errorCluster}
message={
// eslint-disable-next-line no-nested-ternary
errors.buildClusterName
? errors.buildClusterName
: errorCluster
Original file line number Diff line number Diff line change
@@ -7,20 +7,21 @@ import { ensureAccountSet } from '~/console/server/utils/auth-utils';
import { getPagination, getSearch } from '~/console/server/utils/common';
import logger from '~/root/lib/client/helpers/log';
import { IRemixCtx } from '~/root/lib/types/common';
import SecondarySubHeader from '~/console/components/secondary-sub-header';
import fake from '~/root/fake-data-generator/fake';
import TagsResources from './tags-resources';
import Tools from './tools';
import fake from "~/root/fake-data-generator/fake";

export const loader = async (ctx: IRemixCtx) => {
const { repo } = ctx.params;

const promise = pWrapper(async () => {
ensureAccountSet(ctx);
const { data, errors } = await GQLServerHandler(ctx.request).listDigest({
repoName: atob(repo),
pagination: getPagination(ctx),
search: getSearch(ctx),
});

if (errors) {
logger.error(errors[0]);
throw errors[0];
@@ -38,10 +39,10 @@ const Images = () => {
const { promise } = useLoaderData<typeof loader>();
return (
<LoadingComp
data={promise}
skeletonData={{
tagsData: fake.ConsoleListDigestQuery.cr_listDigests as any,
}}
data={promise}
skeletonData={{
tagsData: fake.ConsoleListDigestQuery.cr_listDigests as any,
}}
>
{({ tagsData }) => {
const tags = tagsData.edges?.map(({ node }) => node);
Original file line number Diff line number Diff line change
@@ -4,11 +4,18 @@ import Popup from '~/components/molecule/popup';
import CodeView from '~/console/components/code-view';
import { IDialog } from '~/console/components/types.d';
import { registryHost } from '~/root/lib/configs/base-url.cjs';
import { useOutletContext } from 'react-router-dom';
import { ISHADialogData } from './tags-resources';
import { IRepoContext } from '../_layout';

const SHADialog = ({ show, setShow }: IDialog<ISHADialogData>) => {
const { account, repo } = useParams();
const url = `${registryHost}/${account}/${repo}:${
const { account } = useParams();

const { repoName } = useOutletContext<IRepoContext>();

return null;

const url = `${registryHost}/${account}/${repoName}:${
show?.data?.tag ? show?.data?.tag : `@${show?.data?.sha}`
}`;
return (
Original file line number Diff line number Diff line change
@@ -244,7 +244,7 @@ const TagsResources = ({ items = [] }: { items: BaseType[] }) => {
}
}}
/>
<SHADialog show={showSHADialog} setShow={setShowSHADialog} />
{/* <SHADialog show={showSHADialog} setShow={setShowSHADialog} /> */}
</>
);
};
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ import ExtendedFilledTab from '~/console/components/extended-filled-tab';
import { AnimatePresence, motion } from 'framer-motion';
import { FadeIn } from '~/console/page-components/util';



const ConfigureRepo = () => {
const [setting, setSetting] = useState('general');
return (
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@ import { useConsoleApi } from '~/console/server/gql/api-provider';
import Git from '~/console/components/git';
import { IGIT_PROVIDERS } from '~/console/hooks/use-git';
import { BottomNavigation } from '~/console/components/commons';
import { toast } from '~/components/molecule/toast';
import ReviewBuild from './review-build';
import BuildDetails from './build-details';
import { IRepoContext } from '../_layout';

const NewBuild = () => {
const { loginUrls, logins } = useOutletContext<IRepoContext>();
const { loginUrls, logins, repoName } = useOutletContext<IRepoContext>();

const navigate = useNavigate();

@@ -27,7 +28,6 @@ const NewBuild = () => {
});

const api = useConsoleApi();
const { repo } = useParams();

const { values, errors, handleSubmit, handleChange, isLoading } = useForm({
initialValues: {
@@ -40,7 +40,7 @@ const NewBuild = () => {
tags: [],
buildClusterName: '',
advanceOptions: false,
repository: repo || '',
repository: repoName || '',
buildArgs: {},
buildContexts: {},
contextDir: '',
@@ -69,8 +69,9 @@ const NewBuild = () => {
}),
}),
onSubmit: async (val) => {
if (!repo) {
throw new Error('Repository is required!.');
if (!repoName) {
toast.error('Repository is required!.');
return;
}
const submit = async () => {
try {
@@ -115,21 +116,26 @@ const NewBuild = () => {
if (e) {
throw e[0];
}
navigate(`/${account}/repo/${repo}/builds`);
navigate(`/${account}/repo/${repoName}/builds`);
} catch (err) {
handleError(err);
}
};
switch (currentStep) {
case 1:
nextStep();
break;
case 2:
nextStep();
break;
default:
await submit();
break;

try {
switch (currentStep) {
case 1:
nextStep();
break;
case 2:
nextStep();
break;
default:
await submit();
break;
}
} catch (err) {
handleError(err);
}
},
});
Loading

0 comments on commit a569208

Please sign in to comment.