Skip to content

Commit

Permalink
🎨 Fixed some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abdheshnayak committed Jan 24, 2024
1 parent b826563 commit 22efc74
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 58 deletions.
17 changes: 13 additions & 4 deletions src/apps/console/components/logger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
useSearch,
} from '~/root/lib/client/helpers/search-filter';
import useClass from '~/root/lib/client/hooks/use-class';
import logger from '~/root/lib/client/helpers/log';
import { socketUrl } from '~/root/lib/configs/base-url.cjs';
import { generatePlainColor } from './color-generator';
import Pulsable from './pulsable';
Expand Down Expand Up @@ -403,13 +402,19 @@ const LogBlock = ({
);

const [showAll, setShowAll] = useState(true);

const ref = useRef(null);
// const listRef = useRef(null);

useEffect(() => {
console.log('data', ref.current);

(async () => {
if (follow && ref.current) {
// @ts-ignore
ref.current.scrollTo(0, ref.current.scrollHeight);
ref.current.scrollToIndex({
index: data.length - 1,
});
}
})();
}, [data, maxLines]);
Expand Down Expand Up @@ -470,11 +475,15 @@ const LogBlock = ({
>
<div className="flex flex-1 h-full">
<div
className="flex-1 flex flex-col pb-8"
className="flex-1 flex flex-col pb-8 scroll-container"
style={{ lineHeight: `${fontSize * 1.5}px` }}
ref={ref}
>
<ViewportList items={showAll ? data : searchResult}>
<ViewportList
items={showAll ? data : searchResult}
ref={ref}
// viewportRef={listRef}
>
{(log, index) => {
return (
<LogLine
Expand Down
5 changes: 5 additions & 0 deletions src/apps/console/page-components/app-states.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ export const useAppState = () => {
};
};

export const clearAppState = () => {
if (typeof window === 'undefined') return;
sessionStorage.removeItem('state');
};

export const AppContextProvider = ({
children,
initialAppState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { ensureAccountSet } from '~/console/server/utils/auth-utils';
import { getPagination, getSearch } from '~/console/server/utils/common';
import { IRemixCtx } from '~/root/lib/types/common';
import fake from '~/root/fake-data-generator/fake';
import { clearAppState } from '~/console/page-components/app-states';
import { useEffect } from 'react';
import AppsResources from './apps-resources';
import Tools from './tools';

Expand Down Expand Up @@ -38,12 +40,16 @@ export const loader = async (ctx: IRemixCtx) => {
const Apps = () => {
const { promise } = useLoaderData<typeof loader>();

useEffect(() => {
clearAppState();
}, []);

return (
<LoadingComp
data={promise}
// skeletonData={{
// appsData: fake.ConsoleListAppsQuery.core_listApps as any,
// }}
skeletonData={{
appsData: fake.ConsoleListAppsQuery.core_listApps as any,
}}
>
{({ appsData }) => {
const apps = parseNodes(appsData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ const ListView = ({ items }: { items: BaseType[] }) => {
},
status,
listFlex({ key: `${keyPrefix}flex` }),
{
key: generateKey(keyPrefix, item.clusterName || ''),
className: '',
render: () => (
<div className="flex whitespace-pre items-center gap-md">
<span className="bodyMd-semibold">cluster:</span>{' '}
<span className="bodyMd-medium text-text-soft">
{item.clusterName}
</span>
</div>
),
},
{
key: generateKey(keyPrefix, updateInfo.author),
className: listClass.author,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import DeleteDialog from '~/console/components/delete-dialog';
import Grid from '~/console/components/grid';
import List from '~/console/components/list';
import ListGridView from '~/console/components/list-grid-view';
import ResourceExtraAction from '~/console/components/resource-extra-action';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import {
ExtractNodeType,
Expand Down Expand Up @@ -47,34 +46,11 @@ const parseItem = (item: BaseType) => {
};
};

interface IExtraButton {
onDelete: () => void;
}
const ExtraButton = ({ onDelete }: IExtraButton) => {
return (
<ResourceExtraAction
options={
[
// {
// label: 'Delete',
// icon: <Trash size={16} />,
// type: 'item',
// onClick: onDelete,
// key: 'delete',
// className: '!text-text-critical',
// },
]
}
/>
);
};

interface IResource {
items: BaseType[];
onDelete: (item: BaseType) => void;
}

const GridView = ({ items, onDelete }: IResource) => {
const GridView = ({ items }: IResource) => {
return (
<Grid.Root className="!grid-cols-1 md:!grid-cols-3">
{items.map((item, index) => {
Expand Down Expand Up @@ -169,32 +145,30 @@ const ListItem = ({ item }: { item: BaseType }) => {
</div>
}
subtitle={
<div className="flex items-center gap-md">
{`#${commitHash.substring(
commitHash.length - 7,
commitHash.length
)}`}
<GitBranch size={12} />
{item.metadata?.annotations['github.com/branch']}{' '}
<div className="flex items-center gap-xl pt-md">
<div>
{`#${commitHash.substring(
commitHash.length - 7,
commitHash.length
)}`}
</div>
<div className="flex items-center gap-md">
<GitBranch size={12} />
{item.metadata?.annotations['github.com/branch']}{' '}
</div>

<div className="flex items-center gap-md">
{item.spec?.registry.repo.tags.map((tag) => (
<div className="flex items-center gap-md" key={tag}>
<Tag size={12} />
{tag}{' '}
</div>
))}
</div>
</div>
}
/>
</div>

<div className="flex-1 flex items-center justify-center">
<div className="flex flex-row items-center gap-lg mb-md">
{item.spec?.registry.repo.tags.map((tag) => (
<button
key={tag}
className="rounded-full outline-none ring-offset-1 focus-visible:ring-2 focus-visible:ring-border-focus hover:underline text-text-primary"
>
<Badge type="info" icon={<Tag />}>
{tag}
</Badge>
</button>
))}
</div>
</div>
</div>

<div className="bodyMd text-text-soft truncate">
Expand Down Expand Up @@ -231,7 +205,7 @@ const ListItem = ({ item }: { item: BaseType }) => {
</div>
);
};
const ListView = ({ items, onDelete }: IResource) => {
const ListView = ({ items }: IResource) => {
return (
<List.Root>
{items.map((item, index) => {
Expand Down Expand Up @@ -265,9 +239,9 @@ const BuildRunResources = ({ items = [] }: { items: BaseType[] }) => {

const props: IResource = {
items,
onDelete: (item) => {
setShowDeleteDialog(item);
},
// onDelete: (item) => {
// setShowDeleteDialog(item);
// },
};

const params = useParams();
Expand Down

0 comments on commit 22efc74

Please sign in to comment.